From e2ebaa303ee8d907aded721033917ba323894615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=99=A8?= Date: Mon, 9 Jun 2025 17:19:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:CPM=E5=BE=AE=E4=BF=A1=E5=B0=8F=E6=B8=B8?= =?UTF-8?q?=E6=88=8F=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96=E2=80=94=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E7=AB=AF=20https://jira.shanqu.cc/browse/GHZSCY-8069?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gh/gamecenter/home/custom/CustomPageViewModel.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/gh/gamecenter/home/custom/CustomPageViewModel.kt b/app/src/main/java/com/gh/gamecenter/home/custom/CustomPageViewModel.kt index 7e0014d531..89fae66862 100644 --- a/app/src/main/java/com/gh/gamecenter/home/custom/CustomPageViewModel.kt +++ b/app/src/main/java/com/gh/gamecenter/home/custom/CustomPageViewModel.kt @@ -540,7 +540,7 @@ class CustomPageViewModel(application: Application) : AndroidViewModel(applicati targetItem is CustomSplitSubjectItem -> {// 添加后续的数据 val subject = targetItem.data - subject.data = gameList.toMutableList() + subject.data = ((subject.data ?: emptyList()) + gameList).toMutableList() subject.isWechatColumnCPM = true val cpmSubjectItemList = repository.convertColumnDetailSubjectItems( @@ -551,8 +551,12 @@ class CustomPageViewModel(application: Application) : AndroidViewModel(applicati ) if (cpmSubjectItemList.isEmpty()) return val newData = oldData.toMutableList() - val position = newData.indexOfLast { it.componentPosition == componentPosition } - newData.addAll(position + 1, cpmSubjectItemList) + + val position = newData.indexOfFirst { it.componentPosition == componentPosition } + // 移除旧数据 + newData.removeAll { it.componentPosition == componentPosition } + // 在原来的位置上插入新数据 + newData.addAll(position, cpmSubjectItemList) newData.forEachIndexed { pos, customPageItem -> customPageItem.position = pos }