Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
- onCreate and other lifecycle stuff */
* Loader API callbacks
* */
/* Here we are creating a new instance of our loader and sending it
the presenter which it will store for future. */
public Loader<MainPresenter> onCreateLoader(int id, Bundle args) {
return new MainLoader(this, new MainPresenter(new DataManager(this)));
/* The deliverResult function from Loader delivers the result
back to us here, as you can see we set our local variable in
activity equal to the presenter that the loaders loads for
us. As initLoader() was called in onCreate(), this load
finishes before onStart() of activity, and thus we can start
using the presenter from onStart(). Also if rotation happens
onCreateLoader() is never called and the load from the
previously created loader is given back to us, i.e. the
pre-rotation presenter. */
public void onLoadFinished(Loader<MainPresenter> loader, MainPresenter presenter) {
this.presenter = presenter;
public void onLoaderReset(Loader<MainPresenter> loader) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment