show hidden files only when should

This commit is contained in:
tibbi 2017-04-26 19:54:47 +02:00
parent 27becd9247
commit f137f3db06
2 changed files with 8 additions and 1 deletions

View file

@ -18,6 +18,7 @@ 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
var shouldStop = false var shouldStop = false
val showHidden = config.shouldShowHidden
override fun doInBackground(vararg params: Void): ArrayList<Directory> { override fun doInBackground(vararg params: Void): ArrayList<Directory> {
if (!context.hasWriteStoragePermission()) if (!context.hasWriteStoragePermission())
@ -48,6 +49,9 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
if (isImage && (isPickVideo || showMedia == VIDEOS)) if (isImage && (isPickVideo || showMedia == VIDEOS))
continue continue
if (!showHidden && filename.startsWith('.'))
continue
val file = File(it, filename) val file = File(it, filename)
val size = file.length() val size = file.length()
if (size == 0L) if (size == 0L)
@ -74,7 +78,6 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
private fun groupDirectories(media: ArrayList<Medium>): Map<String, Directory> { private fun groupDirectories(media: ArrayList<Medium>): Map<String, Directory> {
val hidden = context.resources.getString(R.string.hidden) val hidden = context.resources.getString(R.string.hidden)
val directories = LinkedHashMap<String, Directory>() val directories = LinkedHashMap<String, Directory>()
val showHidden = config.shouldShowHidden
for ((name, path, isVideo, dateModified, dateTaken, size) in media) { for ((name, path, isVideo, dateModified, dateTaken, size) in media) {
if (shouldStop) if (shouldStop)
cancel(true) cancel(true)

View file

@ -22,6 +22,7 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo
var fileSorting = 0 var fileSorting = 0
var shouldStop = false var shouldStop = false
var media = ArrayList<Medium>() var media = ArrayList<Medium>()
val showHidden = config.shouldShowHidden
override fun onPreExecute() { override fun onPreExecute() {
super.onPreExecute() super.onPreExecute()
@ -63,6 +64,9 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo
if (isImage && (isPickVideo || showMedia == VIDEOS)) if (isImage && (isPickVideo || showMedia == VIDEOS))
continue continue
if (!showHidden && filename.startsWith('.'))
continue
val file = File(path, filename) val file = File(path, filename)
val size = file.length() val size = file.length()
if (size == 0L) if (size == 0L)