1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.layoutlib.bridge.android; 18 19 import android.content.SharedPreferences; 20 21 import java.util.Map; 22 import java.util.Set; 23 24 /** 25 * An empty shared preferences implementation which doesn't store anything. It always returns 26 * null, 0 or false. 27 */ 28 public class BridgeSharedPreferences implements SharedPreferences { 29 private Editor mEditor; 30 31 @Override getAll()32 public Map<String, ?> getAll() { 33 return null; 34 } 35 36 @Override getString(String key, String defValue)37 public String getString(String key, String defValue) { 38 return null; 39 } 40 41 @Override getStringSet(String key, Set<String> defValues)42 public Set<String> getStringSet(String key, Set<String> defValues) { 43 return null; 44 } 45 46 @Override getInt(String key, int defValue)47 public int getInt(String key, int defValue) { 48 return 0; 49 } 50 51 @Override getLong(String key, long defValue)52 public long getLong(String key, long defValue) { 53 return 0; 54 } 55 56 @Override getFloat(String key, float defValue)57 public float getFloat(String key, float defValue) { 58 return 0; 59 } 60 61 @Override getBoolean(String key, boolean defValue)62 public boolean getBoolean(String key, boolean defValue) { 63 return false; 64 } 65 66 @Override contains(String key)67 public boolean contains(String key) { 68 return false; 69 } 70 71 @Override edit()72 public Editor edit() { 73 if (mEditor != null) { 74 return mEditor; 75 } 76 mEditor = new Editor() { 77 @Override 78 public Editor putString(String key, String value) { 79 return null; 80 } 81 82 @Override 83 public Editor putStringSet(String key, Set<String> values) { 84 return null; 85 } 86 87 @Override 88 public Editor putInt(String key, int value) { 89 return null; 90 } 91 92 @Override 93 public Editor putLong(String key, long value) { 94 return null; 95 } 96 97 @Override 98 public Editor putFloat(String key, float value) { 99 return null; 100 } 101 102 @Override 103 public Editor putBoolean(String key, boolean value) { 104 return null; 105 } 106 107 @Override 108 public Editor remove(String key) { 109 return null; 110 } 111 112 @Override 113 public Editor clear() { 114 return null; 115 } 116 117 @Override 118 public boolean commit() { 119 return false; 120 } 121 122 @Override 123 public void apply() { 124 } 125 }; 126 return mEditor; 127 } 128 129 @Override registerOnSharedPreferenceChangeListener( OnSharedPreferenceChangeListener listener)130 public void registerOnSharedPreferenceChangeListener( 131 OnSharedPreferenceChangeListener listener) { 132 } 133 134 @Override unregisterOnSharedPreferenceChangeListener( OnSharedPreferenceChangeListener listener)135 public void unregisterOnSharedPreferenceChangeListener( 136 OnSharedPreferenceChangeListener listener) { 137 } 138 } 139