mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-27 06:57:59 +01:00
removing an redundant argument
This commit is contained in:
parent
59730dff92
commit
af6121ec63
3 changed files with 10 additions and 27 deletions
|
@ -628,7 +628,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val foldersToScan = mediaFetcher.getFoldersToScan("")
|
val foldersToScan = mediaFetcher.getFoldersToScan()
|
||||||
dirs.forEach {
|
dirs.forEach {
|
||||||
foldersToScan.remove(it.path)
|
foldersToScan.remove(it.path)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickImage
|
||||||
override fun doInBackground(vararg params: Void): ArrayList<Medium> {
|
override fun doInBackground(vararg params: Void): ArrayList<Medium> {
|
||||||
val sorting = context.config.getFileSorting(mPath)
|
val sorting = context.config.getFileSorting(mPath)
|
||||||
return if (showAll) {
|
return if (showAll) {
|
||||||
val foldersToScan = mediaFetcher.getFoldersToScan("")
|
val foldersToScan = mediaFetcher.getFoldersToScan()
|
||||||
val media = ArrayList<Medium>()
|
val media = ArrayList<Medium>()
|
||||||
for (folder in foldersToScan) {
|
for (folder in foldersToScan) {
|
||||||
val newMedia = mediaFetcher.getFilesFrom(folder, isPickImage, isPickVideo, sorting)
|
val newMedia = mediaFetcher.getFilesFrom(folder, isPickImage, isPickVideo, sorting)
|
||||||
|
|
|
@ -35,28 +35,24 @@ class MediaFetcher(val context: Context) {
|
||||||
return curMedia
|
return curMedia
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getFoldersToScan(path: String): ArrayList<String> {
|
fun getFoldersToScan(): ArrayList<String> {
|
||||||
val filterMedia = context.config.filterMedia
|
val filterMedia = context.config.filterMedia
|
||||||
val projection = arrayOf(MediaStore.Images.Media.DATA)
|
val projection = arrayOf(MediaStore.Images.Media.DATA)
|
||||||
val uri = MediaStore.Files.getContentUri("external")
|
val uri = MediaStore.Files.getContentUri("external")
|
||||||
|
|
||||||
val selection = "${getSelectionQuery(path, filterMedia)} ${MediaStore.Images.ImageColumns.BUCKET_ID} IS NOT NULL) GROUP BY (${MediaStore.Images.ImageColumns.BUCKET_ID}"
|
val selection = "${getSelectionQuery(filterMedia)} ${MediaStore.Images.ImageColumns.BUCKET_ID} IS NOT NULL) GROUP BY (${MediaStore.Images.ImageColumns.BUCKET_ID}"
|
||||||
val selectionArgs = getSelectionArgsQuery(path, filterMedia).toTypedArray()
|
val selectionArgs = getSelectionArgsQuery(filterMedia).toTypedArray()
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
val cursor = context.contentResolver.query(uri, projection, selection, selectionArgs, null)
|
val cursor = context.contentResolver.query(uri, projection, selection, selectionArgs, null)
|
||||||
parseCursor(cursor, path)
|
parseCursor(cursor)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
ArrayList()
|
ArrayList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getSelectionQuery(path: String, filterMedia: Int): String {
|
private fun getSelectionQuery(filterMedia: Int): String {
|
||||||
val query = StringBuilder()
|
val query = StringBuilder()
|
||||||
if (path.isNotEmpty()) {
|
|
||||||
query.append("${MediaStore.Images.Media.DATA} LIKE ? AND ${MediaStore.Images.Media.DATA} NOT LIKE ? AND ")
|
|
||||||
}
|
|
||||||
|
|
||||||
query.append("(")
|
query.append("(")
|
||||||
if (filterMedia and TYPE_IMAGES != 0) {
|
if (filterMedia and TYPE_IMAGES != 0) {
|
||||||
photoExtensions.forEach {
|
photoExtensions.forEach {
|
||||||
|
@ -79,13 +75,8 @@ class MediaFetcher(val context: Context) {
|
||||||
return selectionQuery
|
return selectionQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getSelectionArgsQuery(path: String, filterMedia: Int): ArrayList<String> {
|
private fun getSelectionArgsQuery(filterMedia: Int): ArrayList<String> {
|
||||||
val args = ArrayList<String>()
|
val args = ArrayList<String>()
|
||||||
if (path.isNotEmpty()) {
|
|
||||||
args.add("$path/%")
|
|
||||||
args.add("$path/%/%")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filterMedia and TYPE_IMAGES != 0) {
|
if (filterMedia and TYPE_IMAGES != 0) {
|
||||||
photoExtensions.forEach {
|
photoExtensions.forEach {
|
||||||
args.add("%$it")
|
args.add("%$it")
|
||||||
|
@ -105,7 +96,7 @@ class MediaFetcher(val context: Context) {
|
||||||
return args
|
return args
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseCursor(cursor: Cursor, curPath: String): ArrayList<String> {
|
private fun parseCursor(cursor: Cursor): ArrayList<String> {
|
||||||
val config = context.config
|
val config = context.config
|
||||||
val includedFolders = config.includedFolders
|
val includedFolders = config.includedFolders
|
||||||
var foldersToScan = ArrayList<String>()
|
var foldersToScan = ArrayList<String>()
|
||||||
|
@ -123,20 +114,12 @@ class MediaFetcher(val context: Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
includedFolders.forEach {
|
includedFolders.forEach {
|
||||||
if (curPath.isEmpty()) {
|
addFolder(foldersToScan, it)
|
||||||
addFolder(foldersToScan, it)
|
|
||||||
} else if (curPath == it) {
|
|
||||||
foldersToScan.add(it)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val showHidden = config.shouldShowHidden
|
val showHidden = config.shouldShowHidden
|
||||||
val excludedFolders = config.excludedFolders
|
val excludedFolders = config.excludedFolders
|
||||||
foldersToScan = foldersToScan.filter { it.shouldFolderBeVisible(excludedFolders, includedFolders, showHidden) } as ArrayList<String>
|
foldersToScan = foldersToScan.filter { it.shouldFolderBeVisible(excludedFolders, includedFolders, showHidden) } as ArrayList<String>
|
||||||
if (config.isThirdPartyIntent && curPath.isNotEmpty()) {
|
|
||||||
foldersToScan.add(curPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
return foldersToScan.distinctBy { it.getDistinctPath() } as ArrayList<String>
|
return foldersToScan.distinctBy { it.getDistinctPath() } as ArrayList<String>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue