public class BasePresenter<M extends IModel,V extends IView> extends java.lang.Object implements IPresenter
| Modifier and Type | Field and Description |
|---|---|
protected CompositeDisposable |
mCompositeDisposable |
protected M |
mModel |
protected V |
mRootView |
protected java.lang.String |
TAG |
| Constructor and Description |
|---|
BasePresenter() |
BasePresenter(M model,
V rootView)
如果当前页面同时需要 Model 层和 View 层,则使用此构造函数(默认)
|
BasePresenter(V rootView)
如果当前页面不需要操作数据,只需要 View 层,则使用此构造函数
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDispose(Disposable disposable)
将
Disposable 添加到 CompositeDisposable 中统一管理
可在 Activity.onDestroy() 中使用 unDispose() 停止正在执行的 RxJava 任务,避免内存泄漏
目前框架已使用 RxLifecycle 避免内存泄漏,此方法作为备用方案 |
void |
onDestroy()
在框架中
Activity.onDestroy() 时会默认调用 IPresenter.onDestroy() |
void |
onStart()
做一些初始化操作
|
void |
unDispose()
停止集合中正在执行的 RxJava 任务
|
boolean |
useEventBus()
是否使用 EventBus
Arms 核心库现在并不会依赖某个 EventBus, 要想使用 EventBus, 还请在项目中自行依赖对应的 EventBus
现在支持两种 EventBus, greenrobot 的 EventBus 和畅销书 《Android源码设计模式解析与实战》的作者 何红辉 所作的 AndroidEventBus
确保依赖后, 将此方法返回 true, Arms 会自动检测您依赖的 EventBus, 并自动注册
这种做法可以让使用者有自行选择三方库的权利, 并且还可以减轻 Arms 的体积
|
protected final java.lang.String TAG
protected CompositeDisposable mCompositeDisposable
public BasePresenter(M model, V rootView)
model - rootView - public BasePresenter(V rootView)
rootView - public BasePresenter()
public void onStart()
IPresenteronStart in interface IPresenterpublic void onDestroy()
Activity.onDestroy() 时会默认调用 IPresenter.onDestroy()onDestroy in interface IPresenterpublic boolean useEventBus()
true (默认为使用 true), Arms 会自动注册 EventBuspublic void addDispose(Disposable disposable)
Disposable 添加到 CompositeDisposable 中统一管理
可在 Activity.onDestroy() 中使用 unDispose() 停止正在执行的 RxJava 任务,避免内存泄漏
目前框架已使用 RxLifecycle 避免内存泄漏,此方法作为备用方案disposable - public void unDispose()