Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 98d88588 authored by Bjorn Bringert's avatar Bjorn Bringert Committed by Android Git Automerger
Browse files

am ba223760: Close suggestion cursors that arrive after adapter is closed

Merge commit 'ba223760' into eclair

* commit 'ba223760':
  Close suggestion cursors that arrive after adapter is closed
parents 4b8e3fb5 ba223760
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;
    }
+13 −0
Original line number Diff line number Diff line
@@ -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);