package com.bytedance.sdk.component.adexpress.vc;

import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import androidx.core.view.GravityCompat;
/* loaded from: classes2.dex */
public class bZ extends FrameLayout {
    private static final int NjR = (com.bytedance.sdk.component.adexpress.dynamic.wN.eT.Sg("", 0.0f, true)[1] / 2) + 1;
    private static final int nc = (com.bytedance.sdk.component.adexpress.dynamic.wN.eT.Sg("", 0.0f, true)[1] / 2) + 3;
    private float AlY;
    private double DSW;
    LinearLayout Sg;
    LinearLayout YFl;
    private float qsH;
    private float tN;
    private Drawable vc;
    private Drawable wN;

    public Drawable getStarEmptyDrawable() {
        return this.wN;
    }

    public Drawable getStarFillDrawable() {
        return this.vc;
    }

    public bZ(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.YFl = new LinearLayout(getContext());
        this.Sg = new LinearLayout(getContext());
        this.YFl.setOrientation(0);
        this.YFl.setGravity(GravityCompat.START);
        this.Sg.setOrientation(0);
        this.Sg.setGravity(GravityCompat.START);
        this.wN = com.bytedance.sdk.component.utils.qO.tN(context, "tt_star_thick");
        this.vc = com.bytedance.sdk.component.utils.qO.tN(context, "tt_star");
    }

    public void YFl(double d, int i, int i2, int i3) {
        float f = i2;
        this.tN = (int) com.bytedance.sdk.component.adexpress.AlY.qsH.tN(getContext(), f);
        this.AlY = (int) com.bytedance.sdk.component.adexpress.AlY.qsH.tN(getContext(), f);
        this.DSW = d;
        this.qsH = i3;
        removeAllViews();
        for (int i4 = 0; i4 < 5; i4++) {
            ImageView starImageView = getStarImageView();
            starImageView.setScaleType(ImageView.ScaleType.FIT_XY);
            starImageView.setColorFilter(i, PorterDuff.Mode.SRC_IN);
            starImageView.setImageDrawable(getStarFillDrawable());
            this.Sg.addView(starImageView);
        }
        for (int i5 = 0; i5 < 5; i5++) {
            ImageView starImageView2 = getStarImageView();
            starImageView2.setScaleType(ImageView.ScaleType.FIT_XY);
            starImageView2.setImageDrawable(getStarEmptyDrawable());
            this.YFl.addView(starImageView2);
        }
        addView(this.YFl);
        addView(this.Sg);
        requestLayout();
    }

    private ImageView getStarImageView() {
        ImageView imageView = new ImageView(getContext());
        imageView.setLayoutParams(new ViewGroup.LayoutParams((int) this.tN, (int) this.AlY));
        imageView.setPadding(1, NjR, 1, nc);
        return imageView;
    }

    @Override // android.widget.FrameLayout, android.view.View
    protected void onMeasure(int i, int i2) {
        super.onMeasure(i, i2);
        this.YFl.measure(i, i2);
        double d = this.DSW;
        float f = this.tN;
        this.Sg.measure(View.MeasureSpec.makeMeasureSpec((int) ((((int) d) * f) + 1.0f + ((f - 2.0f) * (d - ((int) d)))), 1073741824), View.MeasureSpec.makeMeasureSpec(this.YFl.getMeasuredHeight(), 1073741824));
        if (this.qsH > 0.0f) {
            LinearLayout linearLayout = this.YFl;
            linearLayout.setPadding(0, ((int) (linearLayout.getMeasuredHeight() - this.qsH)) / 2, 0, 0);
            this.Sg.setPadding(0, ((int) (this.YFl.getMeasuredHeight() - this.qsH)) / 2, 0, 0);
        }
    }
}
