Merge pull request #73 from simao/sort-artists-offline-ci

Sort artists using case insensitive comparison when offline
This commit is contained in:
Andrew Rabert 2020-04-13 21:58:00 -04:00 committed by GitHub
commit ec083cd79d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View File

@ -169,7 +169,7 @@ public class SelectArtistFragment extends SelectRecyclerFragment<Serializable> i
String musicFolderId = Util.getSelectedMusicFolderId(context);
Indexes indexes = musicService.getIndexes(musicFolderId, refresh, context, listener);
indexes.sortChildren(context);
indexes.sortChildren();
items = new ArrayList<>(indexes.getShortcuts().size() + indexes.getArtists().size());
items.addAll(indexes.getShortcuts());
items.addAll(indexes.getArtists());
@ -184,8 +184,7 @@ public class SelectArtistFragment extends SelectRecyclerFragment<Serializable> i
}
Indexes indexes = new Indexes();
//indexes.setArtists = artists;
indexes.sortChildren(context);
indexes.sortChildren();
items = new ArrayList<>(indexes.getArtists());
entries = dir.getChildren(false, true);

View File

@ -71,6 +71,7 @@ public class OfflineMusicService implements MusicService {
public Indexes getIndexes(String musicFolderId, boolean refresh, Context context, ProgressListener progressListener) {
List<Artist> artists = new ArrayList<>();
List<Entry> entries = new ArrayList<>();
File root = FileUtil.getMusicDirectory(context);
for (File file : FileUtil.listFiles(root)) {
if (file.isDirectory()) {

View File

@ -1,11 +1,15 @@
package net.nullsum.audinaut.domain
import android.content.Context
import java.io.Serializable
import java.util.*
class Indexes(var shortcuts: MutableList<Artist> = mutableListOf(),
var artists: MutableList<Artist> = mutableListOf(),
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) }
}
}