package com.seewo.factoryaging.mic.view;

import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import com.cvte.vman.R;
import com.seewo.factoryaging.videorecord.c;
import jxl.SheetSettings;

/* JADX INFO: loaded from: classes.dex */
public class MicLedBarView extends LinearLayout {
    private static int d = 20;
    private a[] b;

    private class a extends LinearLayout {
        public a(MicLedBarView micLedBarView, Context context) {
            super(context);
            setOrientation(0);
            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, (c.a.a((Activity) context) - 40) / 40);
            layoutParams.setMargins(2, 0, 2, 2);
            setLayoutParams(layoutParams);
            setBackgroundResource(R.color.color_mic_led_off);
        }
    }

    public MicLedBarView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    private void a() {
        setOrientation(1);
        setBackgroundColor(-16777216);
        this.b = new a[d];
        for (int i2 = 0; i2 < d; i2++) {
            this.b[i2] = new a(this, getContext());
        }
        for (int i3 = 0; i3 < d; i3++) {
            addView(this.b[i3]);
        }
    }

    public void b(int i2) {
        int i3 = i2 / 5;
        if (i3 <= 0) {
            i3 = 1;
        } else if (i3 > 20) {
            i3 = 20;
        }
        int i4 = d - 1;
        while (true) {
            int i5 = d;
            if (i4 < i5 - i3) {
                break;
            }
            this.b[i4].setBackgroundColor((((((i5 - i4) * SheetSettings.DEFAULT_DEFAULT_ROW_HEIGHT) / i5) << 8) - 16777216) + (((i4 * SheetSettings.DEFAULT_DEFAULT_ROW_HEIGHT) / i5) << 16));
            i4--;
        }
        while (i4 >= 0) {
            this.b[i4].setBackgroundResource(R.color.color_mic_led_off);
            i4--;
        }
    }

    public MicLedBarView(Context context, AttributeSet attributeSet, int i2) {
        super(context, attributeSet, i2);
        a();
    }
}
