Skip to content

Commit

Permalink
fix: 搜索页面 集合不能更新
Browse files Browse the repository at this point in the history
  • Loading branch information
Greatwallcorner committed Nov 9, 2024
1 parent dd9109c commit 44ac6ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,16 +270,16 @@ object SiteViewModel {
if (result.list.isEmpty()) return
for (vod in result.list) vod.site = site
if (quick) {
quickSearch.value.copyAdd(Collect.create(result.list))
search.value = quickSearch.value.copyAdd(Collect.create(result.list))
if(quickSearch.value.size == 0){
quickSearch.value.copyAdd(Collect.all())
search.value = quickSearch.value.copyAdd(Collect.all())
}
// 同样的数据添加到全部
quickSearch.value[0].list.addAll(result.list)
} else {
search.value.copyAdd(Collect.create(result.list))
search.value = search.value.copyAdd(Collect.create(result.list))
if(search.value.size == 0){
search.value.copyAdd(Collect.all())
search.value = search.value.copyAdd(Collect.all())
}
// 同样的数据添加到全部
search.value[0].list.addAll(result.list)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ var Color.Companion.FirefoxGray:Color


fun <E> CopyOnWriteArrayList<E>.copyAdd(item: E? = null, list: CopyOnWriteArrayList<E>? = null): CopyOnWriteArrayList<E> {
return CopyOnWriteArrayList<E>().apply {
addAll(this)
if(item != null) add(item)
if(CollectionUtil.isNotEmpty(list)) addAll(list!!)
return CopyOnWriteArrayList<E>().also {
it.addAll(this)
if(item != null) it.add(item)
if(CollectionUtil.isNotEmpty(list)) it.addAll(list!!)
}
}

0 comments on commit 44ac6ac

Please sign in to comment.