From c60b6266bdfdac70f14438562704cc4f469edc25 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Tue, 29 Jan 2013 17:56:37 -0800 Subject: Sort artists with #'s last and not case sensitive like online searches --- .../daneren2005/dsub/service/OfflineMusicService.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'subsonic-android/src') diff --git a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java index 3d8a3881..c63fc0f3 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java @@ -77,6 +77,25 @@ public class OfflineMusicService extends RESTMusicService { artists.add(artist); } } + + Collections.sort(artists, new Comparator() { + public int compare(Artist lhsArtist, Artist rhsArtist) { + String lhs = lhsArtist.getName().toLowerCase(); + String rhs = rhsArtist.getName().toLowerCase(); + + char lhs1 = lhs.charAt(0); + char rhs1 = rhs.charAt(0); + + if(Character.isDigit(lhs1) && !Character.isDigit(rhs1)) { + return 1; + } else if(Character.isDigit(rhs1) && !Character.isDigit(lhs1)) { + return -1; + } + + return lhs.compareTo(rhs); + } + }); + return new Indexes(0L, Collections.emptyList(), artists); } -- cgit v1.2.3