-
- // TODO(yongsheng): I believe this is needed?
- /*public static synchronized void setValue(String key, int value) throws RuntimeException {
- }*/
-
- static synchronized void load(KeyValueChangeListener listener) {
- // Load current settings for initialization of a listener implementor.
- for (Map.Entry<String, Boolean> entry : sPrefMap.entrySet()) {
- listener.onKeyValueChanged(entry.getKey(), entry.getValue());
- }
-
- registerListener(listener);
- }
-
- // Listen to value changes.
- interface KeyValueChangeListener {
- public void onKeyValueChanged(String key, boolean value);
- }
-
- private static synchronized void registerListener(KeyValueChangeListener listener) {
- sListeners.add(listener);
- }
-
- private static void onKeyValueChanged(String key, boolean enabled) {
- for (KeyValueChangeListener listener : sListeners) {
- listener.onKeyValueChanged(key, enabled);
- }
- }
-
- private static void checkKey(String key) throws RuntimeException {
- if (!sPrefMap.containsKey(key)) {
- throw new RuntimeException("Warning: the preference key " + key +
- " is not supported by Crosswalk.");
- }
- }
-