/** * Removes a range of indexes from the selection. * * @param start * The start of the range to remove. * * @param end * The end of the range to remove. * * @return * The ranges that were removed from the selection. */ public Sequence<Span> removeSelectedRange(int start, int end) { if (selectMode != SelectMode.MULTI) { throw new IllegalStateException("List view is not in multi-select mode."); } if (start < 0 || end >= listData.getLength()) { throw new IndexOutOfBoundsException(); } Sequence<Span> removedRanges = rangeSelection.removeRange(start, end); int n = removedRanges.getLength(); for (int i = 0; i < n; i++) { Span removedRange = removedRanges.get(i); listViewSelectionListeners.selectedRangeRemoved(this, removedRange.start, removedRange.end); } if (n > 0) { listViewSelectionListeners.selectedRangesChanged(this, null); } return removedRanges; }
Sequence<Span> removedRanges = rangeSelection.removeRange(start, end);
Sequence<Span> removedRanges = rangeSelection.removeRange(start, end);
Sequence<Span> removedRanges = rangeSelection.removeRange(start, end);
/** * Removes a range of indexes from the span sequence (e.g. when items * are removed from the model data). * * @param index * @param count * * @return * The number of ranges that were updated. */ public int removeIndexes(int index, int count) { // Clear any selections in the given range Sequence<Span> removed = removeRange(index, (index + count) - 1); int updated = removed.getLength(); // Decrement any subsequent selection indexes Span range = new Span(index); int i = ArrayList.binarySearch(selectedRanges, range, INTERSECTION_COMPARATOR); assert (i < 0) : "i should be negative, since index should no longer be selected"; i = -(i + 1); // Determine the number of ranges to modify int n = selectedRanges.getLength(); while (i < n) { Span selectedRange = selectedRanges.get(i); selectedRanges.update(i, new Span(selectedRange.start - count, selectedRange.end - count)); updated++; i++; } return updated; }
/** * Removes a range of indexes from the span sequence (e.g. when items * are removed from the model data). * * @param index * @param count * * @return * The number of ranges that were updated. */ public int removeIndexes(int index, int count) { // Clear any selections in the given range Sequence<Span> removed = removeRange(index, (index + count) - 1); int updated = removed.getLength(); // Decrement any subsequent selection indexes Span range = new Span(index); int i = ArrayList.binarySearch(selectedRanges, range, INTERSECTION_COMPARATOR); assert (i < 0) : "i should be negative, since index should no longer be selected"; i = -(i + 1); // Determine the number of ranges to modify int n = selectedRanges.getLength(); while (i < n) { Span selectedRange = selectedRanges.get(i); selectedRanges.update(i, new Span(selectedRange.start - count, selectedRange.end - count)); updated++; i++; } return updated; }