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