package com.discord.utilities.view; import android.annotation.SuppressLint; import android.content.Context; import android.widget.Toast; import androidx.annotation.MainThread; import androidx.annotation.StringRes; import d0.z.d.m; import java.io.Closeable; /* compiled from: ToastManager.kt */ public class ToastManager implements Closeable { private Toast toast; public static /* synthetic */ void show$default(ToastManager toastManager, Context context, int i, int i2, int i3, Object obj) { if (obj == null) { if ((i3 & 4) != 0) { i2 = 0; } toastManager.show(context, i, i2); return; } throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: show"); } public static /* synthetic */ void show$default(ToastManager toastManager, Context context, CharSequence charSequence, int i, int i2, Object obj) { if (obj == null) { if ((i2 & 4) != 0) { i = 0; } toastManager.show(context, charSequence, i); return; } throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: show"); } @Override // java.io.Closeable, java.lang.AutoCloseable public void close() { Toast toast = this.toast; if (toast != null) { toast.cancel(); } this.toast = null; } @MainThread public final void show(Context context, @StringRes int i) { show$default(this, context, i, 0, 4, (Object) null); } @MainThread public final void show(Context context, @StringRes int i, int i2) { m.checkNotNullParameter(context, "context"); show(context, context.getString(i), i2); } @SuppressLint({"ShowToast"}) @MainThread public void show(Context context, CharSequence charSequence, int i) { m.checkNotNullParameter(context, "context"); Toast makeText = Toast.makeText(context, charSequence, i); m.checkNotNullExpressionValue(makeText, "Toast.makeText(context, text, duration)"); show(makeText); } @MainThread public void show(Toast toast) { m.checkNotNullParameter(toast, "newToast"); Toast toast2 = this.toast; if (toast2 != null) { toast2.cancel(); } toast.show(); this.toast = toast; } }