aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/settings/SettingsActivity.java
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2013-08-25 14:34:14 +0200
committerSamuel Tardieu <sam@rfc1149.net>2013-08-25 14:34:14 +0200
commitc5f97f5dfb2364beb5ea4707185ac404e64fc97f (patch)
tree2c20de56e90e58cacee184b2b2bbb512237d7928 /main/src/cgeo/geocaching/settings/SettingsActivity.java
parentbfb0f601991648e16ee19bf57ec2ca813d2972f2 (diff)
parent8c5a5569f8bb8dcebc2e12528aa4574ccf9e26d4 (diff)
downloadcgeo-c5f97f5dfb2364beb5ea4707185ac404e64fc97f.zip
cgeo-c5f97f5dfb2364beb5ea4707185ac404e64fc97f.tar.gz
cgeo-c5f97f5dfb2364beb5ea4707185ac404e64fc97f.tar.bz2
Merge branch 'issue-3186' into release
Diffstat (limited to 'main/src/cgeo/geocaching/settings/SettingsActivity.java')
-rw-r--r--main/src/cgeo/geocaching/settings/SettingsActivity.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/main/src/cgeo/geocaching/settings/SettingsActivity.java b/main/src/cgeo/geocaching/settings/SettingsActivity.java
index 42f6074..ece2acb 100644
--- a/main/src/cgeo/geocaching/settings/SettingsActivity.java
+++ b/main/src/cgeo/geocaching/settings/SettingsActivity.java
@@ -40,6 +40,7 @@ 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,7 +483,18 @@ public class SettingsActivity extends PreferenceActivity {
} else if (isPreference(preference, R.string.pref_mapsource)) {
// reset the cached map source
int mapSourceId = Integer.valueOf(stringValue);
- final MapSource mapSource = MapProviderFactory.getMapSource(mapSourceId);
+ MapSource mapSource = MapProviderFactory.getMapSource(mapSourceId);
+ // 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) {
+ mapSource = MapProviderFactory.getAnyMapSource();
+ if (mapSource == null) {
+ // There are no map source. There is little we can do here, except log an error and
+ // return to avoid triggering a null pointer exception.
+ Log.e("SettingsActivity.onPreferenceChange: no map source available");
+ return true;
+ }
+ }
Settings.setMapSource(mapSource);
preference.setSummary(mapSource.getName());
} else if (isPreference(preference, R.string.pref_connectorOCActive) || isPreference(preference, R.string.pref_connectorOCPLActive) || isPreference(preference, R.string.pref_connectorGCActive)) {