-
Notifications
You must be signed in to change notification settings - Fork 841
/
ActivityMviDelegate.java
111 lines (97 loc) · 3.1 KB
/
ActivityMviDelegate.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
* Copyright 2015 Hannes Dorfmann.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hannesdorfmann.mosby3;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.hannesdorfmann.mosby3.mvi.MviPresenter;
import com.hannesdorfmann.mosby3.mvp.MvpPresenter;
import com.hannesdorfmann.mosby3.mvp.MvpView;
/**
* A delegate for Activities to attach them to mosbies mvp.
*
* <p>
* The following methods must be invoked from the corresponding Activities lifecycle methods:
* <ul>
* <li>{@link #onCreate(Bundle)}</li>
* <li>{@link #onDestroy()}</li>
* <li>{@link #onPause()} </li>
* <li>{@link #onResume()} </li>
* <li>{@link #onStart()} </li>
* <li>{@link #onStop()} </li>
* <li>{@link #onRestart()} </li>
* <li>{@link #onContentChanged()} </li>
* <li>{@link #onSaveInstanceState(Bundle)} </li>
* <li>{@link #onPostCreate(Bundle)} </li>
* <li></li>
* </ul>
* </p>
*
* @param <V> The type of {@link MvpView}
* @param <P> The type of {@link MvpPresenter}
* @author Hannes Dorfmann
* @since 1.1.0
*/
public interface ActivityMviDelegate<V extends MvpView, P extends MviPresenter<V, ?>> {
/**
* This method must be called from {@link Activity#onCreate(Bundle)}.
* This method internally creates the presenter and attaches the viewState to it.
*/
void onCreate(Bundle bundle);
/**
* This method must be called from {@link Activity#onDestroy()}}.
* This method internally detaches the viewState from presenter
*/
void onDestroy();
/**
* This method must be called from {@link Activity#onPause()}
*/
void onPause();
/**
* This method must be called from {@link Activity#onResume()}
*/
void onResume();
/**
* This method must be called from {@link Activity#onStart()}
*/
void onStart();
/**
* This method must be called from {@link Activity#onStop()}
*/
void onStop();
/**
* This method must be called from {@link Activity#onRestart()}
*/
void onRestart();
/**
* This method must be called from {@link Activity#onContentChanged()}
*/
void onContentChanged();
/**
* This method must be called from {@link Activity#onSaveInstanceState(Bundle)}
*/
void onSaveInstanceState(Bundle outState);
/**
* This method must be called from {@link Activity#onPostCreate(Bundle)}
*/
void onPostCreate(Bundle savedInstanceState);
/**
* This method must be called from {@link FragmentActivity#onRetainCustomNonConfigurationInstance()}
*
* @return Don't forget to return the value returned by this delegate method
*/
Object onRetainCustomNonConfigurationInstance();
}