T.java
2.94 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
99
100
101
102
103
package com.gimi.common.cinema.utils;
import android.content.Context;
import android.widget.Toast;
/**
* @author 李攀 pan[dot]li@xgimi[dot]com
* @describe
* @date 2014/11/12
*/
public class T {
// private static Toast toast;
// private static Handler handler = new Handler();
//
// private static Runnable run = new Runnable() {
// public void run() {
// toast.cancel();
// }
// };
//
// private static void toast(Context ctx, CharSequence msg) {
// handler.removeCallbacks(run);
// // handler的duration不能直接对应Toast的常量时长,在此针对Toast的常量相应定义时长
// if (null != toast) {
// toast.setText(msg);
// } else {
// toast = Toast.makeText(ctx, msg, Toast.LENGTH_SHORT);
// }
// handler.postDelayed(run, 2000);
// toast.show();
// }
//
// private static void toastLong(Context ctx, CharSequence msg) {
// handler.removeCallbacks(run);
// // handler的duration不能直接对应Toast的常量时长,在此针对Toast的常量相应定义时长
// if (null != toast) {
// toast.setText(msg);
// } else {
// toast = Toast.makeText(ctx, msg, Toast.LENGTH_LONG);
// }
// handler.postDelayed(run, 6000);
// toast.show();
// }
//
// /**
// * 弹出Toast
// *
// * @param ctx 弹出Toast的上下文
// * @param msg 弹出Toast的内容
// */
public static void showLong(Context ctx, CharSequence msg) {
Toast.makeText(ctx, msg, Toast.LENGTH_LONG).show();
}
//
// /**
// * 弹出Toast
// *
// * @param ctx 弹出Toast的上下文
// * @param resId 弹出Toast的内容的资源ID
// */
// public static void showLong(Context ctx, int resId)
// throws NullPointerException {
// if (null == ctx) {
// throw new NullPointerException("The ctx is null!");
// }
// toastLong(ctx, ctx.getResources().getString(resId));
// }
/**
* 弹出Toast
*
* @param ctx 弹出Toast的上下文
* @param msg 弹出Toast的内容
*/
public static void show(Context ctx, CharSequence msg) {
// if (null == ctx) {
// throw new NullPointerException("The context is null!");
// }
// toast(ctx, msg);
Toast.makeText(ctx, msg, Toast.LENGTH_SHORT).show();
}
// /**
// * 弹出Toast
// *
// * @param ctx 弹出Toast的上下文
// * @param resId 弹出Toast的内容的资源ID
// */
// public static void show(Context ctx, int resId)
// throws NullPointerException {
// if (null == ctx) {
// throw new NullPointerException("The ctx is null!");
// }
// toast(ctx, ctx.getResources().getString(resId));
// }
//
// public static void cancel() {
// if (toast != null) {
// handler.postDelayed(run, 20);
// }
// }
}