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>
AMvpPresenter
implmenetation 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 void
attachView(V view)
Set or attach the view to this presentervoid
detachView(boolean retainInstance)
Will be called if the view has been destroyed.protected V
getView()
Fetches the attached view.
-
-
-
Method Detail
-
attachView
public void attachView(V view)
Description copied from interface:MvpPresenter
Set or attach the view to this presenter- Specified by:
attachView
in 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:MvpPresenter
Will be called if the view has been destroyed. Typically this method will be invoked fromActivity.detachView()
orFragment.onDestroyView()
- Specified by:
detachView
in interfaceMvpPresenter<V extends MvpView>
- Parameters:
retainInstance
- flag used to retain instance
-
-