Merge branch 'fix/GHZSCY-7989-pr' into 'dev'
fix:【光环助手】页面刷新问题 https://jira.shanqu.cc/browse/GHZSCY-7989 See merge request halo/android/assistant-android!2197
This commit is contained in:
@ -247,7 +247,12 @@ class CustomPageFragment : LazyFragment(), ISmartRefreshContent, IScrollable, IB
|
||||
})
|
||||
|
||||
dataList.observe(viewLifecycleOwner) {
|
||||
adapter.submitList(it)
|
||||
adapter.submitList(it) {
|
||||
if (shouldScrollToTop) {
|
||||
shouldScrollToTop = false
|
||||
binding.gameList.scrollToPosition(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loadStatus.observe(viewLifecycleOwner) { (status, isPullToRefresh) ->
|
||||
|
||||
@ -132,6 +132,8 @@ class CustomPageViewModel(application: Application) : AndroidViewModel(applicati
|
||||
|
||||
val pkVoteResultLiveData = MutableLiveData<Event<Pair<String, Boolean>>>()
|
||||
|
||||
var shouldScrollToTop: Boolean = false
|
||||
|
||||
fun init(
|
||||
pageConfigure: PageConfigure,
|
||||
searchToolbarTabWrapperViewModel: SearchToolbarTabWrapperViewModel?,
|
||||
@ -582,6 +584,11 @@ class CustomPageViewModel(application: Application) : AndroidViewModel(applicati
|
||||
subjectItem.data
|
||||
)
|
||||
if (customPageItemList.isEmpty()) return
|
||||
|
||||
if (index == 0) {
|
||||
shouldScrollToTop = true
|
||||
}
|
||||
|
||||
newData[index] = customPageItemList[0]
|
||||
newData.addAll(index + 1, customPageItemList.subList(1, customPageItemList.size))
|
||||
newData.forEachIndexed { pos, customPageItem ->
|
||||
@ -619,6 +626,10 @@ class CustomPageViewModel(application: Application) : AndroidViewModel(applicati
|
||||
subjectItem.data
|
||||
)
|
||||
if (customPageItemList.isEmpty()) return
|
||||
|
||||
if (index == 0) {
|
||||
shouldScrollToTop = true
|
||||
}
|
||||
newData[index] = customPageItemList[0]
|
||||
newData.addAll(index + 1, customPageItemList.subList(1, customPageItemList.size))
|
||||
newData.forEachIndexed { pos, customPageItem ->
|
||||
|
||||
@ -84,13 +84,13 @@ class CustomPageAdapter(
|
||||
}
|
||||
val firstShowPosition: LiveData<Int> = _firstShowPosition
|
||||
|
||||
override fun submitList(list: List<CustomPageItem>?) {
|
||||
override fun submitList(list: List<CustomPageItem>?, commitCallback: Runnable?) {
|
||||
val dataWithFooter = if (list.isNullOrEmpty()) {
|
||||
ArrayList(list)
|
||||
} else {
|
||||
list + CustomFooterItem
|
||||
}
|
||||
super.submitList(dataWithFooter)
|
||||
super.submitList(dataWithFooter, commitCallback)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user