public class MvpDelegate<Delegated>
extends java.lang.Object
This 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 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 (childDelegates) in parent delegate
property parentDelegate 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 a View into 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 is still alive
|
void |
onDetach()
Detach delegated object from its presenters.
|
void |
onSaveInstanceState()
Similar like
onSaveInstanceState(Bundle). |
void |
onSaveInstanceState(android.os.Bundle outState)
Saves presenters.
|
void |
registerExternalPresenterField(PresenterField<? super Delegated> field) |
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 a View into presenter fields of this object.
If delegate wasn't introduced in onCreate(Bundle) (or
onCreate()) before call to this method, the view will not be attached to its
presenters
public void onDetach()
Detach delegated object from its presenters.
public void onDestroyView()
View was being destroyed, but logical unit is still alive
public void onDestroy()
Destroy presenters.
public void onSaveInstanceState()
Similar like onSaveInstanceState(Bundle). But this method tries to save
its state to the parent presenter Bundle
public void onSaveInstanceState(android.os.Bundle outState)
outState - out state from Android componentpublic android.os.Bundle getChildrenSaveState()
public void registerExternalPresenterField(PresenterField<? super Delegated> field)