Merge commit '70419aa4bb06ab62aa185f0999a578f36708e1e6' * commit '70419aa4bb06ab62aa185f0999a578f36708e1e6': Close suggestion cursors that arrive after adapter is closed
This commit is contained in:
@@ -428,7 +428,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
||||
mSearchAutoComplete.setAdapter((SuggestionsAdapter)null);
|
||||
// close any leftover cursor
|
||||
if (mSuggestionsAdapter != null) {
|
||||
mSuggestionsAdapter.changeCursor(null);
|
||||
mSuggestionsAdapter.close();
|
||||
}
|
||||
mSuggestionsAdapter = null;
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter {
|
||||
private WeakHashMap<String, Drawable.ConstantState> mOutsideDrawablesCache;
|
||||
private SparseArray<Drawable.ConstantState> mBackgroundsCache;
|
||||
private boolean mGlobalSearchMode;
|
||||
private boolean mClosed = false;
|
||||
|
||||
// Cached column indexes, updated when the cursor changes.
|
||||
private int mFormatCol;
|
||||
@@ -199,6 +200,12 @@ class SuggestionsAdapter extends ResourceCursorAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (DBG) Log.d(LOG_TAG, "close()");
|
||||
changeCursor(null);
|
||||
mClosed = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache columns.
|
||||
*/
|
||||
@@ -206,6 +213,12 @@ class SuggestionsAdapter extends ResourceCursorAdapter {
|
||||
public void changeCursor(Cursor c) {
|
||||
if (DBG) Log.d(LOG_TAG, "changeCursor(" + c + ")");
|
||||
|
||||
if (mClosed) {
|
||||
Log.w(LOG_TAG, "Tried to change cursor after adapter was closed.");
|
||||
if (c != null) c.close();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Cursor oldCursor = getCursor();
|
||||
super.changeCursor(c);
|
||||
|
||||
Reference in New Issue
Block a user