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

Commit 01f5db72 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Added setFillWindowForwardOnly"

parents 1ead4390 41cadb7d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -12016,6 +12016,7 @@ package android.database.sqlite {
    method public java.lang.String[] getColumnNames();
    method public int getCount();
    method public android.database.sqlite.SQLiteDatabase getDatabase();
    method public void setFillWindowForwardOnly(boolean);
    method public void setSelectionArguments(java.lang.String[]);
  }
+1 −0
Original line number Diff line number Diff line
@@ -12760,6 +12760,7 @@ package android.database.sqlite {
    method public java.lang.String[] getColumnNames();
    method public int getCount();
    method public android.database.sqlite.SQLiteDatabase getDatabase();
    method public void setFillWindowForwardOnly(boolean);
    method public void setSelectionArguments(java.lang.String[]);
  }
+1 −0
Original line number Diff line number Diff line
@@ -12103,6 +12103,7 @@ package android.database.sqlite {
    method public java.lang.String[] getColumnNames();
    method public int getCount();
    method public android.database.sqlite.SQLiteDatabase getDatabase();
    method public void setFillWindowForwardOnly(boolean);
    method public void setSelectionArguments(java.lang.String[]);
  }
+25 −5
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import android.database.DatabaseUtils;
import android.os.StrictMode;
import android.util.Log;

import com.android.internal.util.Preconditions;

import java.util.HashMap;
import java.util.Map;

@@ -60,6 +62,9 @@ public class SQLiteCursor extends AbstractWindowedCursor {
    /** Used to find out where a cursor was allocated in case it never got released. */
    private final Throwable mStackTrace;

    /** Controls fetching of rows relative to requested position **/
    private boolean mFillWindowForwardOnly;

    /**
     * Execute a query and provide access to its result set through a Cursor
     * interface. For a query such as: {@code SELECT name, birth, phone FROM
@@ -136,18 +141,19 @@ public class SQLiteCursor extends AbstractWindowedCursor {

    private void fillWindow(int requiredPos) {
        clearOrCreateWindow(getDatabase().getPath());

        try {
            Preconditions.checkArgumentNonnegative(requiredPos,
                    "requiredPos cannot be negative, but was " + requiredPos);

            if (mCount == NO_COUNT) {
                int startPos = DatabaseUtils.cursorPickFillWindowStartPosition(requiredPos, 0);
                mCount = mQuery.fillWindow(mWindow, startPos, requiredPos, true);
                mCount = mQuery.fillWindow(mWindow, requiredPos, requiredPos, true);
                mCursorWindowCapacity = mWindow.getNumRows();
                if (Log.isLoggable(TAG, Log.DEBUG)) {
                    Log.d(TAG, "received count(*) from native_fill_window: " + mCount);
                }
            } else {
                int startPos = DatabaseUtils.cursorPickFillWindowStartPosition(requiredPos,
                        mCursorWindowCapacity);
                int startPos = mFillWindowForwardOnly ? requiredPos : DatabaseUtils
                        .cursorPickFillWindowStartPosition(requiredPos, mCursorWindowCapacity);
                mQuery.fillWindow(mWindow, startPos, requiredPos, false);
            }
        } catch (RuntimeException ex) {
@@ -251,6 +257,20 @@ public class SQLiteCursor extends AbstractWindowedCursor {
        mDriver.setBindArguments(selectionArgs);
    }

    /**
     * Controls fetching of rows relative to requested position.
     *
     * <p>Calling this method defines how rows will be loaded, but it doesn't affect rows that
     * are already in the window. This setting is preserved if a new window is
     * {@link #setWindow(CursorWindow) set}
     *
     * @param fillWindowForwardOnly if true, rows will be fetched starting from requested position
     * up to the window's capacity. Default value is false.
     */
    public void setFillWindowForwardOnly(boolean fillWindowForwardOnly) {
        mFillWindowForwardOnly = fillWindowForwardOnly;
    }

    /**
     * Release the native resources, if they haven't been released yet.
     */