Skip to content

Commit f7ff5db

Browse files
committed
[PlayQueue] Fix incorrect UI states of PlayQueue items
onNext() is called after onSubscribe() when creating a PlayQueueAdapter. For that reason the last broadcasted event is applied to the UI state although it is already reflected in the PlayQueue that was used to initialize the adapter. This is the intended behavior of the previously used event broadcaster of the type BehaviorSubject<>. The broadcaster's type was changed to PublishSubject<> which does not emit the last event after onSubscribe(). Ref: #9669
1 parent 86fb618 commit f7ff5db

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueue.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
2424
import io.reactivex.rxjava3.core.BackpressureStrategy;
2525
import io.reactivex.rxjava3.core.Flowable;
26-
import io.reactivex.rxjava3.subjects.BehaviorSubject;
26+
import io.reactivex.rxjava3.subjects.PublishSubject;
2727

2828
/**
2929
* PlayQueue is responsible for keeping track of a list of streams and the index of
@@ -46,7 +46,7 @@ public abstract class PlayQueue implements Serializable {
4646
private List<PlayQueueItem> backup;
4747
private List<PlayQueueItem> streams;
4848

49-
private transient BehaviorSubject<PlayQueueEvent> eventBroadcast;
49+
private transient PublishSubject<PlayQueueEvent> eventBroadcast;
5050
private transient Flowable<PlayQueueEvent> broadcastReceiver;
5151
private transient boolean disposed = false;
5252

@@ -71,7 +71,7 @@ public abstract class PlayQueue implements Serializable {
7171
* </p>
7272
*/
7373
public void init() {
74-
eventBroadcast = BehaviorSubject.create();
74+
eventBroadcast = PublishSubject.create();
7575

7676
broadcastReceiver = eventBroadcast.toFlowable(BackpressureStrategy.BUFFER)
7777
.observeOn(AndroidSchedulers.mainThread())

0 commit comments

Comments
 (0)