fix: file selection on older devices
Fixes bug where file selection was causing app to crash on older devices.
This commit is contained in:
parent
135f8c0459
commit
f513297ba0
|
@ -17,7 +17,7 @@ android {
|
|||
|
||||
val versionMajor = 2
|
||||
val versionMinor = 3
|
||||
val versionPatch = 4
|
||||
val versionPatch = 5
|
||||
val versionBuild = 0
|
||||
|
||||
defaultConfig {
|
||||
|
|
|
@ -144,7 +144,12 @@ class MainViewModel @Inject constructor(private val application : Application,
|
|||
@SuppressLint("Range")
|
||||
private fun getFileName(context: Context, uri: Uri): String {
|
||||
if (uri.scheme == "content") {
|
||||
val cursor = context.contentResolver.query(uri, null, null, null, null)
|
||||
val cursor = try {
|
||||
context.contentResolver.query(uri, null, null, null, null)
|
||||
} catch (e : Exception) {
|
||||
Timber.d("Exception getting config name")
|
||||
null
|
||||
}
|
||||
cursor ?: return defaultConfigName()
|
||||
cursor.use {
|
||||
if(cursor.moveToFirst()) {
|
||||
|
|
Loading…
Reference in New Issue