diff options
author | Amith Yamasani <yamasani@google.com> | 2012-06-20 13:51:40 -0700 |
---|---|---|
committer | Amith Yamasani <yamasani@google.com> | 2012-06-20 13:51:40 -0700 |
commit | ea7b28c2a1b2eab49af7066f53fe19f905d989b2 (patch) | |
tree | 314e76a4bd81978f6494d4e2b4a552bf9f0a7d52 /src | |
parent | fae5978e4a89aa2b8e6a9e1cf95c910a0609923a (diff) | |
download | packages_apps_settings-ea7b28c2a1b2eab49af7066f53fe19f905d989b2.zip packages_apps_settings-ea7b28c2a1b2eab49af7066f53fe19f905d989b2.tar.gz packages_apps_settings-ea7b28c2a1b2eab49af7066f53fe19f905d989b2.tar.bz2 |
Fix incorrect updating of headers in Settings
Settings was overriding the header list in PreferenceActivity and
maintaining its own. In the case where Settings activity is restored
from saved state, the header lists went out of sync and couldn't
be updated anymore.
This makes use of a new private method in PreferenceActivity to
retrieve the header list object so that they stay in sync and can
be updated.
Also make sure to invalidate headers on resume, so that the latest
account types are loaded.
Bug: 6685701
Change-Id: I76ed1e1579a70fb5abfcea417d7e981907bdc02c
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/Settings.java | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java index 37b47c2..e8a8f46 100644 --- a/src/com/android/settings/Settings.java +++ b/src/com/android/settings/Settings.java @@ -52,6 +52,7 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.ArrayAdapter; +import android.widget.BaseAdapter; import android.widget.Button; import android.widget.ImageView; import android.widget.ListAdapter; @@ -71,6 +72,7 @@ public class Settings extends PreferenceActivity implements ButtonBarHandler, OnAccountsUpdateListener { private static final String LOG_TAG = "Settings"; + private static final String META_DATA_KEY_HEADER_ID = "com.android.settings.TOP_LEVEL_HEADER_ID"; private static final String META_DATA_KEY_FRAGMENT_CLASS = @@ -108,7 +110,6 @@ public class Settings extends PreferenceActivity // TODO: Update Call Settings based on airplane mode state. protected HashMap<Integer, Integer> mHeaderIndexMap = new HashMap<Integer, Integer>(); - private List<Header> mHeaders; private AuthenticatorHelper mAuthenticatorHelper; private Header mLastHeader; @@ -189,6 +190,7 @@ public class Settings extends PreferenceActivity if (listAdapter instanceof HeaderAdapter) { ((HeaderAdapter) listAdapter).resume(); } + invalidateHeaders(); } @Override @@ -360,7 +362,7 @@ public class Settings extends PreferenceActivity intent.setClass(this, SubSettings.class); return intent; } - + /** * Populate the activity with the top-level headers. */ @@ -369,8 +371,6 @@ public class Settings extends PreferenceActivity loadHeadersFromResource(R.xml.settings_headers, headers); updateHeaderList(headers); - - mHeaders = headers; } private void updateHeaderList(List<Header> target) { @@ -730,17 +730,11 @@ public class Settings extends PreferenceActivity @Override public void setListAdapter(ListAdapter adapter) { - if (mHeaders == null) { - mHeaders = new ArrayList<Header>(); - // When the saved state provides the list of headers, onBuildHeaders is not called - // Copy the list of Headers from the adapter, preserving their order - for (int i = 0; i < adapter.getCount(); i++) { - mHeaders.add((Header) adapter.getItem(i)); - } + if (adapter == null) { + super.setListAdapter(null); + } else { + super.setListAdapter(new HeaderAdapter(this, getHeaders(), mAuthenticatorHelper)); } - - // Ignore the adapter provided by PreferenceActivity and substitute ours instead - super.setListAdapter(new HeaderAdapter(this, mHeaders, mAuthenticatorHelper)); } @Override |