mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
optimize getting the last files modified timestamp
This commit is contained in:
parent
448fa72017
commit
4a4a054314
1 changed files with 4 additions and 5 deletions
|
@ -195,16 +195,15 @@ fun Context.getNoMediaFolders(): ArrayList<String> {
|
|||
return folders
|
||||
}
|
||||
|
||||
|
||||
fun Context.getLastMediaModified(): Int {
|
||||
val max = "max"
|
||||
val uri = MediaStore.Files.getContentUri("external")
|
||||
val projection = arrayOf(MediaStore.Images.Media._ID, MediaStore.Images.Media.DATE_MODIFIED)
|
||||
val order = "${MediaStore.Images.Media.DATE_MODIFIED} DESC"
|
||||
val projection = arrayOf(MediaStore.Images.Media._ID, "MAX(${MediaStore.Images.Media.DATE_MODIFIED}) AS $max")
|
||||
var cursor: Cursor? = null
|
||||
try {
|
||||
cursor = contentResolver.query(uri, projection, null, null, order)
|
||||
cursor = contentResolver.query(uri, projection, null, null, null)
|
||||
if (cursor?.moveToFirst() == true) {
|
||||
return cursor.getIntValue(MediaStore.Images.Media.DATE_MODIFIED)
|
||||
return cursor.getIntValue(max)
|
||||
}
|
||||
} finally {
|
||||
cursor?.close()
|
||||
|
|
Loading…
Reference in a new issue