From b1fa8bca89b5c85dffec0999c781cd08dca9e913 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 6 Dec 2016 17:14:54 +0100 Subject: [PATCH] show all media files in the appropriate section --- .../simplemobiletools/gallery/activities/MediaActivity.kt | 2 +- .../gallery/activities/ViewPagerActivity.kt | 2 +- .../gallery/asynctasks/GetMediaAsynctask.kt | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index f03d99531..9f049fa4d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -166,7 +166,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { return mIsGettingMedia = true - GetMediaAsynctask(applicationContext, mPath, mIsGetVideoIntent, mIsGetImageIntent, mToBeDeleted) { + GetMediaAsynctask(applicationContext, mPath, mIsGetVideoIntent, mIsGetImageIntent, mToBeDeleted, mShowAll) { gotMedia(it) }.execute() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index a7b403f39..9ab2b2717 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -239,7 +239,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } private fun reloadViewPager() { - GetMediaAsynctask(applicationContext, mDirectory, false, false, ArrayList()) { + GetMediaAsynctask(applicationContext, mDirectory, false, false, ArrayList(), false) { mMedia = it if (isDirEmpty()) return@GetMediaAsynctask diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt index da420a50b..56fb7cf48 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt @@ -13,7 +13,7 @@ import java.io.File import java.util.* class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo: Boolean = false, val isPickImage: Boolean = false, - val mToBeDeleted: List = ArrayList(), val callback: (media: ArrayList) -> Unit) : + val mToBeDeleted: List = ArrayList(), val showAll: Boolean, val callback: (media: ArrayList) -> Unit) : AsyncTask>() { lateinit var mConfig: Config @@ -37,7 +37,8 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI } val where = "${MediaStore.Images.Media.DATA} LIKE ?" - val args = arrayOf("$mPath%") + val checkPath = if (showAll) "%" else "$mPath%" + val args = arrayOf(checkPath) val columns = arrayOf(MediaStore.Images.Media.DATA, MediaStore.Images.Media.DISPLAY_NAME, MediaStore.Images.Media.DATE_MODIFIED, MediaStore.Images.Media.DATE_TAKEN, MediaStore.Images.Media.SIZE) var cursor: Cursor? = null @@ -58,7 +59,7 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo } // exclude images of subdirectories - if (file.parent != mPath) + if (!showAll && file.parent != mPath) continue val name = cursor.getStringValue(MediaStore.Images.Media.DISPLAY_NAME) ?: ""