package defpackage;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.j;
import androidx.constraintlayout.widget.n;
import java.util.Arrays;
import java.util.HashMap;

/* JADX INFO: loaded from: classes.dex */
public class f01 extends n {
    public static int w;
    public static float x;
    public ConstraintLayout m;
    public int n;
    public float[] o;
    public int[] p;
    public int q;
    public int r;
    public String s;
    public String t;
    public Float u;
    public Integer v;

    private void setAngles(String str) {
        if (str == null) {
            return;
        }
        int i = 0;
        this.r = 0;
        while (true) {
            int iIndexOf = str.indexOf(44, i);
            if (iIndexOf == -1) {
                p(str.substring(i).trim());
                return;
            } else {
                p(str.substring(i, iIndexOf).trim());
                i = iIndexOf + 1;
            }
        }
    }

    private void setRadius(String str) {
        if (str == null) {
            return;
        }
        int i = 0;
        this.q = 0;
        while (true) {
            int iIndexOf = str.indexOf(44, i);
            if (iIndexOf == -1) {
                q(str.substring(i).trim());
                return;
            } else {
                q(str.substring(i, iIndexOf).trim());
                i = iIndexOf + 1;
            }
        }
    }

    public float[] getAngles() {
        return Arrays.copyOf(this.o, this.r);
    }

    public int[] getRadius() {
        return Arrays.copyOf(this.p, this.q);
    }

    @Override // androidx.constraintlayout.widget.n, androidx.constraintlayout.widget.b
    public final void j(AttributeSet attributeSet) {
        super.j(attributeSet);
        if (attributeSet != null) {
            TypedArray typedArrayObtainStyledAttributes = getContext().obtainStyledAttributes(attributeSet, j.m.b);
            int indexCount = typedArrayObtainStyledAttributes.getIndexCount();
            for (int i = 0; i < indexCount; i++) {
                int index = typedArrayObtainStyledAttributes.getIndex(i);
                if (index == 33) {
                    this.n = typedArrayObtainStyledAttributes.getResourceId(index, 0);
                } else if (index == 29) {
                    String string = typedArrayObtainStyledAttributes.getString(index);
                    this.s = string;
                    setAngles(string);
                } else if (index == 32) {
                    String string2 = typedArrayObtainStyledAttributes.getString(index);
                    this.t = string2;
                    setRadius(string2);
                } else if (index == 30) {
                    Float fValueOf = Float.valueOf(typedArrayObtainStyledAttributes.getFloat(index, x));
                    this.u = fValueOf;
                    setDefaultAngle(fValueOf.floatValue());
                } else if (index == 31) {
                    Integer numValueOf = Integer.valueOf(typedArrayObtainStyledAttributes.getDimensionPixelSize(index, w));
                    this.v = numValueOf;
                    setDefaultRadius(numValueOf.intValue());
                }
            }
            typedArrayObtainStyledAttributes.recycle();
        }
    }

    @Override // androidx.constraintlayout.widget.n, androidx.constraintlayout.widget.b, android.view.View
    public final void onAttachedToWindow() {
        super.onAttachedToWindow();
        String str = this.s;
        if (str != null) {
            this.o = new float[1];
            setAngles(str);
        }
        String str2 = this.t;
        if (str2 != null) {
            this.p = new int[1];
            setRadius(str2);
        }
        Float f = this.u;
        if (f != null) {
            setDefaultAngle(f.floatValue());
        }
        Integer num = this.v;
        if (num != null) {
            setDefaultRadius(num.intValue());
        }
        HashMap map = this.j;
        this.m = (ConstraintLayout) getParent();
        for (int i = 0; i < this.b; i++) {
            View viewById = this.m.getViewById(this.a[i]);
            if (viewById != null) {
                int i2 = w;
                float f2 = x;
                int[] iArr = this.p;
                if (iArr == null || i >= iArr.length) {
                    Integer num2 = this.v;
                    if (num2 == null || num2.intValue() == -1) {
                        Log.e("CircularFlow", "Added radius to view with id: " + ((String) map.get(Integer.valueOf(viewById.getId()))));
                    } else {
                        this.q++;
                        if (this.p == null) {
                            this.p = new int[1];
                        }
                        int[] radius = getRadius();
                        this.p = radius;
                        radius[this.q - 1] = i2;
                    }
                } else {
                    i2 = iArr[i];
                }
                float[] fArr = this.o;
                if (fArr == null || i >= fArr.length) {
                    Float f3 = this.u;
                    if (f3 == null || f3.floatValue() == -1.0f) {
                        Log.e("CircularFlow", "Added angle to view with id: " + ((String) map.get(Integer.valueOf(viewById.getId()))));
                    } else {
                        this.r++;
                        if (this.o == null) {
                            this.o = new float[1];
                        }
                        float[] angles = getAngles();
                        this.o = angles;
                        angles[this.r - 1] = f2;
                    }
                } else {
                    f2 = fArr[i];
                }
                ConstraintLayout.b bVar = (ConstraintLayout.b) viewById.getLayoutParams();
                bVar.r = f2;
                bVar.p = this.n;
                bVar.q = i2;
                viewById.setLayoutParams(bVar);
            }
        }
        e();
    }

    public final void p(String str) {
        float[] fArr;
        if (str == null || str.length() == 0 || this.c == null || (fArr = this.o) == null) {
            return;
        }
        if (this.r + 1 > fArr.length) {
            this.o = Arrays.copyOf(fArr, fArr.length + 1);
        }
        this.o[this.r] = Integer.parseInt(str);
        this.r++;
    }

    public final void q(String str) {
        int[] iArr;
        Context context = this.c;
        if (str == null || str.length() == 0 || context == null || (iArr = this.p) == null) {
            return;
        }
        if (this.q + 1 > iArr.length) {
            this.p = Arrays.copyOf(iArr, iArr.length + 1);
        }
        this.p[this.q] = (int) (Integer.parseInt(str) * context.getResources().getDisplayMetrics().density);
        this.q++;
    }

    public void setDefaultAngle(float f) {
        x = f;
    }

    public void setDefaultRadius(int i) {
        w = i;
    }
}
