Java Code Examples for android.support.v4.app.fragmentmanager#addOnBackStackChangedListener()

The following examples show how to use android.support.v4.app.fragmentmanager#addOnBackStackChangedListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BrowsingActivityNavigationControllerSinglePane.java    From IslamicLibraryAndroid with GNU General Public License v3.0 5 votes vote down vote up
public BrowsingActivityNavigationControllerSinglePane(int oldPanNumbers, @NonNull FragmentManager fragmentManager, boolean fromRotation, BrowsingActivity browsingActivity, @NonNull BottomNavigationView bottomNavigationView, @NonNull BrowsingActivityControllerListener listener) {
    super(oldPanNumbers, fragmentManager, fromRotation, browsingActivity, bottomNavigationView, listener);
    paneNumber = 1;
    backStackChangedListener = () -> {
        if (fragmentManager.getBackStackEntryCount() == 0) {
            bottomNavigationView.setVisibility(View.VISIBLE);
            listener.setUpNavigation(false);
        } else {
            bottomNavigationView.setVisibility(View.GONE);
            listener.setUpNavigation(true);
        }
    };
    fragmentManager.addOnBackStackChangedListener(backStackChangedListener);
}
 
Example 2
Source File: Wizard.java    From Wizard with Apache License 2.0 5 votes vote down vote up
public void init() {
  if (!activity.isFinishing()) {
    FragmentManager fragmentManager = activity.getSupportFragmentManager();
    fragmentManager.addOnBackStackChangedListener(this);
    WizardPage firstPage = pages[0];
    fragmentManager.beginTransaction().replace(containerId, firstPage.createFragment()).commit();
    fragmentManager.executePendingTransactions();
    if (firstPage.hasOptionMenu()) {
      activity.supportInvalidateOptionsMenu();
    }
    firstPage.setupActionBar(actionBarResolver.getSupportActionBar());
  }
}
 
Example 3
Source File: LoginStateableHandler.java    From state-machine-android with MIT License 5 votes vote down vote up
private void addOnBackStackChangedListener() {
    final FragmentManager supportFragmentManager = mainActivity.getSupportFragmentManager();
    supportFragmentManager.addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() {
        @Override
        public void onBackStackChanged() {
            Fragment currentFragment = supportFragmentManager.findFragmentById(R.id.fragment_container);
            bus.post(new BackStackChangedEvent(currentFragment));
        }
    });
}