From c84a2bfafe29ab5b5f41ca6e29757d4c9dbaef6e Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 11 May 2021 15:01:36 +0200 Subject: [PATCH] fix #2128, properly show recycle bin item size at the app settings --- .../gallery/pro/activities/SettingsActivity.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt index 1a7641b3b..6bc52d698 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt @@ -16,10 +16,7 @@ import com.simplemobiletools.gallery.pro.dialogs.ChangeFileThumbnailStyleDialog import com.simplemobiletools.gallery.pro.dialogs.ChangeFolderThumbnailStyleDialog import com.simplemobiletools.gallery.pro.dialogs.ManageBottomActionsDialog import com.simplemobiletools.gallery.pro.dialogs.ManageExtendedDetailsDialog -import com.simplemobiletools.gallery.pro.extensions.config -import com.simplemobiletools.gallery.pro.extensions.emptyTheRecycleBin -import com.simplemobiletools.gallery.pro.extensions.mediaDB -import com.simplemobiletools.gallery.pro.extensions.showRecycleBinEmptyingDialog +import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.helpers.* import com.simplemobiletools.gallery.pro.models.AlbumCover import kotlinx.android.synthetic.main.activity_settings.* @@ -576,9 +573,18 @@ class SettingsActivity : SimpleActivity() { private fun setupEmptyRecycleBin() { ensureBackgroundThread { try { - mRecycleBinContentSize = mediaDB.getDeletedMedia().sumByLong { it.size } + mRecycleBinContentSize = mediaDB.getDeletedMedia().sumByLong { medium -> + val size = medium.size + if (size == 0L) { + val path = medium.path.removePrefix(RECYCLE_BIN).prependIndent(recycleBinPath) + File(path).length() + } else { + size + } + } } catch (ignored: Exception) { } + runOnUiThread { settings_empty_recycle_bin_size.text = mRecycleBinContentSize.formatSize() }