ToastUtil.java
3.09 KB
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
package com.glsx.libble.util;
import android.content.Context;
import android.graphics.Color;
import android.view.Gravity;
import android.widget.Toast;
import com.blankj.utilcode.util.ToastUtils;
public class ToastUtil {
private static Toast lastToast = null;
public final static int LENGTH_SHORT = Toast.LENGTH_SHORT;
public final static int LENGTH_LONG = Toast.LENGTH_LONG;
public static void clear() {
if (lastToast != null) {
lastToast.cancel();
}
}
public static void show(int i) {
ToastUtils toastUtils = ToastUtils.make();
toastUtils.setDurationIsLong(false);
toastUtils.setBgColor(Color.BLACK);
toastUtils.setTextColor(Color.WHITE);
toastUtils.show(i);
}
public static void show(Context context, int i) {
ToastUtils toastUtils = ToastUtils.make();
toastUtils.setDurationIsLong(false);
toastUtils.setBgColor(Color.BLACK);
toastUtils.setTextColor(Color.WHITE);
toastUtils.show(i);
}
public static void showLongText( int i) {
ToastUtils toastUtils = ToastUtils.make();
toastUtils.setDurationIsLong(true);
toastUtils.setBgColor(Color.BLACK);
toastUtils.setTextColor(Color.WHITE);
toastUtils.show(i);
}
public static void showLongText( CharSequence charsequence) {
ToastUtils toastUtils = ToastUtils.make();
toastUtils.setDurationIsLong(true);
toastUtils.setBgColor(Color.BLACK);
toastUtils.setTextColor(Color.WHITE);
toastUtils.show(charsequence);
}
public static void show(Context context, CharSequence charsequence) {
ToastUtils toastUtils = ToastUtils.make();
toastUtils.setDurationIsLong(true);
toastUtils.setBgColor(Color.BLACK);
toastUtils.setTextColor(Color.WHITE);
toastUtils.show(charsequence);
}
public static void show(CharSequence charsequence) {
ToastUtils toastUtils = ToastUtils.make();
toastUtils.setDurationIsLong(false);
toastUtils.setBgColor(Color.BLACK);
toastUtils.setTextColor(Color.WHITE);
toastUtils.show(charsequence);
}
public static void showCenterTop(int msg) {
ToastUtils toastUtils = ToastUtils.make();
toastUtils.setGravity(Gravity.CENTER, 0, -300);
toastUtils.setDurationIsLong(false);
toastUtils.setBgColor(Color.BLACK);
toastUtils.setTextColor(Color.WHITE);
toastUtils.show(msg);
}
public static void showCenterTop(String msg) {
ToastUtils toastUtils = ToastUtils.make();
toastUtils.setGravity(Gravity.CENTER, 0, -300);
toastUtils.setDurationIsLong(false);
toastUtils.setBgColor(Color.BLACK);
toastUtils.setTextColor(Color.WHITE);
toastUtils.show(msg);
}
private static final boolean isShow = false;
/**
* 调试使用
*
* @param charsequence
*/
// public static void showTest(CharSequence charsequence) {
// if (isShow)
// Toast.makeText(CommonResApp.getContext(), charsequence, Toast.LENGTH_SHORT).show();
// }
}