修复游戏库刷新替换抖动的问题
This commit is contained in:
@ -18,12 +18,14 @@ class GameHorizontalAdapter(context: Context,
|
||||
var entrance = ""
|
||||
var exposureEventList: ArrayList<ExposureEvent>? = null
|
||||
|
||||
private var mDataIds = ""
|
||||
private var countAndKey: Pair<Int, String>? = null
|
||||
|
||||
init {
|
||||
var dataIds = ""
|
||||
mSubjectEntity.data?.forEach {
|
||||
mDataIds += it.id
|
||||
dataIds += it.id
|
||||
}
|
||||
if (dataIds.isNotEmpty()) countAndKey = Pair(mSubjectEntity.data?.size ?: 0, dataIds)
|
||||
}
|
||||
|
||||
fun getIndex(): Int {
|
||||
@ -68,16 +70,21 @@ class GameHorizontalAdapter(context: Context,
|
||||
}
|
||||
}
|
||||
|
||||
// notifyDataSetChanged 会出现页面抖动情况
|
||||
fun checkResetData(subjectEntity: SubjectEntity) {
|
||||
var dataIds = ""
|
||||
subjectEntity.data?.forEach {
|
||||
dataIds += it.id
|
||||
}
|
||||
|
||||
if (mDataIds != dataIds) {
|
||||
mSubjectEntity = subjectEntity
|
||||
if (countAndKey?.first == subjectEntity.data?.size) {
|
||||
if (countAndKey?.second != dataIds) {
|
||||
mSubjectEntity = subjectEntity
|
||||
countAndKey = Pair(subjectEntity.data?.size ?: 0, dataIds)
|
||||
notifyItemRangeChanged(0, itemCount)
|
||||
}
|
||||
} else {
|
||||
notifyDataSetChanged()
|
||||
mDataIds = dataIds
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,7 @@ package com.gh.gamecenter.game.horizontal
|
||||
|
||||
import android.content.Context
|
||||
import android.view.ViewGroup
|
||||
import androidx.collection.SimpleArrayMap
|
||||
import com.gh.common.exposure.ExposureEvent
|
||||
import com.gh.common.util.StringUtils
|
||||
import com.gh.common.util.dip2px
|
||||
@ -19,12 +20,14 @@ class GameHorizontalSlideAdapter(context: Context,
|
||||
var entrance = ""
|
||||
var exposureEventList: ArrayList<ExposureEvent>? = null
|
||||
|
||||
private var mDataIds = ""
|
||||
private var countAndKey: Pair<Int, String>? = null
|
||||
|
||||
init {
|
||||
var dataIds = ""
|
||||
mSubjectEntity.data?.forEach {
|
||||
mDataIds += it.id
|
||||
dataIds += it.id
|
||||
}
|
||||
if (dataIds.isNotEmpty()) countAndKey = Pair(mSubjectEntity.data?.size ?: 0, dataIds)
|
||||
}
|
||||
|
||||
fun getIndex(): Int {
|
||||
@ -64,16 +67,21 @@ class GameHorizontalSlideAdapter(context: Context,
|
||||
}
|
||||
}
|
||||
|
||||
// notifyDataSetChanged 会出现页面抖动情况
|
||||
fun checkResetData(subjectEntity: SubjectEntity) {
|
||||
var dataIds = ""
|
||||
subjectEntity.data?.forEach {
|
||||
dataIds += it.id
|
||||
}
|
||||
|
||||
if (mDataIds != dataIds) {
|
||||
mSubjectEntity = subjectEntity
|
||||
if (countAndKey?.first == subjectEntity.data?.size) {
|
||||
if (countAndKey?.second != dataIds) {
|
||||
mSubjectEntity = subjectEntity
|
||||
countAndKey = Pair(subjectEntity.data?.size ?: 0, dataIds)
|
||||
notifyItemRangeChanged(0, itemCount)
|
||||
}
|
||||
} else {
|
||||
notifyDataSetChanged()
|
||||
mDataIds = dataIds
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user