mac
2024-07-16 3ec7de773bff5582411c6f1f659d35cf8fb1734a
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
package com.hdl.photovoltaic.widget;
 
import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.WindowManager;
import android.widget.TextView;
 
 
import com.hdl.photovoltaic.R;
import com.hdl.photovoltaic.base.BaseDialog;
 
public class LoadingDialog extends BaseDialog {
    private TextView content;
 
    public LoadingDialog(Context context, int theme) {
        super(context, theme);
        init(context);
    }
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
 
    private void init(Context context) {
        setCancelable(true);//系统后退可以取消
        setCanceledOnTouchOutside(false);
        setContentView(R.layout.loading_alert);
        content = (TextView) findViewById(R.id.load_content_tv);
        WindowManager.LayoutParams params = getWindow().getAttributes();
        params.width = WindowManager.LayoutParams.WRAP_CONTENT;
        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
        getWindow().setAttributes(params);
//        content.setText(R.string.device_加载中);
    }
 
    public void setText(String mes) {
        if (content != null && !TextUtils.isEmpty(mes)) {
            content.setText(mes);
        }
    }
 
    public String getTest() {
        return content.getText().toString().trim();
    }
 
    public void start() {
        if (!this.isShowing()) {
            this.show();
        }
    }
 
    //点击外部不关闭
    public void startTouchNotGone() {
        if (!this.isShowing()) {
            this.show();
            setCancelable(true);
            setCanceledOnTouchOutside(false);
        }
    }
 
    public void stop() {
        this.dismiss();
        this.cancel();
    }
 
}