Skip to content
Snippets Groups Projects
Commit ccb1bdf3 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Prevent Thread races by creating a copy

parent 92a67aba
No related branches found
No related tags found
No related merge requests found
...@@ -62,12 +62,12 @@ class BufferListAdapter( ...@@ -62,12 +62,12 @@ class BufferListAdapter(
init { init {
liveData.zip(collapsedNetworks.toLiveData(), selectedBuffer.toLiveData()).observe( liveData.zip(collapsedNetworks.toLiveData(), selectedBuffer.toLiveData()).observe(
lifecycleOwner, Observer { it: Triple<List<BufferProps>?, Set<NetworkId>, BufferId>? -> lifecycleOwner, Observer { it: Triple<List<BufferProps>?, Set<NetworkId>, BufferId>? ->
val old: List<BufferListItem> = ArrayList(data)
runInBackground { runInBackground {
val list = it?.first ?: emptyList() val list = it?.first ?: emptyList()
val collapsedNetworks = it?.second ?: emptySet() val collapsedNetworks = it?.second ?: emptySet()
val selected = it?.third ?: -1 val selected = it?.third ?: -1
val old: List<BufferListItem> = data
val new: List<BufferListItem> = list.sortedBy { props -> val new: List<BufferListItem> = list.sortedBy { props ->
!props.info.type.hasFlag(Buffer_Type.StatusBuffer) !props.info.type.hasFlag(Buffer_Type.StatusBuffer)
}.sortedBy { props -> }.sortedBy { props ->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment