Code cleanup (post review)

This commit is contained in:
Doozy 2022-05-19 10:39:57 +03:00
parent a368db9b87
commit fb17549173
3 changed files with 9 additions and 15 deletions

View file

@ -1104,10 +1104,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
}
private fun askConfirmDelete() {
val path = getCurrentPath()
val fileDirItem = FileDirItem(path, path.getFilenameFromPath(), getIsPathDirectory(path))
val fileDirItem = File(getCurrentPath()).toFileDirItem(this)
val size = fileDirItem.getProperSize(this, countHidden = true).formatSize()
val filename = "\"${path.getFilenameFromPath()}\""
val filename = "\"${getCurrentPath().getFilenameFromPath()}\""
val filenameAndSize = "$filename ($size)"
val baseString = if (config.useRecycleBin && !getCurrentMedium()!!.getIsInRecycleBin()) {

View file

@ -595,17 +595,14 @@ class DirectoryAdapter(
val itemsAndSize = if (itemsCnt == 1) {
val path = getSelectedPaths().first()
val fileDirItem = FileDirItem(path, path.getFilenameFromPath(), activity.getIsPathDirectory(path))
val fileDirItem = File(path).toFileDirItem(activity)
val size = fileDirItem.getProperSize(activity, countHidden = true).formatSize()
val folder = getSelectedPaths().first().getFilenameFromPath()
val folder = path.getFilenameFromPath()
"\"$folder\" ($size)"
} else {
val paths = getSelectedPaths()
val fileDirItems = ArrayList<FileDirItem>(paths.size)
paths.forEach {
val fileDirItem = FileDirItem(it, it.getFilenameFromPath(), activity.getIsPathDirectory(it))
fileDirItems.add(fileDirItem)
}
paths.forEach { fileDirItems.add(File(it).toFileDirItem(activity)) }
val size = fileDirItems.sumByLong { it.getProperSize(activity, countHidden = true) }.formatSize()
"${resources.getQuantityString(R.plurals.delete_items, itemsCnt, itemsCnt)} ($size)"
}

View file

@ -38,6 +38,7 @@ import kotlinx.android.synthetic.main.video_item_grid.view.media_item_holder
import kotlinx.android.synthetic.main.video_item_grid.view.medium_check
import kotlinx.android.synthetic.main.video_item_grid.view.medium_name
import kotlinx.android.synthetic.main.video_item_grid.view.medium_thumbnail
import java.io.File
class MediaAdapter(
activity: BaseSimpleActivity, var media: ArrayList<ThumbnailItem>, val listener: MediaOperationsListener?, val isAGetIntent: Boolean,
@ -462,17 +463,14 @@ class MediaAdapter(
private fun askConfirmDelete() {
val itemsCnt = selectedKeys.size
val firstPath = getSelectedPaths().first()
val fileDirItem = FileDirItem(firstPath, firstPath.getFilenameFromPath(), activity.getIsPathDirectory(firstPath))
val fileDirItem = File(firstPath).toFileDirItem(activity)
val size = fileDirItem.getProperSize(activity, countHidden = true).formatSize()
val itemsAndSize = if (itemsCnt == 1) {
"\"${firstPath.getFilenameFromPath()}\" ($size)"
} else {
val paths = getSelectedPaths()
val fileDirItems = java.util.ArrayList<FileDirItem>(paths.size)
paths.forEach {
val fileDirItem = FileDirItem(it, it.getFilenameFromPath(), activity.getIsPathDirectory(it))
fileDirItems.add(fileDirItem)
}
val fileDirItems = ArrayList<FileDirItem>(paths.size)
paths.forEach { fileDirItems.add(File(it).toFileDirItem(activity)) }
val size = fileDirItems.sumByLong { it.getProperSize(activity, countHidden = true) }.formatSize()
"${resources.getQuantityString(R.plurals.delete_items, itemsCnt, itemsCnt)} ($size)"
}