|
|
@ -45,6 +45,7 @@ public class TabsManager { |
|
|
|
|
|
|
|
|
|
|
|
private final List<LightningView> mTabList = new ArrayList<>(1); |
|
|
|
private final List<LightningView> mTabList = new ArrayList<>(1); |
|
|
|
@Nullable private LightningView mCurrentTab; |
|
|
|
@Nullable private LightningView mCurrentTab; |
|
|
|
|
|
|
|
@Nullable private TabNumberChangedListener mTabNumberListener; |
|
|
|
|
|
|
|
|
|
|
|
@Inject PreferenceManager mPreferenceManager; |
|
|
|
@Inject PreferenceManager mPreferenceManager; |
|
|
|
@Inject Bus mEventBus; |
|
|
|
@Inject Bus mEventBus; |
|
|
@ -53,6 +54,16 @@ public class TabsManager { |
|
|
|
@Inject |
|
|
|
@Inject |
|
|
|
public TabsManager() {} |
|
|
|
public TabsManager() {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO remove and make presenter call new tab methods so it always knows
|
|
|
|
|
|
|
|
@Deprecated |
|
|
|
|
|
|
|
public interface TabNumberChangedListener { |
|
|
|
|
|
|
|
void tabNumberChanged(int newNumber); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setTabNumberChangedListener(@Nullable TabNumberChangedListener listener) { |
|
|
|
|
|
|
|
mTabNumberListener = listener; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Restores old tabs that were open before the browser |
|
|
|
* Restores old tabs that were open before the browser |
|
|
|
* was closed. Handles the intent used to open the browser. |
|
|
|
* was closed. Handles the intent used to open the browser. |
|
|
@ -240,6 +251,9 @@ public class TabsManager { |
|
|
|
Log.d(TAG, "New tab"); |
|
|
|
Log.d(TAG, "New tab"); |
|
|
|
final LightningView tab = new LightningView(activity, url, isIncognito); |
|
|
|
final LightningView tab = new LightningView(activity, url, isIncognito); |
|
|
|
mTabList.add(tab); |
|
|
|
mTabList.add(tab); |
|
|
|
|
|
|
|
if (mTabNumberListener != null) { |
|
|
|
|
|
|
|
mTabNumberListener.tabNumberChanged(size()); |
|
|
|
|
|
|
|
} |
|
|
|
return tab; |
|
|
|
return tab; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -284,9 +298,15 @@ public class TabsManager { |
|
|
|
mCurrentTab = getTabAtPosition(current - 1); |
|
|
|
mCurrentTab = getTabAtPosition(current - 1); |
|
|
|
} |
|
|
|
} |
|
|
|
removeTab(current); |
|
|
|
removeTab(current); |
|
|
|
|
|
|
|
if (mTabNumberListener != null) { |
|
|
|
|
|
|
|
mTabNumberListener.tabNumberChanged(size()); |
|
|
|
|
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
removeTab(position); |
|
|
|
removeTab(position); |
|
|
|
|
|
|
|
if (mTabNumberListener != null) { |
|
|
|
|
|
|
|
mTabNumberListener.tabNumberChanged(size()); |
|
|
|
|
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|