Search in sources :

Example 1 with UrlInputFragment

use of org.mozilla.focus.fragment.UrlInputFragment in project focus-android by mozilla-mobile.

the class MainActivity method onBackPressed.

@Override
public void onBackPressed() {
    final FragmentManager fragmentManager = getSupportFragmentManager();
    final SessionsSheetFragment sessionsSheetFragment = (SessionsSheetFragment) fragmentManager.findFragmentByTag(SessionsSheetFragment.FRAGMENT_TAG);
    if (sessionsSheetFragment != null && sessionsSheetFragment.isVisible() && sessionsSheetFragment.onBackPressed()) {
        // SessionsSheetFragment handles back presses itself (custom animations).
        return;
    }
    final UrlInputFragment urlInputFragment = (UrlInputFragment) fragmentManager.findFragmentByTag(UrlInputFragment.FRAGMENT_TAG);
    if (urlInputFragment != null && urlInputFragment.isVisible() && urlInputFragment.onBackPressed()) {
        // we do not try to remove it from outside.
        return;
    }
    final BrowserFragment browserFragment = (BrowserFragment) fragmentManager.findFragmentByTag(BrowserFragment.FRAGMENT_TAG);
    if (browserFragment != null && browserFragment.isVisible() && browserFragment.onBackPressed()) {
        // in the browsing history.
        return;
    }
    super.onBackPressed();
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) SessionsSheetFragment(org.mozilla.focus.session.ui.SessionsSheetFragment) BrowserFragment(org.mozilla.focus.fragment.BrowserFragment) UrlInputFragment(org.mozilla.focus.fragment.UrlInputFragment)

Aggregations

FragmentManager (android.support.v4.app.FragmentManager)1 BrowserFragment (org.mozilla.focus.fragment.BrowserFragment)1 UrlInputFragment (org.mozilla.focus.fragment.UrlInputFragment)1 SessionsSheetFragment (org.mozilla.focus.session.ui.SessionsSheetFragment)1