mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
handle prefs ArrayIndexOutOfBoundsException
This commit is contained in:
parent
cbd8090137
commit
d94620328b
2 changed files with 5 additions and 20 deletions
|
|
@ -95,9 +95,8 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
|||
val mapStyles by lazy { resources.getStringArray(R.array.map_styles) }
|
||||
|
||||
/// Load preferences and its value
|
||||
val prefs = UIViewModel.getPreferences(context!!)
|
||||
val editor: SharedPreferences.Editor = prefs.edit()
|
||||
val mapStyleInt = prefs.getInt(mapStyleId, 1)
|
||||
val editor: SharedPreferences.Editor = mPrefs.edit()
|
||||
val mapStyleInt = mPrefs.getInt(mapStyleId, 1)
|
||||
debug("mapStyleId from prefs: $mapStyleInt")
|
||||
|
||||
builder.setSingleChoiceItems(mapStyles, mapStyleInt) { dialog, which ->
|
||||
|
|
@ -210,10 +209,9 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
|||
}
|
||||
|
||||
private fun loadOnlineTileSourceBase(): ITileSource {
|
||||
val prefs = context?.getSharedPreferences(uiPrefs, Context.MODE_PRIVATE)
|
||||
val mapSourceId = prefs?.getInt(mapStyleId, 1)
|
||||
debug("mapStyleId from prefs: $mapSourceId")
|
||||
return CustomTileSource.mTileSources[mapSourceId!!]
|
||||
val id = mPrefs.getInt(mapStyleId, 1)
|
||||
debug("mapStyleId from prefs: $id")
|
||||
return CustomTileSource.mTileSources.getOrNull(id) ?: CustomTileSource.DEFAULT_TILE_SOURCE
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="map_styles">
|
||||
<item>Ulice</item>
|
||||
<item>Teren</item>
|
||||
<item>Jasny</item>
|
||||
<item>Ciemny</item>
|
||||
<item>Satelita</item>
|
||||
<item>Satelita (wraz z ulicami)</item>
|
||||
<item>Natężenie ruchu (jasny)</item>
|
||||
<item>Natężenie ruchu (ciemy)</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
Loading…
Add table
Add a link
Reference in a new issue