111
hxb
2022-11-24 0a3e07f10937484145f33c7560607b4b2353cb81
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
package com.mm.android.deviceaddmodule.mobilecommon.base.mvp;
 
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
 
import com.mm.android.deviceaddmodule.R;
import com.mm.android.deviceaddmodule.mobilecommon.base.BaseFragmentActivity;
import com.mm.android.deviceaddmodule.mobilecommon.eventbus.event.BaseEvent;
 
/**
 * MVP模式FragmentActivity基类,继承自common模块基类FragmentAcitivity,实现BaseView中通用接口,所有MVP模式的FragmentActivity需继承自此类。
 **/
public abstract class BaseMvpFragmentActivity<T extends IBasePresenter> extends BaseFragmentActivity implements IBaseView {
 
    protected abstract void initLayout();         //初始化布局
    protected abstract void initView();           //初始化控件
    protected abstract void initData();           //初始化数据
    protected T mPresenter;
 
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initPresenter();
        initData();
        initLayout();
        initView();
    }
 
    @Override
    protected void onDestroy() {
        if(mPresenter != null) mPresenter.unInit();
        super.onDestroy();
    }
 
    @Override
    public Context getContextInfo() {
        return this;
    }
 
    @Override
    public boolean isViewActive() {
        return !isActivityDestory();
    }
 
    @Override
    public void showToastInfo(String msg) {
        toast(msg);
    }
 
    @Override
    public void showToastInfo(int msgId) {
        toast(msgId);
    }
 
    @Override
    public void showToastInfo(int msgId, String errorDesc) {
        if (!TextUtils.isEmpty(errorDesc)) {
            toast(errorDesc);
        } else {
            toast(msgId);
        }
    }
 
    @Override
    public void showProgressDialog() {
        showProgressDialog(R.layout.mobile_common_progressdialog_layout);
    }
 
    @Override
    public void onMessageEvent(BaseEvent event) {
 
    }
 
    @Override
    public void unInit() {
 
    }
 
    @Override
    public void initPresenter() {
 
    }
 
    public void cancelProgressDialog() {
        dissmissProgressDialog();
    }
}