Skip to content

Commit a1fc5d8

Browse files
committed
add cancel all function
Signed-off-by: alperozturk <[email protected]>
1 parent 1ba8b80 commit a1fc5d8

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

app/src/main/java/com/nextcloud/client/jobs/gallery/GalleryImageGenerationJob.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ class GalleryImageGenerationJob(private val user: User, private val storageManag
4040
)
4141
private val activeJobs = WeakHashMap<ImageView, Job>()
4242

43-
fun getActiveJobs(): WeakHashMap<ImageView, Job> = activeJobs
43+
fun cancelAllActiveJobs() {
44+
for ((_, job) in activeJobs) {
45+
job.cancel()
46+
}
47+
activeJobs.clear()
48+
}
4449

4550
fun removeActiveJob(imageView: ImageView, job: CoroutineScope) {
4651
if (isActiveJob(imageView, job)) {

app/src/main/java/com/owncloud/android/ui/adapter/OCFileListDelegate.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -414,13 +414,7 @@ class OCFileListDelegate(
414414
fun cleanup() {
415415
ioScope.cancel()
416416

417-
val activeJobs = GalleryImageGenerationJob.getActiveJobs()
418-
419-
// Cancel all pending thumbnail/generation jobs for gallery images
420-
for ((_, job) in activeJobs) {
421-
job.cancel()
422-
}
423-
activeJobs.clear()
417+
GalleryImageGenerationJob.cancelAllActiveJobs()
424418

425419
// cancel async tasks from ThumbnailsCacheManager
426420
cancelAllPendingTasks()

0 commit comments

Comments
 (0)