Skip to content

Commit

Permalink
Fix issue with removal of tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
Faeb35 committed Jun 19, 2020
1 parent 4c7d668 commit 86dcc3a
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,16 @@ public synchronized void addFiles(boolean append, MediaFile... mediaFiles) {
public synchronized void removeFileAt(int index) {
makeBackup();
index = Math.max(0, Math.min(index, size() - 1));
if (this.index == index) {
this.index = -1;
}
if (this.index > index) {
this.index--;
}
files.remove(index);

this.index = Math.max(0, Math.min(this.index, size() - 1));
if (this.index != -1) {
this.index = Math.max(0, Math.min(this.index, size() - 1));
}
}

/**
Expand All @@ -231,7 +235,7 @@ public synchronized void clear() {
files.clear();
setRandomSearchCriteria(null);
setInternetRadio(null);
index = 0;
index = -1;
}

/**
Expand Down Expand Up @@ -405,9 +409,6 @@ public synchronized Status getStatus() {
*/
public synchronized void setStatus(Status status) {
this.status = status;
if (index == -1) {
index = Math.max(0, Math.min(index, size() - 1));
}
}

/**
Expand Down

0 comments on commit 86dcc3a

Please sign in to comment.