czyrux / MvpLoaderSample

Sample project to showcase how to use Android Loaders with MVP to preserve Presenter across orientation changes
140 stars 24 forks source link

BasePresenterFragment calls onPresenterPrepared before attaching the view. #1

Closed Jogan closed 8 years ago

Jogan commented 8 years ago

In onLoadFinished() of the BasePresenterFragment you call:

onPresenterPrepared(presenter); before presenter.onViewAttached(getPresenterView());

I would think this might potentially cause an issue if you call the presenter in the onPresenterPrepared method of the fragment before the view is attached.

czyrux commented 8 years ago

Probably the confusion here is due to a poor naming from me side. Maybe onInitializePresenter would be a better one. The idea behind onPresenterPrepared is to provide a hook for the fragment implementation to grab a reference to the restored/created Presenter before the view gets attached, so any additional data can be pass to the Presenter. I usually use attaching and detaching of the view in the Presenter as the callbacks to start any Presenter work (eg: start a background job, populate view content, etc), so by that time the Presenter should contain any needed information for its work.

Jogan commented 8 years ago

Ah interesting good to know thanks!