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,11 +559,17 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun deleteDirectoryIfEmpty() {
|
private fun deleteDirectoryIfEmpty() {
|
||||||
|
if (config.deleteEmptyFolders) {
|
||||||
val fileDirItem = FileDirItem(mPath, mPath.getFilenameFromPath(), true)
|
val fileDirItem = FileDirItem(mPath, mPath.getFilenameFromPath(), true)
|
||||||
if (config.deleteEmptyFolders && !fileDirItem.isDownloadsFolder() && fileDirItem.isDirectory && fileDirItem.getProperFileCount(this, true) == 0) {
|
if (!fileDirItem.isDownloadsFolder() && fileDirItem.isDirectory) {
|
||||||
|
ensureBackgroundThread {
|
||||||
|
if (fileDirItem.getProperFileCount(this, true) == 0) {
|
||||||
tryDeleteFileDirItem(fileDirItem, true, true)
|
tryDeleteFileDirItem(fileDirItem, true, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun getMedia() {
|
private fun getMedia() {
|
||||||
if (mIsGettingMedia) {
|
if (mIsGettingMedia) {
|
||||||
|
|
|
@ -1163,8 +1163,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun deleteDirectoryIfEmpty() {
|
private fun deleteDirectoryIfEmpty() {
|
||||||
|
if (config.deleteEmptyFolders) {
|
||||||
val fileDirItem = FileDirItem(mDirectory, mDirectory.getFilenameFromPath(), File(mDirectory).isDirectory)
|
val fileDirItem = FileDirItem(mDirectory, mDirectory.getFilenameFromPath(), File(mDirectory).isDirectory)
|
||||||
if (config.deleteEmptyFolders && !fileDirItem.isDownloadsFolder() && fileDirItem.isDirectory) {
|
if (!fileDirItem.isDownloadsFolder() && fileDirItem.isDirectory) {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
if (fileDirItem.getProperFileCount(this, true) == 0) {
|
if (fileDirItem.getProperFileCount(this, true) == 0) {
|
||||||
tryDeleteFileDirItem(fileDirItem, true, true)
|
tryDeleteFileDirItem(fileDirItem, true, true)
|
||||||
|
@ -1173,6 +1174,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("SourceLockedOrientationActivity")
|
@SuppressLint("SourceLockedOrientationActivity")
|
||||||
private fun checkOrientation() {
|
private fun checkOrientation() {
|
||||||
|
|
|
@ -158,7 +158,9 @@ fun BaseSimpleActivity.addNoMedia(path: String, callback: () -> Unit) {
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
if (file.createNewFile()) {
|
if (file.createNewFile()) {
|
||||||
|
ensureBackgroundThread {
|
||||||
addNoMediaIntoMediaStore(file.absolutePath)
|
addNoMediaIntoMediaStore(file.absolutePath)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(R.string.unknown_error_occurred)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue