fix crash at status details adapter

This commit is contained in:
Tlaster 2021-03-01 17:13:16 +08:00
parent 9d9a98d47b
commit afac44ca43
1 changed files with 11 additions and 12 deletions

View File

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