Search in sources :

Example 1 with BackPressedHandler

use of org.wikipedia.BackPressedHandler in project apps-android-wikipedia by wikimedia.

the class MainFragment method onBackPressed.

@Override
public boolean onBackPressed() {
    SearchFragment searchFragment = searchFragment();
    if (searchFragment != null && searchFragment.onBackPressed()) {
        return true;
    }
    Fragment fragment = ((NavTabFragmentPagerAdapter) viewPager.getAdapter()).getCurrentFragment();
    if (fragment instanceof BackPressedHandler && ((BackPressedHandler) fragment).onBackPressed()) {
        return true;
    }
    return false;
}
Also used : BackPressedHandler(org.wikipedia.BackPressedHandler) NavTabFragmentPagerAdapter(org.wikipedia.navtab.NavTabFragmentPagerAdapter) SearchFragment(org.wikipedia.search.SearchFragment) SearchFragment(org.wikipedia.search.SearchFragment) Fragment(android.support.v4.app.Fragment) HistoryFragment(org.wikipedia.history.HistoryFragment) NearbyFragment(org.wikipedia.nearby.NearbyFragment) FeedFragment(org.wikipedia.feed.FeedFragment)

Aggregations

Fragment (android.support.v4.app.Fragment)1 BackPressedHandler (org.wikipedia.BackPressedHandler)1 FeedFragment (org.wikipedia.feed.FeedFragment)1 HistoryFragment (org.wikipedia.history.HistoryFragment)1 NavTabFragmentPagerAdapter (org.wikipedia.navtab.NavTabFragmentPagerAdapter)1 NearbyFragment (org.wikipedia.nearby.NearbyFragment)1 SearchFragment (org.wikipedia.search.SearchFragment)1