package defpackage;

import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.Resources;
import android.graphics.Rect;
import android.os.Build;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView;
import ar.tvplayer.tv.R;
import java.lang.reflect.Method;
import java.util.WeakHashMap;

/* renamed from: ʽʻ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class ViewOnLongClickListenerC0072 implements View.OnLongClickListener, View.OnHoverListener, View.OnAttachStateChangeListener {

    /* renamed from: ᵧـˌᵎ, reason: contains not printable characters */
    public static ViewOnLongClickListenerC0072 f1310;

    /* renamed from: ᵮᵠـˌ, reason: contains not printable characters */
    public static ViewOnLongClickListenerC0072 f1311;

    /* renamed from: ˀᵗᵝᵭ, reason: contains not printable characters */
    public int f1312;

    /* renamed from: ˎˑː, reason: contains not printable characters */
    public boolean f1313;

    /* renamed from: ˑᵥˁ, reason: contains not printable characters */
    public boolean f1314;

    /* renamed from: ᵡˎ, reason: contains not printable characters */
    public C1188 f1315;

    /* renamed from: ᵡⁱᵥ, reason: contains not printable characters */
    public int f1316;

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public final CharSequence f1317;

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public final RunnableC0662 f1318;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public final View f1319;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public final RunnableC0662 f1320;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public final int f1321;

    /* JADX WARN: Type inference failed for: r0v0, types: [ˁˈʔ] */
    /* JADX WARN: Type inference failed for: r0v1, types: [ˁˈʔ] */
    public ViewOnLongClickListenerC0072(View view, CharSequence charSequence) {
        final int i = 0;
        this.f1320 = new Runnable(this) { // from class: ˁˈʔ

            /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
            public final /* synthetic */ ViewOnLongClickListenerC0072 f3280;

            {
                this.f3280 = this;
            }

            @Override // java.lang.Runnable
            public final void run() throws Resources.NotFoundException {
                int i2 = i;
                ViewOnLongClickListenerC0072 viewOnLongClickListenerC0072 = this.f3280;
                switch (i2) {
                    case 0:
                        viewOnLongClickListenerC0072.m1144(false);
                        break;
                    default:
                        viewOnLongClickListenerC0072.m1145();
                        break;
                }
            }
        };
        final int i2 = 1;
        this.f1318 = new Runnable(this) { // from class: ˁˈʔ

            /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
            public final /* synthetic */ ViewOnLongClickListenerC0072 f3280;

            {
                this.f3280 = this;
            }

            @Override // java.lang.Runnable
            public final void run() throws Resources.NotFoundException {
                int i22 = i2;
                ViewOnLongClickListenerC0072 viewOnLongClickListenerC0072 = this.f3280;
                switch (i22) {
                    case 0:
                        viewOnLongClickListenerC0072.m1144(false);
                        break;
                    default:
                        viewOnLongClickListenerC0072.m1145();
                        break;
                }
            }
        };
        this.f1319 = view;
        this.f1317 = charSequence;
        ViewConfiguration viewConfiguration = ViewConfiguration.get(view.getContext());
        Method method = AbstractC2002.f8044;
        this.f1321 = Build.VERSION.SDK_INT >= 28 ? AbstractC3502.m8006(viewConfiguration) : viewConfiguration.getScaledTouchSlop() / 2;
        this.f1313 = true;
        view.setOnLongClickListener(this);
        view.setOnHoverListener(this);
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public static void m1143(ViewOnLongClickListenerC0072 viewOnLongClickListenerC0072) {
        ViewOnLongClickListenerC0072 viewOnLongClickListenerC00722 = f1311;
        if (viewOnLongClickListenerC00722 != null) {
            viewOnLongClickListenerC00722.f1319.removeCallbacks(viewOnLongClickListenerC00722.f1320);
        }
        f1311 = viewOnLongClickListenerC0072;
        if (viewOnLongClickListenerC0072 != null) {
            viewOnLongClickListenerC0072.f1319.postDelayed(viewOnLongClickListenerC0072.f1320, ViewConfiguration.getLongPressTimeout());
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:29:0x0066  */
    @Override // android.view.View.OnHoverListener
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final boolean onHover(android.view.View r4, android.view.MotionEvent r5) {
        /*
            r3 = this;
            ˉᵖᵨᵱ r4 = r3.f1315
            r0 = 0
            if (r4 == 0) goto La
            boolean r4 = r3.f1314
            if (r4 == 0) goto La
            goto L6f
        La:
            android.view.View r4 = r3.f1319
            android.content.Context r1 = r4.getContext()
            java.lang.String r2 = "accessibility"
            java.lang.Object r1 = r1.getSystemService(r2)
            android.view.accessibility.AccessibilityManager r1 = (android.view.accessibility.AccessibilityManager) r1
            boolean r2 = r1.isEnabled()
            if (r2 == 0) goto L25
            boolean r1 = r1.isTouchExplorationEnabled()
            if (r1 == 0) goto L25
            goto L6f
        L25:
            int r1 = r5.getAction()
            r2 = 7
            if (r1 == r2) goto L38
            r4 = 10
            if (r1 == r4) goto L31
            goto L6f
        L31:
            r4 = 1
            r3.f1313 = r4
            r3.m1145()
            return r0
        L38:
            boolean r4 = r4.isEnabled()
            if (r4 == 0) goto L6f
            ˉᵖᵨᵱ r4 = r3.f1315
            if (r4 != 0) goto L6f
            float r4 = r5.getX()
            int r4 = (int) r4
            float r5 = r5.getY()
            int r5 = (int) r5
            boolean r1 = r3.f1313
            if (r1 != 0) goto L66
            int r1 = r3.f1316
            int r1 = r4 - r1
            int r1 = java.lang.Math.abs(r1)
            int r2 = r3.f1321
            if (r1 > r2) goto L66
            int r1 = r3.f1312
            int r1 = r5 - r1
            int r1 = java.lang.Math.abs(r1)
            if (r1 <= r2) goto L6f
        L66:
            r3.f1316 = r4
            r3.f1312 = r5
            r3.f1313 = r0
            m1143(r3)
        L6f:
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.ViewOnLongClickListenerC0072.onHover(android.view.View, android.view.MotionEvent):boolean");
    }

    @Override // android.view.View.OnLongClickListener
    public final boolean onLongClick(View view) throws Resources.NotFoundException {
        this.f1316 = view.getWidth() / 2;
        this.f1312 = view.getHeight() / 2;
        m1144(true);
        return true;
    }

    @Override // android.view.View.OnAttachStateChangeListener
    public final void onViewAttachedToWindow(View view) {
    }

    @Override // android.view.View.OnAttachStateChangeListener
    public final void onViewDetachedFromWindow(View view) {
        m1145();
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final void m1144(boolean z) throws Resources.NotFoundException {
        int height;
        int i;
        int i2;
        boolean z2;
        int i3;
        int i4;
        long longPressTimeout;
        long j;
        long j2;
        View view = this.f1319;
        if (view.isAttachedToWindow()) {
            m1143(null);
            ViewOnLongClickListenerC0072 viewOnLongClickListenerC0072 = f1310;
            if (viewOnLongClickListenerC0072 != null) {
                viewOnLongClickListenerC0072.m1145();
            }
            f1310 = this;
            this.f1314 = z;
            C1188 c1188 = new C1188(view.getContext());
            View view2 = (View) c1188.f5065;
            Context context = (Context) c1188.f5067;
            this.f1315 = c1188;
            int width = this.f1316;
            int i5 = this.f1312;
            boolean z3 = this.f1314;
            WindowManager.LayoutParams layoutParams = (WindowManager.LayoutParams) c1188.f5068;
            if (view2.getParent() != null && view2.getParent() != null) {
                ((WindowManager) context.getSystemService("window")).removeView(view2);
            }
            ((TextView) c1188.f5069).setText(this.f1317);
            int[] iArr = (int[]) c1188.f5063;
            int[] iArr2 = (int[]) c1188.f5064;
            Rect rect = (Rect) c1188.f5066;
            layoutParams.token = view.getApplicationWindowToken();
            int dimensionPixelOffset = context.getResources().getDimensionPixelOffset(R.dimen._11_res_0x7f0705b7);
            if (view.getWidth() < dimensionPixelOffset) {
                width = view.getWidth() / 2;
            }
            if (view.getHeight() >= dimensionPixelOffset) {
                int dimensionPixelOffset2 = context.getResources().getDimensionPixelOffset(R.dimen._11_res_0x7f0705b6);
                height = i5 + dimensionPixelOffset2;
                i = i5 - dimensionPixelOffset2;
            } else {
                height = view.getHeight();
                i = 0;
            }
            layoutParams.gravity = 49;
            int dimensionPixelOffset3 = context.getResources().getDimensionPixelOffset(z3 ? R.dimen._11_res_0x7f0705ba : R.dimen._11_res_0x7f0705b9);
            View rootView = view.getRootView();
            ViewGroup.LayoutParams layoutParams2 = rootView.getLayoutParams();
            int i6 = width;
            if (!(layoutParams2 instanceof WindowManager.LayoutParams) || ((WindowManager.LayoutParams) layoutParams2).type != 2) {
                Context context2 = view.getContext();
                while (true) {
                    if (!(context2 instanceof ContextWrapper)) {
                        break;
                    }
                    if (context2 instanceof Activity) {
                        rootView = ((Activity) context2).getWindow().getDecorView();
                        break;
                    }
                    context2 = ((ContextWrapper) context2).getBaseContext();
                }
            }
            if (rootView == null) {
                i4 = 1;
            } else {
                rootView.getWindowVisibleDisplayFrame(rect);
                if (rect.left >= 0 || rect.top >= 0) {
                    i2 = i;
                    z2 = z3;
                    i3 = 0;
                    i4 = 1;
                } else {
                    Resources resources = context.getResources();
                    i4 = 1;
                    i2 = i;
                    z2 = z3;
                    int identifier = resources.getIdentifier("status_bar_height", "dimen", "android");
                    int dimensionPixelSize = identifier != 0 ? resources.getDimensionPixelSize(identifier) : 0;
                    DisplayMetrics displayMetrics = resources.getDisplayMetrics();
                    i3 = 0;
                    rect.set(0, dimensionPixelSize, displayMetrics.widthPixels, displayMetrics.heightPixels);
                }
                rootView.getLocationOnScreen(iArr);
                view.getLocationOnScreen(iArr2);
                int i7 = iArr2[i3] - iArr[i3];
                iArr2[i3] = i7;
                iArr2[i4] = iArr2[i4] - iArr[i4];
                layoutParams.x = (i7 + i6) - (rootView.getWidth() / 2);
                int iMakeMeasureSpec = View.MeasureSpec.makeMeasureSpec(i3, i3);
                view2.measure(iMakeMeasureSpec, iMakeMeasureSpec);
                int measuredHeight = view2.getMeasuredHeight();
                int i8 = iArr2[i4];
                int i9 = ((i8 + i2) - dimensionPixelOffset3) - measuredHeight;
                int i10 = i8 + height + dimensionPixelOffset3;
                if (z2) {
                    if (i9 >= 0) {
                        layoutParams.y = i9;
                    } else {
                        layoutParams.y = i10;
                    }
                } else if (measuredHeight + i10 <= rect.height()) {
                    layoutParams.y = i10;
                } else {
                    layoutParams.y = i9;
                }
            }
            ((WindowManager) context.getSystemService("window")).addView(view2, layoutParams);
            view.addOnAttachStateChangeListener(this);
            if (this.f1314) {
                j2 = 2500;
            } else {
                WeakHashMap weakHashMap = AbstractC2873.f11133;
                if ((view.getWindowSystemUiVisibility() & 1) == i4) {
                    longPressTimeout = ViewConfiguration.getLongPressTimeout();
                    j = 3000;
                } else {
                    longPressTimeout = ViewConfiguration.getLongPressTimeout();
                    j = 15000;
                }
                j2 = j - longPressTimeout;
            }
            RunnableC0662 runnableC0662 = this.f1318;
            view.removeCallbacks(runnableC0662);
            view.postDelayed(runnableC0662, j2);
        }
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final void m1145() {
        ViewOnLongClickListenerC0072 viewOnLongClickListenerC0072 = f1310;
        View view = this.f1319;
        if (viewOnLongClickListenerC0072 == this) {
            f1310 = null;
            C1188 c1188 = this.f1315;
            if (c1188 != null) {
                View view2 = (View) c1188.f5065;
                if (view2.getParent() != null) {
                    ((WindowManager) ((Context) c1188.f5067).getSystemService("window")).removeView(view2);
                }
                this.f1315 = null;
                this.f1313 = true;
                view.removeOnAttachStateChangeListener(this);
            }
        }
        if (f1311 == this) {
            m1143(null);
        }
        view.removeCallbacks(this.f1318);
    }
}
