forked from hardcoresushi/DroidFS
Fix crash when default volume gets deleted
This commit is contained in:
parent
eb4e13af46
commit
24215a8b31
@ -118,13 +118,13 @@ class MainActivity : BaseActivity(), VolumeAdapter.Listener {
|
|||||||
volumeOpener.defaultVolumeName?.let { name ->
|
volumeOpener.defaultVolumeName?.let { name ->
|
||||||
val state = savedInstanceState?.getBoolean(OPEN_DEFAULT_VOLUME)
|
val state = savedInstanceState?.getBoolean(OPEN_DEFAULT_VOLUME)
|
||||||
if (state == true || state == null) {
|
if (state == true || state == null) {
|
||||||
val volumeData = volumeAdapter.volumes.first { it.name == name }
|
try {
|
||||||
if (!volumeManager.isOpen(volumeData)) {
|
val volumeData = volumeAdapter.volumes.first { it.name == name }
|
||||||
try {
|
if (!volumeManager.isOpen(volumeData)) {
|
||||||
openVolume(volumeData)
|
openVolume(volumeData)
|
||||||
} catch (e: NoSuchElementException) {
|
|
||||||
unsetDefaultVolume()
|
|
||||||
}
|
}
|
||||||
|
} catch (e: NoSuchElementException) {
|
||||||
|
unsetDefaultVolume()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user