Class MvpNullObjectBasePresenter<V extends MvpView>
- java.lang.Object
-
- com.cheetahdigital.uikit.architecture.mvp.MvpNullObjectBasePresenter<V>
-
- Type Parameters:
V- The type of theMvpView
- All Implemented Interfaces:
MvpPresenter<V>
- Direct Known Subclasses:
AlertChallengePresenter,ChangePasswordPresenter,CodeScannerPresenter,LoginPresenter,Presenter,SubmitReceiptPresenter
public class MvpNullObjectBasePresenter<V extends MvpView> extends java.lang.Object implements MvpPresenter<V>
AMvpPresenterimplmenetation that implements the null object pattern for the attached mvp view. So whenever the view gets detached from this presenter by callingdetachView(boolean), a new "null object" view gets dynamically instantiated by using reflections and set as the current view (instead of null). The new "null object" view simply does nothing. This avoids null pointer exceptions and checks likeif (getView() != null)- Since:
- 1.2.0
- See Also:
MvpBasePresenter
-
-
Constructor Summary
Constructors Constructor Description MvpNullObjectBasePresenter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattachView(V view)Set or attach the view to this presentervoiddetachView(boolean retainInstance)Will be called if the view has been destroyed.protected VgetView()Fetches the attached view.
-
-
-
Method Detail
-
attachView
public void attachView(V view)
Description copied from interface:MvpPresenterSet or attach the view to this presenter- Specified by:
attachViewin interfaceMvpPresenter<V extends MvpView>- Parameters:
view- where presenter is attached
-
getView
@NonNull protected V getView()
Fetches the attached view.- Returns:
- The view.
-
detachView
public void detachView(boolean retainInstance)
Description copied from interface:MvpPresenterWill be called if the view has been destroyed. Typically this method will be invoked fromActivity.detachView()orFragment.onDestroyView()- Specified by:
detachViewin interfaceMvpPresenter<V extends MvpView>- Parameters:
retainInstance- flag used to retain instance
-
-