package ῲ.ᓆ;

import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import androidx.transition.R$id;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;
import ῲ.ᨨ.ᨨ.C1729;
import ῲ.㴹.C2284;

/* renamed from: ῲ.ᓆ.䁗  reason: contains not printable characters */
/* compiled from: TransitionManager */
public class C1679 {

    /* renamed from: ʬ  reason: contains not printable characters */
    public static ArrayList<ViewGroup> f5923 = new ArrayList<>();

    /* renamed from: ῲ  reason: contains not printable characters */
    public static ThreadLocal<WeakReference<C2284<ViewGroup, ArrayList<AbstractC1647>>>> f5924 = new ThreadLocal<>();

    /* renamed from: K  reason: contains not printable characters */
    public static AbstractC1647 f5925 = new C1656();

    /* renamed from: ῲ.ᓆ.䁗$K  reason: contains not printable characters */
    /* compiled from: TransitionManager */
    public static class ViewTreeObserver$OnPreDrawListenerC1680 implements ViewTreeObserver.OnPreDrawListener, View.OnAttachStateChangeListener {

        /* renamed from: ʬ  reason: contains not printable characters */
        public ViewGroup f5926;

        /* renamed from: ῲ  reason: contains not printable characters */
        public AbstractC1647 f5927;

        /* renamed from: ῲ.ᓆ.䁗$K$K  reason: contains not printable characters */
        /* compiled from: TransitionManager */
        public class C1681 extends C1662 {

            /* renamed from: K  reason: contains not printable characters */
            public final /* synthetic */ C2284 f5929;

            public C1681(C2284 k) {
                this.f5929 = k;
            }

            @Override // ῲ.ᓆ.AbstractC1647.AbstractC1652
            public void onTransitionEnd(AbstractC1647 r3) {
                ((ArrayList) this.f5929.get(ViewTreeObserver$OnPreDrawListenerC1680.this.f5926)).remove(r3);
                r3.removeListener(this);
            }
        }

        public ViewTreeObserver$OnPreDrawListenerC1680(AbstractC1647 r1, ViewGroup viewGroup) {
            this.f5927 = r1;
            this.f5926 = viewGroup;
        }

        public boolean onPreDraw() {
            this.f5926.getViewTreeObserver().removeOnPreDrawListener(this);
            this.f5926.removeOnAttachStateChangeListener(this);
            if (!C1679.f5923.remove(this.f5926)) {
                return true;
            }
            C2284<ViewGroup, ArrayList<AbstractC1647>> r0 = C1679.m4262();
            ArrayList<AbstractC1647> arrayList = r0.get(this.f5926);
            ArrayList arrayList2 = null;
            if (arrayList == null) {
                arrayList = new ArrayList<>();
                r0.put(this.f5926, arrayList);
            } else if (arrayList.size() > 0) {
                arrayList2 = new ArrayList(arrayList);
            }
            arrayList.add(this.f5927);
            this.f5927.addListener(new C1681(r0));
            this.f5927.captureValues(this.f5926, false);
            if (arrayList2 != null) {
                Iterator it2 = arrayList2.iterator();
                while (it2.hasNext()) {
                    ((AbstractC1647) it2.next()).resume(this.f5926);
                }
            }
            this.f5927.playTransition(this.f5926);
            return true;
        }

        public void onViewAttachedToWindow(View view) {
        }

        public void onViewDetachedFromWindow(View view) {
            this.f5926.getViewTreeObserver().removeOnPreDrawListener(this);
            this.f5926.removeOnAttachStateChangeListener(this);
            C1679.f5923.remove(this.f5926);
            ArrayList<AbstractC1647> arrayList = C1679.m4262().get(this.f5926);
            if (arrayList != null && arrayList.size() > 0) {
                Iterator<AbstractC1647> it2 = arrayList.iterator();
                while (it2.hasNext()) {
                    it2.next().resume(this.f5926);
                }
            }
            this.f5927.clearValues(true);
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public static C2284<ViewGroup, ArrayList<AbstractC1647>> m4262() {
        C2284<ViewGroup, ArrayList<AbstractC1647>> k;
        WeakReference<C2284<ViewGroup, ArrayList<AbstractC1647>>> weakReference = f5924.get();
        if (weakReference != null && (k = weakReference.get()) != null) {
            return k;
        }
        C2284<ViewGroup, ArrayList<AbstractC1647>> k2 = new C2284<>();
        f5924.set(new WeakReference<>(k2));
        return k2;
    }

    /* renamed from: K  reason: contains not printable characters */
    public static void m4263(ViewGroup viewGroup, AbstractC1647 r4) {
        Runnable runnable;
        if (!f5923.contains(viewGroup) && C1729.m4512(viewGroup)) {
            f5923.add(viewGroup);
            if (r4 == null) {
                r4 = f5925;
            }
            AbstractC1647 clone = r4.clone();
            ArrayList<AbstractC1647> orDefault = m4262().getOrDefault(viewGroup, null);
            if (orDefault != null && orDefault.size() > 0) {
                Iterator<AbstractC1647> it2 = orDefault.iterator();
                while (it2.hasNext()) {
                    it2.next().pause(viewGroup);
                }
            }
            if (clone != null) {
                clone.captureValues(viewGroup, true);
            }
            C1655 r0 = C1655.m4248(viewGroup);
            if (!(r0 == null || C1655.m4248(r0.f5895) != r0 || (runnable = r0.f5894) == null)) {
                runnable.run();
            }
            viewGroup.setTag(R$id.transition_current_scene, null);
            if (clone != null) {
                ViewTreeObserver$OnPreDrawListenerC1680 k = new ViewTreeObserver$OnPreDrawListenerC1680(clone, viewGroup);
                viewGroup.addOnAttachStateChangeListener(k);
                viewGroup.getViewTreeObserver().addOnPreDrawListener(k);
            }
        }
    }
}
