Skip to content

Instantly share code, notes, and snippets.

@guptasanchit90
Created November 22, 2015 09:41
Show Gist options
  • Save guptasanchit90/041a7ae6200f3f37d861 to your computer and use it in GitHub Desktop.
Save guptasanchit90/041a7ae6200f3f37d861 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