Skip to content

Commit 7a1dda4

Browse files
author
Ttt
committed
1.完善部分工具类代码注释、以及部分返回值等。
Former-commit-id: b882150
1 parent 4589e63 commit 7a1dda4

File tree

6 files changed

+233
-5
lines changed

6 files changed

+233
-5
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5e07d731e8f528acc4416b9d82b130e84117f336
1+
188350dfe58874ffa018c8c0b5df3df71b25a66d

DevLibUtils/src/main/java/dev/utils/app/toast/ToastUtils.java

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,44 @@ public static Toast getSignleToast(){
5050
// == Toast.LENGTH_SHORT ==
5151
// ========================
5252

53+
/**
54+
* 显示 一个短Toast
55+
* @param context
56+
* @param text
57+
* @return
58+
*/
5359
public static Toast showShort(Context context, String text) {
5460
return handlerToastStr(true, context, text, Toast.LENGTH_SHORT);
5561
}
5662

63+
/**
64+
* 显示 一个短Toast
65+
* @param context
66+
* @param text
67+
* @param objs
68+
* @return
69+
*/
5770
public static Toast showShort(Context context, String text, Object... objs) {
5871
return handlerToastStr(true, context, text, Toast.LENGTH_SHORT, objs);
5972
}
6073

74+
/**
75+
* 显示 一个短Toast
76+
* @param context
77+
* @param resId
78+
* @return
79+
*/
6180
public static Toast showShort(Context context, int resId) {
6281
return handlerToastRes(true, context, resId, Toast.LENGTH_SHORT);
6382
}
6483

84+
/**
85+
* 显示 一个短Toast
86+
* @param context
87+
* @param resId
88+
* @param objs
89+
* @return
90+
*/
6591
public static Toast showShort(Context context, int resId, Object... objs) {
6692
return handlerToastRes(true, context, resId, Toast.LENGTH_SHORT, objs);
6793
}
@@ -70,18 +96,44 @@ public static Toast showShort(Context context, int resId, Object... objs) {
7096
// == Toast.LENGTH_LONG ===
7197
// ========================
7298

99+
/**
100+
* 显示 一个长Toast
101+
* @param context
102+
* @param text
103+
* @return
104+
*/
73105
public static Toast showLong(Context context, String text) {
74106
return handlerToastStr(true, context, text, Toast.LENGTH_LONG);
75107
}
76108

109+
/**
110+
* 显示 一个长Toast
111+
* @param context
112+
* @param text
113+
* @param objs
114+
* @return
115+
*/
77116
public static Toast showLong(Context context, String text, Object... objs) {
78117
return handlerToastStr(true, context, text, Toast.LENGTH_LONG, objs);
79118
}
80119

120+
/**
121+
* 显示 一个长Toast
122+
* @param context
123+
* @param resId
124+
* @return
125+
*/
81126
public static Toast showLong(Context context, int resId) {
82127
return handlerToastRes(true, context, resId, Toast.LENGTH_LONG);
83128
}
84129

130+
/**
131+
* 显示 一个长Toast
132+
* @param context
133+
* @param resId
134+
* @param objs
135+
* @return
136+
*/
85137
public static Toast showLong(Context context, int resId, Object...objs) {
86138
return handlerToastRes(true, context, resId, Toast.LENGTH_LONG, objs);
87139
}
@@ -222,18 +274,44 @@ private static Toast handlerToastStr(boolean isSingle, Context context, String t
222274
// == Toast.LENGTH_SHORT ==
223275
// ========================
224276

277+
/**
278+
* 显示 一个新的短Toast
279+
* @param context
280+
* @param text
281+
* @return
282+
*/
225283
public static Toast showShortNew(Context context, String text) {
226284
return handlerToastStr(false, context, text, Toast.LENGTH_SHORT);
227285
}
228286

287+
/**
288+
* 显示 一个新的短Toast
289+
* @param context
290+
* @param text
291+
* @param objs
292+
* @return
293+
*/
229294
public static Toast showShortNew(Context context, String text, Object... objs) {
230295
return handlerToastStr(false, context, text, Toast.LENGTH_SHORT, objs);
231296
}
232297

298+
/**
299+
* 显示 一个新的短Toast
300+
* @param context
301+
* @param resId
302+
* @return
303+
*/
233304
public static Toast showShortNew(Context context, int resId) {
234305
return handlerToastRes(false, context, resId, Toast.LENGTH_SHORT);
235306
}
236307

308+
/**
309+
* 显示 一个新的短Toast
310+
* @param context
311+
* @param resId
312+
* @param objs
313+
* @return
314+
*/
237315
public static Toast showShortNew(Context context, int resId, Object... objs) {
238316
return handlerToastRes(false, context, resId, Toast.LENGTH_SHORT, objs);
239317
}
@@ -242,18 +320,44 @@ public static Toast showShortNew(Context context, int resId, Object... objs) {
242320
// == Toast.LENGTH_LONG ===
243321
// ========================
244322

323+
/**
324+
* 显示 一个新的长Toast
325+
* @param context
326+
* @param text
327+
* @return
328+
*/
245329
public static Toast showLongNew(Context context, String text) {
246330
return handlerToastStr(false, context, text, Toast.LENGTH_LONG);
247331
}
248332

333+
/**
334+
* 显示 一个新的长Toast
335+
* @param context
336+
* @param text
337+
* @param objs
338+
* @return
339+
*/
249340
public static Toast showLongNew(Context context, String text, Object... objs) {
250341
return handlerToastStr(false, context, text, Toast.LENGTH_LONG, objs);
251342
}
252343

344+
/**
345+
* 显示 一个新的长Toast
346+
* @param context
347+
* @param resId
348+
* @return
349+
*/
253350
public static Toast showLongNew(Context context, int resId) {
254351
return handlerToastRes(false, context, resId, Toast.LENGTH_LONG);
255352
}
256353

354+
/**
355+
* 显示 一个新的长Toast
356+
* @param context
357+
* @param resId
358+
* @param objs
359+
* @return
360+
*/
257361
public static Toast showLongNew(Context context, int resId, Object...objs) {
258362
return handlerToastRes(false, context, resId, Toast.LENGTH_LONG, objs);
259363
}

DevLibUtils/src/main/java/dev/utils/app/toast/cus/Toasty.java

Lines changed: 101 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ public static class Config {
9393
Config() {
9494
}
9595

96+
/**
97+
* 获取 Toasty 配置实例
98+
* @return
99+
*/
96100
@CheckResult
97101
public static Config getInstance() {
98102
return new Config();
@@ -314,93 +318,188 @@ public static void reset() {
314318

315319
// === normal ===
316320

321+
/**
322+
* 显示 normal 样式 Toast
323+
* @param context
324+
* @param message
325+
*/
317326
public static void normal(@NonNull Context context, @NonNull CharSequence message) {
318327
normal(context, message, Toast.LENGTH_SHORT, null);
319328
}
320329

330+
/**
331+
* 显示 normal 样式 Toast
332+
* @param context
333+
* @param message
334+
*/
321335
public static void normal(@NonNull Context context, @NonNull CharSequence message, Drawable icon) {
322336
normal(context, message, Toast.LENGTH_SHORT, icon);
323337
}
324338

339+
/**
340+
* 显示 normal 样式 Toast
341+
* @param context
342+
* @param message
343+
*/
325344
public static void normal(@NonNull Context context, @NonNull CharSequence message, int duration) {
326345
normal(context, message, duration, null);
327346
}
328347

348+
/**
349+
* 显示 normal 样式 Toast
350+
* @param context
351+
* @param message
352+
*/
329353
public static void normal(@NonNull Context context, @NonNull CharSequence message, int duration, Drawable icon) {
330354
custom(context, message, icon, NORMAL_COLOR, duration, true);
331355
}
332356

333357
// === warning ===
334358

359+
/**
360+
* 显示 warning 样式 Toast
361+
* @param context
362+
* @param message
363+
*/
335364
public static void warning(@NonNull Context context, @NonNull CharSequence message) {
336365
warning(context, message, Toast.LENGTH_SHORT, true);
337366
}
338367

368+
/**
369+
* 显示 warning 样式 Toast
370+
* @param context
371+
* @param message
372+
*/
339373
public static void warning(@NonNull Context context, @NonNull CharSequence message, int duration) {
340374
warning(context, message, duration, true);
341375
}
342376

377+
/**
378+
* 显示 warning 样式 Toast
379+
* @param context
380+
* @param message
381+
*/
343382
public static void warning(@NonNull Context context, @NonNull CharSequence message, int duration, boolean withIcon) {
344383
custom(context, message, ToastyUtils.getDrawable(context, R.drawable.dev_toast_ic_error_outline_white), WARNING_COLOR, duration, withIcon);
345384
}
346385

347386
// === info ===
348387

388+
/**
389+
* 显示 info 样式 Toast
390+
* @param context
391+
* @param message
392+
*/
349393
public static void info(@NonNull Context context, @NonNull CharSequence message) {
350394
info(context, message, Toast.LENGTH_SHORT, true);
351395
}
352396

397+
/**
398+
* 显示 info 样式 Toast
399+
* @param context
400+
* @param message
401+
*/
353402
public static void info(@NonNull Context context, @NonNull CharSequence message, int duration) {
354403
info(context, message, duration, true);
355404
}
356405

406+
/**
407+
* 显示 info 样式 Toast
408+
* @param context
409+
* @param message
410+
*/
357411
public static void info(@NonNull Context context, @NonNull CharSequence message, int duration, boolean withIcon) {
358412
custom(context, message, ToastyUtils.getDrawable(context, R.drawable.dev_toast_ic_info_outline_white), INFO_COLOR, duration, withIcon);
359413
}
360414

361415
// === success ===
362416

417+
/**
418+
* 显示 success 样式 Toast
419+
* @param context
420+
* @param message
421+
*/
363422
public static void success(@NonNull Context context, @NonNull CharSequence message) {
364423
success(context, message, Toast.LENGTH_SHORT, true);
365424
}
366425

426+
/**
427+
* 显示 success 样式 Toast
428+
* @param context
429+
* @param message
430+
*/
367431
public static void success(@NonNull Context context, @NonNull CharSequence message, int duration) {
368432
success(context, message, duration, true);
369433
}
370434

435+
/**
436+
* 显示 success 样式 Toast
437+
* @param context
438+
* @param message
439+
*/
371440
public static void success(@NonNull Context context, @NonNull CharSequence message, int duration, boolean withIcon) {
372441
custom(context, message, ToastyUtils.getDrawable(context, R.drawable.dev_toast_ic_check_white), SUCCESS_COLOR, duration, withIcon);
373442
}
374443

375444
// === error ===
376445

446+
/**
447+
* 显示 error 样式 Toast
448+
* @param context
449+
* @param message
450+
*/
377451
public static void error(@NonNull Context context, @NonNull CharSequence message) {
378452
error(context, message, Toast.LENGTH_SHORT, true);
379453
}
380454

455+
/**
456+
* 显示 error 样式 Toast
457+
* @param context
458+
* @param message
459+
*/
381460
public static void error(@NonNull Context context, @NonNull CharSequence message, int duration) {
382461
error(context, message, duration, true);
383462
}
384463

464+
/**
465+
* 显示 error 样式 Toast
466+
* @param context
467+
* @param message
468+
*/
385469
public static void error(@NonNull Context context, @NonNull CharSequence message, int duration, boolean withIcon) {
386470
custom(context, message, ToastyUtils.getDrawable(context, R.drawable.dev_toast_ic_clear_white), ERROR_COLOR, duration, withIcon);
387471
}
388472

389473
// === custom ===
390474

475+
/**
476+
* 显示 通用自定义Toast
477+
* @param context
478+
* @param message
479+
*/
391480
public static void custom(@NonNull Context context, @NonNull CharSequence message) {
392481
custom(context, message, null, -1, Toast.LENGTH_SHORT, false);
393482
}
394483

484+
/**
485+
* 显示 通用自定义Toast
486+
* @param context
487+
* @param message
488+
*/
395489
public static void custom(@NonNull Context context, @NonNull CharSequence message, Drawable icon) {
396490
custom(context, message, icon, -1, Toast.LENGTH_SHORT, true);
397491
}
398492

493+
/**
494+
* 显示 通用自定义Toast
495+
* @param context
496+
* @param message
497+
*/
399498
public static void custom(@NonNull Context context, @NonNull CharSequence message, @DrawableRes int iconRes, @ColorInt int tintColor) {
400499
custom(context, message, ToastyUtils.getDrawable(context, iconRes), tintColor, Toast.LENGTH_SHORT, true);
401500
}
402501
/**
403-
* 通用自定义显示Toast
502+
* 显示 通用自定义Toast
404503
* @param context
405504
* @param message 显示的内容
406505
* @param icon 图标
@@ -413,7 +512,7 @@ public static void custom(@NonNull Context context, @NonNull CharSequence messag
413512
}
414513

415514
/**
416-
* 通用自定义显示Toast
515+
* 显示 通用自定义Toast
417516
* @param context
418517
* @param message 显示的内容
419518
* @param icon 图标

0 commit comments

Comments
 (0)