package ῲ.ⁱ.K.ῲ;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.RectF;
import android.util.Xml;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewGroup;
import androidx.constraintlayout.motion.widget.MotionLayout;
import androidx.constraintlayout.widget.R$styleable;
import org.xmlpull.v1.XmlPullParser;

/* renamed from: ῲ.ⁱ.K.ῲ.ᓆ  reason: contains not printable characters */
/* compiled from: TouchResponse */
public class C2130 {

    /* renamed from: ᓆ  reason: contains not printable characters */
    public static final float[][] f7384 = {new float[]{0.0f, -1.0f}, new float[]{0.0f, 1.0f}, new float[]{-1.0f, 0.0f}, new float[]{1.0f, 0.0f}, new float[]{-1.0f, 0.0f}, new float[]{1.0f, 0.0f}};

    /* renamed from: 㶋  reason: contains not printable characters */
    public static final float[][] f7385 = {new float[]{0.5f, 0.0f}, new float[]{0.0f, 0.5f}, new float[]{1.0f, 0.5f}, new float[]{0.5f, 1.0f}, new float[]{0.5f, 0.5f}, new float[]{0.0f, 0.5f}, new float[]{1.0f, 0.5f}};

    /* renamed from: ʬ  reason: contains not printable characters */
    public int f7386 = 0;

    /* renamed from: Ԕ  reason: contains not printable characters */
    public float f7387;

    /* renamed from: Ԛ  reason: contains not printable characters */
    public float f7388 = 10.0f;

    /* renamed from: ؿ  reason: contains not printable characters */
    public float f7389 = 4.0f;

    /* renamed from: ݜ  reason: contains not printable characters */
    public float f7390 = 1.0f;

    /* renamed from: ඓ  reason: contains not printable characters */
    public int f7391 = -1;

    /* renamed from: ᓣ  reason: contains not printable characters */
    public float f7392 = 1.2f;

    /* renamed from: ᕣ  reason: contains not printable characters */
    public boolean f7393 = false;

    /* renamed from: ᨨ  reason: contains not printable characters */
    public float f7394 = 0.0f;

    /* renamed from: ῲ  reason: contains not printable characters */
    public int f7395 = 0;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public float f7396 = 0.5f;

    /* renamed from: K  reason: contains not printable characters */
    public int f7397 = 0;

    /* renamed from: 㑃  reason: contains not printable characters */
    public float[] f7398 = new float[2];

    /* renamed from: 㗗  reason: contains not printable characters */
    public final MotionLayout f7399;

    /* renamed from: 㗽  reason: contains not printable characters */
    public boolean f7400 = true;

    /* renamed from: 㳳  reason: contains not printable characters */
    public float f7401 = 1.0f;

    /* renamed from: 㴹  reason: contains not printable characters */
    public int f7402 = -1;

    /* renamed from: 㸾  reason: contains not printable characters */
    public int f7403 = -1;

    /* renamed from: 㿎  reason: contains not printable characters */
    public float f7404 = 0.5f;

    /* renamed from: 䀟  reason: contains not printable characters */
    public int f7405 = 0;

    /* renamed from: 䁗  reason: contains not printable characters */
    public float f7406;

    public C2130(Context context, MotionLayout motionLayout, XmlPullParser xmlPullParser) {
        this.f7399 = motionLayout;
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(Xml.asAttributeSet(xmlPullParser), R$styleable.OnSwipe);
        int indexCount = obtainStyledAttributes.getIndexCount();
        for (int i = 0; i < indexCount; i++) {
            int index = obtainStyledAttributes.getIndex(i);
            if (index == R$styleable.OnSwipe_touchAnchorId) {
                this.f7403 = obtainStyledAttributes.getResourceId(index, this.f7403);
            } else if (index == R$styleable.OnSwipe_touchAnchorSide) {
                this.f7397 = obtainStyledAttributes.getInt(index, this.f7397);
                float[][] fArr = f7385;
                int i2 = this.f7397;
                this.f7404 = fArr[i2][0];
                this.f7396 = fArr[i2][1];
            } else if (index == R$styleable.OnSwipe_dragDirection) {
                this.f7395 = obtainStyledAttributes.getInt(index, this.f7395);
                float[][] fArr2 = f7384;
                int i3 = this.f7395;
                this.f7394 = fArr2[i3][0];
                this.f7401 = fArr2[i3][1];
            } else if (index == R$styleable.OnSwipe_maxVelocity) {
                this.f7389 = obtainStyledAttributes.getFloat(index, this.f7389);
            } else if (index == R$styleable.OnSwipe_maxAcceleration) {
                this.f7392 = obtainStyledAttributes.getFloat(index, this.f7392);
            } else if (index == R$styleable.OnSwipe_moveWhenScrollAtTop) {
                this.f7400 = obtainStyledAttributes.getBoolean(index, this.f7400);
            } else if (index == R$styleable.OnSwipe_dragScale) {
                this.f7390 = obtainStyledAttributes.getFloat(index, this.f7390);
            } else if (index == R$styleable.OnSwipe_dragThreshold) {
                this.f7388 = obtainStyledAttributes.getFloat(index, this.f7388);
            } else if (index == R$styleable.OnSwipe_touchRegionId) {
                this.f7391 = obtainStyledAttributes.getResourceId(index, this.f7391);
            } else if (index == R$styleable.OnSwipe_onTouchUp) {
                this.f7386 = obtainStyledAttributes.getInt(index, this.f7386);
            } else if (index == R$styleable.OnSwipe_nestedScrollFlags) {
                this.f7405 = obtainStyledAttributes.getInteger(index, 0);
            } else if (index == R$styleable.OnSwipe_limitBoundsTo) {
                this.f7402 = obtainStyledAttributes.getResourceId(index, 0);
            }
        }
        obtainStyledAttributes.recycle();
    }

    public String toString() {
        return this.f7394 + " , " + this.f7401;
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m5625(boolean z) {
        if (z) {
            float[][] fArr = f7384;
            fArr[4] = fArr[3];
            fArr[5] = fArr[2];
            float[][] fArr2 = f7385;
            fArr2[5] = fArr2[2];
            fArr2[6] = fArr2[1];
        } else {
            float[][] fArr3 = f7384;
            fArr3[4] = fArr3[2];
            fArr3[5] = fArr3[3];
            float[][] fArr4 = f7385;
            fArr4[5] = fArr4[1];
            fArr4[6] = fArr4[2];
        }
        float[][] fArr5 = f7385;
        int i = this.f7397;
        this.f7404 = fArr5[i][0];
        this.f7396 = fArr5[i][1];
        float[][] fArr6 = f7384;
        int i2 = this.f7395;
        this.f7394 = fArr6[i2][0];
        this.f7401 = fArr6[i2][1];
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m5624(MotionEvent motionEvent, MotionLayout.AbstractC0127 r20) {
        float f;
        int i;
        float f2;
        MotionLayout.C0131 r1 = (MotionLayout.C0131) r20;
        VelocityTracker velocityTracker = r1.f780;
        if (velocityTracker != null) {
            velocityTracker.addMovement(motionEvent);
        }
        int action = motionEvent.getAction();
        if (action == 0) {
            this.f7406 = motionEvent.getRawX();
            this.f7387 = motionEvent.getRawY();
            this.f7393 = false;
        } else if (action == 1) {
            this.f7393 = false;
            r1.f780.computeCurrentVelocity(1000);
            float xVelocity = r1.f780.getXVelocity();
            float yVelocity = r1.f780.getYVelocity();
            float progress = this.f7399.getProgress();
            int i2 = this.f7403;
            if (i2 != -1) {
                this.f7399.m416(i2, progress, this.f7404, this.f7396, this.f7398);
            } else {
                float min = (float) Math.min(this.f7399.getWidth(), this.f7399.getHeight());
                float[] fArr = this.f7398;
                fArr[1] = this.f7401 * min;
                fArr[0] = min * this.f7394;
            }
            float f3 = this.f7394;
            float[] fArr2 = this.f7398;
            float f4 = fArr2[0];
            float f5 = fArr2[1];
            if (f3 != 0.0f) {
                f = xVelocity / fArr2[0];
            } else {
                f = yVelocity / fArr2[1];
            }
            float f6 = !Float.isNaN(f) ? (f / 3.0f) + progress : progress;
            if (f6 != 0.0f && f6 != 1.0f && (i = this.f7386) != 3) {
                this.f7399.m415(i, ((double) f6) < 0.5d ? 0.0f : 1.0f, f);
                if (0.0f >= progress || 1.0f <= progress) {
                    this.f7399.setState(MotionLayout.TransitionState.FINISHED);
                }
            } else if (0.0f >= f6 || 1.0f <= f6) {
                this.f7399.setState(MotionLayout.TransitionState.FINISHED);
            }
        } else if (action == 2) {
            float rawY = motionEvent.getRawY() - this.f7387;
            float rawX = motionEvent.getRawX() - this.f7406;
            if (Math.abs((this.f7401 * rawY) + (this.f7394 * rawX)) > this.f7388 || this.f7393) {
                float progress2 = this.f7399.getProgress();
                if (!this.f7393) {
                    this.f7393 = true;
                    this.f7399.setProgress(progress2);
                }
                int i3 = this.f7403;
                if (i3 != -1) {
                    this.f7399.m416(i3, progress2, this.f7404, this.f7396, this.f7398);
                } else {
                    float min2 = (float) Math.min(this.f7399.getWidth(), this.f7399.getHeight());
                    float[] fArr3 = this.f7398;
                    fArr3[1] = this.f7401 * min2;
                    fArr3[0] = min2 * this.f7394;
                }
                float f7 = this.f7394;
                float[] fArr4 = this.f7398;
                if (((double) Math.abs(((this.f7401 * fArr4[1]) + (f7 * fArr4[0])) * this.f7390)) < 0.01d) {
                    float[] fArr5 = this.f7398;
                    fArr5[0] = 0.01f;
                    fArr5[1] = 0.01f;
                }
                if (this.f7394 != 0.0f) {
                    f2 = rawX / this.f7398[0];
                } else {
                    f2 = rawY / this.f7398[1];
                }
                float max = Math.max(Math.min(progress2 + f2, 1.0f), 0.0f);
                if (max != this.f7399.getProgress()) {
                    this.f7399.setProgress(max);
                    r1.f780.computeCurrentVelocity(1000);
                    this.f7399.f746 = this.f7394 != 0.0f ? r1.f780.getXVelocity() / this.f7398[0] : r1.f780.getYVelocity() / this.f7398[1];
                } else {
                    this.f7399.f746 = 0.0f;
                }
                this.f7406 = motionEvent.getRawX();
                this.f7387 = motionEvent.getRawY();
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public RectF m5623(ViewGroup viewGroup, RectF rectF) {
        View findViewById;
        int i = this.f7391;
        if (i == -1 || (findViewById = viewGroup.findViewById(i)) == null) {
            return null;
        }
        rectF.set((float) findViewById.getLeft(), (float) findViewById.getTop(), (float) findViewById.getRight(), (float) findViewById.getBottom());
        return rectF;
    }
}
