slightly optimized model

This commit is contained in:
zelva 2022-09-02 21:35:02 +03:00 committed by TobiGr
parent 3513f7ac03
commit 16a83dc448
1 changed files with 6 additions and 5 deletions

View File

@ -341,21 +341,22 @@ public abstract class PlayQueue implements Serializable {
final int currentIndex = queueIndex.get();
final int size = size();
int nextIndex = currentIndex;
if (currentIndex > removeIndex) {
queueIndex.decrementAndGet();
nextIndex = currentIndex - 1;
queueIndex.set(nextIndex);
} else if (currentIndex >= size) {
queueIndex.set(currentIndex % (size - 1));
nextIndex = currentIndex % (size - 1);
queueIndex.set(nextIndex);
} else if (currentIndex == removeIndex && currentIndex == size - 1) {
queueIndex.set(0);
queueIndex.set(nextIndex = 0);
}
if (backup != null) {
backup.remove(getItem(removeIndex));
}
final int nextIndex = queueIndex.get();
history.remove(streams.remove(removeIndex));
if (streams.size() > nextIndex) {
history.add(streams.get(nextIndex));