package com.ss.android.ugc.aweme.feed.ui.seekbar;

import X.AnonymousClass4CP;
import X.Euy;
import X.Evx;
import X.M12;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import android.widget.FrameLayout;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.ies.abmock.SettingsManager;
import kotlin.h.b.n;

public final class VideoSeekBarMaskView extends FrameLayout {
    public boolean LIZ;
    public Euy LIZIZ;
    public Evx LIZJ;
    public Rect LIZLLL;
    public float LJ;
    public float LJFF;
    public boolean LJI;
    public int LJII;
    public float LJIIIIZZ;

    static {
        Covode.recordClassIndex(79856);
    }

    public final float getLastDownRawX() {
        return this.LJ;
    }

    public final float getLastDownRawY() {
        return this.LJFF;
    }

    public final float getMoveDx() {
        return this.LJIIIIZZ;
    }

    public final Evx getMutableSeekBar() {
        return this.LIZJ;
    }

    public final boolean getNeedHandleMove() {
        return this.LJI;
    }

    public final Rect getSeekBarRect() {
        return this.LIZLLL;
    }

    public final int getTouchSlop() {
        return this.LJII;
    }

    public final Euy getVideoSeekBar() {
        return this.LIZIZ;
    }

    public final void setDownInRect(boolean z) {
        this.LIZ = z;
    }

    public final void setLastDownRawX(float f) {
        this.LJ = f;
    }

    public final void setLastDownRawY(float f) {
        this.LJFF = f;
    }

    public final void setMoveDx(float f) {
        this.LJIIIIZZ = f;
    }

    public final void setMutableSeekBar(Evx evx) {
        this.LIZJ = evx;
    }

    public final void setNeedHandleMove(boolean z) {
        this.LJI = z;
    }

    public final void setSeekBarRect(Rect rect) {
        this.LIZLLL = rect;
    }

    public final void setTouchSlop(int i) {
        this.LJII = i;
    }

    public final void setVideoSeekBar(Euy euy) {
        this.LIZIZ = euy;
    }

    /* JADX INFO: this call moved to the top of the method (can break code semantics) */
    public VideoSeekBarMaskView(Context context) {
        this(context, (AttributeSet) null);
        M12.LIZ(context);
    }

    public final void setSeekBarView(Euy euy) {
        Evx evx;
        M12.LIZ(euy);
        this.LIZIZ = euy;
        if (euy != null) {
            evx = euy.getMutableSeekBar();
        } else {
            evx = null;
        }
        this.LIZJ = evx;
    }

    public final boolean canScrollHorizontally(int i) {
        if (!AnonymousClass4CP.LIZ.LIZ() || !this.LIZ || this.LJIIIIZZ <= 10.0f) {
            return super.canScrollHorizontally(i);
        }
        return true;
    }

    public final boolean canScrollVertically(int i) {
        int childCount = getChildCount();
        for (int i2 = 0; i2 < childCount; i2++) {
            if (getChildAt(i2).canScrollVertically(i)) {
                return true;
            }
        }
        return super.canScrollVertically(i);
    }

    public final boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        Euy euy;
        Euy euy2;
        Integer valueOf;
        if (!AnonymousClass4CP.LIZ.LIZ() || (((euy = this.LIZIZ) != null && euy.getVisibility() == 8) || ((euy2 = this.LIZIZ) != null && euy2.getVisibility() == 4))) {
            return super.onInterceptTouchEvent(motionEvent);
        }
        Rect rect = new Rect();
        this.LIZLLL = rect;
        Evx evx = this.LIZJ;
        if (evx != null) {
            evx.getGlobalVisibleRect(rect);
        }
        if (!(motionEvent == null || (valueOf = Integer.valueOf(motionEvent.getAction())) == null)) {
            if (valueOf.intValue() == 0) {
                float rawX = motionEvent.getRawX();
                float rawY = motionEvent.getRawY();
                float LIZ2 = (float) SettingsManager.LIZ().LIZ("increase_seek_bar_touch_area", 0);
                Rect rect2 = this.LIZLLL;
                if (rect2 == null || rawX < ((float) rect2.left) || rawX > ((float) rect2.right) || rawY < ((float) rect2.top) - LIZ2 || rawY > ((float) rect2.bottom) + LIZ2) {
                    this.LIZ = false;
                } else {
                    this.LIZ = true;
                    this.LJ = motionEvent.getRawX();
                    this.LJFF = motionEvent.getRawY();
                    Euy euy3 = this.LIZIZ;
                    if (euy3 != null) {
                        euy3.LIZ(motionEvent);
                    }
                    Evx evx2 = this.LIZJ;
                    if (evx2 != null) {
                        evx2.onTouchEvent(motionEvent);
                    }
                }
            } else if (valueOf.intValue() == 2) {
                if (this.LIZ) {
                    float abs = Math.abs(this.LJ - motionEvent.getRawX());
                    float abs2 = Math.abs(this.LJFF - motionEvent.getRawY());
                    this.LJIIIIZZ = abs;
                    if (abs > ((float) this.LJII) && abs > abs2) {
                        this.LJI = true;
                        getParent().requestDisallowInterceptTouchEvent(true);
                        return true;
                    }
                }
            } else if (valueOf.intValue() == 1 || valueOf.intValue() == 3) {
                if (this.LIZ && this.LJI) {
                    getParent().requestDisallowInterceptTouchEvent(false);
                }
                this.LIZ = false;
                this.LJI = false;
            }
        }
        return super.onInterceptTouchEvent(motionEvent);
    }

    public final boolean onTouchEvent(MotionEvent motionEvent) {
        Euy euy;
        Euy euy2;
        Integer valueOf;
        if (!AnonymousClass4CP.LIZ.LIZ() || (((euy = this.LIZIZ) != null && euy.getVisibility() == 8) || ((euy2 = this.LIZIZ) != null && euy2.getVisibility() == 4))) {
            return super.onTouchEvent(motionEvent);
        }
        if (!(motionEvent == null || (valueOf = Integer.valueOf(motionEvent.getAction())) == null)) {
            if (valueOf.intValue() == 2) {
                if (Math.abs(this.LJ - motionEvent.getRawX()) > ((float) this.LJII)) {
                    Euy euy3 = this.LIZIZ;
                    if (euy3 != null) {
                        euy3.LIZ(motionEvent);
                    }
                    Evx evx = this.LIZJ;
                    if (evx != null) {
                        evx.onTouchEvent(motionEvent);
                    }
                    this.LJI = true;
                }
            } else if (valueOf.intValue() == 1 || valueOf.intValue() == 3) {
                if (this.LJI) {
                    Euy euy4 = this.LIZIZ;
                    if (euy4 != null) {
                        euy4.LIZ(motionEvent);
                    }
                    Evx evx2 = this.LIZJ;
                    if (evx2 != null) {
                        evx2.onTouchEvent(motionEvent);
                    }
                }
                this.LIZ = false;
                this.LJI = false;
            }
        }
        return super.onTouchEvent(motionEvent);
    }

    /* JADX INFO: this call moved to the top of the method (can break code semantics) */
    public VideoSeekBarMaskView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, (byte) 0);
        M12.LIZ(context);
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public VideoSeekBarMaskView(Context context, AttributeSet attributeSet, byte b) {
        super(context, attributeSet, 0);
        M12.LIZ(context);
        MethodCollector.i(7618);
        ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
        n.LIZIZ(viewConfiguration, "");
        this.LJII = viewConfiguration.getScaledTouchSlop();
        MethodCollector.o(7618);
    }
}
