package com.google.android.material.datepicker;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import java.util.Calendar;
import java.util.Locale;

/* loaded from: classes3.dex */
class j extends BaseAdapter {

    /* renamed from: s, reason: collision with root package name */
    private static final int f13106s = 4;

    /* renamed from: p, reason: collision with root package name */
    private final Calendar f13107p;

    /* renamed from: q, reason: collision with root package name */
    private final int f13108q;

    /* renamed from: r, reason: collision with root package name */
    private final int f13109r;

    public j() {
        Calendar l10 = w.l();
        this.f13107p = l10;
        this.f13108q = l10.getMaximum(7);
        this.f13109r = l10.getFirstDayOfWeek();
    }

    private int b(int i10) {
        int i11 = i10 + this.f13109r;
        int i12 = this.f13108q;
        return i11 > i12 ? i11 - i12 : i11;
    }

    @Override // android.widget.Adapter
    /* renamed from: a, reason: merged with bridge method [inline-methods] */
    public Integer getItem(int i10) {
        if (i10 >= this.f13108q) {
            return null;
        }
        return Integer.valueOf(b(i10));
    }

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

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

    @Override // android.widget.Adapter
    public View getView(int i10, View view, ViewGroup viewGroup) {
        TextView textView = (TextView) view;
        if (view == null) {
            textView = (TextView) LayoutInflater.from(viewGroup.getContext()).inflate(vi.h.f39850r, viewGroup, false);
        }
        this.f13107p.set(7, b(i10));
        textView.setText(this.f13107p.getDisplayName(7, f13106s, textView.getResources().getConfiguration().locale));
        textView.setContentDescription(String.format(viewGroup.getContext().getString(vi.j.f39876q), this.f13107p.getDisplayName(7, 2, Locale.getDefault())));
        return textView;
    }
}
