Skip to content

Instantly share code, notes, and snippets.

@princessdharmy
Created January 29, 2019 02:56
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 princessdharmy/0572b3f2495333fc94d3e21b66b45788 to your computer and use it in GitHub Desktop.
Save princessdharmy/0572b3f2495333fc94d3e21b66b45788 to your computer and use it in GitHub Desktop.
public abstract class BaseFragment<T extends ViewModel> extends DaggerFragment {
private T viewModel;
/**
*
* @return view model instance
*/
public abstract T getViewModel();
@Override
public void onAttach(Context context) {
super.onAttach(context);
viewModel = getViewModel();
}
@Override
public void onDetach() {
super.onDetach();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment