wxr
2022-11-23 1e7b3abd15d37f6c6bc97ac14922457b9604c275
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
package com.mm.android.deviceaddmodule.base;
 
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
 
import com.mm.android.deviceaddmodule.R;
 
/**
 * 引导提示页基类
 **/
public abstract class BaseTipFragment extends BaseDevAddFragment implements View.OnClickListener {
    protected ImageView mTipImg;
    protected TextView mTipTxt, mTipTxt2, mHelpTxt, mNextBtn;
    protected CheckBox mConfirmCheck;
    protected View mView;
 
    protected abstract void nextAction();       //下一步操作
 
    protected abstract void helpAction();       //帮助操作
 
    protected abstract void init();             //初始化view及Data
 
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        if (mView != null) {
            ViewGroup parent = (ViewGroup) mView.getParent();
            if (parent != null) {
                parent.removeView(mView);
            }
        } else {
            mView = inflater.inflate(R.layout.fragment_base_tip, container, false);
            init();
        }
        return mView;
    }
 
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
 
    }
 
    @Override
    protected void initView(View view) {
        mTipImg = view.findViewById(R.id.tip_img);
        mTipTxt = view.findViewById(R.id.tip_txt);
        mTipTxt2 = view.findViewById(R.id.tip_txt2);
        mHelpTxt = view.findViewById(R.id.help_tip);
        mNextBtn = view.findViewById(R.id.tv_next);
        mConfirmCheck = view.findViewById(R.id.cb_confirm);
        mNextBtn.setOnClickListener(this);
        mConfirmCheck.setOnClickListener(this);
        mHelpTxt.setOnClickListener(this);
    }
 
    //提示图平铺
    protected void tipImageMatch(){
        RelativeLayout.LayoutParams params= (RelativeLayout.LayoutParams) mTipImg.getLayoutParams();
        params.height= RelativeLayout.LayoutParams.WRAP_CONTENT;
        params.width=RelativeLayout.LayoutParams.MATCH_PARENT;
        params.setMargins(0,0,0,0);
    }
 
    @Override
    protected void initData() {
 
    }
 
    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.tv_next) {
            nextAction();
        } else if (id == R.id.cb_confirm) {
            mNextBtn.setEnabled(mConfirmCheck.isChecked());
        } else if (id == R.id.help_tip) {
            helpAction();
        }
    }
}