diff --git a/mobile/android/base/home/HomeConfigPrefsBackend.java b/mobile/android/base/home/HomeConfigPrefsBackend.java index 62cbed48d20..eeb8dc08347 100644 --- a/mobile/android/base/home/HomeConfigPrefsBackend.java +++ b/mobile/android/base/home/HomeConfigPrefsBackend.java @@ -27,7 +27,6 @@ import android.text.TextUtils; import android.util.Log; import java.util.ArrayList; -import java.util.Collections; import java.util.EnumSet; import java.util.List; @@ -114,7 +113,7 @@ class HomeConfigPrefsBackend implements HomeConfigBackend { panelConfigs = loadConfigFromString(jsonString); } - return Collections.unmodifiableList(panelConfigs); + return panelConfigs; } @Override diff --git a/mobile/android/base/preferences/PanelsPreferenceCategory.java b/mobile/android/base/preferences/PanelsPreferenceCategory.java index ceecced16bb..bdf8a0947a6 100644 --- a/mobile/android/base/preferences/PanelsPreferenceCategory.java +++ b/mobile/android/base/preferences/PanelsPreferenceCategory.java @@ -24,7 +24,7 @@ public class PanelsPreferenceCategory extends CustomListCategory { public static final String LOGTAG = "PanelsPrefCategory"; protected HomeConfig mHomeConfig; - protected final List mPanelConfigs = new ArrayList(); + protected List mPanelConfigs; protected UiAsyncTask> mLoadTask; protected UiAsyncTask mSaveTask; @@ -67,17 +67,15 @@ public class PanelsPreferenceCategory extends CustomListCategory { @Override public void onPostExecute(List panelConfigs) { - displayPanelConfig(panelConfigs); + mPanelConfigs = panelConfigs; + displayPanelConfig(); } }; mLoadTask.execute(); } - private void displayPanelConfig(List panelConfigs) { - for (PanelConfig panelConfig: panelConfigs) { - // Populate our local copy of the panels. - mPanelConfigs.add(panelConfig); - + private void displayPanelConfig() { + for (PanelConfig panelConfig : mPanelConfigs) { // Create and add the pref. final PanelsPreference pref = new PanelsPreference(getContext(), PanelsPreferenceCategory.this); pref.setTitle(panelConfig.getTitle()); @@ -102,6 +100,10 @@ public class PanelsPreferenceCategory extends CustomListCategory { * @param panelConfigs Configuration to be saved */ private void saveHomeConfig() { + if (mPanelConfigs == null) { + return; + } + final List panelConfigs = makeConfigListDeepCopy(); mSaveTask = new UiAsyncTask(ThreadUtils.getBackgroundHandler()) { @Override