add the functionality to filter images or videos only

This commit is contained in:
tibbi 2016-12-10 23:38:07 +01:00
parent ce4c098e32
commit 2e88f83844
2 changed files with 9 additions and 7 deletions

View file

@ -9,9 +9,7 @@ import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.extensions.getHumanizedFilename import com.simplemobiletools.gallery.extensions.getHumanizedFilename
import com.simplemobiletools.gallery.extensions.getLongValue import com.simplemobiletools.gallery.extensions.getLongValue
import com.simplemobiletools.gallery.extensions.getStringValue import com.simplemobiletools.gallery.extensions.getStringValue
import com.simplemobiletools.gallery.helpers.Config import com.simplemobiletools.gallery.helpers.*
import com.simplemobiletools.gallery.helpers.SORT_BY_NAME
import com.simplemobiletools.gallery.helpers.SORT_DESCENDING
import com.simplemobiletools.gallery.models.Directory import com.simplemobiletools.gallery.models.Directory
import java.io.File import java.io.File
import java.util.* import java.util.*
@ -28,13 +26,14 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
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 invalidFiles = ArrayList<File>() val invalidFiles = ArrayList<File>()
val showMedia = mConfig.showMedia
for (i in 0..1) { for (i in 0..1) {
if ((isPickVideo) && i == 0) if (i == 0 && (isPickVideo || showMedia == VIDEOS))
continue continue
var uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI var uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI
if (i == 1) { if (i == 1) {
if (isPickImage) if (isPickImage || showMedia == IMAGES)
continue continue
uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI

View file

@ -8,6 +8,8 @@ import com.simplemobiletools.filepicker.extensions.scanFiles
import com.simplemobiletools.gallery.extensions.getLongValue import com.simplemobiletools.gallery.extensions.getLongValue
import com.simplemobiletools.gallery.extensions.getStringValue import com.simplemobiletools.gallery.extensions.getStringValue
import com.simplemobiletools.gallery.helpers.Config import com.simplemobiletools.gallery.helpers.Config
import com.simplemobiletools.gallery.helpers.IMAGES
import com.simplemobiletools.gallery.helpers.VIDEOS
import com.simplemobiletools.gallery.models.Medium import com.simplemobiletools.gallery.models.Medium
import java.io.File import java.io.File
import java.util.* import java.util.*
@ -25,13 +27,14 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo
override fun doInBackground(vararg params: Void): ArrayList<Medium> { override fun doInBackground(vararg params: Void): ArrayList<Medium> {
val media = ArrayList<Medium>() val media = ArrayList<Medium>()
val invalidFiles = ArrayList<File>() val invalidFiles = ArrayList<File>()
val showMedia = mConfig.showMedia
for (i in 0..1) { for (i in 0..1) {
if (isPickVideo && i == 0) if (i == 0 && (isPickVideo || showMedia == VIDEOS))
continue continue
var uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI var uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI
if (i == 1) { if (i == 1) {
if (isPickImage) if (isPickImage || showMedia == IMAGES)
continue continue
uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI