@@ -1082,7 +1082,7 @@ protected Parcelable onSaveInstanceState() {
1082
1082
ss .calendarMode = calendarMode ;
1083
1083
ss .dynamicHeightEnabled = mDynamicHeightEnabled ;
1084
1084
ss .currentMonth = currentMonth ;
1085
- ss .saveCurrentPosition = state .saveCurrentPosition ;
1085
+ ss .cacheCurrentPosition = state .cacheCurrentPosition ;
1086
1086
return ss ;
1087
1087
}
1088
1088
@@ -1095,7 +1095,7 @@ protected void onRestoreInstanceState(Parcelable state) {
1095
1095
.setCalendarDisplayMode (ss .calendarMode )
1096
1096
.setMinimumDate (ss .minDate )
1097
1097
.setMaximumDate (ss .maxDate )
1098
- .setSaveCurrentPosition (ss .saveCurrentPosition )
1098
+ .isCacheCalendarPositionEnabled (ss .cacheCurrentPosition )
1099
1099
.commit ();
1100
1100
1101
1101
setSelectionColor (ss .color );
@@ -1157,7 +1157,7 @@ public static class SavedState extends BaseSavedState {
1157
1157
boolean dynamicHeightEnabled = false ;
1158
1158
CalendarMode calendarMode = CalendarMode .MONTHS ;
1159
1159
CalendarDay currentMonth = null ;
1160
- boolean saveCurrentPosition ;
1160
+ boolean cacheCurrentPosition ;
1161
1161
1162
1162
SavedState (Parcelable superState ) {
1163
1163
super (superState );
@@ -1183,7 +1183,7 @@ public void writeToParcel(@NonNull Parcel out, int flags) {
1183
1183
out .writeInt (dynamicHeightEnabled ? 1 : 0 );
1184
1184
out .writeInt (calendarMode == CalendarMode .WEEKS ? 1 : 0 );
1185
1185
out .writeParcelable (currentMonth , 0 );
1186
- out .writeByte ((byte ) (saveCurrentPosition ? 1 : 0 ));
1186
+ out .writeByte ((byte ) (cacheCurrentPosition ? 1 : 0 ));
1187
1187
}
1188
1188
1189
1189
public static final Parcelable .Creator <SavedState > CREATOR
@@ -1217,7 +1217,7 @@ private SavedState(Parcel in) {
1217
1217
dynamicHeightEnabled = in .readInt () == 1 ;
1218
1218
calendarMode = in .readInt () == 1 ? CalendarMode .WEEKS : CalendarMode .MONTHS ;
1219
1219
currentMonth = in .readParcelable (loader );
1220
- saveCurrentPosition = in .readByte () != 0 ;
1220
+ cacheCurrentPosition = in .readByte () != 0 ;
1221
1221
}
1222
1222
}
1223
1223
@@ -1805,18 +1805,18 @@ public StateBuilder newState() {
1805
1805
}
1806
1806
1807
1807
public class State {
1808
- public final CalendarMode calendarMode ;
1809
- public final int firstDayOfWeek ;
1810
- public final CalendarDay minDate ;
1811
- public final CalendarDay maxDate ;
1812
- public final boolean saveCurrentPosition ;
1808
+ private final CalendarMode calendarMode ;
1809
+ private final int firstDayOfWeek ;
1810
+ private final CalendarDay minDate ;
1811
+ private final CalendarDay maxDate ;
1812
+ private final boolean cacheCurrentPosition ;
1813
1813
1814
- public State (StateBuilder builder ) {
1814
+ private State (final StateBuilder builder ) {
1815
1815
calendarMode = builder .calendarMode ;
1816
1816
firstDayOfWeek = builder .firstDayOfWeek ;
1817
1817
minDate = builder .minDate ;
1818
1818
maxDate = builder .maxDate ;
1819
- saveCurrentPosition = builder .saveCurrentPosition ;
1819
+ cacheCurrentPosition = builder .cacheCurrentPosition ;
1820
1820
}
1821
1821
1822
1822
/**
@@ -1831,9 +1831,9 @@ public StateBuilder edit() {
1831
1831
public class StateBuilder {
1832
1832
private CalendarMode calendarMode = CalendarMode .MONTHS ;
1833
1833
private int firstDayOfWeek = Calendar .getInstance ().getFirstDayOfWeek ();
1834
- public CalendarDay minDate = null ;
1835
- public CalendarDay maxDate = null ;
1836
- public boolean saveCurrentPosition = false ;
1834
+ private boolean cacheCurrentPosition = false ;
1835
+ private CalendarDay minDate = null ;
1836
+ private CalendarDay maxDate = null ;
1837
1837
1838
1838
public StateBuilder () {
1839
1839
}
@@ -1843,7 +1843,7 @@ private StateBuilder(final State state) {
1843
1843
firstDayOfWeek = state .firstDayOfWeek ;
1844
1844
minDate = state .minDate ;
1845
1845
maxDate = state .maxDate ;
1846
- saveCurrentPosition = state .saveCurrentPosition ;
1846
+ cacheCurrentPosition = state .cacheCurrentPosition ;
1847
1847
}
1848
1848
1849
1849
/**
@@ -1921,13 +1921,15 @@ public StateBuilder setMaximumDate(@Nullable CalendarDay calendar) {
1921
1921
}
1922
1922
1923
1923
/**
1924
- * Use this method to enable saving the current position when switching
1925
- * between week and month mode.
1924
+ * Use this method to enable saving the current position when switching
1925
+ * between week and month mode. By default, the calendar update to the latest selected date
1926
+ * or the current date. When set to true, the view will used the month that the calendar is
1927
+ * currently on.
1926
1928
*
1927
- * @param saveCurrentPosition Set to true to save the current position, false otherwise.
1929
+ * @param cacheCurrentPosition Set to true to cache the current position, false otherwise.
1928
1930
*/
1929
- public StateBuilder setSaveCurrentPosition (final boolean saveCurrentPosition ) {
1930
- this .saveCurrentPosition = saveCurrentPosition ;
1931
+ public StateBuilder isCacheCalendarPositionEnabled (final boolean cacheCurrentPosition ) {
1932
+ this .cacheCurrentPosition = cacheCurrentPosition ;
1931
1933
return this ;
1932
1934
}
1933
1935
@@ -1939,7 +1941,7 @@ public void commit() {
1939
1941
private void commit (State state ) {
1940
1942
// Use the calendarDayToShow to determine which date to focus on for the case of switching between month and week views
1941
1943
CalendarDay calendarDayToShow = null ;
1942
- if (adapter != null && state .saveCurrentPosition ) {
1944
+ if (adapter != null && state .cacheCurrentPosition ) {
1943
1945
calendarDayToShow = adapter .getItem (pager .getCurrentItem ());
1944
1946
if (calendarMode != state .calendarMode ) {
1945
1947
CalendarDay currentlySelectedDate = getSelectedDate ();
0 commit comments