Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ class GalleryImageGenerationJob(private val user: User, private val storageManag
)
private val activeJobs = WeakHashMap<ImageView, Job>()

fun cancelAllActiveJobs() {
for ((_, job) in activeJobs) {
job.cancel()
}
activeJobs.clear()
}

fun removeActiveJob(imageView: ImageView, job: CoroutineScope) {
if (isActiveJob(imageView, job)) {
removeJob(imageView)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,4 +372,8 @@ class GalleryAdapter(
override fun setHighlightedItem(file: OCFile) = Unit

override fun setSortOrder(mFile: OCFile, sortOrder: FileSortOrder) = Unit

fun cleanup() {
ocFileListDelegate.cleanup()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,13 @@ class OCFileListDelegate(

fun cleanup() {
ioScope.cancel()

GalleryImageGenerationJob.cancelAllActiveJobs()

// cancel async tasks from ThumbnailsCacheManager
cancelAllPendingTasks()

Log_OC.d(TAG, "background jobs cancelled")
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public static void setLastMediaItemPosition(Integer position) {
public void onDestroyView() {
LocalBroadcastManager.getInstance(requireContext()).unregisterReceiver(refreshSearchEventReceiver);
setLastMediaItemPosition(null);
mAdapter.cleanup();
super.onDestroyView();
}

Expand Down
Loading