mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-06 03:50:19 +02:00
fixed possible index out of bounds exception
This commit is contained in:
parent
1f412fad71
commit
c795f03cae
1 changed files with 4 additions and 1 deletions
|
@ -210,9 +210,12 @@ public class BookCollection extends AbstractBookCollection {
|
|||
allBooks = new ArrayList<Book>(myBooksByFile.values());
|
||||
}
|
||||
final int start = query.Page * query.Limit;
|
||||
if (start >= allBooks.size()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
final int end = start + query.Limit;
|
||||
if (query.Filter instanceof Filter.Empty) {
|
||||
return allBooks.subList(start, end);
|
||||
return allBooks.subList(start, Math.min(end, allBooks.size()));
|
||||
} else {
|
||||
int count = 0;
|
||||
final List<Book> filtered = new ArrayList<Book>(query.Limit);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue