mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 00:17:58 +01:00
catch exceptions thrown at getting file date taken
This commit is contained in:
parent
db210e8bd1
commit
0a98fd0536
1 changed files with 7 additions and 9 deletions
|
@ -894,16 +894,14 @@ fun Context.getFileDateTaken(path: String): Long {
|
|||
val selection = "${Images.Media.DATA} = ?"
|
||||
val selectionArgs = arrayOf(path)
|
||||
|
||||
val cursor = contentResolver.query(uri, projection, selection, selectionArgs, null)
|
||||
cursor?.use {
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
try {
|
||||
return cursor.getLongValue(Images.Media.DATE_TAKEN)
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
} while (cursor.moveToNext())
|
||||
try {
|
||||
val cursor = contentResolver.query(uri, projection, selection, selectionArgs, null)
|
||||
cursor?.use {
|
||||
if (cursor.moveToFirst()) {
|
||||
return cursor.getLongValue(Images.Media.DATE_TAKEN)
|
||||
}
|
||||
}
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
|
||||
return 0L
|
||||
|
|
Loading…
Reference in a new issue