左晓为主开发手持机充值管理机
zuoxiao
2024-07-29 fc1ec55e6ad56dc92737657750bcca7ed49f53eb
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
package com.dayu.qiheonlinelibrary.net.progress;
 
import android.content.Context;
import android.content.DialogInterface;
import android.os.Handler;
import android.os.Message;
 
 
/**
 * Created by qwy on 16/3/10.
 * 展示进度对话框
 */
public class ProgressDialogHandler extends Handler {
 
    public static final int SHOW_PROGRESS_DIALOG = 1;
    public static final int DISMISS_PROGRESS_DIALOG = 2;
 
    private NetLoadingDialog pd;
 
    private Context context;
    private boolean cancelable;
    private ProgressCancelListener mProgressCancelListener;
 
 
    public ProgressDialogHandler(Context context, ProgressCancelListener mProgressCancelListener,
                                 boolean cancelable) {
        super();
        this.context = context;
        this.mProgressCancelListener = mProgressCancelListener;
        this.cancelable = cancelable;
    }
 
    private void initProgressDialog() {
        try {
            if (pd == null) {
                pd = new NetLoadingDialog(context);
                pd.setCancelable(cancelable);
 
                if (cancelable) {
                    pd.setOnCancelListener(new DialogInterface.OnCancelListener() {
                        @Override
                        public void onCancel(DialogInterface dialogInterface) {
                            if (mProgressCancelListener != null)
                            mProgressCancelListener.onCancelProgress();
                        }
                    });
                }
 
                if (!pd.isShowing()) {
                    pd.startAnim();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
    private void dismissProgressDialog() {
        if (pd != null) {
            try {
                if (pd.isShowing()) {
                    pd.dismiss();
                }
                pd.stopAnim();
                pd = null;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
 
    @Override
    public void handleMessage(Message msg) {
        switch (msg.what) {
            case SHOW_PROGRESS_DIALOG:
                initProgressDialog();
                break;
            case DISMISS_PROGRESS_DIALOG:
                dismissProgressDialog();
                break;
        }
    }
 
}