fix #2128, properly show recycle bin item size at the app settings

This commit is contained in:
tibbi 2021-05-11 15:01:36 +02:00
parent 9656da47ae
commit c84a2bfafe

View file

@ -16,10 +16,7 @@ import com.simplemobiletools.gallery.pro.dialogs.ChangeFileThumbnailStyleDialog
import com.simplemobiletools.gallery.pro.dialogs.ChangeFolderThumbnailStyleDialog import com.simplemobiletools.gallery.pro.dialogs.ChangeFolderThumbnailStyleDialog
import com.simplemobiletools.gallery.pro.dialogs.ManageBottomActionsDialog import com.simplemobiletools.gallery.pro.dialogs.ManageBottomActionsDialog
import com.simplemobiletools.gallery.pro.dialogs.ManageExtendedDetailsDialog import com.simplemobiletools.gallery.pro.dialogs.ManageExtendedDetailsDialog
import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.extensions.*
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.helpers.* import com.simplemobiletools.gallery.pro.helpers.*
import com.simplemobiletools.gallery.pro.models.AlbumCover import com.simplemobiletools.gallery.pro.models.AlbumCover
import kotlinx.android.synthetic.main.activity_settings.* import kotlinx.android.synthetic.main.activity_settings.*
@ -576,9 +573,18 @@ class SettingsActivity : SimpleActivity() {
private fun setupEmptyRecycleBin() { private fun setupEmptyRecycleBin() {
ensureBackgroundThread { ensureBackgroundThread {
try { 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) { } catch (ignored: Exception) {
} }
runOnUiThread { runOnUiThread {
settings_empty_recycle_bin_size.text = mRecycleBinContentSize.formatSize() settings_empty_recycle_bin_size.text = mRecycleBinContentSize.formatSize()
} }