21
21
import android .widget .TextView ;
22
22
import android .widget .Toast ;
23
23
24
- import java .lang .ref .WeakReference ;
25
-
26
24
/**
27
25
* <pre>
28
26
* author: Blankj
@@ -36,9 +34,7 @@ public final class ToastUtils {
36
34
private static final int COLOR_DEFAULT = 0xFEFFFFFF ;
37
35
private static final Handler HANDLER = new Handler (Looper .getMainLooper ());
38
36
39
- private static Toast sToast ;
40
- private static WeakReference <View > sViewWeakReference ;
41
- private static int sLayoutId = -1 ;
37
+ private static Toast sToast ;
42
38
private static int gravity = Gravity .CENTER_HORIZONTAL | Gravity .BOTTOM ;
43
39
private static int xOffset = 0 ;
44
40
private static int yOffset = (int ) (64 * Utils .getApp ().getResources ().getDisplayMetrics ().density + 0.5 );
@@ -276,20 +272,8 @@ private static void setBg(final TextView tvMsg) {
276
272
}
277
273
278
274
private static View getView (@ LayoutRes final int layoutId ) {
279
- if (sLayoutId == layoutId ) {
280
- if (sViewWeakReference != null ) {
281
- final View toastView = sViewWeakReference .get ();
282
- if (toastView != null ) {
283
- return toastView ;
284
- }
285
- }
286
- }
287
275
LayoutInflater inflate =
288
276
(LayoutInflater ) Utils .getApp ().getSystemService (Context .LAYOUT_INFLATER_SERVICE );
289
- if (inflate == null ) return null ;
290
- final View toastView = inflate .inflate (layoutId , null );
291
- sViewWeakReference = new WeakReference <>(toastView );
292
- sLayoutId = layoutId ;
293
- return toastView ;
277
+ return inflate != null ? inflate .inflate (layoutId , null ) : null ;
294
278
}
295
279
}
0 commit comments