package androidx.core.g;

import X.2FV;
import X.2He;
import X.7s1;
import X.8jA;
import X.AnonymousClass07Z;
import X.AnonymousClass088;
import X.AnonymousClass08A;
import X.AnonymousClass08C;
import X.AnonymousClass08D;
import X.AnonymousClass08E;
import X.AnonymousClass08G;
import X.AnonymousClass08I;
import X.AnonymousClass08P;
import X.AnonymousClass1AR;
import X.C019707n;
import X.C020207s;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.PointerIcon;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.WindowInsets;
import com.bytedance.covode.number.Covode;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.WeakHashMap;
import java.util.concurrent.atomic.AtomicInteger;

public class t {
    public static final AtomicInteger LIZ = new AtomicInteger(1);
    public static WeakHashMap<View, AnonymousClass08P> LIZIZ = null;
    public static Method LIZJ;
    public static Field LIZLLL;
    public static boolean LJ = false;
    public static ThreadLocal<Rect> LJFF;
    public static final int[] LJI = {2131361854, 2131361855, 2131361866, 2131361877, 2131361880, 2131361881, 2131361882, 2131361883, 2131361884, 2131361885, 2131361856, 2131361857, 2131361858, 2131361859, 2131361860, 2131361861, 2131361862, 2131361863, 2131361864, 2131361865, 2131361867, 2131361868, 2131361869, 2131361870, 2131361871, 2131361872, 2131361873, 2131361874, 2131361875, 2131361876, 2131361878, 2131361879};
    public static AnonymousClass08D LJII = new AnonymousClass08D();

    public static void LIZ(View view, Context context, int[] iArr, AttributeSet attributeSet, TypedArray typedArray, int i) {
        if (Build.VERSION.SDK_INT >= 29) {
            AnonymousClass08G.LIZ(view, context, iArr, attributeSet, typedArray, i, 0);
        }
    }

    public static void LIZ(ViewGroup viewGroup) {
        if (LIZJ == null) {
            Class<ViewGroup> cls = ViewGroup.class;
            try {
                LIZJ = cls.getDeclaredMethod("setChildrenDrawingOrderEnabled", new Class[]{Boolean.TYPE});
            } catch (NoSuchMethodException unused) {
            }
            LIZJ.setAccessible(true);
        }
        try {
            LIZJ.invoke(viewGroup, new Object[]{true});
        } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException unused2) {
        }
    }

    public static void LIZ(View view, ColorStateList colorStateList) {
        view.setBackgroundTintList(colorStateList);
        if (Build.VERSION.SDK_INT == 21) {
            Drawable background = view.getBackground();
            boolean z = (view.getBackgroundTintList() == null && view.getBackgroundTintMode() == null) ? false : true;
            if (background != null && z) {
                if (background.isStateful()) {
                    background.setState(view.getDrawableState());
                }
                view.setBackground(background);
            }
        }
    }

    public static void LIZ(View view, PorterDuff.Mode mode) {
        view.setBackgroundTintMode(mode);
        if (Build.VERSION.SDK_INT == 21) {
            Drawable background = view.getBackground();
            boolean z = (view.getBackgroundTintList() == null && view.getBackgroundTintMode() == null) ? false : true;
            if (background != null && z) {
                if (background.isStateful()) {
                    background.setState(view.getDrawableState());
                }
                view.setBackground(background);
            }
        }
    }

    public static void LIZ(View view, Rect rect) {
        view.setClipBounds(rect);
    }

    public static boolean LIZ(View view, KeyEvent keyEvent) {
        if (Build.VERSION.SDK_INT >= 28) {
            return false;
        }
        return AnonymousClass08I.LIZ(view).LIZ(keyEvent);
    }

    public static AnonymousClass08E<CharSequence> LIZIZ() {
        return new AnonymousClass1AR(CharSequence.class);
    }

    public static Rect LIZ() {
        if (LJFF == null) {
            LJFF = new ThreadLocal<>();
        }
        Rect rect = LJFF.get();
        if (rect == null) {
            rect = new Rect();
            LJFF.set(rect);
        }
        rect.setEmpty();
        return rect;
    }

    static {
        Covode.recordClassIndex(860);
    }

    public static int LIZIZ(View view) {
        return view.getLayoutDirection();
    }

    public static boolean LIZLLL(View view) {
        return view.isLaidOut();
    }

    public static boolean LJ(View view) {
        return view.isAttachedToWindow();
    }

    public static View.AccessibilityDelegate LIZ(View view) {
        if (Build.VERSION.SDK_INT >= 29) {
            return view.getAccessibilityDelegate();
        }
        return LJI(view);
    }

    public static CharSequence LJFF(View view) {
        return LIZIZ().LIZIZ(view);
    }

    public static void LJII(View view) {
        float translationY = view.getTranslationY();
        view.setTranslationY(1.0f + translationY);
        view.setTranslationY(translationY);
    }

    public static AnonymousClass08P LIZJ(View view) {
        if (LIZIZ == null) {
            LIZIZ = new WeakHashMap<>();
        }
        AnonymousClass08P r1 = LIZIZ.get(view);
        if (r1 != null) {
            return r1;
        }
        AnonymousClass08P r12 = new AnonymousClass08P(view);
        LIZIZ.put(view, r12);
        return r12;
    }

    public static View.AccessibilityDelegate LJI(View view) {
        if (LJ) {
            return null;
        }
        if (LIZLLL == null) {
            try {
                Field declaredField = View.class.getDeclaredField("mAccessibilityDelegate");
                LIZLLL = declaredField;
                declaredField.setAccessible(true);
            } catch (Throwable unused) {
                LJ = true;
                return null;
            }
        }
        try {
            Object obj = LIZLLL.get(view);
            if (obj instanceof View.AccessibilityDelegate) {
                return (View.AccessibilityDelegate) obj;
            }
            return null;
        } catch (Throwable unused2) {
            LJ = true;
            return null;
        }
    }

    public static void LIZ(View view, float f) {
        view.setZ(f);
    }

    public static C020207s LIZ(View view, C020207s r2) {
        WindowInsets LJ2 = r2.LJ();
        if (LJ2 != null) {
            WindowInsets onApplyWindowInsets = view.onApplyWindowInsets(LJ2);
            if (!onApplyWindowInsets.equals(LJ2)) {
                return C020207s.LIZ(onApplyWindowInsets);
            }
        }
        return r2;
    }

    public static C020207s LIZIZ(View view, C020207s r3) {
        WindowInsets LJ2 = r3.LJ();
        if (LJ2 == null || view.dispatchApplyWindowInsets(LJ2).equals(LJ2)) {
            return r3;
        }
        return C020207s.LIZ(LJ2);
    }

    public static void LIZLLL(View view, int i) {
        view.offsetTopAndBottom(i);
        if (view.getVisibility() == 0) {
            LJII(view);
            ViewParent parent = view.getParent();
            if (parent instanceof View) {
                LJII((View) parent);
            }
        }
    }

    public static void LJ(View view, int i) {
        view.offsetLeftAndRight(i);
        if (view.getVisibility() == 0) {
            LJII(view);
            ViewParent parent = view.getParent();
            if (parent instanceof View) {
                LJII((View) parent);
            }
        }
    }

    public static boolean LIZIZ(View view, KeyEvent keyEvent) {
        if (Build.VERSION.SDK_INT >= 28) {
            return false;
        }
        return AnonymousClass08I.LIZ(view).LIZ(view, keyEvent);
    }

    public static <T extends View> T LIZ(View view, int i) {
        if (Build.VERSION.SDK_INT >= 28) {
            return view.requireViewById(i);
        }
        T findViewById = view.findViewById(i);
        if (findViewById != null) {
            return findViewById;
        }
        throw new IllegalArgumentException("ID does not reference a View inside this View");
    }

    public static void LIZIZ(View view, int i) {
        if (Build.VERSION.SDK_INT >= 23) {
            view.offsetTopAndBottom(i);
            return;
        }
        Rect LIZ2 = LIZ();
        boolean z = false;
        ViewParent parent = view.getParent();
        if (parent instanceof View) {
            View view2 = (View) parent;
            LIZ2.set(view2.getLeft(), view2.getTop(), view2.getRight(), view2.getBottom());
            z = !LIZ2.intersects(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
        }
        LIZLLL(view, i);
        if (z && LIZ2.intersect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom())) {
            ((View) parent).invalidate(LIZ2);
        }
    }

    public static void LIZJ(View view, int i) {
        if (Build.VERSION.SDK_INT >= 23) {
            view.offsetLeftAndRight(i);
            return;
        }
        Rect LIZ2 = LIZ();
        boolean z = false;
        ViewParent parent = view.getParent();
        if (parent instanceof View) {
            View view2 = (View) parent;
            LIZ2.set(view2.getLeft(), view2.getTop(), view2.getRight(), view2.getBottom());
            z = !LIZ2.intersects(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
        }
        LJ(view, i);
        if (z && LIZ2.intersect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom())) {
            ((View) parent).invalidate(LIZ2);
        }
    }

    public static Object LIZ(Context context, String str) {
        Object systemService;
        if (Build.VERSION.SDK_INT > 27 || !"clipboard".equals(str)) {
            if (!2FV.LIZIZ && "connectivity".equals(str)) {
                try {
                    new 7s1().LIZ();
                    2FV.LIZIZ = true;
                    return context.getSystemService(str);
                } catch (Throwable unused) {
                }
            }
            return context.getSystemService(str);
        } else if (!2FV.LIZ) {
            return context.getSystemService(str);
        } else {
            synchronized (ClipboardManager.class) {
                systemService = context.getSystemService(str);
                if (Thread.currentThread() != Looper.getMainLooper().getThread()) {
                    try {
                        Field declaredField = ClipboardManager.class.getDeclaredField("mHandler");
                        declaredField.setAccessible(true);
                        declaredField.set(systemService, new 2He((Handler) declaredField.get(systemService)));
                    } catch (Exception e) {
                        8jA.LIZ(e, "ClipboardManager Handler Reflect Fail");
                    }
                }
                2FV.LIZ = false;
            }
            return systemService;
        }
    }

    public static void LIZ(View view, C019707n r2) {
        View.AccessibilityDelegate accessibilityDelegate;
        if (r2 == null) {
            if (LIZ(view) instanceof AnonymousClass07Z) {
                r2 = new C019707n();
            } else {
                accessibilityDelegate = null;
                view.setAccessibilityDelegate(accessibilityDelegate);
            }
        }
        accessibilityDelegate = r2.LIZ;
        view.setAccessibilityDelegate(accessibilityDelegate);
    }

    public static void LIZ(View view, AnonymousClass088 r2) {
        if (r2 == null) {
            view.setOnApplyWindowInsetsListener((View.OnApplyWindowInsetsListener) null);
        } else {
            view.setOnApplyWindowInsetsListener(new AnonymousClass08C(r2));
        }
    }

    public static void LIZ(View view, AnonymousClass08A r3) {
        Object obj;
        if (Build.VERSION.SDK_INT >= 24) {
            if (r3 != null) {
                obj = r3.LIZ;
            } else {
                obj = null;
            }
            view.setPointerIcon((PointerIcon) obj);
        }
    }

    public static void LIZ(View view, int i, int i2, int i3, int i4) {
        view.setPaddingRelative(i, i2, i3, i4);
    }
}
