Example usage for android.app FragmentManager getBackStackEntryCount

List of usage examples for android.app FragmentManager getBackStackEntryCount

Introduction

In this page you can find the example usage for android.app FragmentManager getBackStackEntryCount.

Prototype

public abstract int getBackStackEntryCount();

Source Link

Document

Return the number of entries currently in the back stack.

Usage

From source file:com.fusionx.lightirc.ui.SettingsActivityBase.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        FragmentManager fm = getFragmentManager();
        if (fm.getBackStackEntryCount() > 0) {
            fm.popBackStack();//from   ww w .  j  av a 2s.  c  om
        } else {
            finish();
        }
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.samebits.beacon.locator.ui.activity.BaseActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        FragmentManager fm = getFragmentManager();
        if (fm.getBackStackEntryCount() > 0) {
            fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
        } else {/*from   w w  w  .  jav  a2 s  .com*/
            finish();
        }
        return true;
    case R.id.action_settings:
        launchSettingsActivity();
        return true;
    case R.id.action_view_on_github:
        launchGitHubPage();
        return true;
    case R.id.action_help:
        launchHelpPage();
        return true;
    case R.id.action_donate:
        launchDonatePage();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.example.chu.googleplaylibrary.ui.ActionBarCastActivity.java

@Override
public void onBackPressed() {
    // If the drawer is open, back will close it
    // Otherwise, it may return to the previous fragment stack
    FragmentManager fragmentManager = getFragmentManager();
    if (fragmentManager.getBackStackEntryCount() > 0) {
        fragmentManager.popBackStack();/*from   w  ww . j a  v  a  2s  .  c om*/
    } else {
        // Lastly, it will rely on the system behavior for back
        super.onBackPressed();
    }
}

From source file:br.edu.ufabc.padm.cardioufabc.MainActivity.java

@Override
public void onBackPressed() {
    FragmentManager manager = getFragmentManager();
    if (manager.getBackStackEntryCount() > 0) {
        manager.popBackStack();//from www.jav  a 2 s  .  c  om
    } else {
        super.onBackPressed();
    }
}

From source file:com.bradbergeron.splitviewcontrollerdemo.activities.MainActivity.java

@Override
public void onBackPressed() {
    if (mDrawerLayout.isDrawerOpen(Gravity.START)) {
        mDrawerLayout.closeDrawer(Gravity.START);

        return;/*www. j  ava  2s .c o  m*/
    }

    final FragmentManager fragmentManager = getFragmentManager();

    if (fragmentManager.getBackStackEntryCount() > 0) {
        fragmentManager.popBackStackImmediate();

        return;
    }

    super.onBackPressed();
}

From source file:com.phearom.um.ui.ActionBarCastActivity.java

@Override
public void onBackPressed() {
    if (mDrawerLayout != null && mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
        mDrawerLayout.closeDrawers();//ww  w. j a  v  a2s .  com
        return;
    }

    FragmentManager fragmentManager = getFragmentManager();
    if (fragmentManager.getBackStackEntryCount() > 0) {
        fragmentManager.popBackStack();
    } else {
        super.onBackPressed();
    }
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.activities.MainActivity.java

private void popBackStack() {
    final FragmentManager fragmentManager = getFragmentManager();
    final int backStackEntryCount = fragmentManager.getBackStackEntryCount();
    final FragmentManager.BackStackEntry previousFragment = fragmentManager
            .getBackStackEntryAt(backStackEntryCount - 2);
    final String previousFragmentActionBarTitle = previousFragment.getName();
    setActionBarTitle(previousFragmentActionBarTitle);
    fragmentManager.popBackStack();//  www  .j  a v a  2 s.  c  o  m
}

From source file:me.pzheng.conn.MainActivity.java

@Override
public void onBackPressed() {
    FragmentManager fragmentManager = getFragmentManager();
    if (mNavigationDrawerFragment.isDrawerOpen())
        mNavigationDrawerFragment.closeDrawer();
    else if (fragmentManager.getBackStackEntryCount() > 1) {
        fragmentManager.popBackStack();//from  ww  w  . jav  a2 s.  c  om
    } else
        super.onBackPressed();
}

From source file:com.QuarkLabs.BTCeClient.MainActivity.java

@Override
public void onBackPressed() {
    super.onBackPressed();
    int switchToPosition = 0;
    FragmentManager fm = getFragmentManager();
    if (fm.getBackStackEntryCount() != 0) {
        String stackName = fm.getBackStackEntryAt(fm.getBackStackEntryCount() - 1).getName();
        switchToPosition = Integer.parseInt(stackName);
    }//from w  ww .j  ava 2s.c  om
    mDrawerList.setItemChecked(switchToPosition, true);
    mDrawerList.setSelection(switchToPosition);
    setTitle(mDrawerListItems[switchToPosition]);
}

From source file:com.ppgllrd.alfil.MainActivity.java

private void selectCourse(int position) {
    Log.d("ppgllrd", "selectCourse" + position + " " + drawerSelectedIdx);
    boolean isSelectable = drawerItems.get(position) instanceof DrawerCourse;

    if (isSelectable) {
        final DrawerCourse drawerCourse = (DrawerCourse) drawerItems.get(position);
        FragmentManager fragmentManager = getFragmentManager();
        Log.d("ppgllrd", "Count:" + fragmentManager.getBackStackEntryCount());

        if (position != drawerSelectedIdx) {
            Log.d("ppgllrd", "YES");
            drawerSelectedIdx = position;

            studentsListFragment = new StudentsListFragment();
            Bundle args = new Bundle();
            args.putParcelable(StudentsListFragment.ARG_GROUP_STUDENTS_COURSE, drawerCourse.getCourse());
            studentsListFragment.setArguments(args);

            FragmentTransaction ft = getFragmentManager().beginTransaction();
            ft.replace(R.id.list_Fragment_Placeholder, studentsListFragment, StudentsListFragment.FragmentTag);
            //ft.addToBackStack(StudentInfoFragment.FragmentTag);
            ft.commit();/*from  w w w  .ja va 2s  .c om*/
        }
        Log.d("ppgllrd", "YYY");

        actionBarTitleController.closeDrawer();

        if (studentInfoFragment.isShown()) {
            FragmentManager fm = getFragmentManager();
            if (fm.getBackStackEntryCount() > 0) {
                fm.popBackStack();
            }
        }
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.show(studentsListFragment);
        ft.hide(studentInfoFragment);
        // ft.addToBackStack(StudentInfoFragment.FragmentTag);
        ft.commit();

    }
    Log.d("ppgllrd", "ZZZ");
}