From 5d6eaf0a2351faee3ed5161ca26c5f62f3fb5635 Mon Sep 17 00:00:00 2001 From: ChanTsune <41658782+ChanTsune@users.noreply.github.com> Date: Wed, 5 May 2021 00:01:36 +0900 Subject: [PATCH] [demo] Fix IndexOutOfBounds --- .../swipetoaction/demo/mail/repository/MailRepository.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/demo/src/main/java/com/github/chantsune/swipetoaction/demo/mail/repository/MailRepository.kt b/demo/src/main/java/com/github/chantsune/swipetoaction/demo/mail/repository/MailRepository.kt index 3770274..76d2f96 100644 --- a/demo/src/main/java/com/github/chantsune/swipetoaction/demo/mail/repository/MailRepository.kt +++ b/demo/src/main/java/com/github/chantsune/swipetoaction/demo/mail/repository/MailRepository.kt @@ -14,7 +14,10 @@ class MailRepository : IMailRepository { } override suspend fun getList(page: Int, size: Int): List { - return mailList.subList(page * size, (page + 1) * size).toList() + return mailList.subList( + (page * size).coerceAtMost(mailList.size - 1), + ((page + 1) * size).coerceAtMost(mailList.size - 1), + ).toList() } override suspend fun delete(mail: Mail) {