package com.google.android.play.core.tasks;

import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.google.android.play.core.b.r;
import java.util.concurrent.Executor;

public final class t<ResultT> extends e<ResultT> {
    public final Object LIZ = new Object();
    public final o<ResultT> LIZIZ = new o<>();
    public boolean LIZJ;
    public ResultT LIZLLL;
    public Exception LJ;

    static {
        Covode.recordClassIndex(44426);
    }

    private final void LJ() {
        r.LIZ(!this.LIZJ, (Object) "Task is already complete");
    }

    private final void LJFF() {
        boolean z;
        MethodCollector.i(9427);
        synchronized (this.LIZ) {
            try {
                z = this.LIZJ;
            } catch (Throwable th) {
                MethodCollector.o(9427);
                throw th;
            }
        }
        if (!z) {
            MethodCollector.o(9427);
            return;
        }
        this.LIZIZ.LIZ(this);
        MethodCollector.o(9427);
    }

    public final e<ResultT> LIZ(a<ResultT> aVar) {
        this.LIZIZ.LIZ(new i(f.LIZ, aVar));
        LJFF();
        return this;
    }

    public final e<ResultT> LIZ(b bVar) {
        LIZ(f.LIZ, bVar);
        return this;
    }

    public final e<ResultT> LIZ(c<? super ResultT> cVar) {
        LIZ(f.LIZ, cVar);
        return this;
    }

    public final e<ResultT> LIZ(Executor executor, b bVar) {
        this.LIZIZ.LIZ(new k(executor, bVar));
        LJFF();
        return this;
    }

    public final e<ResultT> LIZ(Executor executor, c<? super ResultT> cVar) {
        this.LIZIZ.LIZ(new m(executor, cVar));
        LJFF();
        return this;
    }

    public final void LIZ(Exception exc) {
        MethodCollector.i(9223);
        synchronized (this.LIZ) {
            try {
                LJ();
                this.LIZJ = true;
                this.LJ = exc;
            } catch (Throwable th) {
                MethodCollector.o(9223);
                throw th;
            }
        }
        this.LIZIZ.LIZ(this);
        MethodCollector.o(9223);
    }

    public final void LIZ(ResultT resultt) {
        MethodCollector.i(9020);
        synchronized (this.LIZ) {
            try {
                LJ();
                this.LIZJ = true;
                this.LIZLLL = resultt;
            } catch (Throwable th) {
                MethodCollector.o(9020);
                throw th;
            }
        }
        this.LIZIZ.LIZ(this);
        MethodCollector.o(9020);
    }

    public final boolean LIZ() {
        boolean z;
        MethodCollector.i(8636);
        synchronized (this.LIZ) {
            try {
                z = this.LIZJ;
            } finally {
                MethodCollector.o(8636);
            }
        }
        return z;
    }

    public final boolean LIZIZ() {
        boolean z;
        MethodCollector.i(8638);
        synchronized (this.LIZ) {
            try {
                z = false;
                if (this.LIZJ && this.LJ == null) {
                    z = true;
                }
            } finally {
                MethodCollector.o(8638);
            }
        }
        return z;
    }

    public final boolean LIZIZ(Exception exc) {
        MethodCollector.i(9225);
        synchronized (this.LIZ) {
            try {
                if (this.LIZJ) {
                    MethodCollector.o(9225);
                    return false;
                }
                this.LIZJ = true;
                this.LJ = exc;
                this.LIZIZ.LIZ(this);
                MethodCollector.o(9225);
                return true;
            } catch (Throwable th) {
                MethodCollector.o(9225);
                throw th;
            }
        }
    }

    public final boolean LIZIZ(ResultT resultt) {
        MethodCollector.i(9221);
        synchronized (this.LIZ) {
            try {
                if (this.LIZJ) {
                    MethodCollector.o(9221);
                    return false;
                }
                this.LIZJ = true;
                this.LIZLLL = resultt;
                this.LIZIZ.LIZ(this);
                MethodCollector.o(9221);
                return true;
            } catch (Throwable th) {
                MethodCollector.o(9221);
                throw th;
            }
        }
    }

    public final Exception LIZLLL() {
        Exception exc;
        MethodCollector.i(9011);
        synchronized (this.LIZ) {
            try {
                exc = this.LJ;
            } finally {
                MethodCollector.o(9011);
            }
        }
        return exc;
    }

    public final ResultT LIZJ() {
        ResultT resultt;
        MethodCollector.i(8843);
        synchronized (this.LIZ) {
            try {
                r.LIZ(this.LIZJ, (Object) "Task is not yet complete");
                Exception exc = this.LJ;
                if (exc == null) {
                    resultt = this.LIZLLL;
                } else {
                    d dVar = new d(exc);
                    MethodCollector.o(8843);
                    throw dVar;
                }
            } finally {
                MethodCollector.o(8843);
            }
        }
        return resultt;
    }
}
