Skip to content

Commit

Permalink
Fixed issue with song history
Browse files Browse the repository at this point in the history
  • Loading branch information
kkevinm committed Aug 8, 2020
1 parent 3a31963 commit b55e22f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/main/java/com/github/kevinmussi/itunesrp/data/Track.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ public boolean isNull() {
return this == NULL_TRACK;
}

public boolean isSameTrack(Track other) {
return name.equals(other.name) && album.equals(other.album) && artist.equals(other.artist) && app == other.app
&& duration == other.duration && index == other.index && albumSize == other.albumSize;
}

@Override
public String toString() {
return new StringBuilder().append("Name: ").append(name).append("\nArtist: ").append(artist).append("\nAlbum: ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class ActivePanel extends Commander<ConnectCommand> implements Panel {
private final JPanel panel;
private final TrackPane trackPane;
private final DefaultListModel<Track> listModel;
private Track latestTrack = Track.NULL_TRACK;
private SettingsFrame settingsFrame;

public ActivePanel() {
Expand Down Expand Up @@ -109,9 +110,9 @@ public JPanel getPanel() {
public void setTrack(Track track) {
if(track != null) {
trackPane.setTrack(track);
if(track.getState() == TrackState.PLAYING) {
// Only show the played songs in the history
if(track.getState() == TrackState.PLAYING && !track.isSameTrack(latestTrack)) {
listModel.add(0, track);
latestTrack = track;
}
}
}
Expand Down

0 comments on commit b55e22f

Please sign in to comment.