From 2d080cabb2689b56b720f05d6defd6f88d568d80 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sat, 11 Jun 2016 22:32:38 +0200 Subject: [PATCH] fix NPE by using Objects.equals() --- .../gadgetbridge/model/MusicSpec.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/MusicSpec.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/MusicSpec.java index b941514f..aa9f67ca 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/MusicSpec.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/MusicSpec.java @@ -1,5 +1,7 @@ package nodomain.freeyourgadget.gadgetbridge.model; +import java.util.Objects; + public class MusicSpec { public static final int MUSIC_UNDEFINED = 0; 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_PREVIOUS = 5; - public String artist = ""; - public String album = ""; - public String track = ""; + public String artist; + public String album; + public String track; public int duration; public int trackCount; public int trackNr; @@ -25,9 +27,9 @@ public class MusicSpec { } MusicSpec musicSpec = (MusicSpec) obj; - return this.artist.equals(musicSpec.artist) && - this.album.equals(musicSpec.album) && - this.track.equals(musicSpec.track) && + return Objects.equals(this.artist, musicSpec.artist) && + Objects.equals(this.album, musicSpec.album) && + Objects.equals(this.track, musicSpec.track) && this.duration == musicSpec.duration && this.trackCount == musicSpec.trackCount && this.trackNr == musicSpec.trackNr;