Rabbit-R1/android (non root)/java/sources/com/google/android/material/datepicker/CalendarConstraints.java
2024-05-21 17:08:36 -04:00

225 lines
8.2 KiB
Java

package com.google.android.material.datepicker;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.core.util.ObjectsCompat;
import java.util.Arrays;
import java.util.Objects;
/* loaded from: classes2.dex */
public final class CalendarConstraints implements Parcelable {
public static final Parcelable.Creator<CalendarConstraints> CREATOR = new Parcelable.Creator<CalendarConstraints>() { // from class: com.google.android.material.datepicker.CalendarConstraints.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public CalendarConstraints createFromParcel(Parcel parcel) {
return new CalendarConstraints((Month) parcel.readParcelable(Month.class.getClassLoader()), (Month) parcel.readParcelable(Month.class.getClassLoader()), (DateValidator) parcel.readParcelable(DateValidator.class.getClassLoader()), (Month) parcel.readParcelable(Month.class.getClassLoader()), parcel.readInt());
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // android.os.Parcelable.Creator
public CalendarConstraints[] newArray(int i) {
return new CalendarConstraints[i];
}
};
private final Month end;
private final int firstDayOfWeek;
private final int monthSpan;
private Month openAt;
private final Month start;
private final DateValidator validator;
private final int yearSpan;
/* loaded from: classes2.dex */
public interface DateValidator extends Parcelable {
boolean isValid(long j);
}
@Override // android.os.Parcelable
public int describeContents() {
return 0;
}
public DateValidator getDateValidator() {
return this.validator;
}
/* JADX INFO: Access modifiers changed from: package-private */
public Month getEnd() {
return this.end;
}
/* JADX INFO: Access modifiers changed from: package-private */
public int getFirstDayOfWeek() {
return this.firstDayOfWeek;
}
/* JADX INFO: Access modifiers changed from: package-private */
public int getMonthSpan() {
return this.monthSpan;
}
/* JADX INFO: Access modifiers changed from: package-private */
public Month getOpenAt() {
return this.openAt;
}
/* JADX INFO: Access modifiers changed from: package-private */
public Month getStart() {
return this.start;
}
/* JADX INFO: Access modifiers changed from: package-private */
public int getYearSpan() {
return this.yearSpan;
}
/* JADX INFO: Access modifiers changed from: package-private */
public void setOpenAt(Month month) {
this.openAt = month;
}
private CalendarConstraints(Month month, Month month2, DateValidator dateValidator, Month month3, int i) {
Objects.requireNonNull(month, "start cannot be null");
Objects.requireNonNull(month2, "end cannot be null");
Objects.requireNonNull(dateValidator, "validator cannot be null");
this.start = month;
this.end = month2;
this.openAt = month3;
this.firstDayOfWeek = i;
this.validator = dateValidator;
if (month3 != null && month.compareTo(month3) > 0) {
throw new IllegalArgumentException("start Month cannot be after current Month");
}
if (month3 != null && month3.compareTo(month2) > 0) {
throw new IllegalArgumentException("current Month cannot be after end Month");
}
if (i < 0 || i > UtcDates.getUtcCalendar().getMaximum(7)) {
throw new IllegalArgumentException("firstDayOfWeek is not valid");
}
this.monthSpan = month.monthsUntil(month2) + 1;
this.yearSpan = (month2.year - month.year) + 1;
}
/* JADX INFO: Access modifiers changed from: package-private */
public boolean isWithinBounds(long j) {
if (this.start.getDay(1) <= j) {
Month month = this.end;
if (j <= month.getDay(month.daysInMonth)) {
return true;
}
}
return false;
}
public long getStartMs() {
return this.start.timeInMillis;
}
public long getEndMs() {
return this.end.timeInMillis;
}
public Long getOpenAtMs() {
Month month = this.openAt;
if (month == null) {
return null;
}
return Long.valueOf(month.timeInMillis);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof CalendarConstraints)) {
return false;
}
CalendarConstraints calendarConstraints = (CalendarConstraints) obj;
return this.start.equals(calendarConstraints.start) && this.end.equals(calendarConstraints.end) && ObjectsCompat.equals(this.openAt, calendarConstraints.openAt) && this.firstDayOfWeek == calendarConstraints.firstDayOfWeek && this.validator.equals(calendarConstraints.validator);
}
public int hashCode() {
return Arrays.hashCode(new Object[]{this.start, this.end, this.openAt, Integer.valueOf(this.firstDayOfWeek), this.validator});
}
@Override // android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
parcel.writeParcelable(this.start, 0);
parcel.writeParcelable(this.end, 0);
parcel.writeParcelable(this.openAt, 0);
parcel.writeParcelable(this.validator, 0);
parcel.writeInt(this.firstDayOfWeek);
}
/* JADX INFO: Access modifiers changed from: package-private */
public Month clamp(Month month) {
return month.compareTo(this.start) < 0 ? this.start : month.compareTo(this.end) > 0 ? this.end : month;
}
/* loaded from: classes2.dex */
public static final class Builder {
private static final String DEEP_COPY_VALIDATOR_KEY = "DEEP_COPY_VALIDATOR_KEY";
private long end;
private int firstDayOfWeek;
private Long openAt;
private long start;
private DateValidator validator;
static final long DEFAULT_START = UtcDates.canonicalYearMonthDay(Month.create(1900, 0).timeInMillis);
static final long DEFAULT_END = UtcDates.canonicalYearMonthDay(Month.create(2100, 11).timeInMillis);
public Builder setEnd(long j) {
this.end = j;
return this;
}
public Builder setFirstDayOfWeek(int i) {
this.firstDayOfWeek = i;
return this;
}
public Builder setStart(long j) {
this.start = j;
return this;
}
public Builder() {
this.start = DEFAULT_START;
this.end = DEFAULT_END;
this.validator = DateValidatorPointForward.from(Long.MIN_VALUE);
}
/* JADX INFO: Access modifiers changed from: package-private */
public Builder(CalendarConstraints calendarConstraints) {
this.start = DEFAULT_START;
this.end = DEFAULT_END;
this.validator = DateValidatorPointForward.from(Long.MIN_VALUE);
this.start = calendarConstraints.start.timeInMillis;
this.end = calendarConstraints.end.timeInMillis;
this.openAt = Long.valueOf(calendarConstraints.openAt.timeInMillis);
this.firstDayOfWeek = calendarConstraints.firstDayOfWeek;
this.validator = calendarConstraints.validator;
}
public Builder setOpenAt(long j) {
this.openAt = Long.valueOf(j);
return this;
}
public Builder setValidator(DateValidator dateValidator) {
Objects.requireNonNull(dateValidator, "validator cannot be null");
this.validator = dateValidator;
return this;
}
public CalendarConstraints build() {
Bundle bundle = new Bundle();
bundle.putParcelable(DEEP_COPY_VALIDATOR_KEY, this.validator);
Month create = Month.create(this.start);
Month create2 = Month.create(this.end);
DateValidator dateValidator = (DateValidator) bundle.getParcelable(DEEP_COPY_VALIDATOR_KEY);
Long l = this.openAt;
return new CalendarConstraints(create, create2, dateValidator, l == null ? null : Month.create(l.longValue()), this.firstDayOfWeek);
}
}
}