am 70419aa4: am 98d88588: am ba223760: Close suggestion cursors that arrive after adapter is closed

Merge commit '70419aa4bb06ab62aa185f0999a578f36708e1e6'

* commit '70419aa4bb06ab62aa185f0999a578f36708e1e6':
  Close suggestion cursors that arrive after adapter is closed
This commit is contained in:
Bjorn Bringert
2009-08-26 11:47:41 -07:00
committed by Android Git Automerger
2 changed files with 14 additions and 1 deletions

View File

@@ -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;
}

View File

@@ -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);