package com.google.android.material.datepicker;

import android.annotation.SuppressLint;
import android.os.Build;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.Calendar;
import java.util.Locale;

/* JADX INFO: loaded from: classes2.dex */
public final class h extends BaseAdapter {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final int f22478d;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Calendar f22479a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final int f22480b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final int f22481c;

    static {
        f22478d = Build.VERSION.SDK_INT >= 26 ? 4 : 1;
    }

    public h() {
        Calendar utcCalendarOf = z.getUtcCalendarOf(null);
        this.f22479a = utcCalendarOf;
        this.f22480b = utcCalendarOf.getMaximum(7);
        this.f22481c = utcCalendarOf.getFirstDayOfWeek();
    }

    @Override // android.widget.Adapter
    public final int getCount() {
        return this.f22480b;
    }

    @Override // android.widget.Adapter
    public final long getItemId(int i10) {
        return 0L;
    }

    @Override // android.widget.Adapter
    @Nullable
    @SuppressLint({"WrongConstant"})
    public View getView(int i10, @Nullable View view, @NonNull ViewGroup viewGroup) {
        TextView textView = (TextView) view;
        if (view == null) {
            textView = (TextView) LayoutInflater.from(viewGroup.getContext()).inflate(x8.i.mtrl_calendar_day_of_week, viewGroup, false);
        }
        int i11 = i10 + this.f22481c;
        int i12 = this.f22480b;
        if (i11 > i12) {
            i11 -= i12;
        }
        Calendar calendar = this.f22479a;
        calendar.set(7, i11);
        textView.setText(calendar.getDisplayName(7, f22478d, textView.getResources().getConfiguration().locale));
        textView.setContentDescription(String.format(viewGroup.getContext().getString(x8.k.mtrl_picker_day_of_week_column_header), calendar.getDisplayName(7, 2, Locale.getDefault())));
        return textView;
    }

    @Override // android.widget.Adapter
    @Nullable
    public Integer getItem(int i10) {
        int i11 = this.f22480b;
        if (i10 >= i11) {
            return null;
        }
        int i12 = i10 + this.f22481c;
        if (i12 > i11) {
            i12 -= i11;
        }
        return Integer.valueOf(i12);
    }

    public h(int i10) {
        Calendar utcCalendarOf = z.getUtcCalendarOf(null);
        this.f22479a = utcCalendarOf;
        this.f22480b = utcCalendarOf.getMaximum(7);
        this.f22481c = i10;
    }
}
