haijiang
2018-06-25 586f13d3aa93fc3fdfed65021b1a17a17acf3321
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package com.moral.andbrickslib.utils;
 
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.widget.Toast;
 
/**
 * 吐司相关工具类
 */
public class ToastUtils {
 
    private Toast mToast;
    private Context context;
 
    public ToastUtils(Context context) {
        this.context = context.getApplicationContext();
    }
 
    public Toast getSingletonToast(int resId) {
        if (mToast == null) {
            mToast = Toast.makeText(context, resId, Toast.LENGTH_SHORT);
        } else {
            mToast.setText(resId);
        }
        return mToast;
    }
 
    public Toast getSingletonToast(String text) {
        if (mToast == null) {
            mToast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
        } else {
            mToast.setText(text);
        }
        return mToast;
    }
 
    public Toast getSingleLongToast(int resId) {
        if (mToast == null) {
            mToast = Toast.makeText(context, resId, Toast.LENGTH_LONG);
        } else {
            mToast.setText(resId);
        }
        return mToast;
    }
 
    public Toast getSingleLongToast(String text) {
        if (mToast == null) {
            mToast = Toast.makeText(context, text, Toast.LENGTH_LONG);
        } else {
            mToast.setText(text);
        }
        return mToast;
    }
 
    public Toast getToast(int resId) {
        return Toast.makeText(context, resId, Toast.LENGTH_SHORT);
    }
 
    public Toast getToast(String text) {
        return Toast.makeText(context, text, Toast.LENGTH_SHORT);
    }
 
    public Toast getLongToast(int resId) {
        return Toast.makeText(context, resId, Toast.LENGTH_LONG);
    }
 
    public Toast getLongToast(String text) {
        return Toast.makeText(context, text, Toast.LENGTH_LONG);
    }
 
    public void showSingletonToast(int resId) {
        getSingletonToast(resId).show();
    }
 
 
    public void showSingletonToast(String text) {
        getSingletonToast(text).show();
    }
 
    public void showSingleLongToast(int resId) {
        getSingleLongToast(resId).show();
    }
 
 
    public void showSingleLongToast(String text) {
        getSingleLongToast(text).show();
    }
 
    public void showToast(int resId) {
        getToast(resId).show();
    }
 
    public void showToast(String text) {
        getToast(text).show();
    }
 
    public void showLongToast(int resId) {
        getLongToast(resId).show();
    }
 
    public void showLongToast(String text) {
        getLongToast(text).show();
    }
}