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