hxb
2022-11-24 535d69817e83737f3da6250fc6fb70da25fc1a4c
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
package com.lechange.demo.dialog;
 
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
 
import com.lechange.demo.R;
import com.mm.android.deviceaddmodule.mobilecommon.widget.ClearEditText;
 
public class EncryptKeyInputDialog extends Dialog {
 
    private TextView tvTitle;
    private ClearEditText encryptKey;
    private TextView tvCancel;
    private TextView tvSure;
    private OnClick onClick;
 
    public EncryptKeyInputDialog(Context context) {
        super(context, R.style.custom_dialog);
    }
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_encryptkey_input);
        setCanceledOnTouchOutside(false);
        initView();
    }
 
    public void setText(String content){
        tvTitle.setText(content);
    }
 
 
    private void initView() {
        tvTitle = findViewById(R.id.tv_title);
        encryptKey = findViewById(R.id.encrypt_key);
        tvCancel = findViewById(R.id.tv_cancel);
        tvSure = findViewById(R.id.tv_sure);
        tvCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismissLoading();
            }
        });
        tvSure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String key = encryptKey.getText().toString().trim();
                if (onClick != null && !TextUtils.isEmpty(key)) {
                    onClick.onSure(key);
                    dismissLoading();
                }
            }
        });
    }
 
    public void dismissLoading() {
        dismiss();
    }
 
    public interface OnClick {
        void onSure(String txt);
    }
 
    public void setOnClick(OnClick onClick) {
        this.onClick = onClick;
    }
}