Fixed app crashing when deleting cache/download
This commit is contained in:
@@ -20,7 +20,7 @@ android {
|
|||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 57
|
versionCode 57
|
||||||
versionName "4.20"
|
versionName "4.20-hotfix1"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
"filters": [],
|
"filters": [],
|
||||||
"properties": [],
|
"properties": [],
|
||||||
"versionCode": 57,
|
"versionCode": 57,
|
||||||
"versionName": "4.20",
|
"versionName": "4.20-hotfix1",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"outputFile": "app-release.apk"
|
"outputFile": "app-release.apk"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class SettingsFragment :
|
|||||||
return getString(R.string.settings_storage_usage,
|
return getString(R.string.settings_storage_usage,
|
||||||
Runtime.getRuntime().exec("du -hs " + dir.absolutePath).let {
|
Runtime.getRuntime().exec("du -hs " + dir.absolutePath).let {
|
||||||
BufferedReader(InputStreamReader(it.inputStream)).use { reader ->
|
BufferedReader(InputStreamReader(it.inputStream)).use { reader ->
|
||||||
reader.readLine().split('\t').firstOrNull() ?: "0"
|
reader.readLine()?.split('\t')?.firstOrNull() ?: "0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -106,11 +106,13 @@ class SettingsFragment :
|
|||||||
if (dir.exists())
|
if (dir.exists())
|
||||||
dir.deleteRecursively()
|
dir.deleteRecursively()
|
||||||
|
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
summary = getString(R.string.settings_storage_usage_loading)
|
||||||
summary = getString(R.string.settings_storage_usage_loading)
|
|
||||||
|
|
||||||
launch(Dispatchers.Main) {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
this@with.summary = getDirSize(dir)
|
getDirSize(dir).let {
|
||||||
|
launch(Dispatchers.Main) {
|
||||||
|
this@with.summary = getDirSize(dir)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -127,11 +129,13 @@ class SettingsFragment :
|
|||||||
if (dir.exists())
|
if (dir.exists())
|
||||||
dir.deleteRecursively()
|
dir.deleteRecursively()
|
||||||
|
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
summary = getString(R.string.settings_storage_usage_loading)
|
||||||
summary = getString(R.string.settings_storage_usage_loading)
|
|
||||||
|
|
||||||
launch(Dispatchers.Main) {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
this@with.summary = getDirSize(dir)
|
getDirSize(dir).let {
|
||||||
|
launch(Dispatchers.Main) {
|
||||||
|
this@with.summary = getDirSize(dir)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user