Class MvpDelegate<Delegated>
- java.lang.Object
-
- moxy.MvpDelegate<Delegated>
-
public class MvpDelegate<Delegated> extends java.lang.ObjectDate: 18-Dec-15 Time: 13:51This class represents a delegate you can use to extend MVP support to any class.
When using an
MvpDelegate, the following lifecycle methods should be forwarded to the delegate:onCreate(Bundle)onAttach(): inside onStart() of Activity or FragmentonSaveInstanceState(android.os.Bundle)onDetach(): inside onDestroy() for Activity or onDestroyView() for FragmentonDestroy()
Every
Objectcan only be linked with oneMvpDelegateinstance, so the instance returned fromMvpDelegate(Object)} should be kept until the Object is destroyed.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringMOXY_DELEGATE_TAGS_KEY
-
Constructor Summary
Constructors Constructor Description MvpDelegate(Delegated delegated)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfreeParentDelegate()Free self link from children list (childDelegates) in parent delegate property parentDelegate stay keep link to parent delegate for access to parent bundle for save state inonSaveInstanceState()android.os.BundlegetChildrenSaveState()voidonAttach()Attach delegated object as a View into presenter fields of this object.voidonCreate()Similar likeonCreate(Bundle).voidonCreate(android.os.Bundle bundle)Get(or create if not exists) presenters for delegated object and bind them to this object fieldsvoidonDestroy()Destroy presenters.voidonDestroyView()View was being destroyed, but logical unit is still alivevoidonDetach()Detach delegated object from its presenters.voidonSaveInstanceState()Similar likeonSaveInstanceState(Bundle).voidonSaveInstanceState(android.os.Bundle outState)Saves presenters.voidregisterExternalPresenterField(PresenterField<? super Delegated> field)voidremoveAllChildDelegates()voidsetParentDelegate(MvpDelegate delegate, java.lang.String childId)
-
-
-
Field Detail
-
MOXY_DELEGATE_TAGS_KEY
public static final java.lang.String MOXY_DELEGATE_TAGS_KEY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MvpDelegate
public MvpDelegate(Delegated delegated)
-
-
Method Detail
-
setParentDelegate
public void setParentDelegate(MvpDelegate delegate, java.lang.String childId)
-
freeParentDelegate
public void freeParentDelegate()
Free self link from children list (childDelegates) in parent delegate property parentDelegate stay keep link to parent delegate for access to parent bundle for save state inonSaveInstanceState()
-
removeAllChildDelegates
public void removeAllChildDelegates()
-
onCreate
public void onCreate()
Similar like
onCreate(Bundle). But this method try to get saved state from parent presenter before get presenters
-
onCreate
public void onCreate(android.os.Bundle bundle)
Get(or create if not exists) presenters for delegated object and bind them to this object fields
- Parameters:
bundle- with saved state
-
onAttach
public void onAttach()
Attach delegated object as a View into presenter fields of this object. If delegate wasn't introduced in
onCreate(Bundle)(oronCreate()) before call to this method, the view will not be attached to its presenters
-
onDetach
public void onDetach()
Detach delegated object from its presenters.
-
onDestroyView
public void onDestroyView()
View was being destroyed, but logical unit is still alive
-
onDestroy
public void onDestroy()
Destroy presenters.
-
onSaveInstanceState
public void onSaveInstanceState()
Similar like
onSaveInstanceState(Bundle). But this method tries to save its state to the parent presenter Bundle
-
onSaveInstanceState
public void onSaveInstanceState(android.os.Bundle outState)
Saves presenters. Tag prefix to save state to restore presenters in the future after the delegate will be recreated- Parameters:
outState- out state from Android component
-
getChildrenSaveState
public android.os.Bundle getChildrenSaveState()
-
registerExternalPresenterField
public void registerExternalPresenterField(PresenterField<? super Delegated> field)
-
-