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() { private fun askConfirmDelete() {
val path = getCurrentPath() val fileDirItem = File(getCurrentPath()).toFileDirItem(this)
val fileDirItem = FileDirItem(path, path.getFilenameFromPath(), getIsPathDirectory(path))
val size = fileDirItem.getProperSize(this, countHidden = true).formatSize() val size = fileDirItem.getProperSize(this, countHidden = true).formatSize()
val filename = "\"${path.getFilenameFromPath()}\"" val filename = "\"${getCurrentPath().getFilenameFromPath()}\""
val filenameAndSize = "$filename ($size)" val filenameAndSize = "$filename ($size)"
val baseString = if (config.useRecycleBin && !getCurrentMedium()!!.getIsInRecycleBin()) { val baseString = if (config.useRecycleBin && !getCurrentMedium()!!.getIsInRecycleBin()) {

View file

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