mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
moving some functions into background thread
This commit is contained in:
parent
8fc4fc2f88
commit
2cf4735767
3 changed files with 20 additions and 10 deletions
|
@ -559,9 +559,15 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun deleteDirectoryIfEmpty() {
|
private fun deleteDirectoryIfEmpty() {
|
||||||
val fileDirItem = FileDirItem(mPath, mPath.getFilenameFromPath(), true)
|
if (config.deleteEmptyFolders) {
|
||||||
if (config.deleteEmptyFolders && !fileDirItem.isDownloadsFolder() && fileDirItem.isDirectory && fileDirItem.getProperFileCount(this, true) == 0) {
|
val fileDirItem = FileDirItem(mPath, mPath.getFilenameFromPath(), true)
|
||||||
tryDeleteFileDirItem(fileDirItem, true, true)
|
if (!fileDirItem.isDownloadsFolder() && fileDirItem.isDirectory) {
|
||||||
|
ensureBackgroundThread {
|
||||||
|
if (fileDirItem.getProperFileCount(this, true) == 0) {
|
||||||
|
tryDeleteFileDirItem(fileDirItem, true, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1163,12 +1163,14 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun deleteDirectoryIfEmpty() {
|
private fun deleteDirectoryIfEmpty() {
|
||||||
val fileDirItem = FileDirItem(mDirectory, mDirectory.getFilenameFromPath(), File(mDirectory).isDirectory)
|
if (config.deleteEmptyFolders) {
|
||||||
if (config.deleteEmptyFolders && !fileDirItem.isDownloadsFolder() && fileDirItem.isDirectory) {
|
val fileDirItem = FileDirItem(mDirectory, mDirectory.getFilenameFromPath(), File(mDirectory).isDirectory)
|
||||||
ensureBackgroundThread {
|
if (!fileDirItem.isDownloadsFolder() && fileDirItem.isDirectory) {
|
||||||
if (fileDirItem.getProperFileCount(this, true) == 0) {
|
ensureBackgroundThread {
|
||||||
tryDeleteFileDirItem(fileDirItem, true, true)
|
if (fileDirItem.getProperFileCount(this, true) == 0) {
|
||||||
scanPathRecursively(mDirectory)
|
tryDeleteFileDirItem(fileDirItem, true, true)
|
||||||
|
scanPathRecursively(mDirectory)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,7 +158,9 @@ fun BaseSimpleActivity.addNoMedia(path: String, callback: () -> Unit) {
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
if (file.createNewFile()) {
|
if (file.createNewFile()) {
|
||||||
addNoMediaIntoMediaStore(file.absolutePath)
|
ensureBackgroundThread {
|
||||||
|
addNoMediaIntoMediaStore(file.absolutePath)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(R.string.unknown_error_occurred)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue