Created
June 25, 2017 16:42
-
-
Save GauravChaddha1996/56c35f39094c8cba889440e0e026de40 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
class MainLoader extends Loader<MainPresenter> { | |
private MainPresenter presenter; | |
/* When the loader is being created, we instantiate the | |
presenter also and keep it's object as private */ | |
MainLoader(Context context, MainPresenter presenter) { | |
super(context); | |
this.presenter = presenter; | |
} | |
/* This function is called when activity is being started. | |
Hence we deliver the result, our presenter, here. If the | |
activity is destroyed in rotation, the loader isn't created | |
again as system made sure it survived the rotation, and | |
thus when starting of activity calls this function again | |
automatically and we deliver the pre-rotation presenter as | |
our result to the activity in onLoadFinished callback*/ | |
@Override | |
protected void onStartLoading() { | |
deliverResult(presenter); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment