mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 01:53:31 +00:00
feat: added filter for songs that don't meet a user defined rating threshold
This commit is contained in:
parent
612c05fabc
commit
121c2b33da
9 changed files with 73 additions and 0 deletions
|
|
@ -307,4 +307,17 @@ public class MusicUtil {
|
|||
private static ConnectivityManager getConnectivityManager() {
|
||||
return (ConnectivityManager) App.getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
}
|
||||
|
||||
public static void ratingFilter(List<Child> toFilter) {
|
||||
if (toFilter == null || toFilter.isEmpty()) return;
|
||||
|
||||
List<Child> filtered = toFilter
|
||||
.stream()
|
||||
.filter(child -> (child.getUserRating() != null && child.getUserRating() >= Preferences.getMinStarRatingAccepted()) || (child.getUserRating() == null))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
toFilter.clear();
|
||||
|
||||
toFilter.addAll(filtered);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@ object Preferences {
|
|||
private const val SCROBBLING = "scrobbling"
|
||||
private const val ESTIMATE_CONTENT_LENGTH = "estimate_content_length"
|
||||
private const val BUFFERING_STRATEGY = "buffering_strategy"
|
||||
private const val SKIP_MIN_STAR_RATING = "skip_min_star_rating"
|
||||
private const val MIN_STAR_RATING = "min_star_rating"
|
||||
|
||||
|
||||
@JvmStatic
|
||||
fun getServer(): String? {
|
||||
|
|
@ -338,4 +341,8 @@ object Preferences {
|
|||
return App.getInstance().preferences.getString(BUFFERING_STRATEGY, "1")!!.toDouble()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getMinStarRatingAccepted(): Int {
|
||||
return App.getInstance().preferences.getInt(MIN_STAR_RATING, 0)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue