package androidx.customview.poolingcontainer; import android.view.View; import android.view.ViewGroup; import androidx.core.view.ViewGroupKt; import androidx.core.view.ViewKt; import java.util.Iterator; import kotlin.Metadata; import kotlin.jvm.internal.Intrinsics; /* compiled from: PoolingContainer.kt */ @Metadata(d1 = {"\u00006\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u001a\u0014\u0010\u000f\u001a\u00020\u0010*\u00020\u00062\u0006\u0010\u0011\u001a\u00020\u0012H\u0007\u001a\n\u0010\u0013\u001a\u00020\u0010*\u00020\u0006\u001a\n\u0010\u0014\u001a\u00020\u0010*\u00020\u0015\u001a\u0014\u0010\u0016\u001a\u00020\u0010*\u00020\u00062\u0006\u0010\u0011\u001a\u00020\u0012H\u0007\"\u000e\u0010\u0000\u001a\u00020\u0001X\u0082\u0004¢\u0006\u0002\n\u0000\"\u000e\u0010\u0002\u001a\u00020\u0001X\u0082\u0004¢\u0006\u0002\n\u0000\"(\u0010\u0005\u001a\u00020\u0004*\u00020\u00062\u0006\u0010\u0003\u001a\u00020\u00048F@FX\u0086\u000e¢\u0006\f\u001a\u0004\b\u0005\u0010\u0007\"\u0004\b\b\u0010\t\"\u0015\u0010\n\u001a\u00020\u0004*\u00020\u00068F¢\u0006\u0006\u001a\u0004\b\n\u0010\u0007\"\u0018\u0010\u000b\u001a\u00020\f*\u00020\u00068BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b\r\u0010\u000e¨\u0006\u0017"}, d2 = {"IsPoolingContainerTag", "", "PoolingContainerListenerHolderTag", "value", "", "isPoolingContainer", "Landroid/view/View;", "(Landroid/view/View;)Z", "setPoolingContainer", "(Landroid/view/View;Z)V", "isWithinPoolingContainer", "poolingContainerListenerHolder", "Landroidx/customview/poolingcontainer/PoolingContainerListenerHolder;", "getPoolingContainerListenerHolder", "(Landroid/view/View;)Landroidx/customview/poolingcontainer/PoolingContainerListenerHolder;", "addPoolingContainerListener", "", "listener", "Landroidx/customview/poolingcontainer/PoolingContainerListener;", "callPoolingContainerOnRelease", "callPoolingContainerOnReleaseForChildren", "Landroid/view/ViewGroup;", "removePoolingContainerListener", "customview-poolingcontainer_release"}, k = 2, mv = {1, 6, 0}, xi = 48) /* loaded from: classes.dex */ public final class PoolingContainer { private static final int PoolingContainerListenerHolderTag = R.id.pooling_container_listener_holder_tag; private static final int IsPoolingContainerTag = R.id.is_pooling_container_tag; public static final void addPoolingContainerListener(View view, PoolingContainerListener listener) { Intrinsics.checkNotNullParameter(view, ""); Intrinsics.checkNotNullParameter(listener, "listener"); getPoolingContainerListenerHolder(view).addListener(listener); } public static final void removePoolingContainerListener(View view, PoolingContainerListener listener) { Intrinsics.checkNotNullParameter(view, ""); Intrinsics.checkNotNullParameter(listener, "listener"); getPoolingContainerListenerHolder(view).removeListener(listener); } public static final boolean isPoolingContainer(View view) { Intrinsics.checkNotNullParameter(view, ""); Object tag = view.getTag(IsPoolingContainerTag); Boolean bool = tag instanceof Boolean ? (Boolean) tag : null; if (bool != null) { return bool.booleanValue(); } return false; } public static final void setPoolingContainer(View view, boolean z) { Intrinsics.checkNotNullParameter(view, ""); view.setTag(IsPoolingContainerTag, Boolean.valueOf(z)); } public static final boolean isWithinPoolingContainer(View view) { Intrinsics.checkNotNullParameter(view, ""); for (Object obj : ViewKt.getAncestors(view)) { if ((obj instanceof View) && isPoolingContainer((View) obj)) { return true; } } return false; } public static final void callPoolingContainerOnRelease(View view) { Intrinsics.checkNotNullParameter(view, ""); Iterator it = ViewKt.getAllViews(view).iterator(); while (it.hasNext()) { getPoolingContainerListenerHolder(it.next()).onRelease(); } } public static final void callPoolingContainerOnReleaseForChildren(ViewGroup viewGroup) { Intrinsics.checkNotNullParameter(viewGroup, ""); Iterator it = ViewGroupKt.getChildren(viewGroup).iterator(); while (it.hasNext()) { getPoolingContainerListenerHolder(it.next()).onRelease(); } } private static final PoolingContainerListenerHolder getPoolingContainerListenerHolder(View view) { int i = PoolingContainerListenerHolderTag; PoolingContainerListenerHolder poolingContainerListenerHolder = (PoolingContainerListenerHolder) view.getTag(i); if (poolingContainerListenerHolder != null) { return poolingContainerListenerHolder; } PoolingContainerListenerHolder poolingContainerListenerHolder2 = new PoolingContainerListenerHolder(); view.setTag(i, poolingContainerListenerHolder2); return poolingContainerListenerHolder2; } }