Closed alexei-28 closed 6 years ago
This issue is not Mosby related only. You will face the same issue if you use just Activities.
So there are two things to consider: If your network call lives outside of the lifecycle of Activity because the activity is really destroyed (which seems to be what you are trying to achieve) then you can't use / rely on activity.onSaveInstanceState() or Mosby's ViewState (which is essentially the same under the hood). You have to find another solution for that problem, like using Android Services / JobScheduler plus a Database where you save the state of your request persistently so that once Activity and Presenter gets recreated you can query the database if the request was successful or not.
If you are just talking about the fact that the view is just destroyed temporarily (so no view attached to Presenter) you may find MvpQueuingBasePresenter (take a look at onceViewAttached().
I try to use Mosby. But I have one problem.
I have Activity (view), presenter ,model and viewState. On actvity I have button. When I click on button I call method from presenter to load data:
presenter.loadData()
Method that load data call 2 methods:2.
model.getData()`Method
model.getData()
create async http request (Retrofit). After request finish than presenter call method from view,view.hideProgress()
.OK. Thise scheme work fine.
But I have one problem. Steps:
presenter.loadData()
view.showProgress()
and start async http requestsaveInstanceState()
to save current state of view (progress is show)view.hideProgress()
restoreInstanceState()
The problem is that the progress must be hide , because network request was success finish when application was mnimize (not visible for user).
How I can fix problem? `