avoid some folder operations on Favorites

This commit is contained in:
tibbi 2018-06-20 23:09:42 +02:00
parent cc5bf379c4
commit 283a8254dc

View file

@ -144,11 +144,12 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
private fun showProperties() { private fun showProperties() {
if (selectedPositions.size <= 1) { if (selectedPositions.size <= 1) {
val path = dirs[selectedPositions.first()].path
if (path != FAVORITES) {
PropertiesDialog(activity, dirs[selectedPositions.first()].path, config.shouldShowHidden) PropertiesDialog(activity, dirs[selectedPositions.first()].path, config.shouldShowHidden)
}
} else { } else {
val paths = ArrayList<String>() PropertiesDialog(activity, getSelectedPaths().filter { it != FAVORITES }.toList(), config.shouldShowHidden)
selectedPositions.forEach { paths.add(dirs[it].path) }
PropertiesDialog(activity, paths, config.shouldShowHidden)
} }
} }
@ -178,7 +179,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
} }
private fun toggleFoldersVisibility(hide: Boolean) { private fun toggleFoldersVisibility(hide: Boolean) {
getSelectedPaths().forEach { getSelectedPaths().filter { it != FAVORITES }.forEach {
val path = it val path = it
if (hide) { if (hide) {
if (config.wasHideFolderTooltipShown) { if (config.wasHideFolderTooltipShown) {
@ -260,13 +261,13 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
} }
private fun tryExcludeFolder() { private fun tryExcludeFolder() {
val paths = getSelectedPaths() val paths = getSelectedPaths().filter { it != PATH }.toSet()
if (paths.size == 1) { if (paths.size == 1) {
ExcludeFolderDialog(activity, paths.toList()) { ExcludeFolderDialog(activity, paths.toList()) {
listener?.refreshItems() listener?.refreshItems()
finishActMode() finishActMode()
} }
} else { } else if (paths.size > 1) {
activity.config.addExcludedFolders(paths) activity.config.addExcludedFolders(paths)
listener?.refreshItems() listener?.refreshItems()
finishActMode() finishActMode()
@ -293,7 +294,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
val path = dirs[it].path val path = dirs[it].path
if (path.startsWith(OTG_PATH)) { if (path.startsWith(OTG_PATH)) {
paths.addAll(getOTGFilePaths(path, showHidden)) paths.addAll(getOTGFilePaths(path, showHidden))
} else { } else if (path != FAVORITES) {
File(path).listFiles()?.filter { File(path).listFiles()?.filter {
!activity.getIsPathDirectory(it.absolutePath) && it.isImageVideoGif() && (showHidden || !it.name.startsWith('.')) !activity.getIsPathDirectory(it.absolutePath) && it.isImageVideoGif() && (showHidden || !it.name.startsWith('.'))
}?.mapTo(paths) { it.absolutePath } }?.mapTo(paths) { it.absolutePath }
@ -355,9 +356,17 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
activity.handleSAFDialog(SAFPath) { activity.handleSAFDialog(SAFPath) {
selectedPositions.sortedDescending().forEach { selectedPositions.sortedDescending().forEach {
val directory = dirs[it] val directory = dirs[it]
if (directory.areFavorites()) {
if (selectedPositions.size == 1) {
finishActMode()
} else {
selectedPositions.remove(it)
}
} else {
folders.add(File(directory.path)) folders.add(File(directory.path))
removeFolders.add(directory) removeFolders.add(directory)
} }
}
dirs.removeAll(removeFolders) dirs.removeAll(removeFolders)
listener?.deleteFolders(folders) listener?.deleteFolders(folders)