package f.a.s;

import android.os.Looper;
import f.a.t.b;
import java.util.concurrent.atomic.AtomicBoolean;

/* JADX INFO: compiled from: MainThreadDisposable.java */
/* JADX INFO: loaded from: classes.dex */
public abstract class a implements b {
    private final AtomicBoolean unsubscribed = new AtomicBoolean();

    /* JADX INFO: renamed from: f.a.s.a$a, reason: collision with other inner class name */
    /* JADX INFO: compiled from: MainThreadDisposable.java */
    public class RunnableC0062a implements Runnable {
        public RunnableC0062a() {
        }

        @Override // java.lang.Runnable
        public void run() {
            a.this.onDispose();
        }
    }

    public static void verifyMainThread() {
        if (Looper.myLooper() == Looper.getMainLooper()) {
            return;
        }
        StringBuilder sbB = d.b.a.a.a.B("Expected to be called on the main thread but was ");
        sbB.append(Thread.currentThread().getName());
        throw new IllegalStateException(sbB.toString());
    }

    @Override // f.a.t.b
    public final void dispose() {
        if (this.unsubscribed.compareAndSet(false, true)) {
            if (Looper.myLooper() == Looper.getMainLooper()) {
                onDispose();
            } else {
                f.a.s.b.a.a().b(new RunnableC0062a());
            }
        }
    }

    public final boolean isDisposed() {
        return this.unsubscribed.get();
    }

    public abstract void onDispose();
}
