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.y;
import c1.g;
import c1.i;
import l0.f;
import l0.h;
import l0.k;

/* JADX INFO: compiled from: RadialViewGroup.java */
/* JADX INFO: loaded from: classes.dex */
class b extends ConstraintLayout {
    private g A;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    private final Runnable f4382y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    private int f4383z;

    /* JADX INFO: compiled from: RadialViewGroup.java */
    class a implements Runnable {
        a() {
        }

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

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

    private Drawable B() {
        g gVar = new g();
        this.A = gVar;
        gVar.V(new i(0.5f));
        this.A.X(ColorStateList.valueOf(-1));
        return this.A;
    }

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

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

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

    public void D(int i3) {
        this.f4383z = i3;
        F();
    }

    protected void F() {
        int childCount = getChildCount();
        int i3 = 1;
        for (int i4 = 0; i4 < childCount; i4++) {
            if (E(getChildAt(i4))) {
                i3++;
            }
        }
        d dVar = new d();
        dVar.g(this);
        float f3 = 0.0f;
        for (int i5 = 0; i5 < childCount; i5++) {
            View childAt = getChildAt(i5);
            int id = childAt.getId();
            int i6 = f.f5384b;
            if (id != i6 && !E(childAt)) {
                dVar.i(childAt.getId(), i6, this.f4383z, f3);
                f3 += 360.0f / (childCount - i3);
            }
        }
        dVar.c(this);
    }

    @Override // android.view.ViewGroup
    public void addView(View view, int i3, ViewGroup.LayoutParams layoutParams) {
        super.addView(view, i3, layoutParams);
        if (view.getId() == -1) {
            view.setId(y.m());
        }
        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 i3) {
        this.A.X(ColorStateList.valueOf(i3));
    }

    public b(Context context, AttributeSet attributeSet, int i3) {
        super(context, attributeSet, i3);
        LayoutInflater.from(context).inflate(h.f5417f, this);
        y.v0(this, B());
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, k.l2, i3, 0);
        this.f4383z = typedArrayObtainStyledAttributes.getDimensionPixelSize(k.m2, 0);
        this.f4382y = new a();
        typedArrayObtainStyledAttributes.recycle();
    }
}
