mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2024-12-25 15:52:35 +01:00
handle cases when column _data does not exist
This commit is contained in:
parent
3d089db697
commit
c7dd7b7e2e
@ -13,14 +13,15 @@ fun Context.getRealPathFromURI(uri: Uri): String? {
|
|||||||
try {
|
try {
|
||||||
val projection = arrayOf(MediaStore.Images.Media.DATA)
|
val projection = arrayOf(MediaStore.Images.Media.DATA)
|
||||||
cursor = contentResolver.query(uri, projection, null, null, null)
|
cursor = contentResolver.query(uri, projection, null, null, null)
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor?.moveToFirst() == true) {
|
||||||
val index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA)
|
val index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA)
|
||||||
return cursor.getString(index)
|
return cursor.getString(index)
|
||||||
}
|
}
|
||||||
return null
|
} catch (e: IllegalArgumentException) {
|
||||||
} finally {
|
} finally {
|
||||||
cursor?.close()
|
cursor?.close()
|
||||||
}
|
}
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.getHumanizedFilename(path: String): String {
|
fun Context.getHumanizedFilename(path: String): String {
|
||||||
|
Loading…
Reference in New Issue
Block a user