package com.bytedance.sdk.openadsdk.core.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.view.View;
import com.bytedance.sdk.component.utils.maa;
import com.bytedance.sdk.openadsdk.utils.zan;

/* JADX INFO: loaded from: classes2.dex */
public class irt extends View {
    private float ajl;
    private final Path fm;
    private Drawable jnr;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private int f7346lb;
    private final boolean ro;
    private Drawable yz;

    public irt(Context context) {
        this(context, false);
    }

    private void fm() {
        Context context = getContext();
        this.yz = maa.lb(context, this.ro ? "tt_star_thick_dark" : "tt_star_thick");
        this.jnr = maa.lb(context, "tt_star");
    }

    private void ro() {
        int width = getWidth();
        int height = getHeight();
        if (this.ajl <= 0.0f || width <= 0 || height <= 0) {
            return;
        }
        this.fm.reset();
        this.fm.addRect(new RectF(0.0f, 0.0f, width * this.ajl, height), Path.Direction.CCW);
    }

    @Override // android.view.View
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (this.f7346lb <= 0) {
            return;
        }
        int iSave = canvas.save();
        for (int i10 = 0; i10 < 5; i10++) {
            this.yz.draw(canvas);
            canvas.translate(this.f7346lb, 0.0f);
        }
        canvas.restoreToCount(iSave);
        canvas.clipPath(this.fm);
        for (int i11 = 0; i11 < 5; i11++) {
            this.jnr.draw(canvas);
            canvas.translate(this.f7346lb, 0.0f);
        }
    }

    @Override // android.view.View
    public void onMeasure(int i10, int i11) {
        super.onMeasure(View.MeasureSpec.makeMeasureSpec(this.f7346lb * 5, 1073741824), View.MeasureSpec.makeMeasureSpec(this.f7346lb, 1073741824));
    }

    @Override // android.view.View
    public void onSizeChanged(int i10, int i11, int i12, int i13) {
        super.onSizeChanged(i10, i11, i12, i13);
        ro();
    }

    public irt(Context context, boolean z10) {
        super(context);
        this.fm = new Path();
        this.ro = z10;
        fm();
    }

    public void fm(double d10, int i10) {
        int iFm = (int) zan.fm(getContext(), i10, false);
        this.f7346lb = iFm;
        this.yz.setBounds(0, 0, iFm, iFm);
        Drawable drawable = this.jnr;
        int i11 = this.f7346lb;
        drawable.setBounds(0, 0, i11, i11);
        this.ajl = ((float) d10) / 5.0f;
        ro();
        requestLayout();
    }
}
