fix NPE by using Objects.equals()

This commit is contained in:
Andreas Shimokawa 2016-06-11 22:32:38 +02:00
parent d1a62968f6
commit 2d080cabb2
1 changed files with 8 additions and 6 deletions

View File

@ -1,5 +1,7 @@
package nodomain.freeyourgadget.gadgetbridge.model; package nodomain.freeyourgadget.gadgetbridge.model;
import java.util.Objects;
public class MusicSpec { public class MusicSpec {
public static final int MUSIC_UNDEFINED = 0; public static final int MUSIC_UNDEFINED = 0;
public static final int MUSIC_PLAY = 1; public static final int MUSIC_PLAY = 1;
@ -8,9 +10,9 @@ public class MusicSpec {
public static final int MUSIC_NEXT = 4; public static final int MUSIC_NEXT = 4;
public static final int MUSIC_PREVIOUS = 5; public static final int MUSIC_PREVIOUS = 5;
public String artist = ""; public String artist;
public String album = ""; public String album;
public String track = ""; public String track;
public int duration; public int duration;
public int trackCount; public int trackCount;
public int trackNr; public int trackNr;
@ -25,9 +27,9 @@ public class MusicSpec {
} }
MusicSpec musicSpec = (MusicSpec) obj; MusicSpec musicSpec = (MusicSpec) obj;
return this.artist.equals(musicSpec.artist) && return Objects.equals(this.artist, musicSpec.artist) &&
this.album.equals(musicSpec.album) && Objects.equals(this.album, musicSpec.album) &&
this.track.equals(musicSpec.track) && Objects.equals(this.track, musicSpec.track) &&
this.duration == musicSpec.duration && this.duration == musicSpec.duration &&
this.trackCount == musicSpec.trackCount && this.trackCount == musicSpec.trackCount &&
this.trackNr == musicSpec.trackNr; this.trackNr == musicSpec.trackNr;