Search in sources :

Example 1 with AbstractWindowedCursor

use of android.database.AbstractWindowedCursor in project android_external_GmsApi by microg.

the class DataHolder method getCursorType.

@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
static int getCursorType(Cursor cursor, int i) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        return cursor.getType(i);
    }
    if (cursor instanceof AbstractWindowedCursor) {
        CursorWindow cursorWindow = ((AbstractWindowedCursor) cursor).getWindow();
        int pos = cursor.getPosition();
        int type = -1;
        if (cursorWindow.isNull(pos, i)) {
            type = FIELD_TYPE_NULL;
        } else if (cursorWindow.isLong(pos, i)) {
            type = FIELD_TYPE_INTEGER;
        } else if (cursorWindow.isFloat(pos, i)) {
            type = FIELD_TYPE_FLOAT;
        } else if (cursorWindow.isString(pos, i)) {
            type = FIELD_TYPE_STRING;
        } else if (cursorWindow.isBlob(pos, i)) {
            type = FIELD_TYPE_BLOB;
        }
        return type;
    }
    throw new RuntimeException("Unsupported cursor on this platform!");
}
Also used : AbstractWindowedCursor(android.database.AbstractWindowedCursor) CursorWindow(android.database.CursorWindow) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 2 with AbstractWindowedCursor

use of android.database.AbstractWindowedCursor in project Conversations by siacs.

the class CursorUtils method upgradeCursorWindowSize.

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);
        }
    }
}
Also used : AbstractWindowedCursor(android.database.AbstractWindowedCursor) CursorWindow(android.database.CursorWindow) SQLiteCursor(android.database.sqlite.SQLiteCursor)

Aggregations

AbstractWindowedCursor (android.database.AbstractWindowedCursor)2 CursorWindow (android.database.CursorWindow)2 SuppressLint (android.annotation.SuppressLint)1 SQLiteCursor (android.database.sqlite.SQLiteCursor)1