Created
April 13, 2015 04:08
-
-
Save koush/cf4e16a8b4e292743a37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyFragment { | |
boolean loaded; | |
private void maybeLoad() { | |
if (!loaded && getUserVisibleHint()) { | |
loaded = true; | |
loadMyData(); | |
} | |
} | |
@Override | |
public void onViewCreated(View view, Bundle savedInstanceState) { | |
super.onViewCreated(view, savedInstanceState); | |
maybeLoad(); | |
} | |
@Override | |
public void setUserVisibleHint(boolean isVisibleToUser) { | |
super.setUserVisibleHint(isVisibleToUser); | |
maybeLoad(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment