From 2f791d1a60f2ac41647ee75d7b0a3ef8365a7e31 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Sun, 25 Aug 2013 15:49:36 +0200 Subject: fix #3191: NumberFormatException in SettingsActivity --- main/src/cgeo/geocaching/settings/SettingsActivity.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'main/src') diff --git a/main/src/cgeo/geocaching/settings/SettingsActivity.java b/main/src/cgeo/geocaching/settings/SettingsActivity.java index ece2acb..4bcf279 100644 --- a/main/src/cgeo/geocaching/settings/SettingsActivity.java +++ b/main/src/cgeo/geocaching/settings/SettingsActivity.java @@ -40,7 +40,6 @@ import android.view.View; import android.widget.BaseAdapter; import android.widget.EditText; import android.widget.ListAdapter; -import android.widget.Toast; import java.io.File; import java.util.ArrayList; @@ -482,8 +481,14 @@ public class SettingsActivity extends PreferenceActivity { } } else if (isPreference(preference, R.string.pref_mapsource)) { // reset the cached map source - int mapSourceId = Integer.valueOf(stringValue); - MapSource mapSource = MapProviderFactory.getMapSource(mapSourceId); + MapSource mapSource; + try { + final int mapSourceId = Integer.valueOf(stringValue); + mapSource = MapProviderFactory.getMapSource(mapSourceId); + } catch (final NumberFormatException e) { + Log.e("SettingsActivity.onPreferenceChange: bad source id `" + stringValue + "'"); + mapSource = null; + } // If there is no corresponding map source (because some map sources were // removed from the device since) then use the first one available. if (mapSource == null) { -- cgit v1.1