ensure idx is in data indices

This commit is contained in:
Tlaster 2021-03-22 13:32:50 +08:00
parent 205424735b
commit 94a73bf4b9
1 changed files with 12 additions and 4 deletions

View File

@ -128,8 +128,12 @@ class StatusDetailsAdapter(
ITEM_IDX_CONVERSATION -> { ITEM_IDX_CONVERSATION -> {
data?.let { data -> data?.let { data ->
var idx = position - getIndexStart(ITEM_IDX_CONVERSATION) var idx = position - getIndexStart(ITEM_IDX_CONVERSATION)
if (data[idx].is_filtered) idx++ if (idx !in data.indices) {
return data[idx] if (data[idx].is_filtered) {
idx++
}
return data[idx]
}
} }
} }
ITEM_IDX_REPLY -> { ITEM_IDX_REPLY -> {
@ -137,8 +141,12 @@ class StatusDetailsAdapter(
var idx = position - getIndexStart(ITEM_IDX_CONVERSATION) - var idx = position - getIndexStart(ITEM_IDX_CONVERSATION) -
getTypeCount(ITEM_IDX_CONVERSATION) - getTypeCount(ITEM_IDX_STATUS) + getTypeCount(ITEM_IDX_CONVERSATION) - getTypeCount(ITEM_IDX_STATUS) +
replyStart replyStart
if (data[idx].is_filtered) idx++ if (idx !in data.indices) {
return data[idx] if (data[idx].is_filtered) {
idx++
}
return data[idx]
}
} }
} }
ITEM_IDX_STATUS -> { ITEM_IDX_STATUS -> {