lmw
2023-03-11 4df5bb59e5fe9f9d140e5610f7772dd8a05a28d4
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package com.fuban.driver.base;
 
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
 
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
 
 
import com.fuban.driver.R;
import com.fuban.driver.ui.DialogUtil;
import com.fuban.driver.utils.EasePopup.EasyPopup;
 
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
 
import cn.sinata.xldutils.fragment.BaseFragment;
 
 
/**
 * MyBaseFragment
 *
 * @author Administrator
 * @date 2018/5/16
 */
public abstract class MyBaseFragment extends BaseFragment {
    protected final int PAGE_SIZE = 10;//每页条数
    protected int pageNumber = 1;//当前第几页
    public FragmentActivity mContext;
    public EasyPopup easyPopup;
 
    @Override
    protected int getContentViewLayoutID() {
        return 0;
    }
 
    @Override
    protected void onFirstVisibleToUser() {
 
    }
 
    @Override
    protected void onVisibleToUser() {
 
    }
 
    @Override
    protected void onInvisibleToUser() {
 
    }
 
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//        View view = inflater.inflate(layoutId(),container,false);
        View view = LayoutInflater.from(getActivity()).inflate(layoutId(),container,false);
        mContext = getActivity();
        EventBus.getDefault().register(this);
        return view;
    }
 
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initView();
    }
 
    @Override
    public void onResume() {
        super.onResume();
    }
 
    public abstract int layoutId();
 
    public abstract void initView();
 
 
    public void startActivity(Class tClass){
        startActivity(new Intent(mContext,tClass));
    }
 
    @Override
    public void showDialog() {
//        super.showDialog();
        if (easyPopup == null){
            easyPopup = DialogUtil.INSTANCE.getPopupwindow(getActivity(), R.layout.progress_dialog_main);
        }
        if (easyPopup.isShowing()){
            return;
        }
        FragmentActivity activity = getActivity();
        if (activity != null && activity.getWindow() != null) {
            try {
                getActivity().getWindow().getDecorView().post(() -> easyPopup.showCenter(getActivity().getWindow().getDecorView()));
            }catch (Exception e){
 
            }
        }
    }
 
    @Override
    public void onPause() {
        super.onPause();
        if (easyPopup != null && easyPopup.isShowing()){
            easyPopup.dismiss();
        }
    }
 
    @Override
    public void dismissDialog() {
//        super.dismissDialog();?
        if (easyPopup == null){
            easyPopup = DialogUtil.INSTANCE.getPopupwindow(getActivity(),R.layout.progress_dialog_main);
        }
        easyPopup.dismiss();
    }
 
    @Override
    public void onDestroyView() {
        super.onDestroyView();
        EventBus.getDefault().unregister(this);
    }
 
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventMainThread(BaseEvent event) {
 
    }
}