package o.a.e;

import g.h.a.i;
import java.util.ArrayList;
import o.a.h.g.j;

/* JADX INFO: loaded from: classes.dex */
public final class a implements b, o.a.h.a.a {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public o.a.h.h.b<b> f5961f;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public volatile boolean f5962m;

    @Override // o.a.h.a.a
    public boolean a(b bVar) {
        if (!d(bVar)) {
            return false;
        }
        ((j) bVar).b();
        return true;
    }

    @Override // o.a.e.b
    public void b() {
        if (this.f5962m) {
            return;
        }
        synchronized (this) {
            if (this.f5962m) {
                return;
            }
            this.f5962m = true;
            o.a.h.h.b<b> bVar = this.f5961f;
            this.f5961f = null;
            g(bVar);
        }
    }

    @Override // o.a.h.a.a
    public boolean c(b bVar) {
        if (!this.f5962m) {
            synchronized (this) {
                if (!this.f5962m) {
                    o.a.h.h.b<b> bVar2 = this.f5961f;
                    if (bVar2 == null) {
                        bVar2 = new o.a.h.h.b<>();
                        this.f5961f = bVar2;
                    }
                    bVar2.a(bVar);
                    return true;
                }
            }
        }
        bVar.b();
        return false;
    }

    /* JADX WARN: Removed duplicated region for block: B:25:0x0045  */
    /* JADX WARN: Removed duplicated region for block: B:26:0x0046 A[Catch: all -> 0x004a, DONT_GENERATE, TryCatch #0 {, blocks: (B:6:0x000c, B:8:0x0010, B:10:0x0012, B:12:0x0016, B:26:0x0046, B:15:0x002a, B:17:0x0030, B:18:0x0035, B:21:0x003c, B:28:0x0048), top: B:33:0x000c }] */
    @Override // o.a.h.a.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public boolean d(o.a.e.b r8) {
        /*
            r7 = this;
            java.lang.String r0 = "disposables is null"
            java.util.Objects.requireNonNull(r8, r0)
            boolean r0 = r7.f5962m
            r1 = 0
            if (r0 == 0) goto Lb
            return r1
        Lb:
            monitor-enter(r7)
            boolean r0 = r7.f5962m     // Catch: java.lang.Throwable -> L4a
            if (r0 == 0) goto L12
            monitor-exit(r7)     // Catch: java.lang.Throwable -> L4a
            return r1
        L12:
            o.a.h.h.b<o.a.e.b> r0 = r7.f5961f     // Catch: java.lang.Throwable -> L4a
            if (r0 == 0) goto L48
            T[] r2 = r0.f6106d     // Catch: java.lang.Throwable -> L4a
            int r3 = r0.a     // Catch: java.lang.Throwable -> L4a
            int r4 = r8.hashCode()     // Catch: java.lang.Throwable -> L4a
            int r4 = o.a.h.h.b.b(r4)     // Catch: java.lang.Throwable -> L4a
            r4 = r4 & r3
            r5 = r2[r4]     // Catch: java.lang.Throwable -> L4a
            r6 = 1
            if (r5 != 0) goto L2a
        L28:
            r8 = r1
            goto L43
        L2a:
            boolean r5 = r5.equals(r8)     // Catch: java.lang.Throwable -> L4a
            if (r5 == 0) goto L35
        L30:
            r0.c(r4, r2, r3)     // Catch: java.lang.Throwable -> L4a
            r8 = r6
            goto L43
        L35:
            int r4 = r4 + r6
            r4 = r4 & r3
            r5 = r2[r4]     // Catch: java.lang.Throwable -> L4a
            if (r5 != 0) goto L3c
            goto L28
        L3c:
            boolean r5 = r5.equals(r8)     // Catch: java.lang.Throwable -> L4a
            if (r5 == 0) goto L35
            goto L30
        L43:
            if (r8 != 0) goto L46
            goto L48
        L46:
            monitor-exit(r7)     // Catch: java.lang.Throwable -> L4a
            return r6
        L48:
            monitor-exit(r7)     // Catch: java.lang.Throwable -> L4a
            return r1
        L4a:
            r8 = move-exception
            monitor-exit(r7)     // Catch: java.lang.Throwable -> L4a
            throw r8
        */
        throw new UnsupportedOperationException("Method not decompiled: o.a.e.a.d(o.a.e.b):boolean");
    }

    public void f() {
        if (this.f5962m) {
            return;
        }
        synchronized (this) {
            if (this.f5962m) {
                return;
            }
            o.a.h.h.b<b> bVar = this.f5961f;
            this.f5961f = null;
            g(bVar);
        }
    }

    public void g(o.a.h.h.b<b> bVar) {
        if (bVar == null) {
            return;
        }
        ArrayList arrayList = null;
        for (b bVar2 : bVar.f6106d) {
            if (bVar2 instanceof b) {
                try {
                    bVar2.b();
                } catch (Throwable th) {
                    i.F3(th);
                    if (arrayList == null) {
                        arrayList = new ArrayList();
                    }
                    arrayList.add(th);
                }
            }
        }
        if (arrayList != null) {
            if (arrayList.size() != 1) {
                throw new o.a.f.a(arrayList);
            }
            throw o.a.h.h.a.a((Throwable) arrayList.get(0));
        }
    }
}
