hxb
2022-11-22 b3513b1713bb979d0a69c5a8c4ddcd038f184e6e
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.base;
 
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
 
import com.mm.android.deviceaddmodule.event.DeviceAddEvent;
import com.mm.android.deviceaddmodule.mobilecommon.base.BaseFragment;
import com.mm.android.deviceaddmodule.mobilecommon.utils.LogUtil;
 
import org.greenrobot.eventbus.EventBus;
 
public abstract class BaseDevAddFragment extends BaseFragment {
 
    protected boolean isDestoryView;
 
    protected abstract void initView(View view);
 
    protected abstract void initData();
 
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        isDestoryView = false;
        LogUtil.debugLog("lcxw-fragment",getClass().getSimpleName()+ "--->onViewCreated");
        initView(view);
        initData();
    }
 
    @Override
    public void onDestroyView() {
        super.onDestroyView();
        isDestoryView = true;
        hideSoftKeyboard();
    }
 
    public void hideSoftKeyboard() {
        if (getActivity() == null) return ;
        InputMethodManager im = (InputMethodManager) getActivity()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        if (im.isActive() || getActivity().getCurrentFocus() != null) {
            im.hideSoftInputFromWindow(getActivity().findViewById(android.R.id.content)
                    .getWindowToken(), 0);
        }
    }
 
    public boolean isDestoryView() {
        return isDestoryView;
    }
 
    public Context getContextInfo() {
        return getActivity();
    }
 
    public boolean isViewActive() {
        return !isDestoryView();
    }
 
    public void showToastInfo(String msg) {
        toast(msg);
    }
 
    public void showToastInfo(int msgId) {
        toast(msgId);
    }
 
    public void showToastInfo(int msgId, String msg) {
        if (!TextUtils.isEmpty(msg)) {
            toast(msg);
        } else {
            toast(msgId);
        }
    }
 
    public void showProgressDialog() {
        EventBus.getDefault().post(new DeviceAddEvent(DeviceAddEvent.SHOW_LOADING_VIEW_ACTION));
    }
 
    public void cancelProgressDialog() {
        EventBus.getDefault().post(new DeviceAddEvent(DeviceAddEvent.DISMISS_LOADING_VIEW_ACTION));
    }
 
    public void finish(){
        getActivity().finish();
    }
}