package com.bytedance.sdk.component.adexpress.dynamic.animation.view;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.graphics.Region;
import android.graphics.Shader;
import android.view.View;
import android.view.ViewGroup;
import com.bytedance.sdk.component.adexpress.dynamic.dynamicview.ku;
import com.bytedance.sdk.component.adexpress.dynamic.yz.wsy;

/* JADX INFO: loaded from: classes.dex */
public class lb {
    private int ajl;
    Paint fm;
    private int jnr;
    private int yz;
    Path ro = new Path();

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    Path f6466lb = new Path();

    public lb() {
        Paint paint = new Paint();
        this.fm = paint;
        paint.setAntiAlias(true);
    }

    public void fm(Canvas canvas, IAnimation iAnimation, View view) {
        int iIntValue;
        int iIntValue2;
        String str;
        float[] fArrRo;
        if (iAnimation.getRippleValue() != 0.0f) {
            if (com.bytedance.sdk.component.adexpress.fm.fm.fm.fm().lb() != null) {
                try {
                    str = (String) view.getTag(2097610712);
                    try {
                        fArrRo = wsy.ro(str);
                    } catch (Exception unused) {
                        fArrRo = null;
                    }
                } catch (Exception unused2) {
                    str = "";
                }
                if (str.startsWith("#")) {
                    this.fm.setColor(Color.parseColor(str));
                    this.fm.setAlpha(90);
                } else if (fArrRo != null) {
                    this.fm.setColor(com.bytedance.sdk.component.adexpress.yz.wsy.fm((1.0f - iAnimation.getRippleValue()) * fArrRo[3], fArrRo[0] / 256.0f, fArrRo[1] / 256.0f, fArrRo[2] / 256.0f));
                }
            }
            ((ViewGroup) view.getParent()).setClipChildren(true);
            canvas.drawCircle(this.yz, this.jnr, iAnimation.getRippleValue() * Math.min(r1, r4) * 2, this.fm);
        }
        if (iAnimation.getShineValue() != 0.0f) {
            if (view.getParent() != null) {
                ((ViewGroup) view.getParent()).setClipChildren(true);
            }
            if (view.getParent().getParent() != null) {
                ((ViewGroup) view.getParent().getParent()).setClipChildren(true);
            }
            this.ro.reset();
            try {
                iIntValue2 = ((Integer) view.getTag(2097610711)).intValue();
            } catch (Exception unused3) {
                iIntValue2 = 0;
            }
            if (iIntValue2 >= 0) {
                int shineValue = ((int) (iAnimation.getShineValue() * ((this.jnr * 2) + ((iIntValue2 * 2) + (this.yz * 4))))) - ((this.jnr * 2) + iIntValue2);
                float f10 = shineValue;
                int i10 = this.jnr;
                this.fm.setShader(new LinearGradient(f10, 0.0f, ((iIntValue2 + i10) / 2) + shineValue, i10 / 2, new int[]{Color.parseColor("#20ffffff"), Color.parseColor("#60ffffff"), Color.parseColor("#65ffffff")}, (float[]) null, Shader.TileMode.MIRROR));
                this.fm.setStrokeWidth(this.yz * 2);
                Path path = this.f6466lb;
                if (path != null) {
                    canvas.clipPath(path, Region.Op.INTERSECT);
                }
                int i11 = shineValue + iIntValue2;
                canvas.drawLine(f10, 0.0f, i11 + r1, this.jnr, this.fm);
            }
        }
        if (iAnimation.getMarqueeValue() != 0.0f) {
            try {
                iIntValue = ((Integer) view.getTag(2097610709)).intValue();
            } catch (Exception unused4) {
                iIntValue = 0;
            }
            if (iIntValue >= 0) {
                this.ro.reset();
                this.ro.moveTo(0.0f, 0.0f);
                this.ro.lineTo(this.yz * 2, 0.0f);
                this.ro.lineTo(this.yz * 2, this.jnr * 2);
                this.ro.lineTo(0.0f, this.jnr * 2);
                this.ro.lineTo(0.0f, 0.0f);
                this.fm.setShader(new LinearGradient(0.0f, 0.0f, this.yz * 2, this.jnr * 2, new int[]{(int) (iAnimation.getMarqueeValue() * (-65536.0f)), (int) ((1.0f - iAnimation.getMarqueeValue()) * (-65536.0f))}, (float[]) null, Shader.TileMode.CLAMP));
                this.fm.setColor(-65536);
                this.fm.setStyle(Paint.Style.STROKE);
                this.fm.setStrokeWidth(iIntValue);
                canvas.drawPath(this.ro, this.fm);
            }
        }
    }

    public void fm(View view, float f10) {
        ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        layoutParams.width = (int) (this.ajl * f10);
        view.setTranslationX((r1 - r6) / 2);
        if (view instanceof ku) {
            int i10 = 0;
            while (true) {
                ViewGroup viewGroup = (ViewGroup) view;
                if (i10 >= viewGroup.getChildCount()) {
                    break;
                }
                viewGroup.getChildAt(i10).setTranslationX((-(this.ajl - layoutParams.width)) / 2);
                i10++;
            }
        }
        view.setLayoutParams(layoutParams);
    }

    public void fm(View view, int i10, int i11) {
        String str;
        this.yz = i10 / 2;
        this.jnr = i11 / 2;
        if (this.ajl == 0 && view.getLayoutParams().width > 0) {
            this.ajl = view.getLayoutParams().width;
        }
        try {
            str = (String) view.getTag(2097610710);
            try {
                this.f6466lb.addRoundRect(new RectF(0.0f, 0.0f, i10, i11), i11 / 2, i11 / 2, Path.Direction.CW);
            } catch (Exception unused) {
            }
        } catch (Exception unused2) {
            str = "";
        }
        if ("right".equals(str)) {
            view.setPivotX(this.yz * 2);
            view.setPivotY(this.jnr);
        } else if ("left".equals(str)) {
            view.setPivotX(0.0f);
            view.setPivotY(this.jnr);
        } else {
            view.setPivotX(this.yz);
            view.setPivotY(this.jnr);
        }
    }
}
