258 lines
11 KiB
Java
258 lines
11 KiB
Java
|
package com.google.android.material.datepicker;
|
||
|
|
||
|
import android.R;
|
||
|
import android.content.Context;
|
||
|
import android.graphics.Canvas;
|
||
|
import android.graphics.Rect;
|
||
|
import android.util.AttributeSet;
|
||
|
import android.view.KeyEvent;
|
||
|
import android.view.View;
|
||
|
import android.widget.GridView;
|
||
|
import android.widget.ListAdapter;
|
||
|
import androidx.core.view.ViewCompat;
|
||
|
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||
|
import java.util.Calendar;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.TimeZone;
|
||
|
import o.C17052tZT;
|
||
|
import o.ERL;
|
||
|
import o.OAR;
|
||
|
import o.Zpz;
|
||
|
import o.uOF;
|
||
|
import o.yZt;
|
||
|
import org.bouncycastle.asn1.cmp.PKIFailureInfo;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public final class MaterialCalendarGridView extends GridView {
|
||
|
private final Calendar b;
|
||
|
private final boolean c;
|
||
|
|
||
|
@Override // android.widget.AdapterView
|
||
|
public final /* bridge */ /* synthetic */ void setAdapter(ListAdapter listAdapter) {
|
||
|
setAdapter(listAdapter);
|
||
|
}
|
||
|
|
||
|
public MaterialCalendarGridView(Context context) {
|
||
|
this(context, null);
|
||
|
}
|
||
|
|
||
|
public MaterialCalendarGridView(Context context, AttributeSet attributeSet) {
|
||
|
this(context, attributeSet, 0);
|
||
|
}
|
||
|
|
||
|
public MaterialCalendarGridView(Context context, AttributeSet attributeSet, int i) {
|
||
|
super(context, attributeSet, i);
|
||
|
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
|
||
|
calendar.clear();
|
||
|
this.b = calendar;
|
||
|
if (MaterialDatePicker.e(getContext(), R.attr.windowFullscreen)) {
|
||
|
setNextFocusLeftId(C17052tZT.ZqN.cancel_button);
|
||
|
setNextFocusRightId(C17052tZT.ZqN.confirm_button);
|
||
|
}
|
||
|
this.c = MaterialDatePicker.e(getContext(), C17052tZT.IeS.nestedScrollable);
|
||
|
ViewCompat.e(this, new yZt(this) { // from class: com.google.android.material.datepicker.MaterialCalendarGridView.3
|
||
|
private MaterialCalendarGridView b;
|
||
|
|
||
|
{
|
||
|
this.b = this;
|
||
|
}
|
||
|
|
||
|
@Override // o.yZt
|
||
|
public final void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
|
||
|
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
|
||
|
accessibilityNodeInfoCompat.e((Object) null);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
@Override // android.widget.AbsListView, android.view.ViewGroup, android.view.View
|
||
|
protected final void onAttachedToWindow() {
|
||
|
super.onAttachedToWindow();
|
||
|
((Zpz) super.getAdapter()).notifyDataSetChanged();
|
||
|
}
|
||
|
|
||
|
@Override // android.widget.GridView, android.widget.AbsListView, android.view.View, android.view.KeyEvent.Callback
|
||
|
public final boolean onKeyDown(int i, KeyEvent keyEvent) {
|
||
|
if (!super.onKeyDown(i, keyEvent)) {
|
||
|
return false;
|
||
|
}
|
||
|
if (getSelectedItemPosition() != -1) {
|
||
|
int selectedItemPosition = getSelectedItemPosition();
|
||
|
Zpz zpz = (Zpz) super.getAdapter();
|
||
|
if (selectedItemPosition < zpz.d.e(zpz.a.d)) {
|
||
|
if (19 != i) {
|
||
|
return false;
|
||
|
}
|
||
|
Zpz zpz2 = (Zpz) super.getAdapter();
|
||
|
setSelection(zpz2.d.e(zpz2.a.d));
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public final Zpz a() {
|
||
|
return (Zpz) super.getAdapter();
|
||
|
}
|
||
|
|
||
|
@Override // android.widget.GridView, android.widget.AbsListView
|
||
|
/* renamed from: setAdapter, reason: avoid collision after fix types in other method */
|
||
|
public final void setAdapter2(ListAdapter listAdapter) {
|
||
|
if (!(listAdapter instanceof Zpz)) {
|
||
|
throw new IllegalArgumentException(String.format("%1$s must have its Adapter set to a %2$s", MaterialCalendarGridView.class.getCanonicalName(), Zpz.class.getCanonicalName()));
|
||
|
}
|
||
|
super.setAdapter(listAdapter);
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View
|
||
|
protected final void onDraw(Canvas canvas) {
|
||
|
int e;
|
||
|
int width;
|
||
|
int e2;
|
||
|
int width2;
|
||
|
int i;
|
||
|
int i2;
|
||
|
MaterialCalendarGridView materialCalendarGridView = this;
|
||
|
super.onDraw(canvas);
|
||
|
Zpz zpz = (Zpz) super.getAdapter();
|
||
|
OAR<?> oar = zpz.e;
|
||
|
ERL erl = zpz.b;
|
||
|
int max = Math.max(zpz.d.e(zpz.a.d), getFirstVisiblePosition());
|
||
|
int i3 = 1;
|
||
|
int min = Math.min((zpz.d.e(zpz.a.d) + zpz.d.a) - 1, getLastVisiblePosition());
|
||
|
Long item = zpz.getItem(max);
|
||
|
Long item2 = zpz.getItem(min);
|
||
|
Iterator<uOF<Long, Long>> it = oar.a().iterator();
|
||
|
while (it.hasNext()) {
|
||
|
uOF<Long, Long> next = it.next();
|
||
|
if (next.d == null || next.b == null) {
|
||
|
materialCalendarGridView = this;
|
||
|
} else {
|
||
|
long longValue = next.d.longValue();
|
||
|
long longValue2 = next.b.longValue();
|
||
|
Long valueOf = Long.valueOf(longValue);
|
||
|
Long valueOf2 = Long.valueOf(longValue2);
|
||
|
if (item == null || item2 == null || valueOf == null || valueOf2 == null || valueOf.longValue() > item2.longValue() || valueOf2.longValue() < item.longValue()) {
|
||
|
i3 = 1;
|
||
|
materialCalendarGridView = this;
|
||
|
item = item;
|
||
|
zpz = zpz;
|
||
|
it = it;
|
||
|
} else {
|
||
|
int i4 = ViewCompat.m(this) != i3 ? 0 : i3;
|
||
|
if (longValue >= item.longValue()) {
|
||
|
materialCalendarGridView.b.setTimeInMillis(longValue);
|
||
|
e = zpz.d.e(zpz.a.d) + (materialCalendarGridView.b.get(5) - i3);
|
||
|
View childAt = materialCalendarGridView.getChildAt(e - getFirstVisiblePosition());
|
||
|
width = (childAt.getWidth() / 2) + childAt.getLeft();
|
||
|
} else {
|
||
|
if (max % zpz.d.e == 0) {
|
||
|
width = 0;
|
||
|
} else if (i4 == 0) {
|
||
|
width = materialCalendarGridView.getChildAt((max - 1) - getFirstVisiblePosition()).getRight();
|
||
|
} else {
|
||
|
width = materialCalendarGridView.getChildAt((max - 1) - getFirstVisiblePosition()).getLeft();
|
||
|
}
|
||
|
e = max;
|
||
|
}
|
||
|
if (longValue2 <= item2.longValue()) {
|
||
|
materialCalendarGridView.b.setTimeInMillis(longValue2);
|
||
|
e2 = zpz.d.e(zpz.a.d) + (materialCalendarGridView.b.get(5) - i3);
|
||
|
View childAt2 = materialCalendarGridView.getChildAt(e2 - getFirstVisiblePosition());
|
||
|
width2 = (childAt2.getWidth() / 2) + childAt2.getLeft();
|
||
|
} else {
|
||
|
if ((min + 1) % zpz.d.e == 0) {
|
||
|
width2 = getWidth();
|
||
|
} else if (i4 == 0) {
|
||
|
width2 = materialCalendarGridView.getChildAt(min - getFirstVisiblePosition()).getRight();
|
||
|
} else {
|
||
|
width2 = materialCalendarGridView.getChildAt(min - getFirstVisiblePosition()).getLeft();
|
||
|
}
|
||
|
e2 = min;
|
||
|
}
|
||
|
int itemId = (int) zpz.getItemId(e);
|
||
|
Long l = item;
|
||
|
int itemId2 = (int) zpz.getItemId(e2);
|
||
|
while (itemId <= itemId2) {
|
||
|
int numColumns = getNumColumns() * itemId;
|
||
|
Zpz zpz2 = zpz;
|
||
|
int numColumns2 = (numColumns + getNumColumns()) - 1;
|
||
|
View childAt3 = materialCalendarGridView.getChildAt(numColumns - getFirstVisiblePosition());
|
||
|
int top = childAt3.getTop();
|
||
|
int i5 = erl.c.b.top;
|
||
|
int bottom = childAt3.getBottom();
|
||
|
Iterator<uOF<Long, Long>> it2 = it;
|
||
|
int i6 = erl.c.b.bottom;
|
||
|
if (i4 == 0) {
|
||
|
i = numColumns > e ? 0 : width;
|
||
|
i2 = e2 > numColumns2 ? getWidth() : width2;
|
||
|
} else {
|
||
|
int i7 = e2 > numColumns2 ? 0 : width2;
|
||
|
int width3 = numColumns > e ? getWidth() : width;
|
||
|
i = i7;
|
||
|
i2 = width3;
|
||
|
}
|
||
|
canvas.drawRect(i, top + i5, i2, bottom - i6, erl.a);
|
||
|
itemId++;
|
||
|
materialCalendarGridView = this;
|
||
|
zpz = zpz2;
|
||
|
it = it2;
|
||
|
}
|
||
|
i3 = 1;
|
||
|
materialCalendarGridView = this;
|
||
|
item = l;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // android.widget.GridView, android.widget.AbsListView, android.view.View
|
||
|
public final void onMeasure(int i, int i2) {
|
||
|
if (this.c) {
|
||
|
super.onMeasure(i, View.MeasureSpec.makeMeasureSpec(16777215, PKIFailureInfo.systemUnavail));
|
||
|
getLayoutParams().height = getMeasuredHeight();
|
||
|
return;
|
||
|
}
|
||
|
super.onMeasure(i, i2);
|
||
|
}
|
||
|
|
||
|
@Override // android.widget.GridView, android.widget.AdapterView
|
||
|
public final /* bridge */ /* synthetic */ ListAdapter getAdapter() {
|
||
|
return (Zpz) super.getAdapter();
|
||
|
}
|
||
|
|
||
|
@Override // android.widget.GridView, android.widget.AdapterView
|
||
|
/* renamed from: getAdapter, reason: avoid collision after fix types in other method */
|
||
|
public final /* bridge */ /* synthetic */ ListAdapter getAdapter2() {
|
||
|
return (Zpz) super.getAdapter();
|
||
|
}
|
||
|
|
||
|
@Override // android.widget.GridView, android.widget.AbsListView, android.view.View
|
||
|
protected final void onFocusChanged(boolean z, int i, Rect rect) {
|
||
|
if (!z) {
|
||
|
super.onFocusChanged(false, i, rect);
|
||
|
return;
|
||
|
}
|
||
|
if (i == 33) {
|
||
|
Zpz zpz = (Zpz) super.getAdapter();
|
||
|
setSelection((zpz.d.e(zpz.a.d) + zpz.d.a) - 1);
|
||
|
} else if (i != 130) {
|
||
|
super.onFocusChanged(true, i, rect);
|
||
|
} else {
|
||
|
Zpz zpz2 = (Zpz) super.getAdapter();
|
||
|
setSelection(zpz2.d.e(zpz2.a.d));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // android.widget.GridView, android.widget.AdapterView
|
||
|
public final void setSelection(int i) {
|
||
|
Zpz zpz = (Zpz) super.getAdapter();
|
||
|
if (i >= zpz.d.e(zpz.a.d)) {
|
||
|
super.setSelection(i);
|
||
|
} else {
|
||
|
Zpz zpz2 = (Zpz) super.getAdapter();
|
||
|
super.setSelection(zpz2.d.e(zpz2.a.d));
|
||
|
}
|
||
|
}
|
||
|
}
|