Sort artists using case insensitive comparison when offline
Signed-off-by: Simão Mata <simao.mata@here.com>
This commit is contained in:
parent
ecdae8c6e3
commit
cfae0d30b5
|
@ -169,7 +169,7 @@ public class SelectArtistFragment extends SelectRecyclerFragment<Serializable> i
|
||||||
String musicFolderId = Util.getSelectedMusicFolderId(context);
|
String musicFolderId = Util.getSelectedMusicFolderId(context);
|
||||||
|
|
||||||
Indexes indexes = musicService.getIndexes(musicFolderId, refresh, context, listener);
|
Indexes indexes = musicService.getIndexes(musicFolderId, refresh, context, listener);
|
||||||
indexes.sortChildren(context);
|
indexes.sortChildren();
|
||||||
items = new ArrayList<>(indexes.getShortcuts().size() + indexes.getArtists().size());
|
items = new ArrayList<>(indexes.getShortcuts().size() + indexes.getArtists().size());
|
||||||
items.addAll(indexes.getShortcuts());
|
items.addAll(indexes.getShortcuts());
|
||||||
items.addAll(indexes.getArtists());
|
items.addAll(indexes.getArtists());
|
||||||
|
@ -184,8 +184,7 @@ public class SelectArtistFragment extends SelectRecyclerFragment<Serializable> i
|
||||||
}
|
}
|
||||||
|
|
||||||
Indexes indexes = new Indexes();
|
Indexes indexes = new Indexes();
|
||||||
//indexes.setArtists = artists;
|
indexes.sortChildren();
|
||||||
indexes.sortChildren(context);
|
|
||||||
items = new ArrayList<>(indexes.getArtists());
|
items = new ArrayList<>(indexes.getArtists());
|
||||||
|
|
||||||
entries = dir.getChildren(false, true);
|
entries = dir.getChildren(false, true);
|
||||||
|
|
|
@ -71,6 +71,7 @@ public class OfflineMusicService implements MusicService {
|
||||||
public Indexes getIndexes(String musicFolderId, boolean refresh, Context context, ProgressListener progressListener) {
|
public Indexes getIndexes(String musicFolderId, boolean refresh, Context context, ProgressListener progressListener) {
|
||||||
List<Artist> artists = new ArrayList<>();
|
List<Artist> artists = new ArrayList<>();
|
||||||
List<Entry> entries = new ArrayList<>();
|
List<Entry> entries = new ArrayList<>();
|
||||||
|
|
||||||
File root = FileUtil.getMusicDirectory(context);
|
File root = FileUtil.getMusicDirectory(context);
|
||||||
for (File file : FileUtil.listFiles(root)) {
|
for (File file : FileUtil.listFiles(root)) {
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
package net.nullsum.audinaut.domain
|
package net.nullsum.audinaut.domain
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
class Indexes(var shortcuts: MutableList<Artist> = mutableListOf(),
|
class Indexes(var shortcuts: MutableList<Artist> = mutableListOf(),
|
||||||
var artists: MutableList<Artist> = mutableListOf(),
|
var artists: MutableList<Artist> = mutableListOf(),
|
||||||
var entries: MutableList<MusicDirectory.Entry> = mutableListOf()) : Serializable {
|
var entries: MutableList<MusicDirectory.Entry> = mutableListOf()) : Serializable {
|
||||||
fun sortChildren(context: Context) {
|
|
||||||
|
fun sortChildren() {
|
||||||
|
shortcuts.sortBy { s -> s.id.toLowerCase(Locale.ROOT) }
|
||||||
|
artists.sortBy { a -> a.name.toLowerCase(Locale.ROOT) }
|
||||||
|
entries.sortBy { e -> e.artist.toLowerCase(Locale.ROOT) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue