Loading core/java/android/app/AlertDialog.java +10 −1 Original line number Diff line number Diff line Loading @@ -764,6 +764,15 @@ public class AlertDialog extends Dialog implements DialogInterface { return this; } /** * @hide */ public Builder setRecycleOnMeasureEnabled(boolean enabled) { P.mRecycleOnMeasure = enabled; return this; } /** * Creates a {@link AlertDialog} with the arguments supplied to this builder. It does not * {@link Dialog#show()} the dialog. This allows the user to do any extra processing Loading core/java/com/android/internal/app/AlertController.java +28 −4 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.internal.app; import static android.view.ViewGroup.LayoutParams.FILL_PARENT; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; Loading Loading @@ -49,6 +48,7 @@ import android.widget.ScrollView; import android.widget.SimpleCursorAdapter; import android.widget.TextView; import android.widget.AdapterView.OnItemClickListener; import android.util.AttributeSet; import com.android.internal.R; Loading Loading @@ -673,6 +673,27 @@ public class AlertController { } } public static class RecycleListView extends ListView { boolean mRecycleOnMeasure = true; public RecycleListView(Context context) { super(context); } public RecycleListView(Context context, AttributeSet attrs) { super(context, attrs); } public RecycleListView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected boolean recycleOnMeasure() { return mRecycleOnMeasure; } } public static class AlertParams { public final Context mContext; public final LayoutInflater mInflater; Loading Loading @@ -711,6 +732,7 @@ public class AlertController { public boolean mForceInverseBackground; public AdapterView.OnItemSelectedListener mOnItemSelectedListener; public OnPrepareListViewListener mOnPrepareListViewListener; public boolean mRecycleOnMeasure = true; /** * Interface definition for a callback to be invoked before the ListView Loading Loading @@ -787,7 +809,8 @@ public class AlertController { } private void createListView(final AlertController dialog) { final ListView listView = (ListView) mInflater.inflate(R.layout.select_dialog, null); final RecycleListView listView = (RecycleListView) mInflater.inflate(R.layout.select_dialog, null); ListAdapter adapter; if (mIsMultiChoice) { Loading Loading @@ -886,6 +909,7 @@ public class AlertController { } else if (mIsMultiChoice) { listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); } listView.mRecycleOnMeasure = mRecycleOnMeasure; dialog.mListView = listView; } } Loading core/java/com/android/internal/view/menu/MenuDialogHelper.java +6 −5 Original line number Diff line number Diff line Loading @@ -68,6 +68,10 @@ public class MenuDialogHelper implements DialogInterface.OnKeyListener, DialogIn // Set the key listener builder.setOnKeyListener(this); // Since this is for a menu, disable the recycling of views // This is done by the menu framework anyway builder.setRecycleOnMeasureEnabled(false); // Show the menu mDialog = builder.create(); Loading Loading @@ -97,11 +101,8 @@ public class MenuDialogHelper implements DialogInterface.OnKeyListener, DialogIn } // Menu shortcut matching if (mMenu.performShortcut(keyCode, event, 0)) { return true; } return mMenu.performShortcut(keyCode, event, 0); return false; } /** Loading core/res/res/layout/select_dialog.xml +2 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,8 @@ This layout file is inflated and used as the ListView to display the items. Assign an ID so its state will be saved/restored. --> <ListView xmlns:android="http://schemas.android.com/apk/res/android" <view class="com.android.internal.app.AlertController$RecycleListView" xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+android:id/select_dialog_listview" android:layout_width="fill_parent" android:layout_height="fill_parent" Loading Loading
core/java/android/app/AlertDialog.java +10 −1 Original line number Diff line number Diff line Loading @@ -764,6 +764,15 @@ public class AlertDialog extends Dialog implements DialogInterface { return this; } /** * @hide */ public Builder setRecycleOnMeasureEnabled(boolean enabled) { P.mRecycleOnMeasure = enabled; return this; } /** * Creates a {@link AlertDialog} with the arguments supplied to this builder. It does not * {@link Dialog#show()} the dialog. This allows the user to do any extra processing Loading
core/java/com/android/internal/app/AlertController.java +28 −4 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.internal.app; import static android.view.ViewGroup.LayoutParams.FILL_PARENT; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; Loading Loading @@ -49,6 +48,7 @@ import android.widget.ScrollView; import android.widget.SimpleCursorAdapter; import android.widget.TextView; import android.widget.AdapterView.OnItemClickListener; import android.util.AttributeSet; import com.android.internal.R; Loading Loading @@ -673,6 +673,27 @@ public class AlertController { } } public static class RecycleListView extends ListView { boolean mRecycleOnMeasure = true; public RecycleListView(Context context) { super(context); } public RecycleListView(Context context, AttributeSet attrs) { super(context, attrs); } public RecycleListView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected boolean recycleOnMeasure() { return mRecycleOnMeasure; } } public static class AlertParams { public final Context mContext; public final LayoutInflater mInflater; Loading Loading @@ -711,6 +732,7 @@ public class AlertController { public boolean mForceInverseBackground; public AdapterView.OnItemSelectedListener mOnItemSelectedListener; public OnPrepareListViewListener mOnPrepareListViewListener; public boolean mRecycleOnMeasure = true; /** * Interface definition for a callback to be invoked before the ListView Loading Loading @@ -787,7 +809,8 @@ public class AlertController { } private void createListView(final AlertController dialog) { final ListView listView = (ListView) mInflater.inflate(R.layout.select_dialog, null); final RecycleListView listView = (RecycleListView) mInflater.inflate(R.layout.select_dialog, null); ListAdapter adapter; if (mIsMultiChoice) { Loading Loading @@ -886,6 +909,7 @@ public class AlertController { } else if (mIsMultiChoice) { listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); } listView.mRecycleOnMeasure = mRecycleOnMeasure; dialog.mListView = listView; } } Loading
core/java/com/android/internal/view/menu/MenuDialogHelper.java +6 −5 Original line number Diff line number Diff line Loading @@ -68,6 +68,10 @@ public class MenuDialogHelper implements DialogInterface.OnKeyListener, DialogIn // Set the key listener builder.setOnKeyListener(this); // Since this is for a menu, disable the recycling of views // This is done by the menu framework anyway builder.setRecycleOnMeasureEnabled(false); // Show the menu mDialog = builder.create(); Loading Loading @@ -97,11 +101,8 @@ public class MenuDialogHelper implements DialogInterface.OnKeyListener, DialogIn } // Menu shortcut matching if (mMenu.performShortcut(keyCode, event, 0)) { return true; } return mMenu.performShortcut(keyCode, event, 0); return false; } /** Loading
core/res/res/layout/select_dialog.xml +2 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,8 @@ This layout file is inflated and used as the ListView to display the items. Assign an ID so its state will be saved/restored. --> <ListView xmlns:android="http://schemas.android.com/apk/res/android" <view class="com.android.internal.app.AlertController$RecycleListView" xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+android:id/select_dialog_listview" android:layout_width="fill_parent" android:layout_height="fill_parent" Loading