Skip to content

Instantly share code, notes, and snippets.

@pyadav
Forked from guptasanchit90/FragmentHelper.java
Created August 8, 2016 03:41
Show Gist options
  • Select an option

  • Save pyadav/b600b15c67f5b62f831fa01ffc39da08 to your computer and use it in GitHub Desktop.

Select an option

Save pyadav/b600b15c67f5b62f831fa01ffc39da08 to your computer and use it in GitHub Desktop.
Check if fragment is visible and still not destroyed
public class FragmentHelper {
public static boolean isFragmentVisible(WeakReference<Fragment> fragment) {
if (fragment!=null && fragment.get() != null && fragment.get().getActivity() != null &&
fragment.get()
.isVisible()
&& !fragment.get().isRemoving()) {
return true;
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment