Package moxy

Class MvpPresenter<View extends MvpView>


  • 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
      void attachView​(View view)
      Attach view to a view state or to a presenter (if a view state doesn't exist).
      void destroyView​(View view)  
      void detachView​(View view)
      Detach view from a view state or from a presenter (if a view state doesn't exist).
      java.util.Set<View> getAttachedViews()  
      View getViewState()  
      boolean isInRestoreState​(View view)
      Check if view is in restore state or not
      void onDestroy()
      Called before the reference to this presenter will be cleared and an instance of the presenter will be never used.
      protected void onFirstViewAttach()
      Callback after the first presenter init and view binding.
      void setViewState​(MvpViewState<View> viewState)
      Set a view state to the presenter
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MvpPresenter

        public MvpPresenter()
    • 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 on MvpDelegate.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 on MvpDelegate.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.