mirror of
https://github.com/ev-map/EVMap.git
synced 2026-05-24 23:06:15 -04:00
SearchSelectScreen: catch IOExceptions
This commit is contained in:
@@ -7,8 +7,11 @@ import androidx.car.app.constraints.ConstraintManager
|
||||
import androidx.car.app.model.*
|
||||
import androidx.core.graphics.drawable.IconCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import net.vonforst.evmap.R
|
||||
import okio.IOException
|
||||
|
||||
abstract class MultiSelectSearchScreen<T>(ctx: CarContext) : Screen(ctx),
|
||||
SearchTemplate.SearchCallback {
|
||||
@@ -22,9 +25,20 @@ abstract class MultiSelectSearchScreen<T>(ctx: CarContext) : Screen(ctx),
|
||||
override fun onGetTemplate(): Template {
|
||||
if (fullList == null) {
|
||||
lifecycleScope.launch {
|
||||
fullList = loadData()
|
||||
filterList()
|
||||
invalidate()
|
||||
try {
|
||||
fullList = loadData()
|
||||
filterList()
|
||||
invalidate()
|
||||
} catch (e: IOException) {
|
||||
withContext(Dispatchers.Main) {
|
||||
CarToast.makeText(
|
||||
carContext,
|
||||
R.string.generic_connection_error,
|
||||
CarToast.LENGTH_LONG
|
||||
).show()
|
||||
screenManager.pop()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -365,4 +365,5 @@
|
||||
<string name="referrals">Empfehlungslinks</string>
|
||||
<string name="referrals_info">Du kannst auch einen der Empfehlungslinks unten benutzen, um den Entwickler mit deinem Kauf zu unterstützen.</string>
|
||||
<string name="referral_tesla">Tesla</string>
|
||||
<string name="generic_connection_error">Daten konnten nicht geladen werden</string>
|
||||
</resources>
|
||||
@@ -365,4 +365,5 @@
|
||||
<string name="referrals">Referral links</string>
|
||||
<string name="referrals_info">You can also use one of the referral links below to support the developer with your purchase.</string>
|
||||
<string name="referral_tesla">Tesla</string>
|
||||
<string name="generic_connection_error">Could not load data</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user