moving folder deletion and image orientation fetching to background threads

This commit is contained in:
tibbi 2021-02-19 16:29:47 +01:00
parent 46d298596a
commit 4f79d196d6
2 changed files with 19 additions and 11 deletions

View file

@ -1164,11 +1164,15 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
private fun deleteDirectoryIfEmpty() { private fun deleteDirectoryIfEmpty() {
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 && fileDirItem.getProperFileCount(this, true) == 0) { if (config.deleteEmptyFolders && !fileDirItem.isDownloadsFolder() && fileDirItem.isDirectory) {
ensureBackgroundThread {
if (fileDirItem.getProperFileCount(this, true) == 0) {
tryDeleteFileDirItem(fileDirItem, true, true) tryDeleteFileDirItem(fileDirItem, true, true)
scanPathRecursively(mDirectory) scanPathRecursively(mDirectory)
} }
} }
}
}
@SuppressLint("SourceLockedOrientationActivity") @SuppressLint("SourceLockedOrientationActivity")
private fun checkOrientation() { private fun checkOrientation() {

View file

@ -351,13 +351,17 @@ class PhotoFragment : ViewPagerFragment() {
showPortraitStripe() showPortraitStripe()
} }
ensureBackgroundThread {
mImageOrientation = getImageOrientation() mImageOrientation = getImageOrientation()
activity?.runOnUiThread {
when { when {
mMedium.isGIF() -> loadGif() mMedium.isGIF() -> loadGif()
mMedium.isSVG() -> loadSVG() mMedium.isSVG() -> loadSVG()
else -> loadBitmap() else -> loadBitmap()
} }
} }
}
}
private fun loadGif() { private fun loadGif() {
try { try {