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

Commit 34b32f41 authored by Danny Baumann's avatar Danny Baumann Committed by Gerrit Code Review
Browse files

Merge "Fix requery behaviour of MemoryCursor." into cm-10.1

parents 33c5bc47 17006897
Loading
Loading
Loading
Loading
+25 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ import android.database.DatabaseUtils;
 * @hide
 */
public class MemoryCursor extends AbstractWindowedCursor {

    private CursorWindow mDeactivatedWindow;
    private final String[] mColumnNames;

    public MemoryCursor(String name, String[] columnNames) {
@@ -47,4 +47,28 @@ public class MemoryCursor extends AbstractWindowedCursor {
    public String[] getColumnNames() {
        return mColumnNames;
    }

    @Override
    public boolean requery() {
        if (mDeactivatedWindow != null) {
            setWindow(mDeactivatedWindow);
            mDeactivatedWindow = null;
        }
        return super.requery();
    }

    @Override
    protected void onDeactivateOrClose() {
        // when deactivating the cursor, we need to keep our in-memory cursor
        // window as we have no chance of requerying it later on
        if (!isClosed() && getWindow() != null) {
            mDeactivatedWindow = getWindow();
            mWindow = null;
        }
        super.onDeactivateOrClose();
        if (isClosed() && mDeactivatedWindow != null) {
            mDeactivatedWindow.close();
            mDeactivatedWindow = null;
        }
    }
}