package o; import android.app.Activity; import android.content.Context; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Build; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import com.kofax.mobile.sdk._internal.impl.extraction.rtti.RttiJsonExactionHelper; import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodChannel; import o.C13137fRs; import org.simpleframework.xml.strategy.Name; /* renamed from: o.fRm, reason: case insensitive filesystem */ /* loaded from: classes6.dex */ public final class C13131fRm implements MethodChannel.MethodCallHandler { private Toast a; private Context e; public C13131fRm(Context context) { C14957gcv.e(context, ""); this.e = context; } @Override // io.flutter.plugin.common.MethodChannel.MethodCallHandler public final void onMethodCall(MethodCall methodCall, MethodChannel.Result result) { int i; Toast toast; C14957gcv.e(methodCall, ""); C14957gcv.e(result, ""); String str = methodCall.method; boolean b = C14957gcv.b((Object) str, (Object) "showToast"); Boolean bool = Boolean.TRUE; if (b) { String valueOf = String.valueOf(methodCall.argument("msg")); String valueOf2 = String.valueOf(methodCall.argument(Name.LENGTH)); String valueOf3 = String.valueOf(methodCall.argument("gravity")); Number number = (Number) methodCall.argument("bgcolor"); Number number2 = (Number) methodCall.argument("textcolor"); Number number3 = (Number) methodCall.argument("fontSize"); if (C14957gcv.b((Object) valueOf3, (Object) RttiJsonExactionHelper.TOP)) { i = 48; } else { i = C14957gcv.b((Object) valueOf3, (Object) "center") ? 17 : 80; } boolean b2 = C14957gcv.b((Object) valueOf2, (Object) "long"); if (number != null && Build.VERSION.SDK_INT <= 31) { Object systemService = this.e.getSystemService("layout_inflater"); C14957gcv.d(systemService, ""); View inflate = ((LayoutInflater) systemService).inflate(C13137fRs.LWm.toast_custom, (ViewGroup) null); TextView textView = (TextView) inflate.findViewById(C13137fRs.Sts.text); textView.setText(valueOf); Drawable drawable = this.e.getDrawable(C13137fRs.RVV.corner); C14957gcv.e(drawable); C14957gcv.c(drawable, ""); drawable.setColorFilter(number.intValue(), PorterDuff.Mode.SRC_IN); textView.setBackground(drawable); if (number3 != null) { textView.setTextSize(number3.floatValue()); } if (number2 != null) { textView.setTextColor(number2.intValue()); } Toast toast2 = new Toast(this.e); this.a = toast2; toast2.setDuration(b2 ? 1 : 0); Toast toast3 = this.a; if (toast3 != null) { toast3.setView(inflate); } } else { this.a = Toast.makeText(this.e, valueOf, b2 ? 1 : 0); if (Build.VERSION.SDK_INT <= 31) { try { Toast toast4 = this.a; View view = toast4 != null ? toast4.getView() : null; C14957gcv.e(view); View findViewById = view.findViewById(android.R.id.message); C14957gcv.c(findViewById, ""); TextView textView2 = (TextView) findViewById; if (number3 != null) { textView2.setTextSize(number3.floatValue()); } if (number2 != null) { textView2.setTextColor(number2.intValue()); } } catch (Exception unused) { } } } if (Build.VERSION.SDK_INT <= 31) { if (i == 17) { Toast toast5 = this.a; if (toast5 != null) { toast5.setGravity(i, 0, 0); } } else if (i != 48) { Toast toast6 = this.a; if (toast6 != null) { toast6.setGravity(i, 0, 100); } } else { Toast toast7 = this.a; if (toast7 != null) { toast7.setGravity(i, 0, 100); } } } Context context = this.e; if (context instanceof Activity) { C14957gcv.d(context, ""); ((Activity) context).runOnUiThread(new Runnable(this) { // from class: o.fRr private C13131fRm d; @Override // java.lang.Runnable public final void run() { C13131fRm.c(this.d); } { this.d = this; } }); } else { Toast toast8 = this.a; if (toast8 != null) { toast8.show(); } } if (Build.VERSION.SDK_INT >= 30 && (toast = this.a) != null) { toast.addCallback(new LWm(this)); } result.success(bool); return; } if (C14957gcv.b((Object) str, (Object) "cancel")) { Toast toast9 = this.a; if (toast9 != null) { if (toast9 != null) { toast9.cancel(); } this.a = null; } result.success(bool); return; } result.notImplemented(); } /* renamed from: o.fRm$LWm */ /* loaded from: classes6.dex */ public static final class LWm extends Toast.Callback { private C13131fRm e; LWm(C13131fRm c13131fRm) { this.e = c13131fRm; } @Override // android.widget.Toast.Callback public final void onToastHidden() { super.onToastHidden(); this.e.a = null; } } public static /* synthetic */ void c(C13131fRm c13131fRm) { C14957gcv.e(c13131fRm, ""); Toast toast = c13131fRm.a; if (toast != null) { toast.show(); } } }