use thoe shorter version of cursor looping
This commit is contained in:
parent
60b44c27be
commit
a7b35e36b2
|
@ -442,10 +442,7 @@ class MediaFetcher(val context: Context) {
|
|||
val selection = "${Images.Media.DATA} LIKE ? AND ${Images.Media.DATA} NOT LIKE ?"
|
||||
val selectionArgs = arrayOf("$folder/%", "$folder/%/%")
|
||||
|
||||
val cursor = context.contentResolver.query(uri, projection, selection, selectionArgs, null)
|
||||
cursor?.use {
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
context.queryCursor(uri, projection, selection, selectionArgs) { cursor ->
|
||||
try {
|
||||
val dateTaken = cursor.getLongValue(Images.Media.DATE_TAKEN)
|
||||
if (dateTaken != 0L) {
|
||||
|
@ -454,8 +451,6 @@ class MediaFetcher(val context: Context) {
|
|||
}
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
} while (cursor.moveToNext())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -482,10 +477,7 @@ class MediaFetcher(val context: Context) {
|
|||
val uri = Files.getContentUri("external")
|
||||
|
||||
try {
|
||||
val cursor = context.contentResolver.query(uri, projection, null, null, null)
|
||||
cursor?.use {
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
context.queryCursor(uri, projection) { cursor ->
|
||||
try {
|
||||
val dateTaken = cursor.getLongValue(Images.Media.DATE_TAKEN)
|
||||
if (dateTaken != 0L) {
|
||||
|
@ -494,8 +486,6 @@ class MediaFetcher(val context: Context) {
|
|||
}
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
} while (cursor.moveToNext())
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
|
@ -521,10 +511,7 @@ class MediaFetcher(val context: Context) {
|
|||
val selection = "${Images.Media.DATA} LIKE ? AND ${Images.Media.DATA} NOT LIKE ?"
|
||||
val selectionArgs = arrayOf("$folder/%", "$folder/%/%")
|
||||
|
||||
val cursor = context.contentResolver.query(uri, projection, selection, selectionArgs, null)
|
||||
cursor?.use {
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
context.queryCursor(uri, projection, selection, selectionArgs) { cursor ->
|
||||
try {
|
||||
val lastModified = cursor.getLongValue(Images.Media.DATE_MODIFIED) * 1000
|
||||
if (lastModified != 0L) {
|
||||
|
@ -533,8 +520,6 @@ class MediaFetcher(val context: Context) {
|
|||
}
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
} while (cursor.moveToNext())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -551,10 +536,7 @@ class MediaFetcher(val context: Context) {
|
|||
val uri = Files.getContentUri("external")
|
||||
|
||||
try {
|
||||
val cursor = context.contentResolver.query(uri, projection, null, null, null)
|
||||
cursor?.use {
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
context.queryCursor(uri, projection) { cursor ->
|
||||
try {
|
||||
val lastModified = cursor.getLongValue(Images.Media.DATE_MODIFIED) * 1000
|
||||
if (lastModified != 0L) {
|
||||
|
@ -563,8 +545,6 @@ class MediaFetcher(val context: Context) {
|
|||
}
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
} while (cursor.moveToNext())
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
|
@ -584,10 +564,7 @@ class MediaFetcher(val context: Context) {
|
|||
val selection = "${Images.Media.DATA} LIKE ? AND ${Images.Media.DATA} NOT LIKE ?"
|
||||
val selectionArgs = arrayOf("$folder/%", "$folder/%/%")
|
||||
|
||||
val cursor = context.contentResolver.query(uri, projection, selection, selectionArgs, null)
|
||||
cursor?.use {
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
context.queryCursor(uri, projection, selection, selectionArgs) { cursor ->
|
||||
try {
|
||||
val size = cursor.getLongValue(Images.Media.SIZE)
|
||||
if (size != 0L) {
|
||||
|
@ -596,8 +573,6 @@ class MediaFetcher(val context: Context) {
|
|||
}
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
} while (cursor.moveToNext())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue