package xyz.stream.view;

import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Typeface;
import android.graphics.drawable.GradientDrawable;
import android.media.AudioManager;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import xyz.stream.view.autosize.utils.AutoSizeUtils;

/* JADX INFO: loaded from: classes3.dex */
public class VideoGestureFrameLayout extends FrameLayout {

    /* JADX INFO: renamed from: q0, reason: collision with root package name */
    public static final /* synthetic */ int f36397q0 = 0;
    public float Q;
    public Window R;
    public WindowManager.LayoutParams S;
    public ShowChangeLayout T;
    public ShowChangeLayout U;
    public ShowChangeLayout V;
    public LongPressSpeedLayout W;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public int f36398a;

    /* JADX INFO: renamed from: a0, reason: collision with root package name */
    public boolean f36399a0;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public GestureDetector f36400b;

    /* JADX INFO: renamed from: b0, reason: collision with root package name */
    public float f36401b0;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public VideoGestureListener f36402c;

    /* JADX INFO: renamed from: c0, reason: collision with root package name */
    public float f36403c0;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public boolean f36404d;

    /* JADX INFO: renamed from: d0, reason: collision with root package name */
    public float f36405d0;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public boolean f36406e;

    /* JADX INFO: renamed from: e0, reason: collision with root package name */
    public int f36407e0;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public AudioManager f36408f;

    /* JADX INFO: renamed from: f0, reason: collision with root package name */
    public float f36409f0;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public int f36410g;

    /* JADX INFO: renamed from: g0, reason: collision with root package name */
    public float f36411g0;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public int f36412h;

    /* JADX INFO: renamed from: h0, reason: collision with root package name */
    public float f36413h0;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public int f36414i;

    /* JADX INFO: renamed from: i0, reason: collision with root package name */
    public boolean f36415i0;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public int f36416j;

    /* JADX INFO: renamed from: j0, reason: collision with root package name */
    public boolean f36417j0;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public BrightnessHelper f36418k;

    /* JADX INFO: renamed from: k0, reason: collision with root package name */
    public boolean f36419k0;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public long f36420l;

    /* JADX INFO: renamed from: l0, reason: collision with root package name */
    public boolean f36421l0;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public boolean f36422m;

    /* JADX INFO: renamed from: m0, reason: collision with root package name */
    public boolean f36423m0;

    /* JADX INFO: renamed from: n0, reason: collision with root package name */
    public boolean f36424n0;

    /* JADX INFO: renamed from: o0, reason: collision with root package name */
    public Object f36425o0;

    /* JADX INFO: renamed from: p0, reason: collision with root package name */
    public p000if.e f36426p0;

    public static class LongPressSpeedLayout extends LinearLayout {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public final TriangleStripView f36427a;

        public LongPressSpeedLayout(Context context) {
            super(context);
            setGravity(17);
            setOrientation(0);
            setVisibility(8);
            setFocusable(false);
            setClickable(false);
            int iDp2px = AutoSizeUtils.dp2px(context, 20.0f);
            int iDp2px2 = AutoSizeUtils.dp2px(context, 12.0f);
            setPadding(iDp2px, iDp2px2, iDp2px, iDp2px2);
            GradientDrawable gradientDrawable = new GradientDrawable();
            gradientDrawable.setColor(1711276032);
            gradientDrawable.setCornerRadius(AutoSizeUtils.dp2px(context, 28.0f));
            setBackground(gradientDrawable);
            TriangleStripView triangleStripView = new TriangleStripView(context);
            this.f36427a = triangleStripView;
            addView(triangleStripView, new LinearLayout.LayoutParams(AutoSizeUtils.dp2px(context, 72.0f), AutoSizeUtils.dp2px(context, 24.0f)));
            TextView textView = new TextView(context);
            textView.setText("3.0x");
            textView.setTextColor(-1);
            textView.setTextSize(32.0f);
            textView.setTypeface(Typeface.DEFAULT_BOLD);
            textView.setIncludeFontPadding(false);
            textView.setGravity(17);
            textView.setTextAlignment(4);
            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-2, -2);
            layoutParams.setMargins(AutoSizeUtils.dp2px(context, 10.0f), 0, 0, 0);
            addView(textView, layoutParams);
        }
    }

    @Retention(RetentionPolicy.SOURCE)
    public @interface ScrollMode {
    }

    public static class TriangleStripView extends View {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public final Paint f36428a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public final Path f36429b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public int f36430c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public boolean f36431d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        public final Runnable f36432e;

        public TriangleStripView(Context context) {
            super(context);
            Paint paint = new Paint(1);
            this.f36428a = paint;
            this.f36429b = new Path();
            this.f36430c = 0;
            this.f36431d = false;
            this.f36432e = new Runnable() { // from class: xyz.stream.view.VideoGestureFrameLayout.TriangleStripView.1
                @Override // java.lang.Runnable
                public void run() {
                    TriangleStripView triangleStripView = TriangleStripView.this;
                    if (triangleStripView.f36431d) {
                        triangleStripView.f36430c = (triangleStripView.f36430c + 1) % 3;
                        triangleStripView.invalidate();
                        triangleStripView.postDelayed(this, 160L);
                    }
                }
            };
            paint.setColor(-1);
        }

        @Override // android.view.View
        public void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            float fDp2px = AutoSizeUtils.dp2px(getContext(), 4.0f);
            float width = (getWidth() - (fDp2px * 2.0f)) / 3.0f;
            float height = getHeight();
            int i10 = 0;
            while (i10 < 3) {
                float f10 = (width + fDp2px) * i10;
                Path path = this.f36429b;
                path.reset();
                path.moveTo(f10, 0.0f);
                path.lineTo(f10, height);
                path.lineTo(f10 + width, height / 2.0f);
                path.close();
                Paint paint = this.f36428a;
                paint.setAlpha(i10 == this.f36430c ? 255 : 80);
                canvas.drawPath(path, paint);
                i10++;
            }
        }
    }

    public interface VideoGestureListener {
        void onDoubleTapGesture(MotionEvent motionEvent);

        default void onLongPressSpeedEnd() {
        }

        default boolean onLongPressSpeedStart(float f10) {
            return false;
        }

        default void onSeekGestureCommit(long j10) {
        }

        void onSingleTapGesture(MotionEvent motionEvent);
    }

    public class VideoPlayerOnGestureListener extends GestureDetector.SimpleOnGestureListener {
        public VideoPlayerOnGestureListener() {
        }

        @Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnContextClickListener
        public boolean onContextClick(@NonNull MotionEvent motionEvent) {
            return true;
        }

        @Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnDoubleTapListener
        public boolean onDoubleTap(@NonNull MotionEvent motionEvent) {
            VideoGestureListener videoGestureListener = VideoGestureFrameLayout.this.f36402c;
            if (videoGestureListener != null) {
                videoGestureListener.onDoubleTapGesture(motionEvent);
            }
            return super.onDoubleTap(motionEvent);
        }

        @Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnDoubleTapListener
        public boolean onDoubleTapEvent(@NonNull MotionEvent motionEvent) {
            return super.onDoubleTapEvent(motionEvent);
        }

        @Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnGestureListener
        public boolean onDown(@NonNull MotionEvent motionEvent) {
            VideoGestureFrameLayout videoGestureFrameLayout = VideoGestureFrameLayout.this;
            videoGestureFrameLayout.f36404d = false;
            videoGestureFrameLayout.f36398a = 0;
            AudioManager audioManager = videoGestureFrameLayout.f36408f;
            if (audioManager != null) {
                videoGestureFrameLayout.f36412h = audioManager.getStreamVolume(3);
            }
            float f10 = videoGestureFrameLayout.S.screenBrightness;
            videoGestureFrameLayout.Q = f10;
            if (f10 != -1.0f) {
                return true;
            }
            videoGestureFrameLayout.Q = videoGestureFrameLayout.f36418k.getBrightness() / 255.0f;
            return true;
        }

        @Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnGestureListener
        public boolean onFling(MotionEvent motionEvent, @NonNull MotionEvent motionEvent2, float f10, float f11) {
            return super.onFling(motionEvent, motionEvent2, f10, f11);
        }

        @Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnGestureListener
        public void onLongPress(@NonNull MotionEvent motionEvent) {
            super.onLongPress(motionEvent);
        }

        @Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnGestureListener
        public boolean onScroll(MotionEvent motionEvent, @NonNull MotionEvent motionEvent2, float f10, float f11) {
            ShowChangeLayout showChangeLayout;
            ShowChangeLayout showChangeLayout2;
            ShowChangeLayout showChangeLayout3;
            VideoGestureFrameLayout videoGestureFrameLayout = VideoGestureFrameLayout.this;
            if (!videoGestureFrameLayout.f36406e) {
                return false;
            }
            int i10 = videoGestureFrameLayout.f36398a;
            if (i10 == 0) {
                float fAbs = Math.abs(motionEvent2.getX() - motionEvent.getX());
                float fAbs2 = Math.abs(motionEvent2.getY() - motionEvent.getY());
                int i11 = videoGestureFrameLayout.f36407e0;
                if (fAbs < i11 && fAbs2 < i11) {
                    return true;
                }
                if (fAbs > fAbs2) {
                    float x10 = motionEvent.getX();
                    int width = videoGestureFrameLayout.getWidth();
                    if (width > 0) {
                        float f12 = width;
                        float f13 = 0.2f * f12;
                        float f14 = f12 * 0.8f;
                        if (x10 >= f13 && x10 <= f14) {
                            videoGestureFrameLayout.f36398a = 3;
                        }
                    }
                    return true;
                }
                if (motionEvent.getY() >= videoGestureFrameLayout.getHeight() / 7.0f && motionEvent.getY() <= (videoGestureFrameLayout.getHeight() * 6.0f) / 7.0f) {
                    if (motionEvent.getX() < videoGestureFrameLayout.getWidth() / 2.0f) {
                        videoGestureFrameLayout.f36398a = 1;
                    } else {
                        videoGestureFrameLayout.f36398a = 2;
                    }
                }
            } else if (i10 != 1) {
                float f15 = 0.0f;
                if (i10 != 2) {
                    if (i10 != 3 || !videoGestureFrameLayout.f36399a0 || (showChangeLayout3 = videoGestureFrameLayout.V) == null || !videoGestureFrameLayout.f36422m || videoGestureFrameLayout.f36420l <= 0) {
                        return true;
                    }
                    if (videoGestureFrameLayout.indexOfChild(showChangeLayout3) == -1) {
                        videoGestureFrameLayout.addView(videoGestureFrameLayout.V);
                    }
                    float x11 = motionEvent2.getX() - motionEvent.getX();
                    if (x11 > 0.0f) {
                        videoGestureFrameLayout.V.setImageResource(R.drawable.f36333ff);
                        videoGestureFrameLayout.f36414i = (int) (((x11 / videoGestureFrameLayout.getWidth()) * 100.0f * videoGestureFrameLayout.f36405d0) + videoGestureFrameLayout.f36416j);
                        if (videoGestureFrameLayout.f36414i > 100) {
                            videoGestureFrameLayout.f36414i = 100;
                        }
                    } else {
                        videoGestureFrameLayout.V.setImageResource(R.drawable.fr);
                        videoGestureFrameLayout.f36414i = (int) (((x11 / videoGestureFrameLayout.getWidth()) * 100.0f * videoGestureFrameLayout.f36405d0) + videoGestureFrameLayout.f36416j);
                        if (videoGestureFrameLayout.f36414i < 0) {
                            videoGestureFrameLayout.f36414i = 0;
                        }
                    }
                    videoGestureFrameLayout.V.setProgress(videoGestureFrameLayout.f36414i);
                    videoGestureFrameLayout.V.setProgressText(UiUtils.stringToTime((videoGestureFrameLayout.f36420l * ((long) videoGestureFrameLayout.f36414i)) / 100) + " / " + UiUtils.stringToTime(videoGestureFrameLayout.f36420l));
                    videoGestureFrameLayout.V.show(0);
                    videoGestureFrameLayout.f36404d = true;
                } else {
                    if (!videoGestureFrameLayout.f36399a0 || (showChangeLayout2 = videoGestureFrameLayout.U) == null) {
                        return true;
                    }
                    if (videoGestureFrameLayout.indexOfChild(showChangeLayout2) == -1) {
                        videoGestureFrameLayout.addView(videoGestureFrameLayout.U);
                    }
                    float y10 = (((motionEvent.getY() - motionEvent2.getY()) / videoGestureFrameLayout.getHeight()) * videoGestureFrameLayout.f36403c0) + videoGestureFrameLayout.Q;
                    if (y10 >= 0.0f) {
                        f15 = 1.0f;
                        if (y10 <= 1.0f) {
                            f15 = y10;
                        }
                    }
                    WindowManager.LayoutParams layoutParams = videoGestureFrameLayout.S;
                    layoutParams.screenBrightness = f15;
                    videoGestureFrameLayout.R.setAttributes(layoutParams);
                    videoGestureFrameLayout.U.setProgress((int) (f15 * 100.0f));
                    videoGestureFrameLayout.U.setProgressText("");
                    videoGestureFrameLayout.U.setImageResource(R.drawable.brightness_w);
                    videoGestureFrameLayout.U.show(1);
                }
            } else {
                if (!videoGestureFrameLayout.f36399a0 || (showChangeLayout = videoGestureFrameLayout.T) == null || videoGestureFrameLayout.f36408f == null) {
                    return true;
                }
                if (videoGestureFrameLayout.indexOfChild(showChangeLayout) == -1) {
                    videoGestureFrameLayout.addView(videoGestureFrameLayout.T);
                }
                if (videoGestureFrameLayout.f36410g <= 0) {
                    return true;
                }
                int y11 = (int) ((((motionEvent.getY() - motionEvent2.getY()) / (videoGestureFrameLayout.getHeight() / videoGestureFrameLayout.f36410g)) * videoGestureFrameLayout.f36401b0) + videoGestureFrameLayout.f36412h);
                int i12 = y11 >= 0 ? y11 : 0;
                int i13 = videoGestureFrameLayout.f36410g;
                if (i12 > i13) {
                    i12 = i13;
                }
                videoGestureFrameLayout.f36408f.setStreamVolume(3, i12, 4);
                int i14 = (int) ((i12 / videoGestureFrameLayout.f36410g) * 100.0f);
                if (i14 >= 50) {
                    videoGestureFrameLayout.T.setImageResource(R.drawable.volume_higher_w);
                } else if (i14 > 0) {
                    videoGestureFrameLayout.T.setImageResource(R.drawable.volume_lower_w);
                } else {
                    videoGestureFrameLayout.T.setImageResource(R.drawable.volume_off_w);
                }
                videoGestureFrameLayout.T.setProgress(i14);
                videoGestureFrameLayout.T.setProgressText("");
                videoGestureFrameLayout.T.show(1);
            }
            return true;
        }

        @Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnGestureListener
        public void onShowPress(@NonNull MotionEvent motionEvent) {
            super.onShowPress(motionEvent);
        }

        @Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnDoubleTapListener
        public boolean onSingleTapConfirmed(@NonNull MotionEvent motionEvent) {
            VideoGestureListener videoGestureListener = VideoGestureFrameLayout.this.f36402c;
            if (videoGestureListener != null) {
                videoGestureListener.onSingleTapGesture(motionEvent);
            }
            return super.onSingleTapConfirmed(motionEvent);
        }

        @Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnGestureListener
        public boolean onSingleTapUp(@NonNull MotionEvent motionEvent) {
            return super.onSingleTapUp(motionEvent);
        }
    }

    public VideoGestureFrameLayout(Context context) {
        super(context);
        this.f36398a = 0;
        this.f36404d = false;
        this.f36406e = true;
        this.f36410g = 0;
        this.f36412h = 0;
        this.f36414i = 0;
        this.f36416j = 0;
        this.f36420l = 0L;
        this.f36422m = false;
        this.Q = 1.0f;
        this.f36399a0 = true;
        this.f36401b0 = 0.35f;
        this.f36403c0 = 0.35f;
        this.f36405d0 = 0.4f;
        this.f36413h0 = 1.0f;
        this.f36415i0 = true;
        this.f36417j0 = false;
        this.f36419k0 = false;
        this.f36421l0 = false;
        this.f36423m0 = false;
        this.f36424n0 = false;
        d(context);
    }

    /* JADX WARN: Removed duplicated region for block: B:35:0x0070  */
    /* JADX WARN: Removed duplicated region for block: B:39:0x007e  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static void a(VideoGestureFrameLayout videoGestureFrameLayout) {
        boolean z10;
        Object objInvoke;
        if (videoGestureFrameLayout.f36417j0 && videoGestureFrameLayout.f36398a == 0 && videoGestureFrameLayout.f36399a0 && videoGestureFrameLayout.f36415i0 && videoGestureFrameLayout.f36422m && videoGestureFrameLayout.f36420l > 0) {
            videoGestureFrameLayout.f36417j0 = false;
            videoGestureFrameLayout.f36419k0 = true;
            videoGestureFrameLayout.f36421l0 = true;
            VideoGestureListener videoGestureListener = videoGestureFrameLayout.f36402c;
            boolean z11 = videoGestureListener != null && videoGestureListener.onLongPressSpeedStart(3.0f);
            videoGestureFrameLayout.f36423m0 = z11;
            if (!z11) {
                Object objB = b(videoGestureFrameLayout);
                videoGestureFrameLayout.f36425o0 = objB;
                if (objB == null) {
                    z10 = false;
                } else {
                    try {
                        objInvoke = objB.getClass().getMethod("getSpeed", new Class[0]).invoke(objB, new Object[0]);
                    } catch (Exception unused) {
                    }
                    if (objInvoke instanceof Number) {
                        float fFloatValue = ((Number) objInvoke).floatValue();
                        if (!Float.isNaN(fFloatValue)) {
                            if (Float.isInfinite(fFloatValue) || fFloatValue <= 0.0f) {
                                fFloatValue = 1.0f;
                            }
                            videoGestureFrameLayout.f36413h0 = fFloatValue;
                            if (e(videoGestureFrameLayout.f36425o0, 3.0f)) {
                                z10 = true;
                            }
                        }
                    }
                }
            }
            videoGestureFrameLayout.f36424n0 = z10;
            if (!videoGestureFrameLayout.f36423m0 && !z10) {
                videoGestureFrameLayout.f36419k0 = false;
                videoGestureFrameLayout.f36421l0 = false;
                return;
            }
            if (videoGestureFrameLayout.W == null) {
                videoGestureFrameLayout.W = new LongPressSpeedLayout(videoGestureFrameLayout.getContext());
                FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-2, -2);
                layoutParams.gravity = 17;
                videoGestureFrameLayout.W.setLayoutParams(layoutParams);
            }
            LongPressSpeedLayout longPressSpeedLayout = videoGestureFrameLayout.W;
            if (longPressSpeedLayout == null) {
                return;
            }
            if (videoGestureFrameLayout.indexOfChild(longPressSpeedLayout) == -1) {
                videoGestureFrameLayout.addView(videoGestureFrameLayout.W);
            }
            FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) videoGestureFrameLayout.W.getLayoutParams();
            layoutParams2.gravity = 49;
            int height = videoGestureFrameLayout.getHeight() / 5;
            int measuredHeight = videoGestureFrameLayout.W.getMeasuredHeight();
            if (measuredHeight <= 0) {
                videoGestureFrameLayout.W.measure(View.MeasureSpec.makeMeasureSpec(0, 0), View.MeasureSpec.makeMeasureSpec(0, 0));
                measuredHeight = videoGestureFrameLayout.W.getMeasuredHeight();
            }
            layoutParams2.topMargin = Math.max(0, height - (measuredHeight / 2));
            videoGestureFrameLayout.W.setLayoutParams(layoutParams2);
            LongPressSpeedLayout longPressSpeedLayout2 = videoGestureFrameLayout.W;
            longPressSpeedLayout2.setVisibility(0);
            TriangleStripView triangleStripView = longPressSpeedLayout2.f36427a;
            triangleStripView.f36431d = true;
            triangleStripView.f36430c = 0;
            Runnable runnable = triangleStripView.f36432e;
            triangleStripView.removeCallbacks(runnable);
            triangleStripView.invalidate();
            triangleStripView.postDelayed(runnable, 160L);
            videoGestureFrameLayout.W.bringToFront();
        }
    }

    public static Object b(View view) {
        if (view instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) view;
            for (int i10 = 0; i10 < viewGroup.getChildCount(); i10++) {
                Object objB = b(viewGroup.getChildAt(i10));
                if (objB != null) {
                    return objB;
                }
            }
        }
        try {
            view.getClass().getMethod("setSpeed", Float.TYPE);
            return view;
        } catch (NoSuchMethodException unused) {
            return null;
        }
    }

    public static boolean e(Object obj, float f10) {
        try {
            obj.getClass().getMethod("setSpeed", Float.TYPE).invoke(obj, Float.valueOf(f10));
            return true;
        } catch (Exception unused) {
            return false;
        }
    }

    public final void c() {
        Object obj;
        VideoGestureListener videoGestureListener;
        if (this.f36417j0) {
            this.f36417j0 = false;
            p000if.e eVar = this.f36426p0;
            if (eVar != null) {
                removeCallbacks(eVar);
            }
        }
        if (this.f36419k0) {
            this.f36419k0 = false;
            LongPressSpeedLayout longPressSpeedLayout = this.W;
            if (longPressSpeedLayout != null) {
                TriangleStripView triangleStripView = longPressSpeedLayout.f36427a;
                triangleStripView.f36431d = false;
                triangleStripView.removeCallbacks(triangleStripView.f36432e);
                triangleStripView.f36430c = 0;
                triangleStripView.invalidate();
                longPressSpeedLayout.setVisibility(8);
                if (indexOfChild(this.W) != -1) {
                    removeView(this.W);
                }
            }
            if (this.f36423m0 && (videoGestureListener = this.f36402c) != null) {
                videoGestureListener.onLongPressSpeedEnd();
            }
            if (this.f36424n0 && (obj = this.f36425o0) != null) {
                e(obj, this.f36413h0);
            }
            this.f36423m0 = false;
            this.f36424n0 = false;
            this.f36425o0 = null;
            this.f36413h0 = 1.0f;
        }
    }

    public final void d(Context context) {
        this.f36407e0 = (int) (context.getResources().getDisplayMetrics().density * 12.0f);
        setHapticFeedbackEnabled(false);
        setOnLongClickListener(new p());
        GestureDetector gestureDetector = new GestureDetector(context, new VideoPlayerOnGestureListener());
        this.f36400b = gestureDetector;
        gestureDetector.setIsLongpressEnabled(false);
        setOnTouchListener(new s9.g(this, 3));
    }

    public void initView(Activity activity) {
        this.T = new ShowChangeLayout(activity);
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-2, -2);
        layoutParams.setMargins(AutoSizeUtils.dp2px(activity, 30.0f), 0, 0, 0);
        layoutParams.gravity = 8388627;
        this.T.setLayoutParams(layoutParams);
        this.U = new ShowChangeLayout(activity);
        FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(-2, -2);
        layoutParams2.setMargins(0, 0, AutoSizeUtils.dp2px(activity, 30.0f), 0);
        layoutParams2.gravity = 8388629;
        this.U.setLayoutParams(layoutParams2);
        this.V = new ShowChangeLayout(activity);
        FrameLayout.LayoutParams layoutParams3 = new FrameLayout.LayoutParams(-2, -2);
        layoutParams3.setMargins(0, AutoSizeUtils.dp2px(activity, 100.0f), 0, 0);
        layoutParams3.gravity = 49;
        this.V.setLayoutParams(layoutParams3);
        this.W = new LongPressSpeedLayout(activity);
        FrameLayout.LayoutParams layoutParams4 = new FrameLayout.LayoutParams(-2, -2);
        layoutParams4.gravity = 17;
        this.W.setLayoutParams(layoutParams4);
        AudioManager audioManager = (AudioManager) activity.getSystemService("audio");
        this.f36408f = audioManager;
        if (audioManager == null) {
            return;
        }
        this.f36410g = audioManager.getStreamMaxVolume(3);
        this.f36418k = new BrightnessHelper(activity);
        Window window = activity.getWindow();
        this.R = window;
        WindowManager.LayoutParams attributes = window.getAttributes();
        this.S = attributes;
        this.Q = attributes.screenBrightness;
        setEnable(true);
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onDetachedFromWindow() {
        c();
        super.onDetachedFromWindow();
    }

    @Override // android.view.View
    public boolean performLongClick() {
        return true;
    }

    public void setEnable(boolean z10) {
        this.f36399a0 = z10;
    }

    public void setGestureSensitivity(float f10, float f11, float f12) {
        this.f36401b0 = Math.max(0.1f, Math.min(2.0f, f10));
        this.f36403c0 = Math.max(0.1f, Math.min(2.0f, f11));
        this.f36405d0 = Math.max(0.1f, Math.min(2.0f, f12));
    }

    public void setGestureTriggerSlopDp(int i10) {
        if (i10 <= 0) {
            return;
        }
        this.f36407e0 = (int) (i10 * getResources().getDisplayMetrics().density);
    }

    public void setLongPressSpeedEnabled(boolean z10) {
        this.f36415i0 = z10;
        if (z10) {
            return;
        }
        c();
    }

    public void setScrollEnable(boolean z10) {
        this.f36406e = z10;
    }

    public void setSeekGestureState(long j10, long j11, boolean z10) {
        long jMax = Math.max(j11, 0L);
        this.f36420l = jMax;
        this.f36422m = z10 && jMax > 0;
        if (jMax <= 0) {
            this.f36416j = 0;
            this.f36414i = 0;
        } else {
            int iMax = (int) Math.max(0L, Math.min(100L, (j10 * 100) / jMax));
            this.f36416j = iMax;
            this.f36414i = iMax;
        }
    }

    public void setVideoGestureListener(VideoGestureListener videoGestureListener) {
        this.f36402c = videoGestureListener;
    }

    @Override // android.view.View
    public boolean showContextMenu() {
        return false;
    }

    @Override // android.view.View
    public boolean performLongClick(float f10, float f11) {
        return true;
    }

    @Override // android.view.View
    public boolean showContextMenu(float f10, float f11) {
        return false;
    }

    public VideoGestureFrameLayout(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.f36398a = 0;
        this.f36404d = false;
        this.f36406e = true;
        this.f36410g = 0;
        this.f36412h = 0;
        this.f36414i = 0;
        this.f36416j = 0;
        this.f36420l = 0L;
        this.f36422m = false;
        this.Q = 1.0f;
        this.f36399a0 = true;
        this.f36401b0 = 0.35f;
        this.f36403c0 = 0.35f;
        this.f36405d0 = 0.4f;
        this.f36413h0 = 1.0f;
        this.f36415i0 = true;
        this.f36417j0 = false;
        this.f36419k0 = false;
        this.f36421l0 = false;
        this.f36423m0 = false;
        this.f36424n0 = false;
        d(context);
    }
}
