package j0;

import android.animation.LayoutTransition;
import android.util.Log;
import android.view.ViewGroup;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/* JADX INFO: compiled from: ViewGroupUtilsApi14.java */
/* JADX INFO: loaded from: classes.dex */
class y {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private static LayoutTransition f5047a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private static Field f5048b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private static boolean f5049c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private static Method f5050d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private static boolean f5051e;

    /* JADX INFO: compiled from: ViewGroupUtilsApi14.java */
    static class a extends LayoutTransition {
        a() {
        }

        @Override // android.animation.LayoutTransition
        public boolean isChangingLayout() {
            return true;
        }
    }

    private static void a(LayoutTransition layoutTransition) {
        if (!f5051e) {
            try {
                Method declaredMethod = LayoutTransition.class.getDeclaredMethod("cancel", new Class[0]);
                f5050d = declaredMethod;
                declaredMethod.setAccessible(true);
            } catch (NoSuchMethodException unused) {
                Log.i("ViewGroupUtilsApi14", "Failed to access cancel method by reflection");
            }
            f5051e = true;
        }
        Method method = f5050d;
        if (method != null) {
            try {
                method.invoke(layoutTransition, new Object[0]);
            } catch (IllegalAccessException unused2) {
                Log.i("ViewGroupUtilsApi14", "Failed to access cancel method by reflection");
            } catch (InvocationTargetException unused3) {
                Log.i("ViewGroupUtilsApi14", "Failed to invoke cancel method by reflection");
            }
        }
    }

    static void b(ViewGroup viewGroup, boolean z2) {
        boolean z3 = false;
        if (f5047a == null) {
            a aVar = new a();
            f5047a = aVar;
            aVar.setAnimator(2, null);
            f5047a.setAnimator(0, null);
            f5047a.setAnimator(1, null);
            f5047a.setAnimator(3, null);
            f5047a.setAnimator(4, null);
        }
        if (z2) {
            LayoutTransition layoutTransition = viewGroup.getLayoutTransition();
            if (layoutTransition != null) {
                if (layoutTransition.isRunning()) {
                    a(layoutTransition);
                }
                if (layoutTransition != f5047a) {
                    viewGroup.setTag(j.f4974d, layoutTransition);
                }
            }
            viewGroup.setLayoutTransition(f5047a);
            return;
        }
        viewGroup.setLayoutTransition(null);
        if (!f5049c) {
            try {
                Field declaredField = ViewGroup.class.getDeclaredField("mLayoutSuppressed");
                f5048b = declaredField;
                declaredField.setAccessible(true);
            } catch (NoSuchFieldException unused) {
                Log.i("ViewGroupUtilsApi14", "Failed to access mLayoutSuppressed field by reflection");
            }
            f5049c = true;
        }
        Field field = f5048b;
        if (field != null) {
            try {
                boolean z4 = field.getBoolean(viewGroup);
                if (z4) {
                    try {
                        f5048b.setBoolean(viewGroup, false);
                    } catch (IllegalAccessException unused2) {
                        z3 = z4;
                        Log.i("ViewGroupUtilsApi14", "Failed to get mLayoutSuppressed field by reflection");
                    }
                }
                z3 = z4;
            } catch (IllegalAccessException unused3) {
            }
        }
        if (z3) {
            viewGroup.requestLayout();
        }
        int i3 = j.f4974d;
        LayoutTransition layoutTransition2 = (LayoutTransition) viewGroup.getTag(i3);
        if (layoutTransition2 != null) {
            viewGroup.setTag(i3, null);
            viewGroup.setLayoutTransition(layoutTransition2);
        }
    }
}
