Here I want to deselect a date of a range which is selected using Time Square library. I'm getting selection of range by:
if (selectionMode == SelectionMode.RANGE && selectedCells.size() > 1) {
// Select all days in between start and end.
Date start = selectedCells.get(0).getDate();
Date end = selectedCells.get(1).getDate();
selectedCells.get(0).setRangeState(MonthCellDescriptor.RangeState.FIRST);
selectedCells.get(1).setRangeState(MonthCellDescriptor.RangeState.LAST);
Log.d("First", MonthCellDescriptor.RangeState.FIRST +"");
Log.d("Last",MonthCellDescriptor.RangeState.LAST+"");
for (List<List<MonthCellDescriptor>> month : cells) {
for (List<MonthCellDescriptor> week : month) {
for (MonthCellDescriptor singleCell : week) {
if (singleCell.getDate().after(start)
&& singleCell.getDate().before(end)
&& singleCell.isSelectable()) {
singleCell.setSelected(true);
singleCell.setRangeState(MonthCellDescriptor.RangeState.MIDDLE);
selectedCells.add(singleCell);
}
}
}
}
}
And when I try to remove a selected date of range it removes other dates too:
if (selectedCell.getDate().equals(date)) {
// De-select the currently-selected cell.
selectedCell.setSelected(false);
selectedCells.remove(selectedCell);
date = null;
break;
}
Example: If selected range is 10 to 30, on tap of 22, 22 should get deselected from that range.