avoid refetching mediastore items unnecessarily
This commit is contained in:
parent
dae13c0261
commit
24efdebb86
|
@ -2,14 +2,12 @@ package com.simplemobiletools.gallery.pro.extensions
|
||||||
|
|
||||||
import android.appwidget.AppWidgetManager
|
import android.appwidget.AppWidgetManager
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.ContentUris
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.database.Cursor
|
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.net.Uri
|
|
||||||
import android.os.Process
|
import android.os.Process
|
||||||
import android.provider.MediaStore.Files
|
import android.provider.MediaStore.Files
|
||||||
import android.provider.MediaStore.Images
|
import android.provider.MediaStore.Images
|
||||||
|
@ -29,7 +27,6 @@ import com.bumptech.glide.request.target.Target
|
||||||
import com.bumptech.glide.signature.ObjectKey
|
import com.bumptech.glide.signature.ObjectKey
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.FileDirItem
|
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.activities.SettingsActivity
|
import com.simplemobiletools.gallery.pro.activities.SettingsActivity
|
||||||
import com.simplemobiletools.gallery.pro.asynctasks.GetMediaAsynctask
|
import com.simplemobiletools.gallery.pro.asynctasks.GetMediaAsynctask
|
||||||
|
@ -403,7 +400,7 @@ fun Context.storeDirectoryItems(items: ArrayList<Directory>) {
|
||||||
|
|
||||||
fun Context.checkAppendingHidden(path: String, hidden: String, includedFolders: MutableSet<String>, noMediaFolders: ArrayList<String>): String {
|
fun Context.checkAppendingHidden(path: String, hidden: String, includedFolders: MutableSet<String>, noMediaFolders: ArrayList<String>): String {
|
||||||
val dirName = getFolderNameFromPath(path)
|
val dirName = getFolderNameFromPath(path)
|
||||||
val folderNoMediaStatuses = java.util.HashMap<String, Boolean>()
|
val folderNoMediaStatuses = HashMap<String, Boolean>()
|
||||||
noMediaFolders.forEach { folder ->
|
noMediaFolders.forEach { folder ->
|
||||||
folderNoMediaStatuses["$folder/$NOMEDIA"] = true
|
folderNoMediaStatuses["$folder/$NOMEDIA"] = true
|
||||||
}
|
}
|
||||||
|
@ -646,7 +643,7 @@ fun Context.getCachedDirectories(
|
||||||
val directories = try {
|
val directories = try {
|
||||||
directoryDao.getAll() as ArrayList<Directory>
|
directoryDao.getAll() as ArrayList<Directory>
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
ArrayList<Directory>()
|
ArrayList()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.showRecycleBinAtFolders) {
|
if (!config.showRecycleBinAtFolders) {
|
||||||
|
|
|
@ -46,7 +46,7 @@ class MediaFetcher(val context: Context) {
|
||||||
if (isRPlus() && curPath != FAVORITES && curPath != RECYCLE_BIN) {
|
if (isRPlus() && curPath != FAVORITES && curPath != RECYCLE_BIN) {
|
||||||
if (android11Files?.containsKey(curPath.toLowerCase()) == true) {
|
if (android11Files?.containsKey(curPath.toLowerCase()) == true) {
|
||||||
curMedia.addAll(android11Files[curPath.toLowerCase()]!!)
|
curMedia.addAll(android11Files[curPath.toLowerCase()]!!)
|
||||||
} else {
|
} else if (android11Files == null) {
|
||||||
val files = getAndroid11FolderMedia(isPickImage, isPickVideo, favoritePaths)
|
val files = getAndroid11FolderMedia(isPickImage, isPickVideo, favoritePaths)
|
||||||
if (files.containsKey(curPath.toLowerCase())) {
|
if (files.containsKey(curPath.toLowerCase())) {
|
||||||
curMedia.addAll(files[curPath.toLowerCase()]!!)
|
curMedia.addAll(files[curPath.toLowerCase()]!!)
|
||||||
|
|
Loading…
Reference in New Issue