25
25
* author: Blankj
26
26
* blog : http://blankj.com
27
27
* time : 2016/09/29
28
- * desc : 吐司相关工具类
28
+ * desc : utils about toast
29
29
* </pre>
30
30
*/
31
31
public final class ToastUtils {
@@ -46,11 +46,11 @@ private ToastUtils() {
46
46
}
47
47
48
48
/**
49
- * 设置吐司位置
49
+ * Set the gravity.
50
50
*
51
- * @param gravity 位置
52
- * @param xOffset x 偏移
53
- * @param yOffset y 偏移
51
+ * @param gravity The gravity.
52
+ * @param xOffset X-axis offset, in pixel.
53
+ * @param yOffset Y-axis offset, in pixel.
54
54
*/
55
55
public static void setGravity (final int gravity , final int xOffset , final int yOffset ) {
56
56
sGravity = gravity ;
@@ -59,55 +59,55 @@ public static void setGravity(final int gravity, final int xOffset, final int yO
59
59
}
60
60
61
61
/**
62
- * 设置背景颜色
62
+ * Set the color of background.
63
63
*
64
- * @param backgroundColor 背景色
64
+ * @param backgroundColor The color of background.
65
65
*/
66
66
public static void setBgColor (@ ColorInt final int backgroundColor ) {
67
67
sBgColor = backgroundColor ;
68
68
}
69
69
70
70
/**
71
- * 设置背景资源
71
+ * Set the resource of background.
72
72
*
73
- * @param bgResource 背景资源
73
+ * @param bgResource The resource of background.
74
74
*/
75
75
public static void setBgResource (@ DrawableRes final int bgResource ) {
76
76
sBgResource = bgResource ;
77
77
}
78
78
79
79
/**
80
- * 设置消息颜色
80
+ * Set the color of message.
81
81
*
82
- * @param msgColor 颜色
82
+ * @param msgColor The color of message.
83
83
*/
84
84
public static void setMsgColor (@ ColorInt final int msgColor ) {
85
85
sMsgColor = msgColor ;
86
86
}
87
87
88
88
/**
89
- * 安全地显示短时吐司
89
+ * Show the toast for a short period of time.
90
90
*
91
- * @param text 文本
91
+ * @param text The text.
92
92
*/
93
93
public static void showShort (@ NonNull final CharSequence text ) {
94
94
show (text , Toast .LENGTH_SHORT );
95
95
}
96
96
97
97
/**
98
- * 安全地显示短时吐司
98
+ * Show the toast for a short period of time.
99
99
*
100
- * @param resId 资源 Id
100
+ * @param resId The resource id for text.
101
101
*/
102
102
public static void showShort (@ StringRes final int resId ) {
103
103
show (resId , Toast .LENGTH_SHORT );
104
104
}
105
105
106
106
/**
107
- * 安全地显示短时吐司
107
+ * Show the toast for a short period of time.
108
108
*
109
- * @param resId 资源 Id
110
- * @param args 参数
109
+ * @param resId The resource id for text.
110
+ * @param args The args.
111
111
*/
112
112
public static void showShort (@ StringRes final int resId , final Object ... args ) {
113
113
if (args != null && args .length == 0 ) {
@@ -118,10 +118,10 @@ public static void showShort(@StringRes final int resId, final Object... args) {
118
118
}
119
119
120
120
/**
121
- * 安全地显示短时吐司
121
+ * Show the toast for a short period of time.
122
122
*
123
- * @param format 格式
124
- * @param args 参数
123
+ * @param format The format.
124
+ * @param args The args.
125
125
*/
126
126
public static void showShort (final String format , final Object ... args ) {
127
127
if (args != null && args .length == 0 ) {
@@ -132,28 +132,28 @@ public static void showShort(final String format, final Object... args) {
132
132
}
133
133
134
134
/**
135
- * 安全地显示长时吐司
135
+ * Show the toast for a long period of time.
136
136
*
137
- * @param text 文本
137
+ * @param text The text.
138
138
*/
139
139
public static void showLong (@ NonNull final CharSequence text ) {
140
140
show (text , Toast .LENGTH_LONG );
141
141
}
142
142
143
143
/**
144
- * 安全地显示长时吐司
144
+ * Show the toast for a long period of time.
145
145
*
146
- * @param resId 资源 Id
146
+ * @param resId The resource id for text.
147
147
*/
148
148
public static void showLong (@ StringRes final int resId ) {
149
149
show (resId , Toast .LENGTH_LONG );
150
150
}
151
151
152
152
/**
153
- * 安全地显示长时吐司
153
+ * Show the toast for a long period of time.
154
154
*
155
- * @param resId 资源 Id
156
- * @param args 参数
155
+ * @param resId The resource id for text.
156
+ * @param args The args.
157
157
*/
158
158
public static void showLong (@ StringRes final int resId , final Object ... args ) {
159
159
if (args != null && args .length == 0 ) {
@@ -164,10 +164,10 @@ public static void showLong(@StringRes final int resId, final Object... args) {
164
164
}
165
165
166
166
/**
167
- * 安全地显示长时吐司
167
+ * Show the toast for a long period of time.
168
168
*
169
- * @param format 格式
170
- * @param args 参数
169
+ * @param format The format.
170
+ * @param args The args.
171
171
*/
172
172
public static void showLong (final String format , final Object ... args ) {
173
173
if (args != null && args .length == 0 ) {
@@ -178,7 +178,7 @@ public static void showLong(final String format, final Object... args) {
178
178
}
179
179
180
180
/**
181
- * 安全地显示短时自定义吐司
181
+ * Show custom toast for a short period of time.
182
182
*/
183
183
public static View showCustomShort (@ LayoutRes final int layoutId ) {
184
184
final View view = getView (layoutId );
@@ -187,7 +187,7 @@ public static View showCustomShort(@LayoutRes final int layoutId) {
187
187
}
188
188
189
189
/**
190
- * 安全地显示长时自定义吐司
190
+ * Show custom toast for a long period of time.
191
191
*/
192
192
public static View showCustomLong (@ LayoutRes final int layoutId ) {
193
193
final View view = getView (layoutId );
@@ -196,7 +196,7 @@ public static View showCustomLong(@LayoutRes final int layoutId) {
196
196
}
197
197
198
198
/**
199
- * 取消吐司显示
199
+ * Cancel the toast.
200
200
*/
201
201
public static void cancel () {
202
202
if (sToast != null ) {
0 commit comments