зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1064304 - Pre: Align PrefUtils.putStringSet docstring and reality. r=rnewman
This commit is contained in:
Родитель
2f15da9e36
Коммит
1671bd6291
|
@ -219,7 +219,7 @@ class MultiChoicePreference extends DialogPreference implements DialogInterface.
|
|||
protected boolean persist(SharedPreferences.Editor edit) {
|
||||
if (isPersistent()) {
|
||||
Set<String> vals = getValues();
|
||||
PrefUtils.putStringSet(edit, getKey(), vals);
|
||||
PrefUtils.putStringSet(edit, getKey(), vals).apply();;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,19 +54,27 @@ public class PrefUtils {
|
|||
return new HashSet<String>();
|
||||
}
|
||||
|
||||
// Cross version compatible way to save a string set to a pref.
|
||||
// NOTE: The editor that is passed in will not commit the transaction for you. It is up to callers to commit
|
||||
// when they are done with any other changes to the database.
|
||||
public static SharedPreferences.Editor putStringSet(final SharedPreferences.Editor edit,
|
||||
/**
|
||||
* Cross version compatible way to save a set of strings.
|
||||
* <p>
|
||||
* This method <b>does not commit</b> any transaction. It is up to callers
|
||||
* to commit.
|
||||
*
|
||||
* @param editor to write to.
|
||||
* @param key to write.
|
||||
* @param vals comprising string set.
|
||||
* @return
|
||||
*/
|
||||
public static SharedPreferences.Editor putStringSet(final SharedPreferences.Editor editor,
|
||||
final String key,
|
||||
final Set<String> vals) {
|
||||
if (Versions.preHC) {
|
||||
final JSONArray json = new JSONArray(vals);
|
||||
edit.putString(key, json.toString()).apply();
|
||||
editor.putString(key, json.toString());
|
||||
} else {
|
||||
edit.putStringSet(key, vals).apply();
|
||||
editor.putStringSet(key, vals);
|
||||
}
|
||||
|
||||
return edit;
|
||||
return editor;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче