show all media files in the appropriate section

This commit is contained in:
tibbi 2016-12-06 17:14:54 +01:00
parent c3e3d550d1
commit b1fa8bca89
3 changed files with 6 additions and 5 deletions

View file

@ -166,7 +166,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
return return
mIsGettingMedia = true mIsGettingMedia = true
GetMediaAsynctask(applicationContext, mPath, mIsGetVideoIntent, mIsGetImageIntent, mToBeDeleted) { GetMediaAsynctask(applicationContext, mPath, mIsGetVideoIntent, mIsGetImageIntent, mToBeDeleted, mShowAll) {
gotMedia(it) gotMedia(it)
}.execute() }.execute()
} }

View file

@ -239,7 +239,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
} }
private fun reloadViewPager() { private fun reloadViewPager() {
GetMediaAsynctask(applicationContext, mDirectory, false, false, ArrayList<String>()) { GetMediaAsynctask(applicationContext, mDirectory, false, false, ArrayList<String>(), false) {
mMedia = it mMedia = it
if (isDirEmpty()) if (isDirEmpty())
return@GetMediaAsynctask return@GetMediaAsynctask

View file

@ -13,7 +13,7 @@ import java.io.File
import java.util.* import java.util.*
class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo: Boolean = false, val isPickImage: Boolean = false, class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo: Boolean = false, val isPickImage: Boolean = false,
val mToBeDeleted: List<String> = ArrayList<String>(), val callback: (media: ArrayList<Medium>) -> Unit) : val mToBeDeleted: List<String> = ArrayList<String>(), val showAll: Boolean, val callback: (media: ArrayList<Medium>) -> Unit) :
AsyncTask<Void, Void, ArrayList<Medium>>() { AsyncTask<Void, Void, ArrayList<Medium>>() {
lateinit var mConfig: Config 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 uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI
} }
val where = "${MediaStore.Images.Media.DATA} LIKE ?" 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, 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) MediaStore.Images.Media.DATE_TAKEN, MediaStore.Images.Media.SIZE)
var cursor: Cursor? = null var cursor: Cursor? = null
@ -58,7 +59,7 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo
} }
// exclude images of subdirectories // exclude images of subdirectories
if (file.parent != mPath) if (!showAll && file.parent != mPath)
continue continue
val name = cursor.getStringValue(MediaStore.Images.Media.DISPLAY_NAME) ?: "" val name = cursor.getStringValue(MediaStore.Images.Media.DISPLAY_NAME) ?: ""