package o; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; import androidx.core.view.ViewCompat; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Iterator; import o.C16920sQi; /* loaded from: classes.dex */ public final class kin { private static VKj b = new RZN(); private static ThreadLocal>>> d = new ThreadLocal<>(); static ArrayList e = new ArrayList<>(); private nyh c = new nyh<>(); private nyh> a = new nyh<>(); static nyh> b() { nyh> nyhVar; WeakReference>> weakReference = d.get(); if (weakReference != null && (nyhVar = weakReference.get()) != null) { return nyhVar; } nyh> nyhVar2 = new nyh<>(); d.set(new WeakReference<>(nyhVar2)); return nyhVar2; } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public static class LWm implements ViewTreeObserver.OnPreDrawListener, View.OnAttachStateChangeListener { ViewGroup c; private VKj e; @Override // android.view.View.OnAttachStateChangeListener public final void onViewAttachedToWindow(View view) { } LWm(VKj vKj, ViewGroup viewGroup) { this.e = vKj; this.c = viewGroup; } @Override // android.view.View.OnAttachStateChangeListener public final void onViewDetachedFromWindow(View view) { this.c.getViewTreeObserver().removeOnPreDrawListener(this); this.c.removeOnAttachStateChangeListener(this); kin.e.remove(this.c); ArrayList arrayList = kin.b().get(this.c); if (arrayList != null && arrayList.size() > 0) { Iterator it = arrayList.iterator(); while (it.hasNext()) { it.next().c(this.c); } } this.e.d(true); } @Override // android.view.ViewTreeObserver.OnPreDrawListener public final boolean onPreDraw() { this.c.getViewTreeObserver().removeOnPreDrawListener(this); this.c.removeOnAttachStateChangeListener(this); if (!kin.e.remove(this.c)) { return true; } nyh> b = kin.b(); ArrayList arrayList = b.get(this.c); ArrayList arrayList2 = null; if (arrayList == null) { arrayList = new ArrayList<>(); b.put(this.c, arrayList); } else if (arrayList.size() > 0) { arrayList2 = new ArrayList(arrayList); } arrayList.add(this.e); this.e.a(new C17599yDT(this, b) { // from class: o.kin.LWm.5 final nyh a; final LWm b; { this.b = this; this.a = b; } /* JADX WARN: Multi-variable type inference failed */ @Override // o.C17599yDT, o.VKj.Sts public final void e(VKj vKj) { ((ArrayList) this.a.get(this.b.c)).remove(vKj); vKj.b(this); } }); this.e.Ba_(this.c, false); if (arrayList2 != null) { Iterator it = arrayList2.iterator(); while (it.hasNext()) { ((VKj) it.next()).c(this.c); } } this.e.Be_(this.c); return true; } } public static void Bh_(ViewGroup viewGroup, VKj vKj) { if (e.contains(viewGroup) || !ViewCompat.G(viewGroup)) { return; } e.add(viewGroup); if (vKj == null) { vKj = b; } VKj clone = vKj.clone(); ArrayList arrayList = b().get(viewGroup); if (arrayList != null && arrayList.size() > 0) { Iterator it = arrayList.iterator(); while (it.hasNext()) { it.next().e(viewGroup); } } if (clone != null) { clone.Ba_(viewGroup, true); } snR snr = (snR) viewGroup.getTag(C16920sQi.RVV.transition_current_scene); if (snr != null) { ViewGroup viewGroup2 = snr.a; throw null; } viewGroup.setTag(C16920sQi.RVV.transition_current_scene, null); if (clone == null || viewGroup == null) { return; } LWm lWm = new LWm(clone, viewGroup); viewGroup.addOnAttachStateChangeListener(lWm); viewGroup.getViewTreeObserver().addOnPreDrawListener(lWm); } }