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

The following examples show how to use androidx.fragment.app.Fragment#isDetached() . 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: FragmentStack.java    From cathode with Apache License 2.0 6 votes vote down vote up
private void attachFragment(Fragment fragment, String tag) {
  Preconditions.checkNotNull(tag, "Passed null tag for Fragment %s",
      fragment.getClass().getName());

  Timber.d("Attaching fragment: %s", tag);

  if (fragment.isDetached()) {
    ensureTransaction();

    fragmentTransaction.attach(fragment);
  } else if (!fragment.isAdded()) {
    ensureTransaction();

    fragmentTransaction.add(containerId, fragment, tag);
  }
}
 
Example 2
Source File: TaskHelper.java    From firebase-android-sdk with Apache License 2.0 5 votes vote down vote up
static boolean isFragmentDestroyed(Fragment fragment) {
  return fragment.isRemoving()
      || fragment.getActivity() == null
      || fragment.isDetached()
      || !fragment.isAdded()
      || fragment.getView() == null;
}
 
Example 3
Source File: FragmentStack.java    From cathode with Apache License 2.0 5 votes vote down vote up
private void detachFragment(Fragment fragment) {
  if (fragment != null && !fragment.isDetached()) {
    Timber.d("Detaching fragment: %s", fragment.getTag());

    ensureTransaction();
    fragmentTransaction.detach(fragment);
  }
}
 
Example 4
Source File: FragmentStack.java    From cathode with Apache License 2.0 5 votes vote down vote up
private void removeFragment(Fragment fragment) {
  if (fragment != null && (fragment.isAdded() || fragment.isDetached())) {
    Timber.d("Removing fragment: %s", fragment.getTag());

    ensureTransaction();
    fragmentTransaction.remove(fragment);
  }
}
 
Example 5
Source File: GlideHelper.java    From hipda with GNU General Public License v2.0 4 votes vote down vote up
public static boolean isOkToLoad(Fragment fragment) {
    return fragment != null && fragment.getActivity() != null && !fragment.isDetached();
}