private int mLayoutResId = com.android.internal.R.layout.preference;
private int mWidgetLayoutResId;
- private boolean mHasSpecifiedLayout = false;
+ private boolean mCanRecycleLayout = true;
private OnPreferenceChangeInternalListener mListener;
}
a.recycle();
- if (!getClass().getName().startsWith("android.preference")) {
- // For subclasses not in this package, assume the worst and don't cache views
- mHasSpecifiedLayout = true;
+ if (!getClass().getName().startsWith("android.preference")
+ && !getClass().getName().startsWith("com.android")) {
+ // For non-framework subclasses, assume the worst and don't cache views.
+ mCanRecycleLayout = false;
}
}
public void setLayoutResource(int layoutResId) {
if (layoutResId != mLayoutResId) {
// Layout changed
- mHasSpecifiedLayout = true;
+ mCanRecycleLayout = false;
}
mLayoutResId = layoutResId;
}
/**
- * 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}
* would specify a custom layout (consisting of just the CheckBox) here,
* instead of creating its own main layout.
public void setWidgetLayoutResource(int widgetLayoutResId) {
if (widgetLayoutResId != mWidgetLayoutResId) {
// Layout changed
- mHasSpecifiedLayout = true;
+ mCanRecycleLayout = false;
}
mWidgetLayoutResId = widgetLayoutResId;
}
return mPreferenceManager.getSharedPreferences().getBoolean(mKey, defaultReturnValue);
}
- boolean hasSpecifiedLayout() {
- return mHasSpecifiedLayout;
+ boolean canRecycleLayout() {
+ return mCanRecycleLayout;
}
@Override
preferences.add(preference);
- if (!mHasReturnedViewTypeCount && !preference.hasSpecifiedLayout()) {
+ if (!mHasReturnedViewTypeCount && preference.canRecycleLayout()) {
addPreferenceClassName(preference);
}
}
final Preference preference = this.getItem(position);
- if (preference.hasSpecifiedLayout()) {
+ if (!preference.canRecycleLayout()) {
return IGNORE_ITEM_VIEW_TYPE;
}