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,9 +1164,13 @@ 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) {
tryDeleteFileDirItem(fileDirItem, true, true) ensureBackgroundThread {
scanPathRecursively(mDirectory) if (fileDirItem.getProperFileCount(this, true) == 0) {
tryDeleteFileDirItem(fileDirItem, true, true)
scanPathRecursively(mDirectory)
}
}
} }
} }

View file

@ -351,11 +351,15 @@ class PhotoFragment : ViewPagerFragment() {
showPortraitStripe() showPortraitStripe()
} }
mImageOrientation = getImageOrientation() ensureBackgroundThread {
when { mImageOrientation = getImageOrientation()
mMedium.isGIF() -> loadGif() activity?.runOnUiThread {
mMedium.isSVG() -> loadSVG() when {
else -> loadBitmap() mMedium.isGIF() -> loadGif()
mMedium.isSVG() -> loadSVG()
else -> loadBitmap()
}
}
} }
} }
@ -687,9 +691,9 @@ class PhotoFragment : ViewPagerFragment() {
val inputStream = if (mMedium.path.startsWith("content:/")) context!!.contentResolver.openInputStream(Uri.parse(mMedium.path)) else File(mMedium.path).inputStream() val inputStream = if (mMedium.path.startsWith("content:/")) context!!.contentResolver.openInputStream(Uri.parse(mMedium.path)) else File(mMedium.path).inputStream()
val imageParser = JpegImageParser().getXmpXml(ByteSourceInputStream(inputStream, mMedium.name), HashMap<String, Any>()) val imageParser = JpegImageParser().getXmpXml(ByteSourceInputStream(inputStream, mMedium.name), HashMap<String, Any>())
imageParser.contains("GPano:UsePanoramaViewer=\"True\"", true) || imageParser.contains("GPano:UsePanoramaViewer=\"True\"", true) ||
imageParser.contains("<GPano:UsePanoramaViewer>True</GPano:UsePanoramaViewer>", true) || imageParser.contains("<GPano:UsePanoramaViewer>True</GPano:UsePanoramaViewer>", true) ||
imageParser.contains("GPano:FullPanoWidthPixels=") || imageParser.contains("GPano:FullPanoWidthPixels=") ||
imageParser.contains("GPano:ProjectionType>Equirectangular") imageParser.contains("GPano:ProjectionType>Equirectangular")
} catch (e: Exception) { } catch (e: Exception) {
false false
} catch (e: OutOfMemoryError) { } catch (e: OutOfMemoryError) {