类android.database.AbstractWindowedCursor源码实例Demo

下面列出了怎么用android.database.AbstractWindowedCursor的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: FairEmail   文件: DBUtil.java
/**
 * Performs the SQLiteQuery on the given database.
 * <p>
 * This util method encapsulates copying the cursor if the {@code maybeCopy} parameter is
 * {@code true} and either the api level is below a certain threshold or the full result of the
 * query does not fit in a single window.
 *
 * @param db          The database to perform the query on.
 * @param sqLiteQuery The query to perform.
 * @param maybeCopy   True if the result cursor should maybe be copied, false otherwise.
 * @param signal      The cancellation signal to be attached to the query.
 * @return Result of the query.
 */
@NonNull
public static Cursor query(@NonNull RoomDatabase db, @NonNull SupportSQLiteQuery sqLiteQuery,
        boolean maybeCopy, @Nullable CancellationSignal signal) {
    final Cursor cursor = db.query(sqLiteQuery, signal);
    if (maybeCopy && cursor instanceof AbstractWindowedCursor) {
        AbstractWindowedCursor windowedCursor = (AbstractWindowedCursor) cursor;
        int rowsInCursor = windowedCursor.getCount(); // Should fill the window.
        int rowsInWindow;
        if (windowedCursor.hasWindow()) {
            rowsInWindow = windowedCursor.getWindow().getNumRows();
        } else {
            rowsInWindow = rowsInCursor;
        }
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || rowsInWindow < rowsInCursor) {
            return CursorUtil.copyAndClose(windowedCursor);
        }
    }

    return cursor;
}
 
源代码2 项目: sqlitemagic   文件: FastCursor.java
private FastCursor(@NonNull AbstractWindowedCursor cursor) {
  backingCursor = cursor;
  count = cursor.getCount(); // fills cursor window
  window = cursor.getWindow();
  windowStart = window.getStartPosition();
  windowEnd = windowStart + window.getNumRows();
  position = -1;
}
 
源代码3 项目: Pix-Art-Messenger   文件: CursorUtils.java
public static void upgradeCursorWindowSize(final Cursor cursor) {
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) {
        if (cursor instanceof AbstractWindowedCursor) {
            final AbstractWindowedCursor windowedCursor = (AbstractWindowedCursor) cursor;
            windowedCursor.setWindow(new CursorWindow("4M", 4 * 1024 * 1024));
        }
        if (cursor instanceof SQLiteCursor) {
            ((SQLiteCursor) cursor).setFillWindowForwardOnly(true);
        }
    }
}
 
源代码4 项目: Conversations   文件: CursorUtils.java
public static void upgradeCursorWindowSize(final Cursor cursor) {
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) {
        if (cursor instanceof AbstractWindowedCursor) {
            final AbstractWindowedCursor windowedCursor = (AbstractWindowedCursor) cursor;
            windowedCursor.setWindow(new CursorWindow("4M", 4 * 1024 * 1024));
        }
        if (cursor instanceof SQLiteCursor) {
            ((SQLiteCursor) cursor).setFillWindowForwardOnly(true);
        }
    }
}
 
源代码5 项目: sqlitemagic   文件: FastCursor.java
static Cursor tryCreate(@NonNull Cursor cursor) {
  if (cursor instanceof AbstractWindowedCursor) {
    return new FastCursor((AbstractWindowedCursor) cursor);
  }
  return cursor;
}