catch and show exceptions thrown at importing clips from a file

This commit is contained in:
tibbi 2022-02-02 11:26:53 +01:00
parent dd59e51bec
commit a20ab59df5
1 changed files with 15 additions and 11 deletions

View File

@ -175,6 +175,7 @@ class ManageClipboardItemsActivity : SimpleActivity(), RefreshRecyclerViewListen
var clipsImported = 0 var clipsImported = 0
ensureBackgroundThread { ensureBackgroundThread {
try {
val token = object : TypeToken<List<String>>() {}.type val token = object : TypeToken<List<String>>() {}.type
val clipValues = Gson().fromJson<ArrayList<String>>(inputStream.bufferedReader(), token) ?: ArrayList() val clipValues = Gson().fromJson<ArrayList<String>>(inputStream.bufferedReader(), token) ?: ArrayList()
clipValues.forEach { value -> clipValues.forEach { value ->
@ -189,6 +190,9 @@ class ManageClipboardItemsActivity : SimpleActivity(), RefreshRecyclerViewListen
toast(msg) toast(msg)
updateClips() updateClips()
} }
} catch (e: Exception) {
showErrorToast(e)
}
} }
} }
} }