package androidx.fragment.app;

import android.view.View;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Objects;
import o.AbstractC2462sn;
import o.C2638ug;
import o.InterfaceC2543tg;
import o.WT;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class x {
    public int a;
    public int b;
    public final l c;
    public final ArrayList d;
    public final HashSet e;
    public boolean f;
    public boolean g;
    public final v h;

    public x(int i, int i2, v vVar, C2638ug c2638ug) {
        l lVar = vVar.c;
        this.d = new ArrayList();
        this.e = new HashSet();
        this.f = false;
        this.g = false;
        this.a = i;
        this.b = i2;
        this.c = lVar;
        c2638ug.a(new WT(17, this));
        this.h = vVar;
    }

    public final void a() {
        HashSet hashSet = this.e;
        if (this.f) {
            return;
        }
        this.f = true;
        if (hashSet.isEmpty()) {
            b();
            return;
        }
        ArrayList arrayList = new ArrayList(hashSet);
        int size = arrayList.size();
        int i = 0;
        while (i < size) {
            Object obj = arrayList.get(i);
            i++;
            C2638ug c2638ug = (C2638ug) obj;
            synchronized (c2638ug) {
                try {
                    if (!c2638ug.a) {
                        c2638ug.a = true;
                        c2638ug.c = true;
                        InterfaceC2543tg interfaceC2543tg = c2638ug.b;
                        if (interfaceC2543tg != null) {
                            try {
                                interfaceC2543tg.onCancel();
                            } catch (Throwable th) {
                                synchronized (c2638ug) {
                                    c2638ug.c = false;
                                    c2638ug.notifyAll();
                                    throw th;
                                }
                            }
                        }
                        synchronized (c2638ug) {
                            c2638ug.c = false;
                            c2638ug.notifyAll();
                        }
                    }
                } finally {
                }
            }
        }
    }

    public final void b() {
        if (!this.g) {
            if (s.F(2)) {
                toString();
            }
            this.g = true;
            ArrayList arrayList = this.d;
            int size = arrayList.size();
            int i = 0;
            while (i < size) {
                Object obj = arrayList.get(i);
                i++;
                ((Runnable) obj).run();
            }
        }
        this.h.i();
    }

    public final void c(int i, int i2) {
        int iW = AbstractC2462sn.w(i2);
        l lVar = this.c;
        if (iW == 0) {
            if (this.a != 1) {
                if (s.F(2)) {
                    Objects.toString(lVar);
                }
                this.a = i;
                return;
            }
            return;
        }
        if (iW != 1) {
            if (iW != 2) {
                return;
            }
            if (s.F(2)) {
                Objects.toString(lVar);
            }
            this.a = 1;
            this.b = 3;
            return;
        }
        if (this.a == 1) {
            if (s.F(2)) {
                Objects.toString(lVar);
            }
            this.a = 2;
            this.b = 2;
        }
    }

    public final void d() {
        int i = this.b;
        v vVar = this.h;
        if (i != 2) {
            if (i == 3) {
                l lVar = vVar.c;
                View viewRequireView = lVar.requireView();
                if (s.F(2)) {
                    Objects.toString(viewRequireView.findFocus());
                    viewRequireView.toString();
                    lVar.toString();
                }
                viewRequireView.clearFocus();
                return;
            }
            return;
        }
        l lVar2 = vVar.c;
        View viewFindFocus = lVar2.mView.findFocus();
        if (viewFindFocus != null) {
            lVar2.setFocusedView(viewFindFocus);
            if (s.F(2)) {
                viewFindFocus.toString();
                lVar2.toString();
            }
        }
        View viewRequireView2 = this.c.requireView();
        if (viewRequireView2.getParent() == null) {
            vVar.a();
            viewRequireView2.setAlpha(0.0f);
        }
        if (viewRequireView2.getAlpha() == 0.0f && viewRequireView2.getVisibility() == 0) {
            viewRequireView2.setVisibility(4);
        }
        viewRequireView2.setAlpha(lVar2.getPostOnViewCreatedAlpha());
    }

    public final String toString() {
        StringBuilder sb = new StringBuilder("Operation {");
        sb.append(Integer.toHexString(System.identityHashCode(this)));
        sb.append("} {mFinalState = ");
        int i = this.a;
        sb.append(i != 1 ? i != 2 ? i != 3 ? i != 4 ? "null" : "INVISIBLE" : "GONE" : "VISIBLE" : "REMOVED");
        sb.append("} {mLifecycleImpact = ");
        int i2 = this.b;
        sb.append(i2 != 1 ? i2 != 2 ? i2 != 3 ? "null" : "REMOVING" : "ADDING" : "NONE");
        sb.append("} {mFragment = ");
        sb.append(this.c);
        sb.append("}");
        return sb.toString();
    }
}
