Fixed behaviour when stopping playback but the song is no longer in the playlist.
This commit is contained in:
parent
8619678023
commit
f29be6beee
@ -116,8 +116,8 @@ public class JTablePlaylist extends JScrollPane implements IPlaylist {
|
||||
public void setPlayingSong(Song song){
|
||||
final int index = getIndex(song);
|
||||
playlistTableModel.setPlayingRow(index);
|
||||
if(index >= 0)
|
||||
SwingUtilities.invokeLater(() -> playList.setRowSelectionInterval(index, index));
|
||||
if(index >= 0 && index < playList.getRowCount())
|
||||
playList.setRowSelectionInterval(index, index);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -125,7 +125,7 @@ public class JTablePlaylist extends JScrollPane implements IPlaylist {
|
||||
if(getActive().isPresent()) {
|
||||
int index = getIndex(getActive().get());
|
||||
playlistTableModel.setPlayingRow(-1);
|
||||
SwingUtilities.invokeLater(() -> playList.setRowSelectionInterval(index, index));
|
||||
playList.setRowSelectionInterval(index, index);
|
||||
}
|
||||
else
|
||||
playlistTableModel.setPlayingRow(-1);
|
||||
|
@ -117,7 +117,6 @@ public class JTablePlaylistTest {
|
||||
playlist.addSong(testSong);
|
||||
playlist.setPlayingSong(testSong);
|
||||
assertEquals(testSong, playlist.getActive().get());
|
||||
Thread.sleep(10); // Wait for Swing thread update propagation
|
||||
assertEquals(playlist.getIndex(testSong), innerTable.getSelectedRow());
|
||||
}
|
||||
|
||||
@ -139,6 +138,17 @@ public class JTablePlaylistTest {
|
||||
assertEquals(playlist.getIndex(testSong), innerTable.getSelectedRow());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetStoppedButSongRemovedFromPlaylist() throws Exception {
|
||||
Song testSong = new Song("1", "1", "test 1", new Artist("test artist"), new Album("test album"), "test genre", "");
|
||||
playlist.addSong(testSong);
|
||||
playlist.setPlayingSong(testSong);
|
||||
playlist.delete(testSong);
|
||||
playlist.setStopped();
|
||||
assertEquals(0, playlist.getSongList().size());
|
||||
assertEquals(-1, innerTable.getSelectedRow());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSongList() throws Exception {
|
||||
Song testSong = new Song("1", "1", "test 1", new Artist("test artist"), new Album("test album"), "test genre", "");
|
||||
|
Loading…
Reference in New Issue
Block a user