am d3927bd0: Merge "Allow recycling of Preferences in com.android.* packages" into klp-dev
* commit 'd3927bd0358714fa440cbc0d9595a25b0f571562': Allow recycling of Preferences in com.android.* packages
This commit is contained in:
@@ -124,7 +124,7 @@ public class Preference implements Comparable<Preference> {
|
|||||||
|
|
||||||
private int mLayoutResId = com.android.internal.R.layout.preference;
|
private int mLayoutResId = com.android.internal.R.layout.preference;
|
||||||
private int mWidgetLayoutResId;
|
private int mWidgetLayoutResId;
|
||||||
private boolean mHasSpecifiedLayout = false;
|
private boolean mCanRecycleLayout = true;
|
||||||
|
|
||||||
private OnPreferenceChangeInternalListener mListener;
|
private OnPreferenceChangeInternalListener mListener;
|
||||||
|
|
||||||
@@ -275,9 +275,10 @@ public class Preference implements Comparable<Preference> {
|
|||||||
}
|
}
|
||||||
a.recycle();
|
a.recycle();
|
||||||
|
|
||||||
if (!getClass().getName().startsWith("android.preference")) {
|
if (!getClass().getName().startsWith("android.preference")
|
||||||
// For subclasses not in this package, assume the worst and don't cache views
|
&& !getClass().getName().startsWith("com.android")) {
|
||||||
mHasSpecifiedLayout = true;
|
// For non-framework subclasses, assume the worst and don't cache views.
|
||||||
|
mCanRecycleLayout = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,7 +400,7 @@ public class Preference implements Comparable<Preference> {
|
|||||||
public void setLayoutResource(int layoutResId) {
|
public void setLayoutResource(int layoutResId) {
|
||||||
if (layoutResId != mLayoutResId) {
|
if (layoutResId != mLayoutResId) {
|
||||||
// Layout changed
|
// Layout changed
|
||||||
mHasSpecifiedLayout = true;
|
mCanRecycleLayout = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mLayoutResId = layoutResId;
|
mLayoutResId = layoutResId;
|
||||||
@@ -415,7 +416,7 @@ public class Preference implements Comparable<Preference> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets The layout for the controllable widget portion of this Preference. This
|
* Sets the layout for the controllable widget portion of this Preference. This
|
||||||
* is inflated into the main layout. For example, a {@link CheckBoxPreference}
|
* is inflated into the main layout. For example, a {@link CheckBoxPreference}
|
||||||
* would specify a custom layout (consisting of just the CheckBox) here,
|
* would specify a custom layout (consisting of just the CheckBox) here,
|
||||||
* instead of creating its own main layout.
|
* instead of creating its own main layout.
|
||||||
@@ -427,7 +428,7 @@ public class Preference implements Comparable<Preference> {
|
|||||||
public void setWidgetLayoutResource(int widgetLayoutResId) {
|
public void setWidgetLayoutResource(int widgetLayoutResId) {
|
||||||
if (widgetLayoutResId != mWidgetLayoutResId) {
|
if (widgetLayoutResId != mWidgetLayoutResId) {
|
||||||
// Layout changed
|
// Layout changed
|
||||||
mHasSpecifiedLayout = true;
|
mCanRecycleLayout = false;
|
||||||
}
|
}
|
||||||
mWidgetLayoutResId = widgetLayoutResId;
|
mWidgetLayoutResId = widgetLayoutResId;
|
||||||
}
|
}
|
||||||
@@ -1659,8 +1660,8 @@ public class Preference implements Comparable<Preference> {
|
|||||||
return mPreferenceManager.getSharedPreferences().getBoolean(mKey, defaultReturnValue);
|
return mPreferenceManager.getSharedPreferences().getBoolean(mKey, defaultReturnValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasSpecifiedLayout() {
|
boolean canRecycleLayout() {
|
||||||
return mHasSpecifiedLayout;
|
return mCanRecycleLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ class PreferenceGroupAdapter extends BaseAdapter implements OnPreferenceChangeIn
|
|||||||
|
|
||||||
preferences.add(preference);
|
preferences.add(preference);
|
||||||
|
|
||||||
if (!mHasReturnedViewTypeCount && !preference.hasSpecifiedLayout()) {
|
if (!mHasReturnedViewTypeCount && preference.canRecycleLayout()) {
|
||||||
addPreferenceClassName(preference);
|
addPreferenceClassName(preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,7 +255,7 @@ class PreferenceGroupAdapter extends BaseAdapter implements OnPreferenceChangeIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Preference preference = this.getItem(position);
|
final Preference preference = this.getItem(position);
|
||||||
if (preference.hasSpecifiedLayout()) {
|
if (!preference.canRecycleLayout()) {
|
||||||
return IGNORE_ITEM_VIEW_TYPE;
|
return IGNORE_ITEM_VIEW_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user