Send a special respond to the cursor in SuggestionsAdapter to tell it to
close itself directly because it may not happen correctly for some cursors currently. This fixes http://b/2036290, which is being caused by http://b/2015069 which we are not fixing for Donut, so this is a hack around that for the time being.
This commit is contained in:
@@ -73,6 +73,14 @@ class SuggestionsAdapter extends ResourceCursorAdapter {
|
||||
private int mIconName1Col;
|
||||
private int mIconName2Col;
|
||||
private int mBackgroundColorCol;
|
||||
|
||||
// The extra used to tell a cursor to close itself. This is a hack, see the description by
|
||||
// its use later in this file.
|
||||
private static final String EXTRA_CURSOR_RESPOND_CLOSE_CURSOR = "cursor_respond_close_cursor";
|
||||
|
||||
// The bundle which contains {EXTRA_CURSOR_RESPOND_CLOSE_CURSOR=true}, just cached once
|
||||
// so we don't bother recreating it a bunch.
|
||||
private final Bundle mCursorRespondCloseCursorBundle;
|
||||
|
||||
// This value is stored in SuggestionsAdapter by the SearchDialog to indicate whether
|
||||
// a particular list item should be selected upon the next call to notifyDataSetChanged.
|
||||
@@ -129,6 +137,10 @@ class SuggestionsAdapter extends ResourceCursorAdapter {
|
||||
mSearchDialog.setWorking(false);
|
||||
}
|
||||
};
|
||||
|
||||
// Create this once because we'll reuse it a bunch.
|
||||
mCursorRespondCloseCursorBundle = new Bundle();
|
||||
mCursorRespondCloseCursorBundle.putBoolean(EXTRA_CURSOR_RESPOND_CLOSE_CURSOR, true);
|
||||
|
||||
// delay 500ms when deleting
|
||||
getFilter().setDelayer(new Filter.Delayer() {
|
||||
@@ -195,7 +207,21 @@ class SuggestionsAdapter extends ResourceCursorAdapter {
|
||||
if (DBG) Log.d(LOG_TAG, "changeCursor(" + c + ")");
|
||||
|
||||
try {
|
||||
Cursor oldCursor = getCursor();
|
||||
super.changeCursor(c);
|
||||
|
||||
// We send a special respond to the cursor to tell it to close itself directly because
|
||||
// it may not happen correctly for some cursors currently. This was originally
|
||||
// included as a fix to http://b/2036290, in which the search dialog was holding
|
||||
// on to references to the web search provider unnecessarily. This is being caused by
|
||||
// the fact that the cursor is not being correctly closed in
|
||||
// BulkCursorToCursorAdapter#close, which remains unfixed (see http://b/2015069).
|
||||
//
|
||||
// TODO: Remove this hack once http://b/2015069 is fixed.
|
||||
if (oldCursor != null && oldCursor != c) {
|
||||
oldCursor.respond(mCursorRespondCloseCursorBundle);
|
||||
}
|
||||
|
||||
if (c != null) {
|
||||
mFormatCol = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_FORMAT);
|
||||
mText1Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_1);
|
||||
|
||||
Reference in New Issue
Block a user