reduced cursor moving call

This commit is contained in:
Mariotaku Lee 2017-06-01 17:37:51 +08:00
parent d1dd995167
commit 5574067e08
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
1 changed files with 5 additions and 12 deletions

View File

@ -151,18 +151,11 @@ abstract class ParcelableStatusesAdapter(
} }
override fun isGapItem(position: Int): Boolean { override fun isGapItem(position: Int): Boolean {
val dataPosition = position - statusStartIndex return getFieldValue(position, { info ->
val statusCount = getStatusCount(false) return@getFieldValue info.gap
if (dataPosition < 0 || dataPosition >= statusCount) return false }, { status ->
// Don't show gap if it's last item return@getFieldValue status.is_gap
if (dataPosition == statusCount - 1) return false }, false)
if (data is ObjectCursor) {
val cursor = (data as ObjectCursor).cursor
if (!cursor.moveToPosition(dataPosition)) return false
val indices = (data as ObjectCursor).indices
return cursor.safeGetInt(indices[Statuses.IS_GAP]) == 1
}
return getStatus(position).is_gap
} }
override fun getStatus(position: Int, raw: Boolean): ParcelableStatus { override fun getStatus(position: Int, raw: Boolean): ParcelableStatus {