fix crash at status details adapter

This commit is contained in:
Tlaster 2021-03-01 16:55:25 +08:00
parent b1557f17be
commit 9d9a98d47b
1 changed files with 20 additions and 15 deletions

View File

@ -124,22 +124,27 @@ class StatusDetailsAdapter(
}
override fun getStatus(position: Int, raw: Boolean): ParcelableStatus {
data?.let { data ->
when (getItemCountIndex(position, raw)) {
ITEM_IDX_CONVERSATION -> {
var idx = position - getIndexStart(ITEM_IDX_CONVERSATION)
if (data!![idx].is_filtered) idx++
return data!![idx]
if (data.getOrNull(idx)?.is_filtered == true) idx++
return data[idx]
}
ITEM_IDX_REPLY -> {
var idx = position - getIndexStart(ITEM_IDX_CONVERSATION) -
getTypeCount(ITEM_IDX_CONVERSATION) - getTypeCount(ITEM_IDX_STATUS) +
replyStart
if (data!![idx].is_filtered) idx++
return data!![idx]
if (data.getOrNull(idx)?.is_filtered == true) idx++
return data[idx]
}
ITEM_IDX_STATUS -> {
return status!!
}
else -> {
}
}
}
throw IndexOutOfBoundsException("index: $position")
}