mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-01-27 07:46:09 +01:00
launch restore on Main Thread
This commit is contained in:
parent
81d24f6cbb
commit
647435fe55
@ -136,6 +136,7 @@ class NowPlayingFragment : Fragment() {
|
||||
.navigate(R.id.trackCollectionFragment, bundle)
|
||||
}
|
||||
}
|
||||
|
||||
requireView().setOnTouchListener { _: View?, event: MotionEvent ->
|
||||
handleOnTouch(event)
|
||||
}
|
||||
|
@ -7,13 +7,10 @@
|
||||
|
||||
package org.moire.ultrasonic.service
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Intent
|
||||
import android.view.KeyEvent
|
||||
import io.reactivex.rxjava3.disposables.Disposable
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
import org.moire.ultrasonic.app.UApp.Companion.applicationContext
|
||||
import org.moire.ultrasonic.util.CacheCleaner
|
||||
import org.moire.ultrasonic.util.Constants
|
||||
import org.moire.ultrasonic.util.Util.ifNotNull
|
||||
|
@ -33,7 +33,8 @@ class PlaybackStateSerializer : KoinComponent {
|
||||
private val lock: Lock = ReentrantLock()
|
||||
private val setup = AtomicBoolean(false)
|
||||
|
||||
private val appScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||
private val ioScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||
private val mainScope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
|
||||
|
||||
fun serialize(
|
||||
songs: Iterable<DownloadFile>,
|
||||
@ -42,7 +43,7 @@ class PlaybackStateSerializer : KoinComponent {
|
||||
) {
|
||||
if (!setup.get()) return
|
||||
|
||||
appScope.launch {
|
||||
ioScope.launch {
|
||||
if (lock.tryLock()) {
|
||||
try {
|
||||
serializeNow(songs, currentPlayingIndex, currentPlayingPosition)
|
||||
@ -78,7 +79,7 @@ class PlaybackStateSerializer : KoinComponent {
|
||||
|
||||
fun deserialize(afterDeserialized: (State?) -> Unit?) {
|
||||
|
||||
appScope.launch {
|
||||
ioScope.launch {
|
||||
try {
|
||||
lock.lock()
|
||||
deserializeNow(afterDeserialized)
|
||||
@ -103,6 +104,8 @@ class PlaybackStateSerializer : KoinComponent {
|
||||
state.currentPlayingPosition
|
||||
)
|
||||
|
||||
afterDeserialized(state)
|
||||
mainScope.launch {
|
||||
afterDeserialized(state)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user