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