Java Code Examples for androidx.fragment.app.Fragment#isHidden()

The following examples show how to use androidx.fragment.app.Fragment#isHidden() . 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: MainDiscoveryFragment.java    From edx-app-android with Apache License 2.0 5 votes vote down vote up
private void showFragment(@Nullable Fragment fragment) {
    if (fragment == null || !fragment.isHidden()) {
        return;
    }
    // Use commitNow() method to perform the FragmentManager transaction synchronously
    // instated of commit(), otherwise program discovery screen is not visible to the guest user
    // in case of deep linking.
    getChildFragmentManager().beginTransaction()
            .show(fragment)
            .commitNow();
}
 
Example 2
Source File: MainDiscoveryFragment.java    From edx-app-android with Apache License 2.0 5 votes vote down vote up
private void hideFragment(@Nullable Fragment fragment) {
    if (fragment == null || fragment.isHidden()) {
        return;
    }
    // Use commitNow() method to perform the FragmentManager transaction synchronously
    // instated of commit(), otherwise program discovery screen is not visible to the guest user
    // in case of deep linking.
    getChildFragmentManager().beginTransaction()
            .hide(fragment)
            .commitNow();
}
 
Example 3
Source File: MyActivity.java    From googleads-ima-android with Apache License 2.0 5 votes vote down vote up
private void orientAppUi() {
  int orientation = getResources().getConfiguration().orientation;
  boolean isLandscape = (orientation == Configuration.ORIENTATION_LANDSCAPE);
  // Hide the non-video content when in landscape so the video is as large as possible.
  FragmentManager fragmentManager = getSupportFragmentManager();
  VideoFragment videoFragment =
      (VideoFragment) fragmentManager.findFragmentByTag(VIDEO_EXAMPLE_FRAGMENT_TAG);

  Fragment videoListFragment = fragmentManager.findFragmentByTag(VIDEO_PLAYLIST_FRAGMENT_TAG);

  if (videoFragment != null) {
    // If the video playlist is onscreen (tablets) then hide that fragment.
    if (videoListFragment != null) {
      FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
      if (isLandscape) {
        fragmentTransaction.hide(videoListFragment);
      } else {
        fragmentTransaction.show(videoListFragment);
      }
      fragmentTransaction.commit();
    }
    videoFragment.makeFullscreen(isLandscape);
    if (isLandscape) {
      hideStatusBar();
    } else {
      showStatusBar();
    }
  } else {
    // If returning to the list from a fullscreen video, check if the video
    // list fragment exists and is hidden. If so, show it.
    if (videoListFragment != null && videoListFragment.isHidden()) {
      fragmentManager.beginTransaction().show(videoListFragment).commit();
      showStatusBar();
    }
  }
}
 
Example 4
Source File: AbstractLazyLoadFragment.java    From WanAndroid with Apache License 2.0 4 votes vote down vote up
/**
 * 当前Fragment是否可见
 */
private boolean isFragmentVisible(Fragment fragment) {
    return !fragment.isHidden() && fragment.getUserVisibleHint();
}