You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* This singleton class manages the process of querying [MediaStore] for new audio files, manually scanning storage for missing audio files, and removing outdated
@@ -315,13 +313,11 @@ class SimpleMediaScanner(private val context: Application) {
315
313
returnarrayListOf()
316
314
}
317
315
318
-
val tracksSet =ConcurrentHashMap.newKeySet<Track>()
319
-
val paths = audioFilePaths.toTypedArray()
320
-
val totalPaths = paths.size
316
+
val tracks = arrayListOf<Track>()
317
+
val totalPaths = audioFilePaths.size
321
318
var pathsScanned =0
322
319
323
-
// running metadata retriever in parallel significantly reduces the required time
324
-
Arrays.stream(paths).parallel().forEach { path ->
320
+
audioFilePaths.forEach { path ->
325
321
pathsScanned +=1
326
322
maybeShowScanProgress(
327
323
pathBeingScanned = path,
@@ -364,7 +360,7 @@ class SimpleMediaScanner(private val context: Application) {
364
360
val track =Track(0, id, title, artist, path, duration, album, "", 0, trackId, folderName, 0, 0, year, dateAdded, FLAG_MANUAL_CACHE)
365
361
// use hashCode() as id for tracking purposes, there's a very slim chance of collision
366
362
track.mediaStoreId = track.hashCode().toLong()
367
-
tracksSet.add(track)
363
+
tracks.add(track)
368
364
}
369
365
370
366
try {
@@ -374,11 +370,6 @@ class SimpleMediaScanner(private val context: Application) {
374
370
}
375
371
}
376
372
377
-
val tracks = arrayListOf<Track>()
378
-
tracksSet.stream().forEach {
379
-
tracks.add(it)
380
-
}
381
-
382
373
maybeRescanPaths(audioFilePaths)
383
374
return tracks
384
375
}
@@ -486,7 +477,6 @@ class SimpleMediaScanner(private val context: Application) {
0 commit comments