mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 20:48:00 +01:00
rescan only paths which arent in mediastore yet
This commit is contained in:
parent
7dc0cb660c
commit
443aa9449b
3 changed files with 21 additions and 2 deletions
|
@ -46,7 +46,7 @@ ext {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:3.14.7'
|
||||
implementation 'com.simplemobiletools:commons:3.14.12'
|
||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.0'
|
||||
implementation 'com.android.support:multidex:1.0.3'
|
||||
implementation 'com.google.code.gson:gson:2.8.2'
|
||||
|
|
|
@ -11,6 +11,7 @@ import android.provider.MediaStore
|
|||
import android.view.WindowManager
|
||||
import com.simplemobiletools.commons.extensions.getStringValue
|
||||
import com.simplemobiletools.commons.extensions.humanizePath
|
||||
import com.simplemobiletools.commons.helpers.OTG_PATH
|
||||
import com.simplemobiletools.gallery.activities.SettingsActivity
|
||||
import com.simplemobiletools.gallery.helpers.Config
|
||||
import com.simplemobiletools.gallery.helpers.NOMEDIA
|
||||
|
@ -110,3 +111,20 @@ fun Context.getNoMediaFolders(callback: (folders: ArrayList<String>) -> Unit) {
|
|||
callback(folders)
|
||||
}.start()
|
||||
}
|
||||
|
||||
fun Context.isPathInMediaStore(path: String): Boolean {
|
||||
if (path.startsWith(OTG_PATH)) {
|
||||
return false
|
||||
}
|
||||
|
||||
val projection = arrayOf(MediaStore.Images.Media.DATE_MODIFIED)
|
||||
val uri = MediaStore.Files.getContentUri("external")
|
||||
val selection = "${MediaStore.MediaColumns.DATA} = ?"
|
||||
val selectionArgs = arrayOf(path)
|
||||
val cursor = contentResolver.query(uri, projection, selection, selectionArgs, null)
|
||||
|
||||
cursor?.use {
|
||||
return cursor.moveToFirst()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.simplemobiletools.commons.helpers.*
|
|||
import com.simplemobiletools.gallery.extensions.config
|
||||
import com.simplemobiletools.gallery.extensions.containsNoMedia
|
||||
import com.simplemobiletools.gallery.extensions.doesParentHaveNoMedia
|
||||
import com.simplemobiletools.gallery.extensions.isPathInMediaStore
|
||||
import com.simplemobiletools.gallery.models.Medium
|
||||
import java.io.File
|
||||
import java.util.LinkedHashMap
|
||||
|
@ -64,7 +65,7 @@ class MediaFetcher(val context: Context) {
|
|||
files.forEach {
|
||||
val filePath = it.absolutePath
|
||||
if ((showHidden || !it.name.startsWith(".")) && !dirPaths.contains(filePath)) {
|
||||
if (it.exists() && it.length() > 0 && it.isImageVideoGif()) {
|
||||
if (it.exists() && it.length() > 0 && it.isImageVideoGif() && !context.isPathInMediaStore(it.absolutePath)) {
|
||||
newPaths.add(it.absolutePath)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue