public class MvpDelegate<Delegated>
extends java.lang.Object
This class represents a delegate which you can use to extend Mvp's support to any class.
When using an MvpDelegate, lifecycle methods which should be proxied 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 Object can only be linked with one MvpDelegate instance,
so the instance returned from MvpDelegate(Object)} should be kept
until the Object is destroyed.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
MOXY_DELEGATE_TAGS_KEY |
| Constructor and Description |
|---|
MvpDelegate(Delegated delegated) |
| Modifier and Type | Method and Description |
|---|---|
void |
freeParentDelegate()
Free self link from children list (mChildDelegates) in parent delegate
property mParentDelegate stay keep link to parent delegate for access to
parent bundle for save state in
onSaveInstanceState() |
android.os.Bundle |
getChildrenSaveState() |
void |
onAttach()
Attach delegated object as view to presenter fields of this object.
|
void |
onCreate()
Similar like
onCreate(Bundle). |
void |
onCreate(android.os.Bundle bundle)
Get(or create if not exists) presenters for delegated object and bind
them to this object fields
|
void |
onDestroy()
Destroy presenters.
|
void |
onDestroyView()
View was being destroyed, but logical unit still alive
|
void |
onDetach()
Detach delegated object from their presenters.
|
void |
onSaveInstanceState()
Similar like
onSaveInstanceState(Bundle). |
void |
onSaveInstanceState(android.os.Bundle outState)
Save presenters tag prefix to save state for restore presenters at future after delegate recreate
|
void |
removeAllChildDelegates() |
void |
setParentDelegate(MvpDelegate delegate,
java.lang.String childId) |
public static final java.lang.String MOXY_DELEGATE_TAGS_KEY
public MvpDelegate(Delegated delegated)
public void setParentDelegate(MvpDelegate delegate, java.lang.String childId)
public void freeParentDelegate()
onSaveInstanceState()public void removeAllChildDelegates()
public void onCreate()
Similar like onCreate(Bundle). But this method try to get saved
state from parent presenter before get presenters
public void onCreate(android.os.Bundle bundle)
Get(or create if not exists) presenters for delegated object and bind them to this object fields
bundle - with saved statepublic void onAttach()
Attach delegated object as view to presenter fields of this object.
If delegate did not enter at onCreate(Bundle)(or
onCreate()) before this method, then view will not be attached to
presenters
public void onDetach()
Detach delegated object from their presenters.
public void onDestroyView()
View was being destroyed, but logical unit still alive
public void onDestroy()
Destroy presenters.
public void onSaveInstanceState()
Similar like onSaveInstanceState(Bundle). But this method try to save
state to parent presenter Bundle
public void onSaveInstanceState(android.os.Bundle outState)
outState - out state from Android componentpublic android.os.Bundle getChildrenSaveState()