- java.lang.Object
-
- moxy.MvpPresenter<View>
-
public abstract class MvpPresenter<View extends MvpView> extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description MvpPresenter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattachView(View view)Attach view to a view state or to a presenter (if a view state doesn't exist).voiddestroyView(View view)voiddetachView(View view)Detach view from a view state or from a presenter (if a view state doesn't exist).java.util.Set<View>getAttachedViews()ViewgetViewState()booleanisInRestoreState(View view)Check if view is in restore state or notvoidonDestroy()Called before the reference to this presenter will be cleared and an instance of the presenter will be never used.protected voidonFirstViewAttach()Callback after the first presenter init and view binding.voidsetViewState(MvpViewState<View> viewState)Set a view state to the presenter
-
-
-
Method Detail
-
attachView
public void attachView(View view)
Attach view to a view state or to a presenter (if a view state doesn't exist).
If you're using a
MvpDelegate, you should not call this method directly. It will be called onMvpDelegate.onAttach(), if a view is not attached yet.- Parameters:
view- a view to attach
-
onFirstViewAttach
protected void onFirstViewAttach()
Callback after the first presenter init and view binding. If this presenter instance will have to attach more views in the future, this method will not be called.
There you can interact with a
viewState.
-
detachView
public void detachView(View view)
Detach view from a view state or from a presenter (if a view state doesn't exist).
If you're using a
MvpDelegate, you should not call this method directly. It will be called onMvpDelegate.onDetach().- Parameters:
view- a view to detach
-
destroyView
public void destroyView(View view)
-
getAttachedViews
public java.util.Set<View> getAttachedViews()
- Returns:
- views attached to a view state, or attached to a presenter (if a view state doesn't exist)
-
getViewState
public View getViewState()
- Returns:
- view state, casted to the view interface for simplicity
-
setViewState
public void setViewState(MvpViewState<View> viewState)
Set a view state to the presenter- Parameters:
viewState- that implements type, setted as View generic param
-
isInRestoreState
public boolean isInRestoreState(View view)
Check if view is in restore state or not- Parameters:
view- a view for check- Returns:
- true if the view state is in restore state for the given view. False otherwise.
-
onDestroy
public void onDestroy()
Called before the reference to this presenter will be cleared and an instance of the presenter will be never used.
-
-