Skip to content

Commit 339a07f

Browse files
authored
SES-4557 / SES-4559 : Fixed out of bounds error (#1492)
Fixes crash caused by invalid position from the same function.
1 parent 3064983 commit 339a07f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/src/main/java/org/thoughtcrime/securesms/util/adapter/RecyclerViewUtils.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ fun RecyclerView.applyImeBottomPadding() {
2020
}
2121

2222
// Handle scroll logic
23-
fun RecyclerView.handleScrollToBottom(){
23+
fun RecyclerView.handleScrollToBottom() {
2424
val layoutManager = this.layoutManager as LinearLayoutManager
25-
val last = this.adapter?.itemCount?.minus(1) ?: return
25+
val last = this.adapter?.itemCount?.minus(1)?.coerceAtLeast(0) ?: return
26+
2627
val bottomOffset = this.paddingBottom
2728

2829
if (layoutManager.isSmoothScrolling) {

0 commit comments

Comments
 (0)