From 56063c577abdb4792c572b6ac3302685bda4180e Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Sat, 20 Sep 2014 16:06:27 +0300 Subject: [PATCH] Fixed crash when changing app preferences (fixes #125). --- .../syncthingandroid/fragments/SettingsFragment.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/nutomic/syncthingandroid/fragments/SettingsFragment.java b/src/main/java/com/nutomic/syncthingandroid/fragments/SettingsFragment.java index 6531bf10..0c07f78e 100644 --- a/src/main/java/com/nutomic/syncthingandroid/fragments/SettingsFragment.java +++ b/src/main/java/com/nutomic/syncthingandroid/fragments/SettingsFragment.java @@ -136,9 +136,12 @@ public class SettingsFragment extends PreferenceFragment */ @Override public boolean onPreferenceChange(Preference preference, Object o) { - EditTextPreference etp = (EditTextPreference) preference; - if (etp.getEditText().getInputType() == InputType.TYPE_CLASS_NUMBER) { - o = Integer.parseInt((String) o); + // Convert new value to integer if input type is number. + if (preference instanceof EditTextPreference) { + EditTextPreference etp = (EditTextPreference) preference; + if (etp.getEditText().getInputType() == InputType.TYPE_CLASS_NUMBER) { + o = Integer.parseInt((String) o); + } } if (preference.equals(mSyncOnlyCharging) || preference.equals(mSyncOnlyWifi)) { @@ -158,6 +161,7 @@ public class SettingsFragment extends PreferenceFragment ((SyncthingActivity) getActivity()).getApi().requireRestart(getActivity()); } + // Set the preference value as summary. if (preference instanceof EditTextPreference) { String value = (String) o; preference.setSummary(value);