Smoothly close browser by closing the activity after the drawers are closed, removed bus event
This commit is contained in:
parent
e0ace14029
commit
6308677438
@ -1064,9 +1064,12 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
mBrowserFrame.setBackgroundColor(mBackgroundColor);
|
||||
performExitCleanUp();
|
||||
mBrowserFrame.removeAllViews();
|
||||
int size = mTabsManager.size();
|
||||
mTabsManager.shutdown();
|
||||
mCurrentView = null;
|
||||
mEventBus.post(new BrowserEvents.TabsChanged());
|
||||
for (int n = 0; n < size; n++) {
|
||||
mTabsView.tabRemoved(n);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
@ -1393,8 +1396,39 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
mDrawerLayout.openDrawer(mDrawerRight);
|
||||
}
|
||||
|
||||
void closeDrawers() {
|
||||
/**
|
||||
* This method closes any open drawer and executes
|
||||
* the runnable after the drawers are completely closed.
|
||||
*
|
||||
* @param runnable an optional runnable to run after
|
||||
* the drawers are closed.
|
||||
*/
|
||||
void closeDrawers(@Nullable final Runnable runnable) {
|
||||
if (!mDrawerLayout.isDrawerOpen(mDrawerLeft) && !mDrawerLayout.isDrawerOpen(mDrawerRight)) {
|
||||
if (runnable != null) {
|
||||
runnable.run();
|
||||
return;
|
||||
}
|
||||
}
|
||||
mDrawerLayout.closeDrawers();
|
||||
mDrawerLayout.addDrawerListener(new DrawerListener() {
|
||||
@Override
|
||||
public void onDrawerSlide(View drawerView, float slideOffset) {}
|
||||
|
||||
@Override
|
||||
public void onDrawerOpened(View drawerView) {}
|
||||
|
||||
@Override
|
||||
public void onDrawerClosed(View drawerView) {
|
||||
if (runnable != null) {
|
||||
runnable.run();
|
||||
}
|
||||
mDrawerLayout.removeDrawerListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawerStateChanged(int newState) {}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1913,7 +1947,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
case R.id.action_toggle_desktop:
|
||||
currentTab.toggleDesktopUA(this);
|
||||
currentTab.reload();
|
||||
closeDrawers();
|
||||
closeDrawers(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2174,7 +2208,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
final LightningView currentTab = mTabsManager.getCurrentTab();
|
||||
if (currentTab != null) {
|
||||
currentTab.loadHomepage();
|
||||
closeDrawers();
|
||||
closeDrawers(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,11 @@ public class IncognitoActivity extends BrowserActivity {
|
||||
|
||||
@Override
|
||||
public void closeActivity() {
|
||||
closeDrawers();
|
||||
closeDrawers(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
closeBrowser();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -65,10 +65,14 @@ public class MainActivity extends BrowserActivity {
|
||||
|
||||
@Override
|
||||
public void closeActivity() {
|
||||
closeDrawers();
|
||||
closeDrawers(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
performExitCleanUp();
|
||||
moveTaskToBack(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -40,12 +40,6 @@ public final class BrowserEvents {
|
||||
public static class UserPressedBack {
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify that the user closed or opened a tab
|
||||
*/
|
||||
public static class TabsChanged {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -183,13 +183,6 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
|
||||
mBus.unregister(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void tabsChanged(final BrowserEvents.TabsChanged event) {
|
||||
if (mTabsAdapter != null) {
|
||||
mTabsAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(@NonNull View v) {
|
||||
switch (v.getId()) {
|
||||
|
Loading…
Reference in New Issue
Block a user