Example usage for android.app FragmentManager popBackStack

List of usage examples for android.app FragmentManager popBackStack

Introduction

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

Prototype

public abstract void popBackStack();

Source Link

Document

Pop the top state off the back stack.

Usage

From source file:com.axum.darivb.searchview.SlidingTabsBasicFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {

    searchView = (SearchView) view.findViewById(R.id.search_view);
    searchView.setIconified(false);//from www.  ja  va  2 s . c o  m
    ImageView back = (ImageView) view.findViewById(R.id.imageView);
    back.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            android.app.FragmentManager fm = getFragmentManager();
            fm.popBackStack();
        }
    });

    ViewPager mViewPager = (ViewPager) view.findViewById(R.id.viewpager);
    mViewPager.setAdapter(new SearchPagerAdapter());

    SlidingTabLayout mSlidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tabs);
    mSlidingTabLayout.setViewPager(mViewPager);

    mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {

            searchView.setQueryHint("Search " + tabs[position]);
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });

}

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();
        } else {/*from  w w  w .  j av  a 2  s . co m*/
            finish();
        }
        return true;
    }
    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();
    } else {//from  w w  w .  java2  s  .c o  m
        // 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();
    } else {// w ww  . j  a va2s  . c o  m
        super.onBackPressed();
    }
}

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

@Override
public void onBackPressed() {
    if (mDrawerLayout != null && mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
        mDrawerLayout.closeDrawers();//from   ww w .j  a v  a 2s  .c  o m
        return;
    }

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

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();
    } else//from   w  ww . ja v  a  2s.  c  om
        super.onBackPressed();
}

From source file:com.royclarkson.springagram.MainActivity.java

public void onGalleryAddComplete() {
    FragmentManager fragmentManager = getFragmentManager();
    fragmentManager.popBackStack();
    GalleryListFragment galleryListFragment = (GalleryListFragment) fragmentManager
            .findFragmentByTag(GalleryListFragment.TAG);
    galleryListFragment.fetchGalleryList();
}

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  ww. j a v a  2  s .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");
}

From source file:com.royclarkson.springagram.MainActivity.java

@Override
public void onPhotoAddComplete() {
    FragmentManager fragmentManager = getFragmentManager();
    fragmentManager.popBackStack();
    PhotoListFragment photoListFragment = (PhotoListFragment) fragmentManager
            .findFragmentByTag(PhotoListFragment.TAG);
    photoListFragment.fetchPhotoList();/*  www.j a  va  2 s.co  m*/
}

From source file:com.royclarkson.springagram.MainActivity.java

@Override
public void onNavigationDrawerItemSelected(int position) {
    this.menuPosition = position;
    String url = null;//from   w w w  .j  a  v  a2 s.  c o  m
    Fragment fragment = null;
    String tag = null;
    switch (position) {
    case 0:
        url = getString(R.string.base_uri);
        fragment = HomeFragment.newInstance(url);
        tag = HomeFragment.TAG;
        break;
    case 1:
        if (this.apiResource != null) {
            url = this.apiResource.getLink(ApiResource.REL_ITEMS).getHref();
        }
        fragment = PhotoListFragment.newInstance(url);
        tag = PhotoListFragment.TAG;
        break;
    case 2:
        if (this.apiResource != null) {
            url = this.apiResource.getLink(ApiResource.REL_GALLERIES).getHref();
        }
        fragment = GalleryListFragment.newInstance(url);
        tag = GalleryListFragment.TAG;
        break;
    }
    // update the main content by replacing fragments
    if (fragment != null) {
        FragmentManager fragmentManager = getFragmentManager();
        fragmentManager.popBackStack();
        fragmentManager.beginTransaction().replace(R.id.container, fragment, tag).commit();
    }
}