mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2025-01-18 22:37:59 +01:00
tweak getdirectories to use the string extensions
This commit is contained in:
parent
795fad2240
commit
b778e60781
1 changed files with 5 additions and 9 deletions
|
@ -2,6 +2,9 @@ package com.simplemobiletools.gallery.asynctasks
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.AsyncTask
|
import android.os.AsyncTask
|
||||||
|
import com.simplemobiletools.commons.extensions.isGif
|
||||||
|
import com.simplemobiletools.commons.extensions.isImageFast
|
||||||
|
import com.simplemobiletools.commons.extensions.isVideoFast
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.extensions.config
|
import com.simplemobiletools.gallery.extensions.config
|
||||||
import com.simplemobiletools.gallery.extensions.containsNoMedia
|
import com.simplemobiletools.gallery.extensions.containsNoMedia
|
||||||
|
@ -18,13 +21,6 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
|
||||||
val callback: (dirs: ArrayList<Directory>) -> Unit) : AsyncTask<Void, Void, ArrayList<Directory>>() {
|
val callback: (dirs: ArrayList<Directory>) -> Unit) : AsyncTask<Void, Void, ArrayList<Directory>>() {
|
||||||
var config = context.config
|
var config = context.config
|
||||||
|
|
||||||
val photoExtensions = arrayOf("jpg", "png", "jpeg", "bmp", "webp", "tiff")
|
|
||||||
val videoExtensions = arrayOf("webm", "mkv", "flv", "vob", "avi", "wmv", "mp4", "ogv", "qt", "m4p", "mpg", "m4v", "mp2", "mpeg", "3gp")
|
|
||||||
|
|
||||||
private fun localIsImage(path: String) = photoExtensions.any { path.endsWith(".$it", true) }
|
|
||||||
private fun localIsGif(path: String) = path.endsWith(".gif", true)
|
|
||||||
private fun localIsVideo(path: String) = videoExtensions.any { path.endsWith(".$it", true) }
|
|
||||||
|
|
||||||
override fun doInBackground(vararg params: Void): ArrayList<Directory> {
|
override fun doInBackground(vararg params: Void): ArrayList<Directory> {
|
||||||
val directories = LinkedHashMap<String, Directory>()
|
val directories = LinkedHashMap<String, Directory>()
|
||||||
val media = ArrayList<Medium>()
|
val media = ArrayList<Medium>()
|
||||||
|
@ -36,8 +32,8 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
|
||||||
val paths = File(it).list()
|
val paths = File(it).list()
|
||||||
if (paths?.size ?: 0 > 0) {
|
if (paths?.size ?: 0 > 0) {
|
||||||
for (path in paths) {
|
for (path in paths) {
|
||||||
val isImage = localIsGif(path) or localIsImage(path)
|
val isImage = path.isGif() or path.isImageFast()
|
||||||
val isVideo = if (isImage) false else localIsVideo(path)
|
val isVideo = if (isImage) false else path.isVideoFast()
|
||||||
|
|
||||||
if (!isImage && !isVideo)
|
if (!isImage && !isVideo)
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in a new issue