Skip to content

Commit

Permalink
fix: 订阅中APP排序
Browse files Browse the repository at this point in the history
更改排序为: 已安装(有名字->无名字)->未安装(有名字(来自订阅)->无名字)
  • Loading branch information
lisonge committed Sep 19, 2023
1 parent 038cc06 commit a300ca1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/src/main/java/li/songe/gkd/ui/SubsVm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ class SubsVm @Inject constructor(stateHandle: SavedStateHandle) : ViewModel() {
) { subsItem, appSubsConfigs, appInfoCache, groupSubsConfigs, subsIdToRaw ->
if (subsItem == null) return@combine emptyList()
val apps = (subsIdToRaw[subsItem.id]?.apps ?: emptyList()).sortedWith { a, b ->
// 使用 \\uFFFF 确保 id 排在名字后面
Collator.getInstance(Locale.CHINESE).compare(
appInfoCache[a.id]?.name ?: a.name ?: ("\uFFFF" + a.id),
appInfoCache[b.id]?.name ?: b.name ?: ("\uFFFF" + b.id)
)
// 顺序: 已安装(有名字->无名字)->未安装(有名字(来自订阅)->无名字)
Collator.getInstance(Locale.CHINESE)
.compare(appInfoCache[a.id]?.name ?: a.name?.let { "\uFFFF" + it }
?: ("\uFFFF\uFFFF" + a.id),
appInfoCache[b.id]?.name ?: b.name?.let { "\uFFFF" + it }
?: ("\uFFFF\uFFFF" + b.id))
}
apps.map { app ->
val subsConfig = appSubsConfigs.find { s -> s.appId == app.id }
Expand Down

0 comments on commit a300ca1

Please sign in to comment.