summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2014-03-09 21:54:43 (GMT)
committerJorge Ruesga <jorge@ruesga.com>2014-03-09 21:54:43 (GMT)
commita5d4a78d0831d0385df0da57378ee41c95234fb1 (patch)
tree68b3a22f1617a1f26522691d263f734d9cf61a85
parent99a7b0f03ce98a21c6dc44e7606643b99c2910d7 (diff)
downloadandroid_packages_apps_Trebuchet-a5d4a78d0831d0385df0da57378ee41c95234fb1.zip
android_packages_apps_Trebuchet-a5d4a78d0831d0385df0da57378ee41c95234fb1.tar.gz
android_packages_apps_Trebuchet-a5d4a78d0831d0385df0da57378ee41c95234fb1.tar.bz2
trebuchet: build headers from internal adapter instance
Trebuchet will be killed if any of its settings changed, so if it is accessed from recents then the PreferencesActivity is rebuilt from its saved instance and the headers are not filled by onBuildHeaders, because this is not called. Just ensure we build the headers from the internal adapter. Change-Id: I3159daadd715d5cbc0d9bcd377d8bbe51f638d32 Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
-rw-r--r--src/com/android/launcher3/settings/SettingsActivity.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/com/android/launcher3/settings/SettingsActivity.java b/src/com/android/launcher3/settings/SettingsActivity.java
index 466a01f..182a6bf 100644
--- a/src/com/android/launcher3/settings/SettingsActivity.java
+++ b/src/com/android/launcher3/settings/SettingsActivity.java
@@ -31,6 +31,7 @@ import android.widget.ListAdapter;
import android.widget.TextView;
import com.android.launcher3.R;
+import java.util.ArrayList;
import java.util.List;
public class SettingsActivity extends PreferenceActivity
@@ -38,7 +39,6 @@ public class SettingsActivity extends PreferenceActivity
private static final String TAG = "Launcher3.SettingsActivity";
private SharedPreferences mSettings;
- private List<Header> mHeaders;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -90,7 +90,6 @@ public class SettingsActivity extends PreferenceActivity
public void onBuildHeaders(List<Header> target) {
loadHeadersFromResource(R.xml.preferences_headers, target);
updateHeaders(target);
- mHeaders = target;
}
private void updateHeaders(List<Header> headers) {
@@ -115,7 +114,8 @@ public class SettingsActivity extends PreferenceActivity
if (adapter == null) {
super.setListAdapter(null);
} else {
- super.setListAdapter(new HeaderAdapter(this, mHeaders));
+ List<Header> headers = getHeadersFromAdapter(adapter);
+ super.setListAdapter(new HeaderAdapter(this, headers));
}
}
@@ -126,6 +126,15 @@ public class SettingsActivity extends PreferenceActivity
editor.commit();
}
+ private List<Header> getHeadersFromAdapter(ListAdapter adapter) {
+ List<Header> headers = new ArrayList<Header>();
+ int count = adapter.getCount();
+ for (int i = 0; i < count; i++) {
+ headers.add((Header)adapter.getItem(i));
+ }
+ return headers;
+ }
+
public static class HomescreenFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {