try setting higher thread priority at fetching cached folders

This commit is contained in:
tibbi 2021-03-08 22:59:08 +01:00
parent 95a8c327ee
commit f4c788fa94

View file

@ -8,6 +8,7 @@ import android.database.Cursor
import android.graphics.Bitmap import android.graphics.Bitmap
import android.graphics.drawable.PictureDrawable import android.graphics.drawable.PictureDrawable
import android.media.AudioManager import android.media.AudioManager
import android.os.Process
import android.provider.MediaStore.Files import android.provider.MediaStore.Files
import android.provider.MediaStore.Images import android.provider.MediaStore.Images
import android.widget.ImageView import android.widget.ImageView
@ -587,6 +588,11 @@ fun Context.tryLoadingWithPicasso(path: String, view: MySquareImageView, cropThu
fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly: Boolean = false, forceShowHidden: Boolean = false, callback: (ArrayList<Directory>) -> Unit) { fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly: Boolean = false, forceShowHidden: Boolean = false, callback: (ArrayList<Directory>) -> Unit) {
ensureBackgroundThread { ensureBackgroundThread {
try {
Process.setThreadPriority(Process.THREAD_PRIORITY_MORE_FAVORABLE)
} catch (ignored: Exception) {
}
val directories = try { val directories = try {
directoryDao.getAll() as ArrayList<Directory> directoryDao.getAll() as ArrayList<Directory>
} catch (e: Exception) { } catch (e: Exception) {