mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-04-12 07:30:06 +03:00
Fix wrong thread in throttled observers
This commit is contained in:
parent
fc637166bb
commit
6bc09854ac
@ -248,7 +248,10 @@ class MediaPlayerManager(
|
||||
mediaControllerFuture = MediaController.Builder(
|
||||
context,
|
||||
sessionToken
|
||||
).buildAsync()
|
||||
)
|
||||
// Specify mainThread explicitely
|
||||
.setApplicationLooper(Looper.getMainLooper())
|
||||
.buildAsync()
|
||||
|
||||
mediaControllerFuture?.addListener({
|
||||
controller = mediaControllerFuture?.get()
|
||||
|
@ -12,6 +12,11 @@ import org.moire.ultrasonic.domain.Track
|
||||
|
||||
class RxBus {
|
||||
|
||||
/**
|
||||
* IMPORTANT: methods like .delay() or .throttle() will implicitly change the thread to the
|
||||
* RxComputationScheduler. Always use the function call with the additional arguments of the
|
||||
* desired scheduler
|
||||
**/
|
||||
companion object {
|
||||
|
||||
fun mainThread(): Scheduler = AndroidSchedulers.mainThread()
|
||||
@ -52,7 +57,8 @@ class RxBus {
|
||||
playerStatePublisher
|
||||
.replay(1)
|
||||
.autoConnect(0)
|
||||
.throttleLatest(300, TimeUnit.MILLISECONDS)
|
||||
// Need to specify thread, see comment at beginning
|
||||
.throttleLatest(300, TimeUnit.MILLISECONDS, mainThread())
|
||||
|
||||
val playlistPublisher: PublishSubject<List<Track>> =
|
||||
PublishSubject.create()
|
||||
@ -64,7 +70,8 @@ class RxBus {
|
||||
playlistPublisher
|
||||
.replay(1)
|
||||
.autoConnect(0)
|
||||
.throttleLatest(300, TimeUnit.MILLISECONDS)
|
||||
// Need to specify thread, see comment at beginning
|
||||
.throttleLatest(300, TimeUnit.MILLISECONDS, mainThread())
|
||||
|
||||
val trackDownloadStatePublisher: PublishSubject<TrackDownloadState> =
|
||||
PublishSubject.create()
|
||||
|
Loading…
x
Reference in New Issue
Block a user