package androidx.lifecycle;

/* JADX INFO: loaded from: classes.dex */
public abstract class u {
    boolean mActive;
    int mLastVersion = -1;
    final x mObserver;
    final /* synthetic */ v this$0;

    public u(v vVar, x xVar) {
        this.this$0 = vVar;
        this.mObserver = xVar;
    }

    public void activeStateChanged(boolean z10) {
        if (z10 == this.mActive) {
            return;
        }
        this.mActive = z10;
        v vVar = this.this$0;
        int i10 = z10 ? 1 : -1;
        int i11 = vVar.f2710c;
        vVar.f2710c = i10 + i11;
        if (!vVar.f2711d) {
            vVar.f2711d = true;
            while (true) {
                try {
                    int i12 = vVar.f2710c;
                    if (i11 == i12) {
                        break;
                    }
                    boolean z11 = i11 == 0 && i12 > 0;
                    boolean z12 = i11 > 0 && i12 == 0;
                    if (z11) {
                        vVar.e();
                    } else if (z12) {
                        vVar.f();
                    }
                    i11 = i12;
                } catch (Throwable th) {
                    vVar.f2711d = false;
                    throw th;
                }
            }
            vVar.f2711d = false;
        }
        if (this.mActive) {
            this.this$0.dispatchingValue(this);
        }
    }

    public void detachObserver() {
    }

    public boolean isAttachedTo(p pVar) {
        return false;
    }

    public abstract boolean shouldBeActive();
}
