mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-03-15 02:40:18 +01:00
Changed runCatching to try/catch block
This commit is contained in:
parent
22a2fbb331
commit
3892c5f5d5
@ -304,7 +304,7 @@ class SettingsActivity : SimpleActivity() {
|
||||
|
||||
|
||||
private fun importCallHistory(uri: Uri) {
|
||||
runCatching {
|
||||
try {
|
||||
val jsonString = contentResolver.openInputStream(uri)!!.use { inputStream ->
|
||||
inputStream.bufferedReader().readText()
|
||||
}
|
||||
@ -315,8 +315,8 @@ class SettingsActivity : SimpleActivity() {
|
||||
RecentsHelper(this).restoreRecentCalls(this, objects) {
|
||||
toast(R.string.importing_successful)
|
||||
}
|
||||
}.onFailure {
|
||||
toast(R.string.importing_failed)
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
}
|
||||
}
|
||||
|
||||
@ -324,17 +324,16 @@ class SettingsActivity : SimpleActivity() {
|
||||
if (recents.isEmpty()) {
|
||||
toast(R.string.no_entries_for_exporting)
|
||||
} else {
|
||||
runCatching {
|
||||
try {
|
||||
val outputStream = contentResolver.openOutputStream(uri)!!
|
||||
|
||||
val jsonString = Gson().toJson(recents)
|
||||
outputStream.use {
|
||||
it.write(jsonString.toByteArray())
|
||||
}
|
||||
}.onSuccess {
|
||||
toast(R.string.exporting_successful)
|
||||
}.onFailure {
|
||||
toast(R.string.exporting_failed)
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user