Fix NPE in SearchDialog (and thereby fix bug 2045398).

This commit is contained in:
Karl Rosaen
2009-08-10 17:08:05 -07:00
parent 021fa3fa6f
commit abf44279ad

View File

@@ -67,6 +67,7 @@ import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.ListAdapter;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
@@ -1750,7 +1751,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
// case we want to dismiss the soft keyboard so the user can see the rest of the
// shortcuts.
if (isInputMethodNotNeeded() ||
(isEmpty() && getDropDownChildCount() >= getAdapter().getCount())) {
(isEmpty() && getDropDownChildCount() >= getAdapterCount())) {
mSearchDialog.cancel();
return true;
}
@@ -1758,6 +1759,11 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
}
return false;
}
private int getAdapterCount() {
final ListAdapter adapter = getAdapter();
return adapter == null ? 0 : adapter.getCount();
}
}
protected boolean handleBackKey(int keyCode, KeyEvent event) {