mirror of
https://github.com/SimpleMobileTools/Simple-Keyboard.git
synced 2025-04-20 05:07:34 +02:00
catch and show exceptions thrown at importing clips from a file
This commit is contained in:
parent
dd59e51bec
commit
a20ab59df5
@ -175,19 +175,23 @@ class ManageClipboardItemsActivity : SimpleActivity(), RefreshRecyclerViewListen
|
|||||||
|
|
||||||
var clipsImported = 0
|
var clipsImported = 0
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
val token = object : TypeToken<List<String>>() {}.type
|
try {
|
||||||
val clipValues = Gson().fromJson<ArrayList<String>>(inputStream.bufferedReader(), token) ?: ArrayList()
|
val token = object : TypeToken<List<String>>() {}.type
|
||||||
clipValues.forEach { value ->
|
val clipValues = Gson().fromJson<ArrayList<String>>(inputStream.bufferedReader(), token) ?: ArrayList()
|
||||||
val clip = Clip(null, value)
|
clipValues.forEach { value ->
|
||||||
if (ClipsHelper(this).insertClip(clip) > 0) {
|
val clip = Clip(null, value)
|
||||||
clipsImported++
|
if (ClipsHelper(this).insertClip(clip) > 0) {
|
||||||
|
clipsImported++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
val msg = if (clipsImported > 0) R.string.importing_successful else R.string.no_new_entries_for_importing
|
val msg = if (clipsImported > 0) R.string.importing_successful else R.string.no_new_entries_for_importing
|
||||||
toast(msg)
|
toast(msg)
|
||||||
updateClips()
|
updateClips()
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
showErrorToast(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user