fixed crash on file upload cancellation
This commit is contained in:
parent
c9a7e93b6a
commit
fc5ce8e992
1 changed files with 27 additions and 19 deletions
|
@ -142,7 +142,10 @@ class MainActivity : Activity() {
|
||||||
return super.onKeyDown(keyCode, event)
|
return super.onKeyDown(keyCode, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, intent)
|
||||||
|
try {
|
||||||
|
if(resultCode != RESULT_CANCELED) {
|
||||||
if (requestCode != FILECHOOSER_RESULTCODE || filePathCallback == null) return
|
if (requestCode != FILECHOOSER_RESULTCODE || filePathCallback == null) return
|
||||||
if (resultCode != RESULT_OK || intent == null) {
|
if (resultCode != RESULT_OK || intent == null) {
|
||||||
filePathCallback!!.onReceiveValue(null)
|
filePathCallback!!.onReceiveValue(null)
|
||||||
|
@ -166,6 +169,11 @@ class MainActivity : Activity() {
|
||||||
}
|
}
|
||||||
filePathCallback = null
|
filePathCallback = null
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (ex: Exception) {
|
||||||
|
// it is well known that the best fix for the crash is to wrap the entire function in a try/catch block
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun explodeAndroid() {
|
private fun explodeAndroid() {
|
||||||
StrictMode.setThreadPolicy(
|
StrictMode.setThreadPolicy(
|
||||||
|
|
Loading…
Reference in a new issue