mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-02-02 12:19:16 +00:00
Fix checkstyle and remove comment
This commit is contained in:
parent
deed486159
commit
5f6a9161d0
@ -18,8 +18,6 @@ import java.io.Serializable;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
|
|
||||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.rxjava3.core.BackpressureStrategy;
|
import io.reactivex.rxjava3.core.BackpressureStrategy;
|
||||||
@ -54,9 +52,9 @@ public abstract class PlayQueue implements Serializable {
|
|||||||
// volatile is needed for the isDisposed method
|
// volatile is needed for the isDisposed method
|
||||||
private transient volatile boolean disposed = false;
|
private transient volatile boolean disposed = false;
|
||||||
|
|
||||||
PlayQueue(final int index, final List<PlayQueueItem> startWith) {
|
PlayQueue(final int index, @NonNull final List<PlayQueueItem> startWith) {
|
||||||
|
|
||||||
List<PlayQueueItem> h = new ArrayList<>();
|
final List<PlayQueueItem> h = new ArrayList<>();
|
||||||
if (startWith.size() > index) {
|
if (startWith.size() > index) {
|
||||||
h.add(startWith.get(index));
|
h.add(startWith.get(index));
|
||||||
}
|
}
|
||||||
@ -79,7 +77,7 @@ public abstract class PlayQueue implements Serializable {
|
|||||||
*/
|
*/
|
||||||
public synchronized void init() {
|
public synchronized void init() {
|
||||||
if (broadcastReceiver == null || eventBroadcast == null) {
|
if (broadcastReceiver == null || eventBroadcast == null) {
|
||||||
BehaviorSubject<PlayQueueEvent> b = BehaviorSubject.create();
|
final BehaviorSubject<PlayQueueEvent> b = BehaviorSubject.create();
|
||||||
|
|
||||||
broadcastReceiver = b.toFlowable(BackpressureStrategy.BUFFER)
|
broadcastReceiver = b.toFlowable(BackpressureStrategy.BUFFER)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
@ -332,7 +330,8 @@ public abstract class PlayQueue implements Serializable {
|
|||||||
*/
|
*/
|
||||||
public synchronized void error() {
|
public synchronized void error() {
|
||||||
final int oldIndex = queueIndex;
|
final int oldIndex = queueIndex;
|
||||||
final int nextIndex = queueIndex = oldIndex + 1;
|
queueIndex = oldIndex + 1;
|
||||||
|
final int nextIndex = queueIndex;
|
||||||
if (streams.size() > nextIndex) {
|
if (streams.size() > nextIndex) {
|
||||||
history.add(streams.get(nextIndex));
|
history.add(streams.get(nextIndex));
|
||||||
}
|
}
|
||||||
@ -345,13 +344,14 @@ public abstract class PlayQueue implements Serializable {
|
|||||||
|
|
||||||
int nextIndex = currentIndex;
|
int nextIndex = currentIndex;
|
||||||
if (currentIndex > removeIndex) {
|
if (currentIndex > removeIndex) {
|
||||||
queueIndex = nextIndex = currentIndex - 1;
|
nextIndex = currentIndex - 1;
|
||||||
|
queueIndex = nextIndex;
|
||||||
} else if (currentIndex >= size) {
|
} else if (currentIndex >= size) {
|
||||||
queueIndex = nextIndex = currentIndex % (size - 1);
|
nextIndex = currentIndex % (size - 1);
|
||||||
|
queueIndex = nextIndex;
|
||||||
} else if (currentIndex == removeIndex && currentIndex == size - 1) {
|
} else if (currentIndex == removeIndex && currentIndex == size - 1) {
|
||||||
queueIndex = nextIndex = 0;
|
nextIndex = 0;
|
||||||
|
queueIndex = nextIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (backup != null) {
|
if (backup != null) {
|
||||||
@ -450,7 +450,7 @@ public abstract class PlayQueue implements Serializable {
|
|||||||
// Note: The backup-list has to be created at all cost (even when size <= 2).
|
// Note: The backup-list has to be created at all cost (even when size <= 2).
|
||||||
// Otherwise it's not possible to enter shuffle-mode!
|
// Otherwise it's not possible to enter shuffle-mode!
|
||||||
|
|
||||||
List<PlayQueueItem> copy = backup == null ? new ArrayList<>(streams) : null;
|
final List<PlayQueueItem> copy = backup == null ? new ArrayList<>(streams) : null;
|
||||||
|
|
||||||
// Can't shuffle a list that's empty or only has one element
|
// Can't shuffle a list that's empty or only has one element
|
||||||
if (size() <= 2) {
|
if (size() <= 2) {
|
||||||
@ -469,8 +469,9 @@ public abstract class PlayQueue implements Serializable {
|
|||||||
|
|
||||||
history.add(currentItem);
|
history.add(currentItem);
|
||||||
|
|
||||||
if (copy != null)
|
if (copy != null) {
|
||||||
backup = copy;
|
backup = copy;
|
||||||
|
}
|
||||||
|
|
||||||
broadcast(new ReorderEvent(originalIndex, 0));
|
broadcast(new ReorderEvent(originalIndex, 0));
|
||||||
}
|
}
|
||||||
@ -493,7 +494,6 @@ public abstract class PlayQueue implements Serializable {
|
|||||||
final PlayQueueItem current = getItem(originIndex);
|
final PlayQueueItem current = getItem(originIndex);
|
||||||
|
|
||||||
streams = backup;
|
streams = backup;
|
||||||
// storeStoreFence
|
|
||||||
backup = null;
|
backup = null;
|
||||||
|
|
||||||
final int newIndex = streams.indexOf(current);
|
final int newIndex = streams.indexOf(current);
|
||||||
|
Loading…
Reference in New Issue
Block a user