aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorDaniel Bowman <daniel@danielbowman.co.uk>2018-10-27 14:46:48 +0100
committerDaniel Bowman <daniel@danielbowman.co.uk>2018-10-27 14:46:48 +0100
commitac260b65765e55910517d1d468927936d1688d04 (patch)
tree0b81db9e002ba971970f68af1473e03f81a7a716 /app/src
parent0a4f6215972d970e69859fa690938ef9f0ea2e0a (diff)
downloaddsub-ac260b65765e55910517d1d468927936d1688d04.tar.gz
dsub-ac260b65765e55910517d1d468927936d1688d04.tar.bz2
dsub-ac260b65765e55910517d1d468927936d1688d04.zip
Fix Genre comparator to pass unit tests
Diffstat (limited to 'app/src')
-rw-r--r--app/src/androidTest/java/github/daneren2005/dsub/domain/GenreComparatorTest.java8
-rw-r--r--app/src/main/java/github/daneren2005/dsub/domain/Genre.java11
2 files changed, 8 insertions, 11 deletions
diff --git a/app/src/androidTest/java/github/daneren2005/dsub/domain/GenreComparatorTest.java b/app/src/androidTest/java/github/daneren2005/dsub/domain/GenreComparatorTest.java
index 9ffa518e..16d189fa 100644
--- a/app/src/androidTest/java/github/daneren2005/dsub/domain/GenreComparatorTest.java
+++ b/app/src/androidTest/java/github/daneren2005/dsub/domain/GenreComparatorTest.java
@@ -16,7 +16,7 @@ public class GenreComparatorTest extends TestCase {
Genre g2 = new Genre();
- List<Genre> genres = new ArrayList<Genre>();
+ List<Genre> genres = new ArrayList<>();
genres.add(g1);
genres.add(g2);
@@ -34,7 +34,7 @@ public class GenreComparatorTest extends TestCase {
Genre g2 = new Genre();
g2.setName("genre");
- List<Genre> genres = new ArrayList<Genre>();
+ List<Genre> genres = new ArrayList<>();
genres.add(g1);
genres.add(g2);
@@ -53,9 +53,9 @@ public class GenreComparatorTest extends TestCase {
g2.setName("Pop");
Genre g3 = new Genre();
- g2.setName("Rap");
+ g3.setName("Rap");
- List<Genre> genres = new ArrayList<Genre>();
+ List<Genre> genres = new ArrayList<>();
genres.add(g1);
genres.add(g2);
genres.add(g3);
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<Genre> {
@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<Genre> sort(List<Genre> genres) {