Use lambdas in OfflineMusicService

This commit is contained in:
tzugen 2021-05-21 22:39:21 +02:00
parent 1b5db9da1f
commit 00e64cdddc
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
1 changed files with 53 additions and 73 deletions

View File

@ -21,9 +21,6 @@ package org.moire.ultrasonic.service;
import android.graphics.Bitmap;
import android.media.MediaMetadataRetriever;
import kotlin.Pair;
import timber.log.Timber;
import org.moire.ultrasonic.data.ActiveServerProvider;
import org.moire.ultrasonic.domain.Artist;
import org.moire.ultrasonic.domain.Bookmark;
@ -54,7 +51,6 @@ import java.io.Reader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@ -64,6 +60,8 @@ import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import kotlin.Lazy;
import kotlin.Pair;
import timber.log.Timber;
import static org.koin.java.KoinJavaComponent.inject;
@ -95,11 +93,7 @@ public class OfflineMusicService implements MusicService
String ignoredArticlesString = "The El La Los Las Le Les";
final String[] ignoredArticles = COMPILE.split(ignoredArticlesString);
Collections.sort(artists, new Comparator<Artist>()
{
@Override
public int compare(Artist lhsArtist, Artist rhsArtist)
{
Collections.sort(artists, (lhsArtist, rhsArtist) -> {
String lhs = lhsArtist.getName().toLowerCase();
String rhs = rhsArtist.getName().toLowerCase();
@ -134,10 +128,9 @@ public class OfflineMusicService implements MusicService
}
return lhs.compareTo(rhs);
}
});
return new Indexes(0L, ignoredArticlesString, Collections.<Artist>emptyList(), artists);
return new Indexes(0L, ignoredArticlesString, Collections.emptyList(), artists);
}
@Override
@ -387,44 +380,31 @@ public class OfflineMusicService implements MusicService
}
}
Collections.sort(artists, new Comparator<Artist>()
{
@Override
public int compare(Artist lhs, Artist rhs)
{
Collections.sort(artists, (lhs, rhs) -> {
if (lhs.getCloseness() == rhs.getCloseness())
{
return 0;
}
else return lhs.getCloseness() > rhs.getCloseness() ? -1 : 1;
}
});
Collections.sort(albums, new Comparator<MusicDirectory.Entry>()
{
@Override
public int compare(MusicDirectory.Entry lhs, MusicDirectory.Entry rhs)
{
Collections.sort(albums, (lhs, rhs) -> {
if (lhs.getCloseness() == rhs.getCloseness())
{
return 0;
}
else return lhs.getCloseness() > rhs.getCloseness() ? -1 : 1;
}
});
Collections.sort(songs, new Comparator<MusicDirectory.Entry>()
{
@Override
public int compare(MusicDirectory.Entry lhs, MusicDirectory.Entry rhs)
{
Collections.sort(songs, (lhs, rhs) -> {
if (lhs.getCloseness() == rhs.getCloseness())
{
return 0;
}
else return lhs.getCloseness() > rhs.getCloseness() ? -1 : 1;
}
});
return new SearchResult(artists, albums, songs);