package com.seewo.ota.util;

import android.content.Context;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.widget.Toast;
import com.seewo.ota.R;

/* JADX INFO: compiled from: ToastUtils.java */
/* JADX INFO: loaded from: classes.dex */
public class s {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private static volatile s f2341c;
    private Toast a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private final Handler f2342b = new Handler(Looper.getMainLooper());

    private s() {
    }

    public static s a() {
        if (f2341c == null) {
            synchronized (s.class) {
                if (f2341c == null) {
                    f2341c = new s();
                }
            }
        }
        return f2341c;
    }

    public /* synthetic */ void b(Context context, CharSequence charSequence, int i2) {
        Toast toast = this.a;
        if (toast == null) {
            this.a = Toast.makeText(context, charSequence, i2);
        } else {
            toast.setText(charSequence);
            this.a.setDuration(i2);
        }
        this.a.setGravity(80, 0, (int) context.getResources().getDimension(R.dimen.toast_margin_bottom_height));
        this.a.show();
    }

    public void c(Context context, int i2) {
        d(context, context.getResources().getText(i2));
    }

    public void d(Context context, CharSequence charSequence) {
        e(context, charSequence, 1);
    }

    public void e(final Context context, final CharSequence charSequence, final int i2) {
        Toast toast;
        if (Build.VERSION.SDK_INT >= 28 && (toast = this.a) != null) {
            toast.cancel();
            this.a = null;
        }
        this.f2342b.post(new Runnable() { // from class: com.seewo.ota.util.b
            @Override // java.lang.Runnable
            public final void run() {
                this.f2327b.b(context, charSequence, i2);
            }
        });
    }
}
