package com.google.android.material.timepicker;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.d;
import androidx.core.view.s0;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import lj.g;
import lj.i;
import vi.f;
import vi.h;
import vi.l;

/* loaded from: classes3.dex */
abstract class b extends ConstraintLayout {
    private final Runnable N;
    private int O;
    private g P;

    /* loaded from: classes3.dex */
    class a implements Runnable {
        a() {
        }

        @Override // java.lang.Runnable
        public void run() {
            b.this.F();
        }
    }

    public b(Context context, AttributeSet attributeSet, int i10) {
        super(context, attributeSet, i10);
        LayoutInflater.from(context).inflate(h.f39844l, this);
        s0.q0(this, B());
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, l.f40158y5, i10, 0);
        this.O = obtainStyledAttributes.getDimensionPixelSize(l.f40168z5, 0);
        this.N = new a();
        obtainStyledAttributes.recycle();
    }

    private Drawable B() {
        g gVar = new g();
        this.P = gVar;
        gVar.U(new i(0.5f));
        this.P.W(ColorStateList.valueOf(-1));
        return this.P;
    }

    private static boolean E(View view) {
        return "skip".equals(view.getTag());
    }

    private void G() {
        Handler handler = getHandler();
        if (handler != null) {
            handler.removeCallbacks(this.N);
            handler.post(this.N);
        }
    }

    public int C() {
        return this.O;
    }

    public void D(int i10) {
        this.O = i10;
        F();
    }

    protected void F() {
        int childCount = getChildCount();
        int i10 = 1;
        for (int i11 = 0; i11 < childCount; i11++) {
            if (E(getChildAt(i11))) {
                i10++;
            }
        }
        d dVar = new d();
        dVar.g(this);
        float f10 = BitmapDescriptorFactory.HUE_RED;
        for (int i12 = 0; i12 < childCount; i12++) {
            View childAt = getChildAt(i12);
            int id2 = childAt.getId();
            int i13 = f.f39805b;
            if (id2 != i13 && !E(childAt)) {
                dVar.h(childAt.getId(), i13, this.O, f10);
                f10 += 360.0f / (childCount - i10);
            }
        }
        dVar.c(this);
    }

    @Override // android.view.ViewGroup
    public void addView(View view, int i10, ViewGroup.LayoutParams layoutParams) {
        super.addView(view, i10, layoutParams);
        if (view.getId() == -1) {
            view.setId(s0.k());
        }
        G();
    }

    @Override // android.view.View
    protected void onFinishInflate() {
        super.onFinishInflate();
        F();
    }

    @Override // androidx.constraintlayout.widget.ConstraintLayout, android.view.ViewGroup
    public void onViewRemoved(View view) {
        super.onViewRemoved(view);
        G();
    }

    @Override // android.view.View
    public void setBackgroundColor(int i10) {
        this.P.W(ColorStateList.valueOf(i10));
    }
}
