int (List<TextRange> ranges, int offset) { int result = 0; for (int i = 0; i < ranges.size(); i++) { final TextRange range = ranges.get(i); final int startOffset = range.getStartOffset(); if (startOffset < offset) { result = i + 1; } else { ranges.set(i, new TextRange(startOffset - offset, range.getEndOffset() - offset)); } } return result; }