Skip to content

Instantly share code, notes, and snippets.

@princessdharmy
Created January 29, 2019 02:51
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/0356d0b9e7e8f6207b6bbd3e2c27c58c to your computer and use it in GitHub Desktop.
Save princessdharmy/0356d0b9e7e8f6207b6bbd3e2c27c58c to your computer and use it in GitHub Desktop.
public abstract class BaseActivity<T extends ViewModel> extends DaggerAppCompatActivity {
private T viewModel;
/**
*
* @return view model instance
*/
public abstract T getViewModel();
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.viewModel = viewModel == null ? getViewModel() : viewModel;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment