484 lines
20 KiB
Java
484 lines
20 KiB
Java
|
package com.google.android.material.datepicker;
|
||
|
|
||
|
import android.R;
|
||
|
import android.content.res.Resources;
|
||
|
import android.graphics.Canvas;
|
||
|
import android.os.Bundle;
|
||
|
import android.view.ContextThemeWrapper;
|
||
|
import android.view.LayoutInflater;
|
||
|
import android.view.View;
|
||
|
import android.view.ViewGroup;
|
||
|
import android.widget.GridView;
|
||
|
import android.widget.ListAdapter;
|
||
|
import androidx.core.view.ViewCompat;
|
||
|
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||
|
import androidx.recyclerview.widget.GridLayoutManager;
|
||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||
|
import androidx.recyclerview.widget.RecyclerView;
|
||
|
import com.google.android.material.button.MaterialButton;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Calendar;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.TimeZone;
|
||
|
import o.AbstractC16801rOL;
|
||
|
import o.C17009tEr;
|
||
|
import o.C17052tZT;
|
||
|
import o.C17195uiA;
|
||
|
import o.ERL;
|
||
|
import o.FOT;
|
||
|
import o.OAR;
|
||
|
import o.OnG;
|
||
|
import o.SIS;
|
||
|
import o.SxS;
|
||
|
import o.UJG;
|
||
|
import o.ZBO;
|
||
|
import o.Zpz;
|
||
|
import o.onm;
|
||
|
import o.uOF;
|
||
|
import o.yZt;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public final class MaterialCalendar<S> extends PickerFragment<S> {
|
||
|
public UJG a;
|
||
|
public ERL b;
|
||
|
public OAR<S> c;
|
||
|
public FOT d;
|
||
|
RVV e;
|
||
|
View g;
|
||
|
RecyclerView i;
|
||
|
RecyclerView j;
|
||
|
private AbstractC16801rOL k;
|
||
|
private View n;
|
||
|
private View q;
|
||
|
private View r;
|
||
|
private int t;
|
||
|
private static Object f = "MONTHS_VIEW_GROUP_TAG";
|
||
|
|
||
|
/* renamed from: o, reason: collision with root package name */
|
||
|
private static Object f6473o = "NAVIGATION_PREV_TAG";
|
||
|
private static Object m = "NAVIGATION_NEXT_TAG";
|
||
|
private static Object l = "SELECTOR_TOGGLE_TAG";
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public interface IeS {
|
||
|
void d(long j);
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public enum RVV {
|
||
|
DAY,
|
||
|
YEAR
|
||
|
}
|
||
|
|
||
|
@Override // androidx.fragment.app.Fragment
|
||
|
public final void onSaveInstanceState(Bundle bundle) {
|
||
|
super.onSaveInstanceState(bundle);
|
||
|
bundle.putInt("THEME_RES_ID_KEY", this.t);
|
||
|
bundle.putParcelable("GRID_SELECTOR_KEY", this.c);
|
||
|
bundle.putParcelable("CALENDAR_CONSTRAINTS_KEY", this.d);
|
||
|
bundle.putParcelable("DAY_VIEW_DECORATOR_KEY", this.k);
|
||
|
bundle.putParcelable("CURRENT_MONTH_KEY", this.a);
|
||
|
}
|
||
|
|
||
|
@Override // androidx.fragment.app.Fragment
|
||
|
public final void onCreate(Bundle bundle) {
|
||
|
super.onCreate(bundle);
|
||
|
if (bundle == null) {
|
||
|
bundle = getArguments();
|
||
|
}
|
||
|
this.t = bundle.getInt("THEME_RES_ID_KEY");
|
||
|
this.c = (OAR) bundle.getParcelable("GRID_SELECTOR_KEY");
|
||
|
this.d = (FOT) bundle.getParcelable("CALENDAR_CONSTRAINTS_KEY");
|
||
|
this.k = (AbstractC16801rOL) bundle.getParcelable("DAY_VIEW_DECORATOR_KEY");
|
||
|
this.a = (UJG) bundle.getParcelable("CURRENT_MONTH_KEY");
|
||
|
}
|
||
|
|
||
|
@Override // androidx.fragment.app.Fragment
|
||
|
public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
|
||
|
int i;
|
||
|
ViewGroup viewGroup2;
|
||
|
int i2;
|
||
|
ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(getContext(), this.t);
|
||
|
this.b = new ERL(contextThemeWrapper);
|
||
|
LayoutInflater cloneInContext = layoutInflater.cloneInContext(contextThemeWrapper);
|
||
|
UJG ujg = this.d.b;
|
||
|
if (MaterialDatePicker.e(contextThemeWrapper, R.attr.windowFullscreen)) {
|
||
|
i = C17052tZT.tOB.mtrl_calendar_vertical;
|
||
|
viewGroup2 = viewGroup;
|
||
|
i2 = 1;
|
||
|
} else {
|
||
|
i = C17052tZT.tOB.mtrl_calendar_horizontal;
|
||
|
viewGroup2 = viewGroup;
|
||
|
i2 = 0;
|
||
|
}
|
||
|
View inflate = cloneInContext.inflate(i, viewGroup2, false);
|
||
|
Resources resources = requireContext().getResources();
|
||
|
inflate.setMinimumHeight(resources.getDimensionPixelSize(C17052tZT.HBt.mtrl_calendar_navigation_height) + resources.getDimensionPixelOffset(C17052tZT.HBt.mtrl_calendar_navigation_top_padding) + resources.getDimensionPixelOffset(C17052tZT.HBt.mtrl_calendar_navigation_bottom_padding) + resources.getDimensionPixelSize(C17052tZT.HBt.mtrl_calendar_days_of_week_height) + (Zpz.c * resources.getDimensionPixelSize(C17052tZT.HBt.mtrl_calendar_day_height)) + ((Zpz.c - 1) * resources.getDimensionPixelOffset(C17052tZT.HBt.mtrl_calendar_month_vertical_padding)) + resources.getDimensionPixelOffset(C17052tZT.HBt.mtrl_calendar_bottom_padding));
|
||
|
GridView gridView = (GridView) inflate.findViewById(C17052tZT.ZqN.mtrl_calendar_days_of_week);
|
||
|
ViewCompat.e(gridView, new yZt(this) { // from class: com.google.android.material.datepicker.MaterialCalendar.3
|
||
|
private MaterialCalendar e;
|
||
|
|
||
|
{
|
||
|
this.e = this;
|
||
|
}
|
||
|
|
||
|
@Override // o.yZt
|
||
|
public final void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
|
||
|
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
|
||
|
accessibilityNodeInfoCompat.e((Object) null);
|
||
|
}
|
||
|
});
|
||
|
int i3 = this.d.d;
|
||
|
gridView.setAdapter((ListAdapter) (i3 > 0 ? new ZBO(i3) : new ZBO()));
|
||
|
gridView.setNumColumns(ujg.e);
|
||
|
gridView.setEnabled(false);
|
||
|
this.i = (RecyclerView) inflate.findViewById(C17052tZT.ZqN.mtrl_calendar_months);
|
||
|
getContext();
|
||
|
this.i.setLayoutManager(new SmoothCalendarLayoutManager(this, i2, i2) { // from class: com.google.android.material.datepicker.MaterialCalendar.2
|
||
|
private int a;
|
||
|
private MaterialCalendar e;
|
||
|
|
||
|
{
|
||
|
this.e = this;
|
||
|
this.a = i2;
|
||
|
}
|
||
|
|
||
|
@Override // androidx.recyclerview.widget.LinearLayoutManager
|
||
|
public final void a(RecyclerView.AcL acL, int[] iArr) {
|
||
|
if (this.a == 0) {
|
||
|
iArr[0] = this.e.i.getWidth();
|
||
|
iArr[1] = this.e.i.getWidth();
|
||
|
} else {
|
||
|
iArr[0] = this.e.i.getHeight();
|
||
|
iArr[1] = this.e.i.getHeight();
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
this.i.setTag(f);
|
||
|
C17009tEr c17009tEr = new C17009tEr(contextThemeWrapper, this.c, this.d, this.k, new IeS(this) { // from class: com.google.android.material.datepicker.MaterialCalendar.1
|
||
|
private MaterialCalendar b;
|
||
|
|
||
|
{
|
||
|
this.b = this;
|
||
|
}
|
||
|
|
||
|
@Override // com.google.android.material.datepicker.MaterialCalendar.IeS
|
||
|
public final void d(long j) {
|
||
|
if (this.b.d.f.e(j)) {
|
||
|
OAR<S> oar = this.b.c;
|
||
|
Iterator<SIS<S>> it = this.b.h.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
it.next().e(this.b.c.d());
|
||
|
}
|
||
|
this.b.i.g.notifyDataSetChanged();
|
||
|
if (this.b.j != null) {
|
||
|
this.b.j.g.notifyDataSetChanged();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
this.i.setAdapter(c17009tEr);
|
||
|
int integer = contextThemeWrapper.getResources().getInteger(C17052tZT.saX.mtrl_calendar_year_selector_span);
|
||
|
RecyclerView recyclerView = (RecyclerView) inflate.findViewById(C17052tZT.ZqN.mtrl_calendar_year_selector_frame);
|
||
|
this.j = recyclerView;
|
||
|
if (recyclerView != null) {
|
||
|
recyclerView.setHasFixedSize(true);
|
||
|
this.j.setLayoutManager(new GridLayoutManager(integer));
|
||
|
this.j.setAdapter(new onm(this));
|
||
|
this.j.d(new RecyclerView.ZqN(this) { // from class: com.google.android.material.datepicker.MaterialCalendar.10
|
||
|
private final Calendar b;
|
||
|
private final Calendar c;
|
||
|
private MaterialCalendar e;
|
||
|
|
||
|
{
|
||
|
this.e = this;
|
||
|
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
|
||
|
calendar.clear();
|
||
|
this.c = calendar;
|
||
|
Calendar calendar2 = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
|
||
|
calendar2.clear();
|
||
|
this.b = calendar2;
|
||
|
}
|
||
|
|
||
|
@Override // androidx.recyclerview.widget.RecyclerView.ZqN
|
||
|
public final void apA_(Canvas canvas, RecyclerView recyclerView2) {
|
||
|
int width;
|
||
|
if ((recyclerView2.g instanceof onm) && (recyclerView2.x instanceof GridLayoutManager)) {
|
||
|
onm onmVar = (onm) recyclerView2.g;
|
||
|
GridLayoutManager gridLayoutManager = (GridLayoutManager) recyclerView2.x;
|
||
|
for (uOF<Long, Long> uof : this.e.c.a()) {
|
||
|
if (uof.d != null && uof.b != null) {
|
||
|
this.c.setTimeInMillis(uof.d.longValue());
|
||
|
this.b.setTimeInMillis(uof.b.longValue());
|
||
|
int i4 = this.c.get(1) - onmVar.b.d.b.g;
|
||
|
int i5 = this.b.get(1) - onmVar.b.d.b.g;
|
||
|
View a_ = gridLayoutManager.a_(i4);
|
||
|
View a_2 = gridLayoutManager.a_(i5);
|
||
|
int i6 = i4 / gridLayoutManager.e;
|
||
|
int i7 = i5 / gridLayoutManager.e;
|
||
|
int i8 = i6;
|
||
|
while (i8 <= i7) {
|
||
|
View a_3 = gridLayoutManager.a_(gridLayoutManager.e * i8);
|
||
|
if (a_3 != null) {
|
||
|
int top = a_3.getTop();
|
||
|
int i9 = this.e.b.j.b.top;
|
||
|
int bottom = a_3.getBottom();
|
||
|
int i10 = this.e.b.j.b.bottom;
|
||
|
int left = (i8 != i6 || a_ == null) ? 0 : a_.getLeft() + (a_.getWidth() / 2);
|
||
|
if (i8 == i7 && a_2 != null) {
|
||
|
width = a_2.getLeft() + (a_2.getWidth() / 2);
|
||
|
} else {
|
||
|
width = recyclerView2.getWidth();
|
||
|
}
|
||
|
canvas.drawRect(left, top + i9, width, bottom - i10, this.e.b.a);
|
||
|
}
|
||
|
i8++;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}, -1);
|
||
|
}
|
||
|
if (inflate.findViewById(C17052tZT.ZqN.month_navigation_fragment_toggle) != null) {
|
||
|
MaterialButton materialButton = (MaterialButton) inflate.findViewById(C17052tZT.ZqN.month_navigation_fragment_toggle);
|
||
|
materialButton.setTag(l);
|
||
|
ViewCompat.e(materialButton, new yZt(this) { // from class: com.google.android.material.datepicker.MaterialCalendar.9
|
||
|
private MaterialCalendar b;
|
||
|
|
||
|
{
|
||
|
this.b = this;
|
||
|
}
|
||
|
|
||
|
@Override // o.yZt
|
||
|
public final void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
|
||
|
String string;
|
||
|
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
|
||
|
if (this.b.g.getVisibility() == 0) {
|
||
|
string = this.b.getString(C17052tZT.ojQ.mtrl_picker_toggle_to_year_selection);
|
||
|
} else {
|
||
|
string = this.b.getString(C17052tZT.ojQ.mtrl_picker_toggle_to_day_selection);
|
||
|
}
|
||
|
accessibilityNodeInfoCompat.a((CharSequence) string);
|
||
|
}
|
||
|
});
|
||
|
View findViewById = inflate.findViewById(C17052tZT.ZqN.month_navigation_previous);
|
||
|
this.q = findViewById;
|
||
|
findViewById.setTag(f6473o);
|
||
|
View findViewById2 = inflate.findViewById(C17052tZT.ZqN.month_navigation_next);
|
||
|
this.n = findViewById2;
|
||
|
findViewById2.setTag(m);
|
||
|
this.r = inflate.findViewById(C17052tZT.ZqN.mtrl_calendar_year_selector_frame);
|
||
|
this.g = inflate.findViewById(C17052tZT.ZqN.mtrl_calendar_day_selector_frame);
|
||
|
d(RVV.DAY);
|
||
|
UJG ujg2 = this.a;
|
||
|
if (ujg2.b == null) {
|
||
|
ujg2.b = C17195uiA.b(ujg2.c.getTimeInMillis());
|
||
|
}
|
||
|
materialButton.setText(ujg2.b);
|
||
|
RecyclerView recyclerView2 = this.i;
|
||
|
RecyclerView.dAO dao = new RecyclerView.dAO(this, c17009tEr, materialButton) { // from class: com.google.android.material.datepicker.MaterialCalendar.8
|
||
|
private C17009tEr a;
|
||
|
private MaterialButton c;
|
||
|
private MaterialCalendar e;
|
||
|
|
||
|
{
|
||
|
this.e = this;
|
||
|
this.a = c17009tEr;
|
||
|
this.c = materialButton;
|
||
|
}
|
||
|
|
||
|
@Override // androidx.recyclerview.widget.RecyclerView.dAO
|
||
|
public final void onScrolled(RecyclerView recyclerView3, int i4, int i5) {
|
||
|
int h;
|
||
|
if (i4 < 0) {
|
||
|
h = ((LinearLayoutManager) this.e.i.x).j();
|
||
|
} else {
|
||
|
h = ((LinearLayoutManager) this.e.i.x).h();
|
||
|
}
|
||
|
MaterialCalendar materialCalendar = this.e;
|
||
|
Calendar c = OnG.c(this.a.d.b.c);
|
||
|
c.add(2, h);
|
||
|
materialCalendar.a = new UJG(c);
|
||
|
MaterialButton materialButton2 = this.c;
|
||
|
Calendar c2 = OnG.c(this.a.d.b.c);
|
||
|
c2.add(2, h);
|
||
|
UJG ujg3 = new UJG(c2);
|
||
|
if (ujg3.b == null) {
|
||
|
ujg3.b = C17195uiA.b(ujg3.c.getTimeInMillis());
|
||
|
}
|
||
|
materialButton2.setText(ujg3.b);
|
||
|
}
|
||
|
|
||
|
@Override // androidx.recyclerview.widget.RecyclerView.dAO
|
||
|
public final void onScrollStateChanged(RecyclerView recyclerView3, int i4) {
|
||
|
if (i4 == 0) {
|
||
|
recyclerView3.announceForAccessibility(this.c.getText());
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
if (recyclerView2.S == null) {
|
||
|
recyclerView2.S = new ArrayList();
|
||
|
}
|
||
|
recyclerView2.S.add(dao);
|
||
|
materialButton.setOnClickListener(new View.OnClickListener(this) { // from class: com.google.android.material.datepicker.MaterialCalendar.6
|
||
|
private MaterialCalendar d;
|
||
|
|
||
|
{
|
||
|
this.d = this;
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View.OnClickListener
|
||
|
public final void onClick(View view) {
|
||
|
MaterialCalendar materialCalendar = this.d;
|
||
|
if (materialCalendar.e == RVV.YEAR) {
|
||
|
materialCalendar.d(RVV.DAY);
|
||
|
} else if (materialCalendar.e == RVV.DAY) {
|
||
|
materialCalendar.d(RVV.YEAR);
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
this.n.setOnClickListener(new View.OnClickListener(this, c17009tEr) { // from class: com.google.android.material.datepicker.MaterialCalendar.12
|
||
|
private MaterialCalendar b;
|
||
|
private C17009tEr d;
|
||
|
|
||
|
{
|
||
|
this.b = this;
|
||
|
this.d = c17009tEr;
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View.OnClickListener
|
||
|
public final void onClick(View view) {
|
||
|
int j = ((LinearLayoutManager) this.b.i.x).j() + 1;
|
||
|
if (j < this.b.i.g.getItemCount()) {
|
||
|
MaterialCalendar materialCalendar = this.b;
|
||
|
Calendar c = OnG.c(this.d.d.b.c);
|
||
|
c.add(2, j);
|
||
|
materialCalendar.e(new UJG(c));
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
this.q.setOnClickListener(new View.OnClickListener(this, c17009tEr) { // from class: com.google.android.material.datepicker.MaterialCalendar.4
|
||
|
private MaterialCalendar b;
|
||
|
private C17009tEr d;
|
||
|
|
||
|
{
|
||
|
this.b = this;
|
||
|
this.d = c17009tEr;
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View.OnClickListener
|
||
|
public final void onClick(View view) {
|
||
|
int h = ((LinearLayoutManager) this.b.i.x).h() - 1;
|
||
|
if (h >= 0) {
|
||
|
MaterialCalendar materialCalendar = this.b;
|
||
|
Calendar c = OnG.c(this.d.d.b.c);
|
||
|
c.add(2, h);
|
||
|
materialCalendar.e(new UJG(c));
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
if (!MaterialDatePicker.e(contextThemeWrapper, R.attr.windowFullscreen)) {
|
||
|
new SxS().a(this.i);
|
||
|
}
|
||
|
this.i.d(c17009tEr.d.b.c(this.a));
|
||
|
ViewCompat.e(this.i, new yZt(this) { // from class: com.google.android.material.datepicker.MaterialCalendar.7
|
||
|
private MaterialCalendar b;
|
||
|
|
||
|
{
|
||
|
this.b = this;
|
||
|
}
|
||
|
|
||
|
@Override // o.yZt
|
||
|
public final void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) {
|
||
|
super.onInitializeAccessibilityNodeInfo(view, accessibilityNodeInfoCompat);
|
||
|
accessibilityNodeInfoCompat.n(false);
|
||
|
}
|
||
|
});
|
||
|
return inflate;
|
||
|
}
|
||
|
|
||
|
public final void d(RVV rvv) {
|
||
|
this.e = rvv;
|
||
|
if (rvv != RVV.YEAR) {
|
||
|
if (rvv == RVV.DAY) {
|
||
|
this.r.setVisibility(8);
|
||
|
this.g.setVisibility(0);
|
||
|
this.q.setVisibility(0);
|
||
|
this.n.setVisibility(0);
|
||
|
e(this.a);
|
||
|
return;
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
this.j.x.b(this.a.g - ((onm) this.j.g).b.d.b.g);
|
||
|
this.r.setVisibility(0);
|
||
|
this.g.setVisibility(8);
|
||
|
this.q.setVisibility(8);
|
||
|
this.n.setVisibility(8);
|
||
|
}
|
||
|
|
||
|
@Override // com.google.android.material.datepicker.PickerFragment
|
||
|
public final boolean b(SIS<S> sis) {
|
||
|
return super.b(sis);
|
||
|
}
|
||
|
|
||
|
public final void e(UJG ujg) {
|
||
|
C17009tEr c17009tEr = (C17009tEr) this.i.g;
|
||
|
int c = c17009tEr.d.b.c(ujg);
|
||
|
int c2 = c - c17009tEr.d.b.c(this.a);
|
||
|
boolean z = Math.abs(c2) > 3;
|
||
|
boolean z2 = c2 > 0;
|
||
|
this.a = ujg;
|
||
|
if (z && z2) {
|
||
|
this.i.d(c - 3);
|
||
|
this.i.post(new Runnable(this, c) { // from class: com.google.android.material.datepicker.MaterialCalendar.5
|
||
|
private MaterialCalendar c;
|
||
|
private int d;
|
||
|
|
||
|
{
|
||
|
this.c = this;
|
||
|
this.d = c;
|
||
|
}
|
||
|
|
||
|
@Override // java.lang.Runnable
|
||
|
public final void run() {
|
||
|
this.c.i.e(this.d);
|
||
|
}
|
||
|
});
|
||
|
} else if (z) {
|
||
|
this.i.d(c + 3);
|
||
|
this.i.post(new Runnable(this, c) { // from class: com.google.android.material.datepicker.MaterialCalendar.5
|
||
|
private MaterialCalendar c;
|
||
|
private int d;
|
||
|
|
||
|
{
|
||
|
this.c = this;
|
||
|
this.d = c;
|
||
|
}
|
||
|
|
||
|
@Override // java.lang.Runnable
|
||
|
public final void run() {
|
||
|
this.c.i.e(this.d);
|
||
|
}
|
||
|
});
|
||
|
} else {
|
||
|
this.i.post(new Runnable(this, c) { // from class: com.google.android.material.datepicker.MaterialCalendar.5
|
||
|
private MaterialCalendar c;
|
||
|
private int d;
|
||
|
|
||
|
{
|
||
|
this.c = this;
|
||
|
this.d = c;
|
||
|
}
|
||
|
|
||
|
@Override // java.lang.Runnable
|
||
|
public final void run() {
|
||
|
this.c.i.e(this.d);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
}
|