75 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			75 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package com.google.android.material.datepicker;
 | |
| 
 | |
| 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 com.google.android.material.R;
 | |
| import java.util.Calendar;
 | |
| import java.util.Locale;
 | |
| 
 | |
| /* loaded from: classes.dex */
 | |
| class DaysOfWeekAdapter extends BaseAdapter {
 | |
|     private static final int CALENDAR_DAY_STYLE;
 | |
|     private static final int NARROW_FORMAT = 4;
 | |
|     private final Calendar calendar;
 | |
|     private final int daysInWeek;
 | |
|     private final int firstDayOfWeek;
 | |
| 
 | |
|     static {
 | |
|         CALENDAR_DAY_STYLE = Build.VERSION.SDK_INT >= 26 ? 4 : 1;
 | |
|     }
 | |
| 
 | |
|     private int positionToDayOfWeek(int i) {
 | |
|         int i2 = i + this.firstDayOfWeek;
 | |
|         int i3 = this.daysInWeek;
 | |
|         return i2 > i3 ? i2 - i3 : i2;
 | |
|     }
 | |
| 
 | |
|     @Override // android.widget.Adapter
 | |
|     public int getCount() {
 | |
|         return this.daysInWeek;
 | |
|     }
 | |
| 
 | |
|     @Override // android.widget.Adapter
 | |
|     public long getItemId(int i) {
 | |
|         return 0L;
 | |
|     }
 | |
| 
 | |
|     public DaysOfWeekAdapter() {
 | |
|         Calendar utcCalendar = UtcDates.getUtcCalendar();
 | |
|         this.calendar = utcCalendar;
 | |
|         this.daysInWeek = utcCalendar.getMaximum(7);
 | |
|         this.firstDayOfWeek = utcCalendar.getFirstDayOfWeek();
 | |
|     }
 | |
| 
 | |
|     public DaysOfWeekAdapter(int i) {
 | |
|         Calendar utcCalendar = UtcDates.getUtcCalendar();
 | |
|         this.calendar = utcCalendar;
 | |
|         this.daysInWeek = utcCalendar.getMaximum(7);
 | |
|         this.firstDayOfWeek = i;
 | |
|     }
 | |
| 
 | |
|     @Override // android.widget.Adapter
 | |
|     public Integer getItem(int i) {
 | |
|         if (i >= this.daysInWeek) {
 | |
|             return null;
 | |
|         }
 | |
|         return Integer.valueOf(positionToDayOfWeek(i));
 | |
|     }
 | |
| 
 | |
|     @Override // android.widget.Adapter
 | |
|     public View getView(int i, View view, ViewGroup viewGroup) {
 | |
|         TextView textView = (TextView) view;
 | |
|         if (view == null) {
 | |
|             textView = (TextView) LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.mtrl_calendar_day_of_week, viewGroup, false);
 | |
|         }
 | |
|         this.calendar.set(7, positionToDayOfWeek(i));
 | |
|         textView.setText(this.calendar.getDisplayName(7, CALENDAR_DAY_STYLE, textView.getResources().getConfiguration().locale));
 | |
|         textView.setContentDescription(String.format(viewGroup.getContext().getString(R.string.mtrl_picker_day_of_week_column_header), this.calendar.getDisplayName(7, 2, Locale.getDefault())));
 | |
|         return textView;
 | |
|     }
 | |
| }
 |