Cleanup: inline SelectionData.

This commit is contained in:
Dennis Guse
2025-12-06 11:41:47 +01:00
parent 8db381c448
commit e6367b1dfa
4 changed files with 41 additions and 70 deletions
@@ -757,7 +757,7 @@ public class ContentProviderUtils {
@NonNull
public List<AggregatedStatistic> getAggregatedStatisticsForTracks(ContentProviderSelectionInterface selection) {
SelectionData data = selection.buildSelection();
try (Cursor cursor = contentResolver.query(TracksColumns.CONTENT_URI_AGGREGATED_STATISTICS, null, data.selection(), data.selectionArgs(), null)) {
try (Cursor cursor = contentResolver.query(TracksColumns.CONTENT_URI_AGGREGATED_STATISTICS, null, data.selection(), data.getSelectionArgs(), null)) {
ArrayList<AggregatedStatistic> aggregatedStatistics = new ArrayList<>(cursor.getCount());
while (cursor.moveToNext()) {
aggregatedStatistics.add(new AggregatedStatistic(
@@ -771,4 +771,15 @@ public class ContentProviderUtils {
return aggregatedStatistics;
}
}
public record SelectionData(
String selection,
List<String> selectionArgs
) {
public String[] getSelectionArgs() {
if (selectionArgs == null) return null;
return selectionArgs.toArray(String[]::new);
}
}
}