package com.bytedance.adsdk.ugeno.ef.jnr;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.PorterDuff;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.bytedance.adsdk.ugeno.wsy.wu;
import com.bytedance.adsdk.ugeno.yz;

/* JADX INFO: loaded from: classes.dex */
public class fm extends FrameLayout {
    private LinearLayout ajl;
    private float fm;
    private LinearLayout jnr;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private double f6333lb;
    private float ro;
    private Context wsy;
    private yz wu;
    private float yz;

    public fm(Context context) {
        super(context);
        this.wsy = context;
        this.jnr = new LinearLayout(context);
        this.ajl = new LinearLayout(context);
        this.jnr.setOrientation(0);
        this.jnr.setGravity(8388611);
        this.ajl.setOrientation(0);
        this.ajl.setGravity(8388611);
    }

    private ImageView getStarImageView() {
        ImageView imageView = new ImageView(getContext());
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams((int) this.fm, (int) this.ro);
        float f10 = this.yz;
        layoutParams.leftMargin = (int) f10;
        layoutParams.topMargin = 0;
        layoutParams.rightMargin = (int) f10;
        layoutParams.bottomMargin = 1;
        imageView.setLayoutParams(layoutParams);
        return imageView;
    }

    public void fm(yz yzVar) {
        this.wu = yzVar;
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        yz yzVar = this.wu;
        if (yzVar != null) {
            yzVar.wsy();
        }
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        yz yzVar = this.wu;
        if (yzVar != null) {
            yzVar.wu();
        }
    }

    @Override // android.view.View
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);
    }

    @Override // android.widget.FrameLayout, android.view.ViewGroup, android.view.View
    public void onLayout(boolean z10, int i10, int i11, int i12, int i13) {
        yz yzVar = this.wu;
        if (yzVar != null) {
            yzVar.fm(i10, i11, i12, i13);
        }
        super.onLayout(z10, i10, i11, i12, i13);
    }

    @Override // android.widget.FrameLayout, android.view.View
    public void onMeasure(int i10, int i11) {
        yz yzVar = this.wu;
        if (yzVar != null) {
            yzVar.fm(i10, i11);
        }
        super.onMeasure(i10, i11);
        this.jnr.measure(i10, i11);
        double dFloor = Math.floor(this.f6333lb);
        float f10 = this.yz;
        float f11 = this.fm;
        this.ajl.measure(View.MeasureSpec.makeMeasureSpec((int) (((this.f6333lb - dFloor) * ((double) f11)) + (((double) (f10 + f10 + f11)) * dFloor) + ((double) f10)), 1073741824), View.MeasureSpec.makeMeasureSpec(this.jnr.getMeasuredHeight(), 1073741824));
    }

    @Override // android.view.View
    public void onSizeChanged(int i10, int i11, int i12, int i13) {
        super.onSizeChanged(i10, i11, i12, i13);
        yz yzVar = this.wu;
        if (yzVar != null) {
            yzVar.ro(i10, i11, i12, i13);
        }
    }

    @Override // android.view.View
    public void onWindowFocusChanged(boolean z10) {
        super.onWindowFocusChanged(z10);
    }

    public void fm(double d10, int i10, int i11, float f10, int i12) {
        removeAllViews();
        this.jnr.removeAllViews();
        this.ajl.removeAllViews();
        this.fm = (int) wu.fm(this.wsy, f10);
        this.ro = (int) wu.fm(this.wsy, f10);
        this.f6333lb = d10;
        this.yz = i12;
        for (int i13 = 0; i13 < 5; i13++) {
            ImageView starImageView = getStarImageView();
            starImageView.setScaleType(ImageView.ScaleType.FIT_XY);
            fm(starImageView, "tt_ugen_rating_star");
            starImageView.setColorFilter(i10, PorterDuff.Mode.SRC_IN);
            this.ajl.addView(starImageView);
        }
        for (int i14 = 0; i14 < 5; i14++) {
            ImageView starImageView2 = getStarImageView();
            starImageView2.setScaleType(ImageView.ScaleType.FIT_XY);
            fm(starImageView2, "tt_ugen_rating_star");
            starImageView2.setColorFilter(i11);
            this.jnr.addView(starImageView2);
        }
        addView(this.jnr);
        addView(this.ajl);
        requestLayout();
    }

    public void fm(ImageView imageView, String str) {
        imageView.setImageResource(com.bytedance.adsdk.ugeno.wsy.yz.ro(this.wsy, str));
    }
}
