I follow MVP pattern. I have two methods in the presenter setView(Avtivity a) & clearView()
What is better for performance, to call those on onStart() & onStop() or onCreate() & onDestroy
I follow MVP pattern. I have two methods in the presenter setView(Avtivity a) & clearView()
What is better for performance, to call those on onStart() & onStop() or onCreate() & onDestroy
From the diagram we can see that in the onStop() the view is just hidden so i would suggest you to clearView in onDestroy(). And an extra suggestion is that it would be better to implement the activity with a interface such as mvpView which holds all the methods that presenter is likely to call and change the as setView(MvpView view).
What do you mean? i use MVP and each View have presenter that have a presenter interface with attachView and detachView
And i always call them on onCreate()
I think you should look at the first answer of this post Difference between onCreate() and onStart()?
i think onCreate() is what you should always use if you are attaching a view
I would suggest to set Activity View onCreate, and remove it onDestroy, you can also set Fragment View onAttach and remove it onDetach.
I have to add that this is not a concept of performance! You have to avoid memory leak in this regard.
It depends.. There are 3 sets of callbacks you can use
1) onResume() onPause()
Which will make the view reference available to your presenter only when that view is visible and user can interact with it
2) onStart() onStop()
Which will make the view reference available to your presenter as above plus if the view is even partially visible
3) onCreate() onDestroy()
Which will make the view reference available to your presenter as long as it exists basically
onCreate() onDestroy() pair will be called only once for each view, while on the other hand the other ones will be called more frequently