Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ protected void onCreate(Bundle savedInstanceState) {

calendar.init(lastYear.getTime(), nextYear.getTime(), new SimpleDateFormat("MMMM, YYYY", Locale.getDefault())) //
.inMode(CalendarPickerView.SelectionMode.RANGE) //
.withMaxRangeSize(7)
.withDeactivateDates(list)
.withSubTitles(getSubTitles())
.withHighlightedDates(arrayList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public enum SelectionMode {
private Typeface titleTypeface;
private Typeface dateTypeface;

// the max range size
private int maxRangeSize = Integer.MAX_VALUE;

private OnDateSelectedListener dateListener;
private DateSelectableFilter dateConfiguredListener;
private OnInvalidDateSelectedListener invalidDateListener =
Expand Down Expand Up @@ -344,6 +347,16 @@ public FluentInitializer withSubTitles(ArrayList<SubTitle> subTitles) {
setSubTitles(subTitles);
return this;
}

/**
* set max range size
* @param size
* @return
*/
public FluentInitializer withMaxRangeSize(int size) {
maxRangeSize = size;
return this;
}
}

private void setSubTitles(ArrayList<SubTitle> subTitles) {
Expand Down Expand Up @@ -666,6 +679,10 @@ private boolean doSelectDate(Date date, MonthCellDescriptor cell) {
}
}
}

if (selectedCells.size() > maxRangeSize) {
clearSelectedDates();
}
}
}

Expand Down