44import android .content .Context ;
55import android .graphics .Typeface ;
66import android .graphics .drawable .Drawable ;
7- import android .os .Build ;
87import android .util .TypedValue ;
98import android .view .LayoutInflater ;
109import android .view .View ;
@@ -312,9 +311,6 @@ public static Toast custom(@NonNull Context context, @NonNull CharSequence messa
312311 if (icon == null ) {
313312 throw new IllegalArgumentException ("Avoid passing 'icon' as null if 'withIcon' is set to true" );
314313 }
315- if (Config .get ().isRTL && Build .VERSION .SDK_INT >= Build .VERSION_CODES .JELLY_BEAN_MR1 ) {
316- toastLayout .setLayoutDirection (View .LAYOUT_DIRECTION_RTL );
317- }
318314 Utils .setBackground (toastIcon , Config .get ().tintIcon ? Utils .tintIcon (icon , textColor ) : icon );
319315 } else {
320316 toastIcon .setVisibility (View .GONE );
@@ -330,26 +326,15 @@ public static Toast custom(@NonNull Context context, @NonNull CharSequence messa
330326 toastLayout .getBackground ().setAlpha (Config .get ().alpha );
331327 }
332328 currentToast .setView (toastLayout );
333- if (Config .get ().gravity != -1 ) {
334- currentToast .setGravity (Config .get ().gravity , Config .get ().xOffset , Config .get ().yOffset );
335- }
329+
336330 if (!Config .get ().allowQueue ) {
337331 if (lastToast != null ) {
338332 lastToast .cancel ();
339333 }
340334 lastToast = currentToast ;
341- // solve the problem of lastToast memory leak
342- currentToast .getView ().addOnAttachStateChangeListener (new View .OnAttachStateChangeListener () {
343- @ Override
344- public void onViewAttachedToWindow (View v ) {}
345- @ Override
346- public void onViewDetachedFromWindow (View v ) {
347- v .removeOnAttachStateChangeListener (this );
348- if (currentToast == lastToast ) {
349- lastToast = null ;
350- }
351- }
352- });
335+ }
336+ if (Config .get ().gravity != -1 ) {
337+ currentToast .setGravity (Config .get ().gravity , Config .get ().xOffset , Config .get ().yOffset );
353338 }
354339 return currentToast ;
355340 }
@@ -366,7 +351,6 @@ public static class Config {
366351 private int gravity = -1 ;
367352 private int xOffset = 0 ;
368353 private int yOffset = 0 ;
369- private boolean isRTL = false ;
370354
371355 private Config () {
372356
@@ -375,7 +359,7 @@ private Config() {
375359 /**
376360 * 获取单例
377361 *
378- * @return 配置
362+ * @return
379363 */
380364 public static Config get () {
381365 if (sInstance == null ) {
@@ -397,7 +381,6 @@ public void reset() {
397381 gravity = -1 ;
398382 xOffset = 0 ;
399383 yOffset = 0 ;
400- isRTL = false ;
401384 }
402385
403386 @ CheckResult
@@ -459,10 +442,5 @@ public Config setYOffset(int yOffset) {
459442 this .yOffset = yOffset ;
460443 return this ;
461444 }
462-
463- public Config setRTL (boolean isRTL ) {
464- this .isRTL = isRTL ;
465- return this ;
466- }
467445 }
468446}
0 commit comments