mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
handle cases when column _data does not exist
This commit is contained in:
parent
3d089db697
commit
c7dd7b7e2e
1 changed files with 3 additions and 2 deletions
|
@ -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 a new issue