mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-27 09:32:27 -06:00
156 lines
4.7 KiB
Java
156 lines
4.7 KiB
Java
|
package com.google.android.material.timepicker;
|
||
|
|
||
|
import android.content.res.Resources;
|
||
|
import android.os.Parcel;
|
||
|
import android.os.Parcelable;
|
||
|
import com.google.android.material.R;
|
||
|
import java.util.Arrays;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes2.dex */
|
||
|
public class TimeModel implements Parcelable {
|
||
|
public static final Parcelable.Creator<TimeModel> CREATOR = new Parcelable.Creator<TimeModel>() { // from class: com.google.android.material.timepicker.TimeModel.1
|
||
|
/* JADX WARN: Can't rename method to resolve collision */
|
||
|
@Override // android.os.Parcelable.Creator
|
||
|
public TimeModel createFromParcel(Parcel parcel) {
|
||
|
return new TimeModel(parcel);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Can't rename method to resolve collision */
|
||
|
@Override // android.os.Parcelable.Creator
|
||
|
public TimeModel[] newArray(int i) {
|
||
|
return new TimeModel[i];
|
||
|
}
|
||
|
};
|
||
|
public static final String NUMBER_FORMAT = "%d";
|
||
|
public static final String ZERO_LEADING_NUMBER_FORMAT = "%02d";
|
||
|
final int format;
|
||
|
int hour;
|
||
|
private final MaxInputValidator hourInputValidator;
|
||
|
int minute;
|
||
|
private final MaxInputValidator minuteInputValidator;
|
||
|
int period;
|
||
|
int selection;
|
||
|
|
||
|
private static int getPeriod(int i) {
|
||
|
return i >= 12 ? 1 : 0;
|
||
|
}
|
||
|
|
||
|
@Override // android.os.Parcelable
|
||
|
public int describeContents() {
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
public MaxInputValidator getHourInputValidator() {
|
||
|
return this.hourInputValidator;
|
||
|
}
|
||
|
|
||
|
public MaxInputValidator getMinuteInputValidator() {
|
||
|
return this.minuteInputValidator;
|
||
|
}
|
||
|
|
||
|
public void setPeriod(int i) {
|
||
|
if (i != this.period) {
|
||
|
this.period = i;
|
||
|
int i2 = this.hour;
|
||
|
if (i2 < 12 && i == 1) {
|
||
|
this.hour = i2 + 12;
|
||
|
} else {
|
||
|
if (i2 < 12 || i != 0) {
|
||
|
return;
|
||
|
}
|
||
|
this.hour = i2 - 12;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public TimeModel() {
|
||
|
this(0);
|
||
|
}
|
||
|
|
||
|
public TimeModel(int i) {
|
||
|
this(0, 0, 10, i);
|
||
|
}
|
||
|
|
||
|
public TimeModel(int i, int i2, int i3, int i4) {
|
||
|
this.hour = i;
|
||
|
this.minute = i2;
|
||
|
this.selection = i3;
|
||
|
this.format = i4;
|
||
|
this.period = getPeriod(i);
|
||
|
this.minuteInputValidator = new MaxInputValidator(59);
|
||
|
this.hourInputValidator = new MaxInputValidator(i4 == 1 ? 23 : 12);
|
||
|
}
|
||
|
|
||
|
protected TimeModel(Parcel parcel) {
|
||
|
this(parcel.readInt(), parcel.readInt(), parcel.readInt(), parcel.readInt());
|
||
|
}
|
||
|
|
||
|
public void setHourOfDay(int i) {
|
||
|
this.period = getPeriod(i);
|
||
|
this.hour = i;
|
||
|
}
|
||
|
|
||
|
public void setHour(int i) {
|
||
|
if (this.format == 1) {
|
||
|
this.hour = i;
|
||
|
} else {
|
||
|
this.hour = (i % 12) + (this.period != 1 ? 0 : 12);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setMinute(int i) {
|
||
|
this.minute = i % 60;
|
||
|
}
|
||
|
|
||
|
public int getHourForDisplay() {
|
||
|
if (this.format == 1) {
|
||
|
return this.hour % 24;
|
||
|
}
|
||
|
int i = this.hour;
|
||
|
if (i % 12 == 0) {
|
||
|
return 12;
|
||
|
}
|
||
|
return this.period == 1 ? i - 12 : i;
|
||
|
}
|
||
|
|
||
|
public int getHourContentDescriptionResId() {
|
||
|
return this.format == 1 ? R.string.material_hour_24h_suffix : R.string.material_hour_suffix;
|
||
|
}
|
||
|
|
||
|
public int hashCode() {
|
||
|
return Arrays.hashCode(new Object[]{Integer.valueOf(this.format), Integer.valueOf(this.hour), Integer.valueOf(this.minute), Integer.valueOf(this.selection)});
|
||
|
}
|
||
|
|
||
|
public boolean equals(Object obj) {
|
||
|
if (this == obj) {
|
||
|
return true;
|
||
|
}
|
||
|
if (!(obj instanceof TimeModel)) {
|
||
|
return false;
|
||
|
}
|
||
|
TimeModel timeModel = (TimeModel) obj;
|
||
|
return this.hour == timeModel.hour && this.minute == timeModel.minute && this.format == timeModel.format && this.selection == timeModel.selection;
|
||
|
}
|
||
|
|
||
|
@Override // android.os.Parcelable
|
||
|
public void writeToParcel(Parcel parcel, int i) {
|
||
|
parcel.writeInt(this.hour);
|
||
|
parcel.writeInt(this.minute);
|
||
|
parcel.writeInt(this.selection);
|
||
|
parcel.writeInt(this.format);
|
||
|
}
|
||
|
|
||
|
public static String formatText(Resources resources, CharSequence charSequence) {
|
||
|
return formatText(resources, charSequence, ZERO_LEADING_NUMBER_FORMAT);
|
||
|
}
|
||
|
|
||
|
public static String formatText(Resources resources, CharSequence charSequence, String str) {
|
||
|
try {
|
||
|
return String.format(resources.getConfiguration().locale, str, Integer.valueOf(Integer.parseInt(String.valueOf(charSequence))));
|
||
|
} catch (NumberFormatException unused) {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
}
|