ensure decompression is in background thread

This commit is contained in:
darthpaul
2021-11-14 23:00:12 +00:00
parent c695fd0955
commit d92af2f97d

View File

@@ -505,15 +505,17 @@ class ItemsAdapter(
} }
val paths = getSelectedFileDirItems().asSequence().map { it.path }.filter { it.isZipFile() }.toList() val paths = getSelectedFileDirItems().asSequence().map { it.path }.filter { it.isZipFile() }.toList()
tryDecompressingPaths(paths) { ensureBackgroundThread {
if (it) { tryDecompressingPaths(paths) { success ->
activity.toast(R.string.decompression_successful)
activity.runOnUiThread { activity.runOnUiThread {
listener?.refreshFragment() if (success) {
finishActMode() activity.toast(R.string.decompression_successful)
listener?.refreshFragment()
finishActMode()
} else {
activity.toast(R.string.decompressing_failed)
}
} }
} else {
activity.toast(R.string.decompressing_failed)
} }
} }
} }
@@ -540,7 +542,6 @@ class ItemsAdapter(
} }
} }
} catch (exception: Exception) { } catch (exception: Exception) {
exception.printStackTrace()
activity.showErrorToast(exception) activity.showErrorToast(exception)
} }
} }
@@ -589,7 +590,6 @@ class ItemsAdapter(
} }
callback(true) callback(true)
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace()
activity.showErrorToast(e) activity.showErrorToast(e)
callback(false) callback(false)
} }