Example usage for android.app Fragment isHidden

List of usage examples for android.app Fragment isHidden

Introduction

In this page you can find the example usage for android.app Fragment isHidden.

Prototype

final public boolean isHidden() 

Source Link

Document

Return true if the fragment has been hidden.

Usage

From source file:com.poloure.simplerss.Utilities.java

private static void switchToFragment(Fragment fragment, boolean addToBackStack) {
    if (fragment.isHidden()) {
        Fragment[] fragments = { s_fragmentFavourites, s_fragmentManage, s_fragmentFeeds, s_fragmentSettings };
        FragmentTransaction transaction = s_fragmentManager.beginTransaction();

        for (Fragment frag : fragments) {
            if (frag.isVisible()) {
                transaction.hide(frag);/*from  www .  j a  va 2 s  .  c  o m*/
            }
        }
        transaction.show(fragment);
        if (addToBackStack) {
            transaction.addToBackStack(null);

            // Set the default transition for adding to the stack.
            transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        }
        transaction.commit();
        s_fragmentManager.executePendingTransactions();
        fragment.getActivity().invalidateOptionsMenu();
    }
}

From source file:com.codefororlando.transport.MapsActivity.java

@Override
public void onBackPressed() {
    Fragment fragment = getFragmentManager().findFragmentByTag(ISelectableItemFragment.TAG);
    if (filterView.isExpanded()) {
        // Close the FilterView if it is open
        filterView.animateOpen(false);/*from w  w w .  ja v a  2 s  .  c om*/
    } else if (fragment != null && !fragment.isHidden()) {
        // Display the filter fab
        filterView.animateOnScreen(true);

        // Remove the on screen fragment
        removeSelectableItemFragment();
    } else {
        super.onBackPressed();
    }
}

From source file:com.evandroid.musica.MainLyricActivity.java

private LyricsViewFragment init(FragmentManager fragmentManager, boolean startEmpty) {
    LyricsViewFragment lyricsViewFragment = (LyricsViewFragment) fragmentManager
            .findFragmentByTag(LYRICS_FRAGMENT_TAG);
    if (lyricsViewFragment == null || lyricsViewFragment.isDetached())
        lyricsViewFragment = new LyricsViewFragment();
    lyricsViewFragment.startEmpty(startEmpty);
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    if (!lyricsViewFragment.isAdded()) {
        fragmentTransaction.add(R.id.main_fragment_container, lyricsViewFragment, LYRICS_FRAGMENT_TAG);
    }//from  ww  w  .  j a  va  2  s. com

    Fragment[] activeFragments = getActiveFragments();
    displayedFragment = getDisplayedFragment(activeFragments);

    for (Fragment fragment : activeFragments)
        if (fragment != null) {
            if (fragment != displayedFragment && !fragment.isHidden()) {
                fragmentTransaction.hide(fragment);
                fragment.onHiddenChanged(true);
            } else if (fragment == displayedFragment)
                fragmentTransaction.show(fragment);
        }
    fragmentTransaction.commit();
    return lyricsViewFragment;
}

From source file:com.geecko.QuickLyric.MainActivity.java

private LyricsViewFragment init(FragmentManager fragmentManager, boolean startEmpty) {
    LyricsViewFragment lyricsViewFragment = (LyricsViewFragment) fragmentManager
            .findFragmentByTag(LYRICS_FRAGMENT_TAG);
    if (lyricsViewFragment == null || lyricsViewFragment.isDetached())
        lyricsViewFragment = new LyricsViewFragment();
    lyricsViewFragment.startEmpty(startEmpty);
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.setCustomAnimations(R.animator.slide_in_end, R.animator.slide_out_start,
            R.animator.slide_in_start, R.animator.slide_out_end);
    if (!lyricsViewFragment.isAdded()) {
        fragmentTransaction.add(id.main_fragment_container, lyricsViewFragment, LYRICS_FRAGMENT_TAG);
    }/*from w  w w  . j  a v a 2  s .c  om*/

    Fragment[] activeFragments = getActiveFragments();
    displayedFragment = getDisplayedFragment(activeFragments);

    for (Fragment fragment : activeFragments)
        if (fragment != null) {
            if (fragment != displayedFragment && !fragment.isHidden()) {
                fragmentTransaction.hide(fragment);
                fragment.onHiddenChanged(true);
            } else if (fragment == displayedFragment)
                fragmentTransaction.show(fragment);
        }
    fragmentTransaction.commit();
    return lyricsViewFragment;
}