mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 00:17:58 +01:00
moving file deletion handling into Commons
This commit is contained in:
parent
841d770167
commit
f6a1ba1c74
3 changed files with 1 additions and 42 deletions
|
@ -78,7 +78,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:8663595392'
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:9da550ecf3'
|
||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
|
||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
||||
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.22'
|
||||
|
|
|
@ -1098,18 +1098,3 @@ fun Context.getFileDateTaken(path: String): Long {
|
|||
|
||||
return 0L
|
||||
}
|
||||
|
||||
fun Context.getFileUrisFromFileDirItems(fileDirItems: ArrayList<FileDirItem>): ArrayList<Uri> {
|
||||
val fileUris = ArrayList<Uri>()
|
||||
val allIds = MediaFetcher(this).getMediaStoreIds()
|
||||
val filePaths = fileDirItems.map { it.path.lowercase(Locale.getDefault()) }
|
||||
for ((filePath, mediaStoreId) in allIds) {
|
||||
if (filePaths.contains(filePath.lowercase(Locale.getDefault()))) {
|
||||
val baseUri = getFileUri(filePath)
|
||||
val uri = ContentUris.withAppendedId(baseUri, mediaStoreId)
|
||||
fileUris.add(uri)
|
||||
}
|
||||
}
|
||||
|
||||
return fileUris
|
||||
}
|
||||
|
|
|
@ -616,32 +616,6 @@ class MediaFetcher(val context: Context) {
|
|||
return sizes
|
||||
}
|
||||
|
||||
fun getMediaStoreIds(): HashMap<String, Long> {
|
||||
val ids = HashMap<String, Long>()
|
||||
val projection = arrayOf(
|
||||
Images.Media.DATA,
|
||||
Images.Media._ID
|
||||
)
|
||||
|
||||
val uri = Files.getContentUri("external")
|
||||
|
||||
try {
|
||||
context.queryCursor(uri, projection) { cursor ->
|
||||
try {
|
||||
val id = cursor.getLongValue(Images.Media._ID)
|
||||
if (id != 0L) {
|
||||
val path = cursor.getStringValue(Images.Media.DATA)
|
||||
ids[path] = id
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
|
||||
return ids
|
||||
}
|
||||
|
||||
fun sortMedia(media: ArrayList<Medium>, sorting: Int) {
|
||||
if (sorting and SORT_BY_RANDOM != 0) {
|
||||
media.shuffle()
|
||||
|
|
Loading…
Reference in a new issue