Browse Source

Temporarily fix bug where tabs created outside the presenter class (in manager) cause the tab number to be mismatched

master
Anthony Restaino 9 years ago
parent
commit
c9323cc7fd
  1. 20
      app/src/main/java/acr/browser/lightning/activity/TabsManager.java
  2. 8
      app/src/main/java/acr/browser/lightning/browser/BrowserPresenter.java

20
app/src/main/java/acr/browser/lightning/activity/TabsManager.java

@ -45,6 +45,7 @@ public class TabsManager { @@ -45,6 +45,7 @@ public class TabsManager {
private final List<LightningView> mTabList = new ArrayList<>(1);
@Nullable private LightningView mCurrentTab;
@Nullable private TabNumberChangedListener mTabNumberListener;
@Inject PreferenceManager mPreferenceManager;
@Inject Bus mEventBus;
@ -53,6 +54,16 @@ public class TabsManager { @@ -53,6 +54,16 @@ public class TabsManager {
@Inject
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
* was closed. Handles the intent used to open the browser.
@ -240,6 +251,9 @@ public class TabsManager { @@ -240,6 +251,9 @@ public class TabsManager {
Log.d(TAG, "New tab");
final LightningView tab = new LightningView(activity, url, isIncognito);
mTabList.add(tab);
if (mTabNumberListener != null) {
mTabNumberListener.tabNumberChanged(size());
}
return tab;
}
@ -284,9 +298,15 @@ public class TabsManager { @@ -284,9 +298,15 @@ public class TabsManager {
mCurrentTab = getTabAtPosition(current - 1);
}
removeTab(current);
if (mTabNumberListener != null) {
mTabNumberListener.tabNumberChanged(size());
}
return true;
} else {
removeTab(position);
if (mTabNumberListener != null) {
mTabNumberListener.tabNumberChanged(size());
}
return false;
}
}

8
app/src/main/java/acr/browser/lightning/browser/BrowserPresenter.java

@ -44,6 +44,12 @@ public class BrowserPresenter { @@ -44,6 +44,12 @@ public class BrowserPresenter {
BrowserApp.getAppComponent().inject(this);
mView = view;
mIsIncognito = isIncognito;
mTabsModel.setTabNumberChangedListener(new TabsManager.TabNumberChangedListener() {
@Override
public void tabNumberChanged(int newNumber) {
mView.updateTabNumber(newNumber);
}
});
}
public void setupTabs(Intent intent, boolean isIncognito) {
@ -214,6 +220,8 @@ public class BrowserPresenter { @@ -214,6 +220,8 @@ public class BrowserPresenter {
return false;
}
Log.d(TAG, "New tab, show: " + show);
mIsNewIntent = false;
LightningView startingTab = mTabsModel.newTab((Activity) mView, url, mIsIncognito);
if (mTabsModel.size() == 1) {

Loading…
Cancel
Save