2121import android .widget .TextView ;
2222import android .widget .Toast ;
2323
24- import java .lang .ref .WeakReference ;
25-
2624/**
2725 * <pre>
2826 * author: Blankj
@@ -36,9 +34,7 @@ public final class ToastUtils {
3634 private static final int COLOR_DEFAULT = 0xFEFFFFFF ;
3735 private static final Handler HANDLER = new Handler (Looper .getMainLooper ());
3836
39- private static Toast sToast ;
40- private static WeakReference <View > sViewWeakReference ;
41- private static int sLayoutId = -1 ;
37+ private static Toast sToast ;
4238 private static int gravity = Gravity .CENTER_HORIZONTAL | Gravity .BOTTOM ;
4339 private static int xOffset = 0 ;
4440 private static int yOffset = (int ) (64 * Utils .getApp ().getResources ().getDisplayMetrics ().density + 0.5 );
@@ -276,20 +272,8 @@ private static void setBg(final TextView tvMsg) {
276272 }
277273
278274 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- }
287275 LayoutInflater inflate =
288276 (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 ;
294278 }
295279}
0 commit comments