Skip to content

Commit fb954aa

Browse files
committed
properly clear preferences when editing uploader
1 parent f8f6057 commit fb954aa

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

app/src/main/java/eu/imouto/hupl/ui/EditHttpUploaderActivity.java

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -97,34 +97,37 @@ protected void onCreate(Bundle savedInstanceState)
9797
if (pref == null)
9898
continue;
9999

100-
if (isNew)
101-
{
102-
String def = jsonDefaults.get(p);
103-
if (pref instanceof StringMapPreference)
104-
((StringMapPreference)pref).setText("");
105-
else if (pref instanceof EditTextPreference)
106-
((EditTextPreference)pref).setText(def == null ? "" : def);
107-
else if (pref instanceof CheckBoxPreference)
108-
((CheckBoxPreference)pref).setChecked(false);
109-
}
110-
else
100+
String def = jsonDefaults.get(p);
101+
if (pref instanceof StringMapPreference)
102+
((StringMapPreference)pref).setText("");
103+
else if (pref instanceof EditTextPreference)
104+
((EditTextPreference)pref).setText(def == null ? "" : def);
105+
else if (pref instanceof CheckBoxPreference)
106+
((CheckBoxPreference)pref).setChecked(false);
107+
}
108+
109+
for (String p : jsonPrefs)
110+
{
111+
pref = findPreference(p);
112+
if (pref == null)
113+
continue;
114+
115+
try
111116
{
112-
try
113-
{
114-
if (entry.json.has(p))
115-
{
116-
if (pref instanceof StringMapPreference)
117-
((StringMapPreference)pref).setObj(entry.json.getJSONObject(p));
118-
else if (pref instanceof EditTextPreference)
119-
((EditTextPreference)pref).setText(entry.json.getString(p));
120-
else if (pref instanceof CheckBoxPreference)
121-
((CheckBoxPreference)pref).setChecked(entry.json.getBoolean(p));
122-
}
123-
}
124-
catch (JSONException e)
117+
if (entry.json.has(p))
125118
{
119+
if (pref instanceof StringMapPreference)
120+
((StringMapPreference)pref).setObj(entry.json.getJSONObject(p));
121+
else if (pref instanceof EditTextPreference)
122+
((EditTextPreference)pref).setText(entry.json.getString(p));
123+
else if (pref instanceof CheckBoxPreference)
124+
((CheckBoxPreference)pref).setChecked(entry.json.getBoolean(p));
126125
}
127126
}
127+
catch (JSONException e)
128+
{
129+
}
130+
128131
if (pref instanceof EditTextPreference)
129132
pref.setSummary(((EditTextPreference)pref).getText());
130133
pref.setOnPreferenceChangeListener(this);

0 commit comments

Comments
 (0)