Skip to content

Instantly share code, notes, and snippets.

@orhanobut
Created September 22, 2015 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orhanobut/6dc198f834bdf428bf1c to your computer and use it in GitHub Desktop.
Save orhanobut/6dc198f834bdf428bf1c to your computer and use it in GitHub Desktop.
public class BaseFragment extends Fragment {
private static final String KEY_UUUID = "KEY_UUID";
private String uuid;
@Override public void onCreate(Bundle bundle) {
super.onCreate(bundle);
if (bundle != null && bundle.containsKey(KEY_UUID)) {
uuid = bundle.getString(KEY_UUID);
} else {
uuid = UUID.randomUUID().toString();
}
}
@Override public void onSaveInstanceState(Bundle outState) {
outState.putString(KEY_UUID, uuid);
super.onSaveInstanceState(outState);
}
protected boolean isEqual(String uuid) {
return TextUtils.equals(uuid, this.uuid);
}
public String getUUID(){
return uuid;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment