feat: added filter for songs that don't meet a user defined rating threshold

This commit is contained in:
antonio 2023-11-29 19:21:42 +01:00
parent 612c05fabc
commit 121c2b33da
9 changed files with 73 additions and 0 deletions

View file

@ -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);
}
}

View file

@ -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)
}
}