1404 lines
54 KiB
Java
1404 lines
54 KiB
Java
|
package com.prolificinteractive.materialcalendarview;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.content.res.TypedArray;
|
||
|
import android.graphics.drawable.Drawable;
|
||
|
import android.os.Parcel;
|
||
|
import android.os.Parcelable;
|
||
|
import android.util.AttributeSet;
|
||
|
import android.util.SparseArray;
|
||
|
import android.util.TypedValue;
|
||
|
import android.view.MotionEvent;
|
||
|
import android.view.View;
|
||
|
import android.view.ViewGroup;
|
||
|
import android.view.accessibility.AccessibilityEvent;
|
||
|
import android.view.accessibility.AccessibilityNodeInfo;
|
||
|
import android.widget.ImageView;
|
||
|
import android.widget.LinearLayout;
|
||
|
import android.widget.TextView;
|
||
|
import androidx.viewpager.widget.ViewPager;
|
||
|
import com.prolificinteractive.materialcalendarview.format.ArrayWeekDayFormatter;
|
||
|
import com.prolificinteractive.materialcalendarview.format.DateFormatTitleFormatter;
|
||
|
import com.prolificinteractive.materialcalendarview.format.DayFormatter;
|
||
|
import com.prolificinteractive.materialcalendarview.format.MonthArrayTitleFormatter;
|
||
|
import com.prolificinteractive.materialcalendarview.format.TitleFormatter;
|
||
|
import com.prolificinteractive.materialcalendarview.format.WeekDayFormatter;
|
||
|
import java.lang.annotation.Retention;
|
||
|
import java.lang.annotation.RetentionPolicy;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Arrays;
|
||
|
import java.util.Calendar;
|
||
|
import java.util.Collection;
|
||
|
import java.util.Date;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.List;
|
||
|
import o.nMh;
|
||
|
|
||
|
/* loaded from: classes3.dex */
|
||
|
public class MaterialCalendarView extends ViewGroup {
|
||
|
private static final int DAY_NAMES_ROW = 1;
|
||
|
private static final int DEFAULT_DAYS_IN_WEEK = 7;
|
||
|
private static final int DEFAULT_MAX_WEEKS = 6;
|
||
|
public static final int DEFAULT_TILE_SIZE_DP = 44;
|
||
|
private static final TitleFormatter DEFAULT_TITLE_FORMATTER = new DateFormatTitleFormatter();
|
||
|
public static final int HORIZONTAL = 1;
|
||
|
public static final int INVALID_TILE_DIMENSION = -10;
|
||
|
public static final int SELECTION_MODE_MULTIPLE = 2;
|
||
|
public static final int SELECTION_MODE_NONE = 0;
|
||
|
public static final int SELECTION_MODE_RANGE = 3;
|
||
|
public static final int SELECTION_MODE_SINGLE = 1;
|
||
|
public static final int SHOW_ALL = 7;
|
||
|
public static final int SHOW_DECORATED_DISABLED = 4;
|
||
|
public static final int SHOW_DEFAULTS = 4;
|
||
|
public static final int SHOW_NONE = 0;
|
||
|
public static final int SHOW_OTHER_MONTHS = 1;
|
||
|
public static final int SHOW_OUT_OF_RANGE = 2;
|
||
|
public static final int VERTICAL = 0;
|
||
|
private int accentColor;
|
||
|
private CalendarPagerAdapter<?> adapter;
|
||
|
private boolean allowClickDaysOutsideCurrentMonth;
|
||
|
private int arrowColor;
|
||
|
private final DirectionButton buttonFuture;
|
||
|
private final DirectionButton buttonPast;
|
||
|
CharSequence calendarContentDescription;
|
||
|
private CalendarMode calendarMode;
|
||
|
private CalendarDay currentMonth;
|
||
|
private final ArrayList<DayViewDecorator> dayViewDecorators;
|
||
|
private int dividerColor;
|
||
|
private int dividerSize;
|
||
|
private boolean enableWeekDivider;
|
||
|
private boolean enableWeekOfMonthDivider;
|
||
|
private int firstDayOfWeek;
|
||
|
private Drawable leftArrowMask;
|
||
|
private OnDateSelectedListener listener;
|
||
|
private boolean mDynamicHeightEnabled;
|
||
|
private CalendarDay maxDate;
|
||
|
private CalendarDay minDate;
|
||
|
private OnMonthChangedListener monthListener;
|
||
|
private final View.OnClickListener onClickListener;
|
||
|
private final ViewPager.ojQ pageChangeListener;
|
||
|
private final CalendarPager pager;
|
||
|
private OnRangeSelectedListener rangeListener;
|
||
|
private Drawable rightArrowMask;
|
||
|
|
||
|
@SelectionMode
|
||
|
private int selectionMode;
|
||
|
private State state;
|
||
|
private int tileHeight;
|
||
|
private int tileWidth;
|
||
|
private final TextView title;
|
||
|
private final TitleChanger titleChanger;
|
||
|
private LinearLayout topbar;
|
||
|
|
||
|
@Retention(RetentionPolicy.RUNTIME)
|
||
|
/* loaded from: classes.dex */
|
||
|
public @interface SelectionMode {
|
||
|
}
|
||
|
|
||
|
@Retention(RetentionPolicy.RUNTIME)
|
||
|
/* loaded from: classes.dex */
|
||
|
public @interface ShowOtherDates {
|
||
|
}
|
||
|
|
||
|
public static boolean showDecoratedDisabled(@ShowOtherDates int i) {
|
||
|
return (i & 4) != 0;
|
||
|
}
|
||
|
|
||
|
public static boolean showOtherMonths(@ShowOtherDates int i) {
|
||
|
return (i & 1) != 0;
|
||
|
}
|
||
|
|
||
|
public static boolean showOutOfRange(@ShowOtherDates int i) {
|
||
|
return (i & 2) != 0;
|
||
|
}
|
||
|
|
||
|
@Override // android.view.ViewGroup
|
||
|
public boolean shouldDelayChildPressedState() {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
public MaterialCalendarView(Context context) {
|
||
|
this(context, null);
|
||
|
}
|
||
|
|
||
|
public MaterialCalendarView(Context context, AttributeSet attributeSet) {
|
||
|
super(context, attributeSet);
|
||
|
this.dividerSize = 0;
|
||
|
this.dividerColor = 0;
|
||
|
this.dayViewDecorators = new ArrayList<>();
|
||
|
View.OnClickListener onClickListener = new View.OnClickListener(this) { // from class: com.prolificinteractive.materialcalendarview.MaterialCalendarView.1
|
||
|
final MaterialCalendarView this$0;
|
||
|
|
||
|
{
|
||
|
this.this$0 = this;
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View.OnClickListener
|
||
|
public void onClick(View view) {
|
||
|
if (view == this.this$0.buttonFuture) {
|
||
|
this.this$0.pager.setCurrentItem(this.this$0.pager.getCurrentItem() + 1, true);
|
||
|
} else if (view == this.this$0.buttonPast) {
|
||
|
this.this$0.pager.setCurrentItem(this.this$0.pager.getCurrentItem() - 1, true);
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
this.onClickListener = onClickListener;
|
||
|
ViewPager.ojQ ojq = new ViewPager.ojQ(this) { // from class: com.prolificinteractive.materialcalendarview.MaterialCalendarView.2
|
||
|
final MaterialCalendarView this$0;
|
||
|
|
||
|
@Override // androidx.viewpager.widget.ViewPager.ojQ
|
||
|
public void onPageScrollStateChanged(int i) {
|
||
|
}
|
||
|
|
||
|
@Override // androidx.viewpager.widget.ViewPager.ojQ
|
||
|
public void onPageScrolled(int i, float f, int i2) {
|
||
|
}
|
||
|
|
||
|
{
|
||
|
this.this$0 = this;
|
||
|
}
|
||
|
|
||
|
@Override // androidx.viewpager.widget.ViewPager.ojQ
|
||
|
public void onPageSelected(int i) {
|
||
|
this.this$0.titleChanger.setPreviousMonth(this.this$0.currentMonth);
|
||
|
MaterialCalendarView materialCalendarView = this.this$0;
|
||
|
materialCalendarView.currentMonth = materialCalendarView.adapter.getItem(i);
|
||
|
this.this$0.updateUi();
|
||
|
MaterialCalendarView materialCalendarView2 = this.this$0;
|
||
|
materialCalendarView2.dispatchOnMonthChanged(materialCalendarView2.currentMonth);
|
||
|
}
|
||
|
};
|
||
|
this.pageChangeListener = ojq;
|
||
|
this.minDate = null;
|
||
|
this.maxDate = null;
|
||
|
this.accentColor = 0;
|
||
|
this.arrowColor = -16777216;
|
||
|
this.tileHeight = -10;
|
||
|
this.tileWidth = -10;
|
||
|
this.selectionMode = 1;
|
||
|
this.allowClickDaysOutsideCurrentMonth = true;
|
||
|
setClipToPadding(false);
|
||
|
setClipChildren(false);
|
||
|
DirectionButton directionButton = new DirectionButton(getContext());
|
||
|
this.buttonPast = directionButton;
|
||
|
directionButton.setContentDescription(getContext().getString(R.string.previous));
|
||
|
TextView textView = new TextView(getContext());
|
||
|
this.title = textView;
|
||
|
DirectionButton directionButton2 = new DirectionButton(getContext());
|
||
|
this.buttonFuture = directionButton2;
|
||
|
directionButton2.setContentDescription(getContext().getString(R.string.next));
|
||
|
CalendarPager calendarPager = new CalendarPager(getContext());
|
||
|
this.pager = calendarPager;
|
||
|
directionButton.setOnClickListener(onClickListener);
|
||
|
directionButton2.setOnClickListener(onClickListener);
|
||
|
TitleChanger titleChanger = new TitleChanger(textView);
|
||
|
this.titleChanger = titleChanger;
|
||
|
titleChanger.setTitleFormatter(DEFAULT_TITLE_FORMATTER);
|
||
|
calendarPager.setOnPageChangeListener(ojq);
|
||
|
calendarPager.setPageTransformer(false, new ViewPager.tOB(this) { // from class: com.prolificinteractive.materialcalendarview.MaterialCalendarView.3
|
||
|
final MaterialCalendarView this$0;
|
||
|
|
||
|
{
|
||
|
this.this$0 = this;
|
||
|
}
|
||
|
|
||
|
@Override // androidx.viewpager.widget.ViewPager.tOB
|
||
|
public void transformPage(View view, float f) {
|
||
|
view.setAlpha((float) Math.sqrt(1.0f - Math.abs(f)));
|
||
|
}
|
||
|
});
|
||
|
TypedArray obtainStyledAttributes = context.getTheme().obtainStyledAttributes(attributeSet, R.styleable.MaterialCalendarView, 0, 0);
|
||
|
try {
|
||
|
int integer = obtainStyledAttributes.getInteger(R.styleable.MaterialCalendarView_mcv_calendarMode, 0);
|
||
|
this.firstDayOfWeek = obtainStyledAttributes.getInteger(R.styleable.MaterialCalendarView_mcv_firstDayOfWeek, -1);
|
||
|
titleChanger.setOrientation(obtainStyledAttributes.getInteger(R.styleable.MaterialCalendarView_mcv_titleAnimationOrientation, 0));
|
||
|
if (this.firstDayOfWeek < 0) {
|
||
|
this.firstDayOfWeek = Calendar.getInstance().getFirstDayOfWeek();
|
||
|
}
|
||
|
newState().setFirstDayOfWeek(this.firstDayOfWeek).setCalendarDisplayMode(CalendarMode.values()[integer]).commit();
|
||
|
int layoutDimension = obtainStyledAttributes.getLayoutDimension(R.styleable.MaterialCalendarView_mcv_tileSize, -10);
|
||
|
if (layoutDimension > -10) {
|
||
|
setTileSize(layoutDimension);
|
||
|
}
|
||
|
int layoutDimension2 = obtainStyledAttributes.getLayoutDimension(R.styleable.MaterialCalendarView_mcv_tileWidth, -10);
|
||
|
if (layoutDimension2 > -10) {
|
||
|
setTileWidth(layoutDimension2);
|
||
|
}
|
||
|
int layoutDimension3 = obtainStyledAttributes.getLayoutDimension(R.styleable.MaterialCalendarView_mcv_tileHeight, -10);
|
||
|
if (layoutDimension3 > -10) {
|
||
|
setTileHeight(layoutDimension3);
|
||
|
}
|
||
|
setArrowColor(obtainStyledAttributes.getColor(R.styleable.MaterialCalendarView_mcv_arrowColor, -16777216));
|
||
|
Drawable drawable = obtainStyledAttributes.getDrawable(R.styleable.MaterialCalendarView_mcv_leftArrowMask);
|
||
|
setLeftArrowMask(drawable == null ? getResources().getDrawable(R.drawable.mcv_action_previous) : drawable);
|
||
|
Drawable drawable2 = obtainStyledAttributes.getDrawable(R.styleable.MaterialCalendarView_mcv_rightArrowMask);
|
||
|
setRightArrowMask(drawable2 == null ? getResources().getDrawable(R.drawable.mcv_action_next) : drawable2);
|
||
|
setSelectionColor(obtainStyledAttributes.getColor(R.styleable.MaterialCalendarView_mcv_selectionColor, getThemeAccentColor(context)));
|
||
|
CharSequence[] textArray = obtainStyledAttributes.getTextArray(R.styleable.MaterialCalendarView_mcv_weekDayLabels);
|
||
|
if (textArray != null) {
|
||
|
setWeekDayFormatter(new ArrayWeekDayFormatter(textArray));
|
||
|
}
|
||
|
CharSequence[] textArray2 = obtainStyledAttributes.getTextArray(R.styleable.MaterialCalendarView_mcv_monthLabels);
|
||
|
if (textArray2 != null) {
|
||
|
setTitleFormatter(new MonthArrayTitleFormatter(textArray2));
|
||
|
}
|
||
|
setHeaderTextAppearance(obtainStyledAttributes.getResourceId(R.styleable.MaterialCalendarView_mcv_headerTextAppearance, R.style.TextAppearance_MaterialCalendarWidget_Header));
|
||
|
setWeekDayTextAppearance(obtainStyledAttributes.getResourceId(R.styleable.MaterialCalendarView_mcv_weekDayTextAppearance, R.style.TextAppearance_MaterialCalendarWidget_WeekDay));
|
||
|
setDateTextAppearance(obtainStyledAttributes.getResourceId(R.styleable.MaterialCalendarView_mcv_dateTextAppearance, R.style.TextAppearance_MaterialCalendarWidget_Date));
|
||
|
setShowOtherDates(obtainStyledAttributes.getInteger(R.styleable.MaterialCalendarView_mcv_showOtherDates, 4));
|
||
|
setAllowClickDaysOutsideCurrentMonth(obtainStyledAttributes.getBoolean(R.styleable.MaterialCalendarView_mcv_allowClickDaysOutsideCurrentMonth, true));
|
||
|
setEnableWeekDivider(obtainStyledAttributes.getBoolean(R.styleable.MaterialCalendarView_mcv_enableWeekDivider, false));
|
||
|
setEnableWeekOfMonthDivider(obtainStyledAttributes.getBoolean(R.styleable.MaterialCalendarView_mcv_enableWeekOfMonthDivider, false));
|
||
|
setDividerSize(obtainStyledAttributes.getDimensionPixelOffset(R.styleable.MaterialCalendarView_mcv_dividerSize, getResources().getDimensionPixelOffset(R.dimen.mcv_border_size)));
|
||
|
setDividerColor(obtainStyledAttributes.getColor(R.styleable.MaterialCalendarView_mcv_dividerColor, nMh.getColor(getContext(), R.color.mcv_border_color)));
|
||
|
} catch (Exception unused) {
|
||
|
} catch (Throwable th) {
|
||
|
obtainStyledAttributes.recycle();
|
||
|
throw th;
|
||
|
}
|
||
|
obtainStyledAttributes.recycle();
|
||
|
this.adapter.setTitleFormatter(DEFAULT_TITLE_FORMATTER);
|
||
|
this.adapter.setEnableWeekDivider(isEnableWeekDivider());
|
||
|
this.adapter.setEnableWeekOfMonthDivider(isEnableWeekOfMonthDivider());
|
||
|
this.adapter.setDividerColor(getDividerColor());
|
||
|
this.adapter.setDividerSize(getDividerSize());
|
||
|
setupChildren();
|
||
|
CalendarDay calendarDay = CalendarDay.today();
|
||
|
this.currentMonth = calendarDay;
|
||
|
setCurrentDate(calendarDay);
|
||
|
if (isInEditMode()) {
|
||
|
removeView(this.pager);
|
||
|
MonthView monthView = new MonthView(this, this.currentMonth, getFirstDayOfWeek());
|
||
|
monthView.setSelectionColor(getSelectionColor());
|
||
|
monthView.setDateTextAppearance(this.adapter.getDateTextAppearance());
|
||
|
monthView.setWeekDayTextAppearance(this.adapter.getWeekDayTextAppearance());
|
||
|
monthView.setShowOtherDates(getShowOtherDates());
|
||
|
addView(monthView, new LayoutParams(this.calendarMode.visibleWeeksCount + 1));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void setupChildren() {
|
||
|
LinearLayout linearLayout = new LinearLayout(getContext());
|
||
|
this.topbar = linearLayout;
|
||
|
linearLayout.setOrientation(0);
|
||
|
this.topbar.setClipChildren(false);
|
||
|
this.topbar.setClipToPadding(false);
|
||
|
addView(this.topbar, new LayoutParams(1));
|
||
|
this.buttonPast.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||
|
this.topbar.addView(this.buttonPast, new LinearLayout.LayoutParams(0, -1, 1.0f));
|
||
|
this.title.setGravity(17);
|
||
|
this.topbar.addView(this.title, new LinearLayout.LayoutParams(0, -1, 5.0f));
|
||
|
this.buttonFuture.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||
|
this.topbar.addView(this.buttonFuture, new LinearLayout.LayoutParams(0, -1, 1.0f));
|
||
|
this.pager.setId(R.id.mcv_pager);
|
||
|
this.pager.setOffscreenPageLimit(1);
|
||
|
addView(this.pager, new LayoutParams(this.calendarMode.visibleWeeksCount + 1));
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
public void updateUi() {
|
||
|
this.titleChanger.change(this.currentMonth);
|
||
|
this.buttonPast.setEnabled(canGoBack());
|
||
|
this.buttonFuture.setEnabled(canGoForward());
|
||
|
}
|
||
|
|
||
|
public void setSelectionMode(@SelectionMode int i) {
|
||
|
int i2 = this.selectionMode;
|
||
|
this.selectionMode = i;
|
||
|
if (i != 1) {
|
||
|
if (i != 2) {
|
||
|
if (i != 3) {
|
||
|
this.selectionMode = 0;
|
||
|
if (i2 != 0) {
|
||
|
clearSelection();
|
||
|
}
|
||
|
} else {
|
||
|
clearSelection();
|
||
|
}
|
||
|
}
|
||
|
} else if ((i2 == 2 || i2 == 3) && !getSelectedDates().isEmpty()) {
|
||
|
setSelectedDate(getSelectedDate());
|
||
|
}
|
||
|
this.adapter.setSelectionEnabled(this.selectionMode != 0);
|
||
|
}
|
||
|
|
||
|
public void goToPrevious() {
|
||
|
if (canGoBack()) {
|
||
|
CalendarPager calendarPager = this.pager;
|
||
|
calendarPager.setCurrentItem(calendarPager.getCurrentItem() - 1, true);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void goToNext() {
|
||
|
if (canGoForward()) {
|
||
|
CalendarPager calendarPager = this.pager;
|
||
|
calendarPager.setCurrentItem(calendarPager.getCurrentItem() + 1, true);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Deprecated
|
||
|
public int getTileSize() {
|
||
|
return Math.max(this.tileHeight, this.tileWidth);
|
||
|
}
|
||
|
|
||
|
public void setTileSize(int i) {
|
||
|
this.tileWidth = i;
|
||
|
this.tileHeight = i;
|
||
|
requestLayout();
|
||
|
}
|
||
|
|
||
|
public void setTileSizeDp(int i) {
|
||
|
setTileSize(dpToPx(i));
|
||
|
}
|
||
|
|
||
|
public void setTileHeight(int i) {
|
||
|
this.tileHeight = i;
|
||
|
requestLayout();
|
||
|
}
|
||
|
|
||
|
public void setTileHeightDp(int i) {
|
||
|
setTileHeight(dpToPx(i));
|
||
|
}
|
||
|
|
||
|
public void setTileWidth(int i) {
|
||
|
this.tileWidth = i;
|
||
|
requestLayout();
|
||
|
}
|
||
|
|
||
|
public void setTileWidthDp(int i) {
|
||
|
setTileWidth(dpToPx(i));
|
||
|
}
|
||
|
|
||
|
private int dpToPx(int i) {
|
||
|
return (int) TypedValue.applyDimension(1, i, getResources().getDisplayMetrics());
|
||
|
}
|
||
|
|
||
|
public boolean canGoForward() {
|
||
|
return this.pager.getCurrentItem() < this.adapter.getCount() - 1;
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View
|
||
|
public boolean onTouchEvent(MotionEvent motionEvent) {
|
||
|
return this.pager.dispatchTouchEvent(motionEvent);
|
||
|
}
|
||
|
|
||
|
public boolean canGoBack() {
|
||
|
return this.pager.getCurrentItem() > 0;
|
||
|
}
|
||
|
|
||
|
public void setSelectionColor(int i) {
|
||
|
if (i == 0) {
|
||
|
if (!isInEditMode()) {
|
||
|
return;
|
||
|
} else {
|
||
|
i = -7829368;
|
||
|
}
|
||
|
}
|
||
|
this.accentColor = i;
|
||
|
this.adapter.setSelectionColor(i);
|
||
|
invalidate();
|
||
|
}
|
||
|
|
||
|
public void setArrowColor(int i) {
|
||
|
if (i == 0) {
|
||
|
return;
|
||
|
}
|
||
|
this.arrowColor = i;
|
||
|
this.buttonPast.setColor(i);
|
||
|
this.buttonFuture.setColor(i);
|
||
|
invalidate();
|
||
|
}
|
||
|
|
||
|
public void setContentDescriptionArrowPast(CharSequence charSequence) {
|
||
|
this.buttonPast.setContentDescription(charSequence);
|
||
|
}
|
||
|
|
||
|
public void setContentDescriptionArrowFuture(CharSequence charSequence) {
|
||
|
this.buttonFuture.setContentDescription(charSequence);
|
||
|
}
|
||
|
|
||
|
public CharSequence getCalendarContentDescription() {
|
||
|
CharSequence charSequence = this.calendarContentDescription;
|
||
|
return charSequence == null ? getContext().getString(R.string.calendar) : charSequence;
|
||
|
}
|
||
|
|
||
|
public void setLeftArrowMask(Drawable drawable) {
|
||
|
this.leftArrowMask = drawable;
|
||
|
this.buttonPast.setImageDrawable(drawable);
|
||
|
}
|
||
|
|
||
|
public void setRightArrowMask(Drawable drawable) {
|
||
|
this.rightArrowMask = drawable;
|
||
|
this.buttonFuture.setImageDrawable(drawable);
|
||
|
}
|
||
|
|
||
|
public void setHeaderTextAppearance(int i) {
|
||
|
this.title.setTextAppearance(getContext(), i);
|
||
|
}
|
||
|
|
||
|
public void setDateTextAppearance(int i) {
|
||
|
this.adapter.setDateTextAppearance(i);
|
||
|
}
|
||
|
|
||
|
public void setWeekDayTextAppearance(int i) {
|
||
|
this.adapter.setWeekDayTextAppearance(i);
|
||
|
}
|
||
|
|
||
|
public CalendarDay getSelectedDate() {
|
||
|
List<CalendarDay> selectedDates = this.adapter.getSelectedDates();
|
||
|
if (selectedDates.isEmpty()) {
|
||
|
return null;
|
||
|
}
|
||
|
return selectedDates.get(selectedDates.size() - 1);
|
||
|
}
|
||
|
|
||
|
public List<CalendarDay> getSelectedDates() {
|
||
|
return this.adapter.getSelectedDates();
|
||
|
}
|
||
|
|
||
|
public void clearSelection() {
|
||
|
List<CalendarDay> selectedDates = getSelectedDates();
|
||
|
this.adapter.clearSelections();
|
||
|
Iterator<CalendarDay> it = selectedDates.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
dispatchOnDateSelected(it.next(), false);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setSelectedDate(Calendar calendar) {
|
||
|
setSelectedDate(CalendarDay.from(calendar));
|
||
|
}
|
||
|
|
||
|
public void setSelectedDate(Date date) {
|
||
|
setSelectedDate(CalendarDay.from(date));
|
||
|
}
|
||
|
|
||
|
public void setSelectedDate(CalendarDay calendarDay) {
|
||
|
clearSelection();
|
||
|
if (calendarDay != null) {
|
||
|
setDateSelected(calendarDay, true);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setDateSelected(Calendar calendar, boolean z) {
|
||
|
setDateSelected(CalendarDay.from(calendar), z);
|
||
|
}
|
||
|
|
||
|
public void setDateSelected(Date date, boolean z) {
|
||
|
setDateSelected(CalendarDay.from(date), z);
|
||
|
}
|
||
|
|
||
|
public void setDateSelected(CalendarDay calendarDay, boolean z) {
|
||
|
if (calendarDay == null) {
|
||
|
return;
|
||
|
}
|
||
|
this.adapter.setDateSelected(calendarDay, z);
|
||
|
}
|
||
|
|
||
|
public void setCurrentDate(Calendar calendar) {
|
||
|
setCurrentDate(CalendarDay.from(calendar));
|
||
|
}
|
||
|
|
||
|
public void setCurrentDate(Date date) {
|
||
|
setCurrentDate(CalendarDay.from(date));
|
||
|
}
|
||
|
|
||
|
public CalendarDay getCurrentDate() {
|
||
|
return this.adapter.getItem(this.pager.getCurrentItem());
|
||
|
}
|
||
|
|
||
|
public void setCurrentDate(CalendarDay calendarDay) {
|
||
|
setCurrentDate(calendarDay, true);
|
||
|
}
|
||
|
|
||
|
public void setCurrentDate(CalendarDay calendarDay, boolean z) {
|
||
|
if (calendarDay == null) {
|
||
|
return;
|
||
|
}
|
||
|
this.pager.setCurrentItem(this.adapter.getIndexForDay(calendarDay), z);
|
||
|
updateUi();
|
||
|
}
|
||
|
|
||
|
public void setShowOtherDates(@ShowOtherDates int i) {
|
||
|
this.adapter.setShowOtherDates(i);
|
||
|
}
|
||
|
|
||
|
public void setWeekDayFormatter(WeekDayFormatter weekDayFormatter) {
|
||
|
CalendarPagerAdapter<?> calendarPagerAdapter = this.adapter;
|
||
|
if (weekDayFormatter == null) {
|
||
|
weekDayFormatter = WeekDayFormatter.DEFAULT;
|
||
|
}
|
||
|
calendarPagerAdapter.setWeekDayFormatter(weekDayFormatter);
|
||
|
}
|
||
|
|
||
|
public void setDayFormatter(DayFormatter dayFormatter) {
|
||
|
CalendarPagerAdapter<?> calendarPagerAdapter = this.adapter;
|
||
|
if (dayFormatter == null) {
|
||
|
dayFormatter = DayFormatter.DEFAULT;
|
||
|
}
|
||
|
calendarPagerAdapter.setDayFormatter(dayFormatter);
|
||
|
}
|
||
|
|
||
|
public void setWeekDayLabels(CharSequence[] charSequenceArr) {
|
||
|
setWeekDayFormatter(new ArrayWeekDayFormatter(charSequenceArr));
|
||
|
}
|
||
|
|
||
|
public void setWeekDayLabels(int i) {
|
||
|
setWeekDayLabels(getResources().getTextArray(i));
|
||
|
}
|
||
|
|
||
|
@ShowOtherDates
|
||
|
public int getShowOtherDates() {
|
||
|
return this.adapter.getShowOtherDates();
|
||
|
}
|
||
|
|
||
|
public void setTitleFormatter(TitleFormatter titleFormatter) {
|
||
|
if (titleFormatter == null) {
|
||
|
titleFormatter = DEFAULT_TITLE_FORMATTER;
|
||
|
}
|
||
|
this.titleChanger.setTitleFormatter(titleFormatter);
|
||
|
this.adapter.setTitleFormatter(titleFormatter);
|
||
|
updateUi();
|
||
|
}
|
||
|
|
||
|
public void setTitleMonths(CharSequence[] charSequenceArr) {
|
||
|
setTitleFormatter(new MonthArrayTitleFormatter(charSequenceArr));
|
||
|
}
|
||
|
|
||
|
public void setTitleMonths(int i) {
|
||
|
setTitleMonths(getResources().getTextArray(i));
|
||
|
}
|
||
|
|
||
|
public void setTitleAnimationOrientation(int i) {
|
||
|
this.titleChanger.setOrientation(i);
|
||
|
}
|
||
|
|
||
|
public int getTitleAnimationOrientation() {
|
||
|
return this.titleChanger.getOrientation();
|
||
|
}
|
||
|
|
||
|
public void setTopbarVisible(boolean z) {
|
||
|
this.topbar.setVisibility(z ? 0 : 8);
|
||
|
requestLayout();
|
||
|
}
|
||
|
|
||
|
public boolean getTopbarVisible() {
|
||
|
return this.topbar.getVisibility() == 0;
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View
|
||
|
protected Parcelable onSaveInstanceState() {
|
||
|
SavedState savedState = new SavedState(super.onSaveInstanceState());
|
||
|
savedState.color = getSelectionColor();
|
||
|
savedState.dateTextAppearance = this.adapter.getDateTextAppearance();
|
||
|
savedState.weekDayTextAppearance = this.adapter.getWeekDayTextAppearance();
|
||
|
savedState.showOtherDates = getShowOtherDates();
|
||
|
savedState.allowClickDaysOutsideCurrentMonth = allowClickDaysOutsideCurrentMonth();
|
||
|
savedState.minDate = getMinimumDate();
|
||
|
savedState.maxDate = getMaximumDate();
|
||
|
savedState.selectedDates = getSelectedDates();
|
||
|
savedState.firstDayOfWeek = getFirstDayOfWeek();
|
||
|
savedState.orientation = getTitleAnimationOrientation();
|
||
|
savedState.selectionMode = getSelectionMode();
|
||
|
savedState.tileWidthPx = getTileWidth();
|
||
|
savedState.tileHeightPx = getTileHeight();
|
||
|
savedState.topbarVisible = getTopbarVisible();
|
||
|
savedState.calendarMode = this.calendarMode;
|
||
|
savedState.dynamicHeightEnabled = this.mDynamicHeightEnabled;
|
||
|
savedState.currentMonth = this.currentMonth;
|
||
|
savedState.cacheCurrentPosition = this.state.cacheCurrentPosition;
|
||
|
savedState.enableWeekDivider = this.state.enableWeekDivider;
|
||
|
savedState.enableWeekOfMonthDivider = this.state.enableWeekOfMonthDivider;
|
||
|
return savedState;
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View
|
||
|
protected void onRestoreInstanceState(Parcelable parcelable) {
|
||
|
SavedState savedState = (SavedState) parcelable;
|
||
|
super.onRestoreInstanceState(savedState.getSuperState());
|
||
|
newState().setFirstDayOfWeek(savedState.firstDayOfWeek).setCalendarDisplayMode(savedState.calendarMode).setMinimumDate(savedState.minDate).setMaximumDate(savedState.maxDate).isCacheCalendarPositionEnabled(savedState.cacheCurrentPosition).setEnableWeekDivider(savedState.enableWeekDivider).setEnableWeekOfMonthDivider(savedState.enableWeekOfMonthDivider).commit();
|
||
|
setSelectionColor(savedState.color);
|
||
|
setDateTextAppearance(savedState.dateTextAppearance);
|
||
|
setWeekDayTextAppearance(savedState.weekDayTextAppearance);
|
||
|
setShowOtherDates(savedState.showOtherDates);
|
||
|
setAllowClickDaysOutsideCurrentMonth(savedState.allowClickDaysOutsideCurrentMonth);
|
||
|
clearSelection();
|
||
|
Iterator<CalendarDay> it = savedState.selectedDates.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
setDateSelected(it.next(), true);
|
||
|
}
|
||
|
setTitleAnimationOrientation(savedState.orientation);
|
||
|
setTileWidth(savedState.tileWidthPx);
|
||
|
setTileHeight(savedState.tileHeightPx);
|
||
|
setTopbarVisible(savedState.topbarVisible);
|
||
|
setSelectionMode(savedState.selectionMode);
|
||
|
setDynamicHeightEnabled(savedState.dynamicHeightEnabled);
|
||
|
setCurrentDate(savedState.currentMonth);
|
||
|
}
|
||
|
|
||
|
@Override // android.view.ViewGroup, android.view.View
|
||
|
protected void dispatchSaveInstanceState(SparseArray<Parcelable> sparseArray) {
|
||
|
dispatchFreezeSelfOnly(sparseArray);
|
||
|
}
|
||
|
|
||
|
@Override // android.view.ViewGroup, android.view.View
|
||
|
protected void dispatchRestoreInstanceState(SparseArray<Parcelable> sparseArray) {
|
||
|
dispatchThawSelfOnly(sparseArray);
|
||
|
}
|
||
|
|
||
|
private void setRangeDates(CalendarDay calendarDay, CalendarDay calendarDay2) {
|
||
|
CalendarDay calendarDay3 = this.currentMonth;
|
||
|
this.adapter.setRangeDates(calendarDay, calendarDay2);
|
||
|
this.currentMonth = calendarDay3;
|
||
|
if (calendarDay != null) {
|
||
|
if (!calendarDay.isAfter(calendarDay3)) {
|
||
|
calendarDay = this.currentMonth;
|
||
|
}
|
||
|
this.currentMonth = calendarDay;
|
||
|
}
|
||
|
this.pager.setCurrentItem(this.adapter.getIndexForDay(calendarDay3), false);
|
||
|
updateUi();
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes3.dex */
|
||
|
public static class SavedState extends View.BaseSavedState {
|
||
|
public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<SavedState>() { // from class: com.prolificinteractive.materialcalendarview.MaterialCalendarView.SavedState.1
|
||
|
/* JADX WARN: Can't rename method to resolve collision */
|
||
|
@Override // android.os.Parcelable.Creator
|
||
|
public final SavedState createFromParcel(Parcel parcel) {
|
||
|
return new SavedState(parcel);
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Can't rename method to resolve collision */
|
||
|
@Override // android.os.Parcelable.Creator
|
||
|
public final SavedState[] newArray(int i) {
|
||
|
return new SavedState[i];
|
||
|
}
|
||
|
};
|
||
|
boolean allowClickDaysOutsideCurrentMonth;
|
||
|
boolean cacheCurrentPosition;
|
||
|
CalendarMode calendarMode;
|
||
|
int color;
|
||
|
CalendarDay currentMonth;
|
||
|
int dateTextAppearance;
|
||
|
boolean dynamicHeightEnabled;
|
||
|
boolean enableWeekDivider;
|
||
|
boolean enableWeekOfMonthDivider;
|
||
|
int firstDayOfWeek;
|
||
|
CalendarDay maxDate;
|
||
|
CalendarDay minDate;
|
||
|
int orientation;
|
||
|
List<CalendarDay> selectedDates;
|
||
|
int selectionMode;
|
||
|
int showOtherDates;
|
||
|
int tileHeightPx;
|
||
|
int tileWidthPx;
|
||
|
boolean topbarVisible;
|
||
|
int weekDayTextAppearance;
|
||
|
|
||
|
SavedState(Parcelable parcelable) {
|
||
|
super(parcelable);
|
||
|
this.color = 0;
|
||
|
this.dateTextAppearance = 0;
|
||
|
this.weekDayTextAppearance = 0;
|
||
|
this.showOtherDates = 4;
|
||
|
this.allowClickDaysOutsideCurrentMonth = true;
|
||
|
this.minDate = null;
|
||
|
this.maxDate = null;
|
||
|
this.selectedDates = new ArrayList();
|
||
|
this.firstDayOfWeek = 1;
|
||
|
this.orientation = 0;
|
||
|
this.tileWidthPx = -1;
|
||
|
this.tileHeightPx = -1;
|
||
|
this.topbarVisible = true;
|
||
|
this.selectionMode = 1;
|
||
|
this.dynamicHeightEnabled = false;
|
||
|
this.calendarMode = CalendarMode.MONTHS;
|
||
|
this.currentMonth = null;
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View.BaseSavedState, android.view.AbsSavedState, android.os.Parcelable
|
||
|
public void writeToParcel(Parcel parcel, int i) {
|
||
|
super.writeToParcel(parcel, i);
|
||
|
parcel.writeInt(this.color);
|
||
|
parcel.writeInt(this.dateTextAppearance);
|
||
|
parcel.writeInt(this.weekDayTextAppearance);
|
||
|
parcel.writeInt(this.showOtherDates);
|
||
|
parcel.writeByte(this.allowClickDaysOutsideCurrentMonth ? (byte) 1 : (byte) 0);
|
||
|
parcel.writeParcelable(this.minDate, 0);
|
||
|
parcel.writeParcelable(this.maxDate, 0);
|
||
|
parcel.writeTypedList(this.selectedDates);
|
||
|
parcel.writeInt(this.firstDayOfWeek);
|
||
|
parcel.writeInt(this.orientation);
|
||
|
parcel.writeInt(this.tileWidthPx);
|
||
|
parcel.writeInt(this.tileHeightPx);
|
||
|
parcel.writeInt(this.topbarVisible ? 1 : 0);
|
||
|
parcel.writeInt(this.selectionMode);
|
||
|
parcel.writeInt(this.dynamicHeightEnabled ? 1 : 0);
|
||
|
parcel.writeInt(this.calendarMode == CalendarMode.WEEKS ? 1 : 0);
|
||
|
parcel.writeParcelable(this.currentMonth, 0);
|
||
|
parcel.writeByte(this.cacheCurrentPosition ? (byte) 1 : (byte) 0);
|
||
|
parcel.writeByte(this.enableWeekDivider ? (byte) 1 : (byte) 0);
|
||
|
parcel.writeByte(this.enableWeekOfMonthDivider ? (byte) 1 : (byte) 0);
|
||
|
}
|
||
|
|
||
|
private SavedState(Parcel parcel) {
|
||
|
super(parcel);
|
||
|
this.color = 0;
|
||
|
this.dateTextAppearance = 0;
|
||
|
this.weekDayTextAppearance = 0;
|
||
|
this.showOtherDates = 4;
|
||
|
this.allowClickDaysOutsideCurrentMonth = true;
|
||
|
this.minDate = null;
|
||
|
this.maxDate = null;
|
||
|
this.selectedDates = new ArrayList();
|
||
|
this.firstDayOfWeek = 1;
|
||
|
this.orientation = 0;
|
||
|
this.tileWidthPx = -1;
|
||
|
this.tileHeightPx = -1;
|
||
|
this.topbarVisible = true;
|
||
|
this.selectionMode = 1;
|
||
|
this.dynamicHeightEnabled = false;
|
||
|
this.calendarMode = CalendarMode.MONTHS;
|
||
|
this.currentMonth = null;
|
||
|
this.color = parcel.readInt();
|
||
|
this.dateTextAppearance = parcel.readInt();
|
||
|
this.weekDayTextAppearance = parcel.readInt();
|
||
|
this.showOtherDates = parcel.readInt();
|
||
|
this.allowClickDaysOutsideCurrentMonth = parcel.readByte() != 0;
|
||
|
ClassLoader classLoader = CalendarDay.class.getClassLoader();
|
||
|
this.minDate = (CalendarDay) parcel.readParcelable(classLoader);
|
||
|
this.maxDate = (CalendarDay) parcel.readParcelable(classLoader);
|
||
|
parcel.readTypedList(this.selectedDates, CalendarDay.CREATOR);
|
||
|
this.firstDayOfWeek = parcel.readInt();
|
||
|
this.orientation = parcel.readInt();
|
||
|
this.tileWidthPx = parcel.readInt();
|
||
|
this.tileHeightPx = parcel.readInt();
|
||
|
this.topbarVisible = parcel.readInt() == 1;
|
||
|
this.selectionMode = parcel.readInt();
|
||
|
this.dynamicHeightEnabled = parcel.readInt() == 1;
|
||
|
this.calendarMode = parcel.readInt() == 1 ? CalendarMode.WEEKS : CalendarMode.MONTHS;
|
||
|
this.currentMonth = (CalendarDay) parcel.readParcelable(classLoader);
|
||
|
this.cacheCurrentPosition = parcel.readByte() != 0;
|
||
|
this.enableWeekDivider = parcel.readByte() == 1;
|
||
|
this.enableWeekOfMonthDivider = parcel.readByte() == 1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static int getThemeAccentColor(Context context) {
|
||
|
TypedValue typedValue = new TypedValue();
|
||
|
context.getTheme().resolveAttribute(android.R.attr.colorAccent, typedValue, true);
|
||
|
return typedValue.data;
|
||
|
}
|
||
|
|
||
|
public void addDecorators(Collection<? extends DayViewDecorator> collection) {
|
||
|
if (collection == null) {
|
||
|
return;
|
||
|
}
|
||
|
this.dayViewDecorators.addAll(collection);
|
||
|
this.adapter.setDecorators(this.dayViewDecorators);
|
||
|
}
|
||
|
|
||
|
public void addDecorators(DayViewDecorator... dayViewDecoratorArr) {
|
||
|
addDecorators(Arrays.asList(dayViewDecoratorArr));
|
||
|
}
|
||
|
|
||
|
public void addDecorator(DayViewDecorator dayViewDecorator) {
|
||
|
if (dayViewDecorator == null) {
|
||
|
return;
|
||
|
}
|
||
|
this.dayViewDecorators.add(dayViewDecorator);
|
||
|
this.adapter.setDecorators(this.dayViewDecorators);
|
||
|
}
|
||
|
|
||
|
public void removeDecorators() {
|
||
|
this.dayViewDecorators.clear();
|
||
|
this.adapter.setDecorators(this.dayViewDecorators);
|
||
|
}
|
||
|
|
||
|
public void removeDecorator(DayViewDecorator dayViewDecorator) {
|
||
|
this.dayViewDecorators.remove(dayViewDecorator);
|
||
|
this.adapter.setDecorators(this.dayViewDecorators);
|
||
|
}
|
||
|
|
||
|
public void invalidateDecorators() {
|
||
|
this.adapter.invalidateDecorators();
|
||
|
}
|
||
|
|
||
|
public void setOnTitleClickListener(View.OnClickListener onClickListener) {
|
||
|
this.title.setOnClickListener(onClickListener);
|
||
|
}
|
||
|
|
||
|
protected void dispatchOnDateSelected(CalendarDay calendarDay, boolean z) {
|
||
|
OnDateSelectedListener onDateSelectedListener = this.listener;
|
||
|
if (onDateSelectedListener != null) {
|
||
|
onDateSelectedListener.onDateSelected(this, calendarDay, z);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
protected void dispatchOnRangeSelected(CalendarDay calendarDay, CalendarDay calendarDay2) {
|
||
|
OnRangeSelectedListener onRangeSelectedListener = this.rangeListener;
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
Calendar calendar = Calendar.getInstance();
|
||
|
calendar.setTime(calendarDay.getDate());
|
||
|
Calendar calendar2 = Calendar.getInstance();
|
||
|
calendar2.setTime(calendarDay2.getDate());
|
||
|
while (true) {
|
||
|
if (!calendar.before(calendar2) && !calendar.equals(calendar2)) {
|
||
|
break;
|
||
|
}
|
||
|
CalendarDay from = CalendarDay.from(calendar);
|
||
|
this.adapter.setDateSelected(from, true);
|
||
|
arrayList.add(from);
|
||
|
calendar.add(5, 1);
|
||
|
}
|
||
|
if (onRangeSelectedListener != null) {
|
||
|
onRangeSelectedListener.onRangeSelected(this, arrayList);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
protected void dispatchOnMonthChanged(CalendarDay calendarDay) {
|
||
|
OnMonthChangedListener onMonthChangedListener = this.monthListener;
|
||
|
if (onMonthChangedListener != null) {
|
||
|
onMonthChangedListener.onMonthChanged(this, calendarDay);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
protected void onDateClicked(CalendarDay calendarDay, boolean z) {
|
||
|
int i = this.selectionMode;
|
||
|
if (i != 2) {
|
||
|
if (i == 3) {
|
||
|
this.adapter.setDateSelected(calendarDay, z);
|
||
|
if (this.adapter.getSelectedDates().size() > 2) {
|
||
|
this.adapter.clearSelections();
|
||
|
} else {
|
||
|
if (this.adapter.getSelectedDates().size() == 2) {
|
||
|
List<CalendarDay> selectedDates = this.adapter.getSelectedDates();
|
||
|
if (selectedDates.get(0).isAfter(selectedDates.get(1))) {
|
||
|
dispatchOnRangeSelected(selectedDates.get(1), selectedDates.get(0));
|
||
|
return;
|
||
|
} else {
|
||
|
dispatchOnRangeSelected(selectedDates.get(0), selectedDates.get(1));
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
this.adapter.setDateSelected(calendarDay, z);
|
||
|
dispatchOnDateSelected(calendarDay, z);
|
||
|
return;
|
||
|
}
|
||
|
} else {
|
||
|
this.adapter.clearSelections();
|
||
|
this.adapter.setDateSelected(calendarDay, true);
|
||
|
dispatchOnDateSelected(calendarDay, true);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
this.adapter.setDateSelected(calendarDay, z);
|
||
|
dispatchOnDateSelected(calendarDay, z);
|
||
|
}
|
||
|
|
||
|
public void selectRange(CalendarDay calendarDay, CalendarDay calendarDay2) {
|
||
|
clearSelection();
|
||
|
if (calendarDay == null || calendarDay2 == null) {
|
||
|
return;
|
||
|
}
|
||
|
if (calendarDay.isAfter(calendarDay2)) {
|
||
|
dispatchOnRangeSelected(calendarDay2, calendarDay);
|
||
|
} else {
|
||
|
dispatchOnRangeSelected(calendarDay, calendarDay2);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
public void onDateClicked(DayView dayView) {
|
||
|
CalendarDay currentDate = getCurrentDate();
|
||
|
CalendarDay date = dayView.getDate();
|
||
|
int month = currentDate.getMonth();
|
||
|
int month2 = date.getMonth();
|
||
|
if (this.calendarMode == CalendarMode.MONTHS && this.allowClickDaysOutsideCurrentMonth && month != month2) {
|
||
|
if (currentDate.isAfter(date)) {
|
||
|
goToPrevious();
|
||
|
} else if (currentDate.isBefore(date)) {
|
||
|
goToNext();
|
||
|
}
|
||
|
}
|
||
|
onDateClicked(dayView.getDate(), !dayView.isChecked());
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
public void onDateUnselected(CalendarDay calendarDay) {
|
||
|
dispatchOnDateSelected(calendarDay, false);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
@Override // android.view.ViewGroup
|
||
|
public LayoutParams generateDefaultLayoutParams() {
|
||
|
return new LayoutParams(1);
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View
|
||
|
protected void onMeasure(int i, int i2) {
|
||
|
int i3;
|
||
|
int size = View.MeasureSpec.getSize(i);
|
||
|
int mode = View.MeasureSpec.getMode(i);
|
||
|
int size2 = View.MeasureSpec.getSize(i2);
|
||
|
int mode2 = View.MeasureSpec.getMode(i2);
|
||
|
int paddingLeft = getPaddingLeft();
|
||
|
int paddingRight = getPaddingRight();
|
||
|
int paddingTop = getPaddingTop();
|
||
|
int paddingBottom = getPaddingBottom();
|
||
|
int weekCountBasedOnMode = getWeekCountBasedOnMode();
|
||
|
if (getTopbarVisible()) {
|
||
|
weekCountBasedOnMode++;
|
||
|
}
|
||
|
int i4 = ((size - paddingLeft) - paddingRight) / 7;
|
||
|
int i5 = ((size2 - paddingTop) - paddingBottom) / weekCountBasedOnMode;
|
||
|
int i6 = this.tileWidth;
|
||
|
int i7 = -1;
|
||
|
if (i6 == -10 && this.tileHeight == -10) {
|
||
|
if (mode == 1073741824 || mode == Integer.MIN_VALUE) {
|
||
|
if (mode2 == 1073741824) {
|
||
|
i4 = Math.min(i4, i5);
|
||
|
}
|
||
|
} else if (mode2 == 1073741824 || mode2 == Integer.MIN_VALUE) {
|
||
|
i4 = i5;
|
||
|
} else {
|
||
|
i4 = -1;
|
||
|
i5 = -1;
|
||
|
}
|
||
|
i5 = -1;
|
||
|
i7 = i4;
|
||
|
i4 = -1;
|
||
|
} else {
|
||
|
if (i6 > 0) {
|
||
|
i4 = i6;
|
||
|
}
|
||
|
int i8 = this.tileHeight;
|
||
|
if (i8 > 0) {
|
||
|
i5 = i8;
|
||
|
}
|
||
|
}
|
||
|
if (i7 > 0) {
|
||
|
i3 = i7;
|
||
|
} else {
|
||
|
if (i7 <= 0) {
|
||
|
if (i4 <= 0) {
|
||
|
i4 = dpToPx(44);
|
||
|
}
|
||
|
i7 = i4;
|
||
|
if (i5 <= 0) {
|
||
|
i3 = dpToPx(44);
|
||
|
}
|
||
|
} else {
|
||
|
i7 = i4;
|
||
|
}
|
||
|
i3 = i5;
|
||
|
}
|
||
|
int i9 = i7 * 7;
|
||
|
setMeasuredDimension(clampSize(getPaddingLeft() + getPaddingRight() + i9, i), clampSize((weekCountBasedOnMode * i3) + getTotalDividerHeight(weekCountBasedOnMode) + getPaddingTop() + getPaddingBottom(), i2));
|
||
|
int childCount = getChildCount();
|
||
|
for (int i10 = 0; i10 < childCount; i10++) {
|
||
|
View childAt = getChildAt(i10);
|
||
|
childAt.measure(View.MeasureSpec.makeMeasureSpec(i9, 1073741824), View.MeasureSpec.makeMeasureSpec(((ViewGroup.LayoutParams) ((LayoutParams) childAt.getLayoutParams())).height * i3, 1073741824));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private int getTotalDividerHeight(int i) {
|
||
|
if (!isEnableWeekDivider() && !isEnableWeekOfMonthDivider()) {
|
||
|
return 0;
|
||
|
}
|
||
|
if (!isEnableWeekDivider()) {
|
||
|
i--;
|
||
|
}
|
||
|
int dividerSize = getDividerSize();
|
||
|
if (isDynamicHeightEnabled()) {
|
||
|
i--;
|
||
|
}
|
||
|
return dividerSize * i;
|
||
|
}
|
||
|
|
||
|
private int getWeekCountBasedOnMode() {
|
||
|
CalendarPagerAdapter<?> calendarPagerAdapter;
|
||
|
CalendarPager calendarPager;
|
||
|
int i = this.calendarMode.visibleWeeksCount;
|
||
|
if (this.calendarMode.equals(CalendarMode.MONTHS) && this.mDynamicHeightEnabled && (calendarPagerAdapter = this.adapter) != null && (calendarPager = this.pager) != null) {
|
||
|
Calendar calendar = (Calendar) calendarPagerAdapter.getItem(calendarPager.getCurrentItem()).getCalendar().clone();
|
||
|
calendar.set(5, calendar.getActualMaximum(5));
|
||
|
calendar.setFirstDayOfWeek(getFirstDayOfWeek());
|
||
|
i = calendar.get(4);
|
||
|
}
|
||
|
return i + 1;
|
||
|
}
|
||
|
|
||
|
private static int clampSize(int i, int i2) {
|
||
|
int mode = View.MeasureSpec.getMode(i2);
|
||
|
int size = View.MeasureSpec.getSize(i2);
|
||
|
if (mode != Integer.MIN_VALUE) {
|
||
|
return mode != 1073741824 ? i : size;
|
||
|
}
|
||
|
return Math.min(i, size);
|
||
|
}
|
||
|
|
||
|
@Override // android.view.ViewGroup, android.view.View
|
||
|
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
|
||
|
int childCount = getChildCount();
|
||
|
int paddingLeft = getPaddingLeft();
|
||
|
int paddingRight = getPaddingRight();
|
||
|
int paddingTop = getPaddingTop();
|
||
|
for (int i5 = 0; i5 < childCount; i5++) {
|
||
|
View childAt = getChildAt(i5);
|
||
|
if (childAt.getVisibility() != 8) {
|
||
|
int measuredWidth = childAt.getMeasuredWidth();
|
||
|
int i6 = (((((i3 - i) - paddingLeft) - paddingRight) - measuredWidth) / 2) + paddingLeft;
|
||
|
int measuredHeight = childAt.getMeasuredHeight() + paddingTop;
|
||
|
childAt.layout(i6, paddingTop, measuredWidth + i6, measuredHeight);
|
||
|
paddingTop = measuredHeight;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // android.view.ViewGroup
|
||
|
public LayoutParams generateLayoutParams(AttributeSet attributeSet) {
|
||
|
return new LayoutParams(1);
|
||
|
}
|
||
|
|
||
|
@Override // android.view.ViewGroup
|
||
|
protected boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) {
|
||
|
return layoutParams instanceof LayoutParams;
|
||
|
}
|
||
|
|
||
|
@Override // android.view.ViewGroup
|
||
|
protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
|
||
|
return new LayoutParams(1);
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View
|
||
|
public void onInitializeAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
|
||
|
super.onInitializeAccessibilityEvent(accessibilityEvent);
|
||
|
accessibilityEvent.setClassName(MaterialCalendarView.class.getName());
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View
|
||
|
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
|
||
|
super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
|
||
|
accessibilityNodeInfo.setClassName(MaterialCalendarView.class.getName());
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
/* loaded from: classes3.dex */
|
||
|
public static class LayoutParams extends ViewGroup.MarginLayoutParams {
|
||
|
public LayoutParams(int i) {
|
||
|
super(-1, i);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void setPagingEnabled(boolean z) {
|
||
|
this.pager.setPagingEnabled(z);
|
||
|
updateUi();
|
||
|
}
|
||
|
|
||
|
public boolean isPagingEnabled() {
|
||
|
return this.pager.isPagingEnabled();
|
||
|
}
|
||
|
|
||
|
public StateBuilder newState() {
|
||
|
return new StateBuilder(this);
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes3.dex */
|
||
|
public class State {
|
||
|
private final boolean cacheCurrentPosition;
|
||
|
private final CalendarMode calendarMode;
|
||
|
private final int dividerColor;
|
||
|
private final int dividerSize;
|
||
|
private final boolean enableWeekDivider;
|
||
|
private final boolean enableWeekOfMonthDivider;
|
||
|
private final int firstDayOfWeek;
|
||
|
private final CalendarDay maxDate;
|
||
|
private final CalendarDay minDate;
|
||
|
final MaterialCalendarView this$0;
|
||
|
|
||
|
private State(MaterialCalendarView materialCalendarView, StateBuilder stateBuilder) {
|
||
|
this.this$0 = materialCalendarView;
|
||
|
this.calendarMode = stateBuilder.calendarMode;
|
||
|
this.firstDayOfWeek = stateBuilder.firstDayOfWeek;
|
||
|
this.minDate = stateBuilder.minDate;
|
||
|
this.maxDate = stateBuilder.maxDate;
|
||
|
this.cacheCurrentPosition = stateBuilder.cacheCurrentPosition;
|
||
|
this.enableWeekDivider = stateBuilder.enableWeekDivider;
|
||
|
this.enableWeekOfMonthDivider = stateBuilder.enableWeekOfMonthDivider;
|
||
|
this.dividerColor = stateBuilder.dividerColor;
|
||
|
this.dividerSize = stateBuilder.dividerSize;
|
||
|
}
|
||
|
|
||
|
public StateBuilder edit() {
|
||
|
return new StateBuilder(this);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes3.dex */
|
||
|
public class StateBuilder {
|
||
|
private boolean cacheCurrentPosition;
|
||
|
private CalendarMode calendarMode;
|
||
|
private int dividerColor;
|
||
|
private int dividerSize;
|
||
|
private boolean enableWeekDivider;
|
||
|
private boolean enableWeekOfMonthDivider;
|
||
|
private int firstDayOfWeek;
|
||
|
private CalendarDay maxDate;
|
||
|
private CalendarDay minDate;
|
||
|
final MaterialCalendarView this$0;
|
||
|
|
||
|
public StateBuilder(MaterialCalendarView materialCalendarView) {
|
||
|
this.this$0 = materialCalendarView;
|
||
|
this.calendarMode = CalendarMode.MONTHS;
|
||
|
this.firstDayOfWeek = Calendar.getInstance().getFirstDayOfWeek();
|
||
|
this.cacheCurrentPosition = false;
|
||
|
this.minDate = null;
|
||
|
this.maxDate = null;
|
||
|
this.enableWeekDivider = false;
|
||
|
this.enableWeekOfMonthDivider = false;
|
||
|
this.dividerSize = 0;
|
||
|
this.dividerColor = 0;
|
||
|
}
|
||
|
|
||
|
private StateBuilder(MaterialCalendarView materialCalendarView, State state) {
|
||
|
this.this$0 = materialCalendarView;
|
||
|
this.calendarMode = CalendarMode.MONTHS;
|
||
|
this.firstDayOfWeek = Calendar.getInstance().getFirstDayOfWeek();
|
||
|
this.cacheCurrentPosition = false;
|
||
|
this.minDate = null;
|
||
|
this.maxDate = null;
|
||
|
this.enableWeekDivider = false;
|
||
|
this.enableWeekOfMonthDivider = false;
|
||
|
this.dividerSize = 0;
|
||
|
this.dividerColor = 0;
|
||
|
this.calendarMode = state.calendarMode;
|
||
|
this.firstDayOfWeek = state.firstDayOfWeek;
|
||
|
this.minDate = state.minDate;
|
||
|
this.maxDate = state.maxDate;
|
||
|
this.cacheCurrentPosition = state.cacheCurrentPosition;
|
||
|
this.enableWeekDivider = state.enableWeekDivider;
|
||
|
this.enableWeekOfMonthDivider = state.enableWeekOfMonthDivider;
|
||
|
this.dividerColor = state.dividerColor;
|
||
|
this.dividerSize = state.dividerSize;
|
||
|
}
|
||
|
|
||
|
public StateBuilder setMinimumDate(Calendar calendar) {
|
||
|
setMinimumDate(CalendarDay.from(calendar));
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public StateBuilder setMinimumDate(Date date) {
|
||
|
setMinimumDate(CalendarDay.from(date));
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public StateBuilder setMaximumDate(Calendar calendar) {
|
||
|
setMaximumDate(CalendarDay.from(calendar));
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public StateBuilder setMaximumDate(Date date) {
|
||
|
setMaximumDate(CalendarDay.from(date));
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public void commit() {
|
||
|
MaterialCalendarView materialCalendarView = this.this$0;
|
||
|
materialCalendarView.commit(new State(this));
|
||
|
}
|
||
|
|
||
|
public StateBuilder setMinimumDate(CalendarDay calendarDay) {
|
||
|
this.minDate = calendarDay;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public StateBuilder setMaximumDate(CalendarDay calendarDay) {
|
||
|
this.maxDate = calendarDay;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public StateBuilder setFirstDayOfWeek(int i) {
|
||
|
this.firstDayOfWeek = i;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public StateBuilder setEnableWeekOfMonthDivider(boolean z) {
|
||
|
this.enableWeekOfMonthDivider = z;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public StateBuilder setEnableWeekDivider(boolean z) {
|
||
|
this.enableWeekDivider = z;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public StateBuilder setDividerSize(int i) {
|
||
|
this.dividerSize = i;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public StateBuilder setDividerColor(int i) {
|
||
|
this.dividerColor = i;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public StateBuilder setCalendarDisplayMode(CalendarMode calendarMode) {
|
||
|
this.calendarMode = calendarMode;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
public StateBuilder isCacheCalendarPositionEnabled(boolean z) {
|
||
|
this.cacheCurrentPosition = z;
|
||
|
return this;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: private */
|
||
|
/* JADX WARN: Code restructure failed: missing block: B:15:0x0047, code lost:
|
||
|
|
||
|
if (r3.isBefore(r4) == false) goto L33;
|
||
|
*/
|
||
|
/*
|
||
|
Code decompiled incorrectly, please refer to instructions dump.
|
||
|
To view partially-correct add '--show-bad-code' argument
|
||
|
*/
|
||
|
public void commit(com.prolificinteractive.materialcalendarview.MaterialCalendarView.State r8) {
|
||
|
/*
|
||
|
Method dump skipped, instructions count: 282
|
||
|
To view this dump add '--comments-level debug' option
|
||
|
*/
|
||
|
throw new UnsupportedOperationException("Method not decompiled: com.prolificinteractive.materialcalendarview.MaterialCalendarView.commit(com.prolificinteractive.materialcalendarview.MaterialCalendarView$State):void");
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* renamed from: com.prolificinteractive.materialcalendarview.MaterialCalendarView$4, reason: invalid class name */
|
||
|
/* loaded from: classes3.dex */
|
||
|
public static /* synthetic */ class AnonymousClass4 {
|
||
|
static final int[] $SwitchMap$com$prolificinteractive$materialcalendarview$CalendarMode;
|
||
|
|
||
|
static {
|
||
|
int[] iArr = new int[CalendarMode.values().length];
|
||
|
$SwitchMap$com$prolificinteractive$materialcalendarview$CalendarMode = iArr;
|
||
|
try {
|
||
|
iArr[CalendarMode.MONTHS.ordinal()] = 1;
|
||
|
} catch (NoSuchFieldError unused) {
|
||
|
}
|
||
|
try {
|
||
|
$SwitchMap$com$prolificinteractive$materialcalendarview$CalendarMode[CalendarMode.WEEKS.ordinal()] = 2;
|
||
|
} catch (NoSuchFieldError unused2) {
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public State state() {
|
||
|
return this.state;
|
||
|
}
|
||
|
|
||
|
public void setOnRangeSelectedListener(OnRangeSelectedListener onRangeSelectedListener) {
|
||
|
this.rangeListener = onRangeSelectedListener;
|
||
|
}
|
||
|
|
||
|
public void setOnMonthChangedListener(OnMonthChangedListener onMonthChangedListener) {
|
||
|
this.monthListener = onMonthChangedListener;
|
||
|
}
|
||
|
|
||
|
public void setOnDateChangedListener(OnDateSelectedListener onDateSelectedListener) {
|
||
|
this.listener = onDateSelectedListener;
|
||
|
}
|
||
|
|
||
|
public void setEnableWeekOfMonthDivider(boolean z) {
|
||
|
this.enableWeekOfMonthDivider = z;
|
||
|
}
|
||
|
|
||
|
public void setEnableWeekDivider(boolean z) {
|
||
|
this.enableWeekDivider = z;
|
||
|
}
|
||
|
|
||
|
public void setDynamicHeightEnabled(boolean z) {
|
||
|
this.mDynamicHeightEnabled = z;
|
||
|
}
|
||
|
|
||
|
public void setDividerSize(int i) {
|
||
|
this.dividerSize = i;
|
||
|
}
|
||
|
|
||
|
public void setDividerColor(int i) {
|
||
|
this.dividerColor = i;
|
||
|
}
|
||
|
|
||
|
public void setContentDescriptionCalendar(CharSequence charSequence) {
|
||
|
this.calendarContentDescription = charSequence;
|
||
|
}
|
||
|
|
||
|
public void setAllowClickDaysOutsideCurrentMonth(boolean z) {
|
||
|
this.allowClickDaysOutsideCurrentMonth = z;
|
||
|
}
|
||
|
|
||
|
public boolean isEnableWeekOfMonthDivider() {
|
||
|
return this.enableWeekOfMonthDivider;
|
||
|
}
|
||
|
|
||
|
public boolean isEnableWeekDivider() {
|
||
|
return this.enableWeekDivider;
|
||
|
}
|
||
|
|
||
|
public boolean isDynamicHeightEnabled() {
|
||
|
return this.mDynamicHeightEnabled;
|
||
|
}
|
||
|
|
||
|
public int getTileWidth() {
|
||
|
return this.tileWidth;
|
||
|
}
|
||
|
|
||
|
public int getTileHeight() {
|
||
|
return this.tileHeight;
|
||
|
}
|
||
|
|
||
|
@SelectionMode
|
||
|
public int getSelectionMode() {
|
||
|
return this.selectionMode;
|
||
|
}
|
||
|
|
||
|
public int getSelectionColor() {
|
||
|
return this.accentColor;
|
||
|
}
|
||
|
|
||
|
public Drawable getRightArrowMask() {
|
||
|
return this.rightArrowMask;
|
||
|
}
|
||
|
|
||
|
public CalendarDay getMinimumDate() {
|
||
|
return this.minDate;
|
||
|
}
|
||
|
|
||
|
public CalendarDay getMaximumDate() {
|
||
|
return this.maxDate;
|
||
|
}
|
||
|
|
||
|
public Drawable getLeftArrowMask() {
|
||
|
return this.leftArrowMask;
|
||
|
}
|
||
|
|
||
|
public int getFirstDayOfWeek() {
|
||
|
return this.firstDayOfWeek;
|
||
|
}
|
||
|
|
||
|
public int getDividerSize() {
|
||
|
return this.dividerSize;
|
||
|
}
|
||
|
|
||
|
public int getDividerColor() {
|
||
|
return this.dividerColor;
|
||
|
}
|
||
|
|
||
|
public int getArrowColor() {
|
||
|
return this.arrowColor;
|
||
|
}
|
||
|
|
||
|
public boolean allowClickDaysOutsideCurrentMonth() {
|
||
|
return this.allowClickDaysOutsideCurrentMonth;
|
||
|
}
|
||
|
}
|