From ac260b65765e55910517d1d468927936d1688d04 Mon Sep 17 00:00:00 2001 From: Daniel Bowman Date: Sat, 27 Oct 2018 14:46:48 +0100 Subject: Fix Genre comparator to pass unit tests --- app/src/main/java/github/daneren2005/dsub/domain/Genre.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'app/src/main/java/github/daneren2005') diff --git a/app/src/main/java/github/daneren2005/dsub/domain/Genre.java b/app/src/main/java/github/daneren2005/dsub/domain/Genre.java index 4b6ac344..dcf12a1d 100644 --- a/app/src/main/java/github/daneren2005/dsub/domain/Genre.java +++ b/app/src/main/java/github/daneren2005/dsub/domain/Genre.java @@ -1,16 +1,10 @@ package github.daneren2005.dsub.domain; -import android.content.Context; -import android.content.SharedPreferences; - import java.io.Serializable; import java.util.Collections; import java.util.Comparator; import java.util.List; -import github.daneren2005.dsub.util.Constants; -import github.daneren2005.dsub.util.Util; - public class Genre implements Serializable { private String name; private String index; @@ -57,7 +51,10 @@ public class Genre implements Serializable { public static class GenreComparator implements Comparator { @Override public int compare(Genre genre1, Genre genre2) { - return genre1.getName().compareToIgnoreCase(genre2.getName()); + String genre1Name = genre1.getName() != null ? genre1.getName() : ""; + String genre2Name = genre2.getName() != null ? genre2.getName() : ""; + + return genre1Name.compareToIgnoreCase(genre2Name); } public static List sort(List genres) { -- cgit v1.2.3