From 376c3d0d1ea9d659aabe74a7b3e5827eaf093564 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 5 May 2019 23:27:12 +0200 Subject: [PATCH] do not show the Date Taken value fixing related toast messages at bin --- .../gallery/pro/adapters/MediaAdapter.kt | 2 +- .../gallery/pro/extensions/Activity.kt | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt index c1f7475b9..dfdca930f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt @@ -331,7 +331,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList, mediumDa callback() } - fixDateTaken(newPaths) + fixDateTaken(newPaths, false) }.start() } @@ -328,9 +328,12 @@ fun Activity.hasNavBar(): Boolean { return (realDisplayMetrics.widthPixels - displayMetrics.widthPixels > 0) || (realDisplayMetrics.heightPixels - displayMetrics.heightPixels > 0) } -fun Activity.fixDateTaken(paths: ArrayList, callback: (() -> Unit)? = null) { +fun Activity.fixDateTaken(paths: ArrayList, showToasts: Boolean, callback: (() -> Unit)? = null) { val BATCH_SIZE = 50 - toast(R.string.fixing) + if (showToasts) { + toast(R.string.fixing) + } + try { var didUpdateFile = false val operations = ArrayList() @@ -371,13 +374,18 @@ fun Activity.fixDateTaken(paths: ArrayList, callback: (() -> Unit)? = nu didUpdateFile = false } - toast(if (didUpdateFile) R.string.dates_fixed_successfully else R.string.unknown_error_occurred) runOnUiThread { + if (showToasts) { + toast(if (didUpdateFile) R.string.dates_fixed_successfully else R.string.unknown_error_occurred) + } + callback?.invoke() } } } catch (e: Exception) { - showErrorToast(e) + if (showToasts) { + showErrorToast(e) + } } }