當前位置: 首頁>>代碼示例>>Java>>正文


Java CursorWindow.setStartPosition方法代碼示例

本文整理匯總了Java中android.database.CursorWindow.setStartPosition方法的典型用法代碼示例。如果您正苦於以下問題:Java CursorWindow.setStartPosition方法的具體用法?Java CursorWindow.setStartPosition怎麽用?Java CursorWindow.setStartPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.database.CursorWindow的用法示例。


在下文中一共展示了CursorWindow.setStartPosition方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fillWindow

import android.database.CursorWindow; //導入方法依賴的package包/類
@Override
public void fillWindow(int position, CursorWindow window) {
    if (position < 0 || position > getCount()) {
        return;
    }
    window.acquireReference();
    try {
        moveToPosition(position - 1);
        window.clear();
        window.setStartPosition(position);
        int columnNum = getColumnCount();
        window.setNumColumns(columnNum);
        boolean isFull = false;
        int numRows = 10;

        while (!isFull && --numRows > 0 && moveToNext() && window.allocRow()) {
            for (int i = 0; i < columnNum; i++) {
                String field = getString(i);
                if (field != null) {
                    if (!window.putString(field, getPosition(), i)) {
                        window.freeLastRow();
                        isFull = true;
                        break;
                    }
                } else {
                    if (!window.putNull(getPosition(), i)) {
                        window.freeLastRow();
                        isFull = true;
                        break;
                    }
                }
            }
        }
    } catch (IllegalStateException e) {
        // simply ignore it
    } finally {
        window.releaseReference();
    }
}
 
開發者ID:zom,項目名稱:Zom-Android,代碼行數:40,代碼來源:ImpsProvider.java

示例2: fillWindow

import android.database.CursorWindow; //導入方法依賴的package包/類
public void fillWindow(int position, CursorWindow window) {
    int count = getCount();
    if (position < 0 || position > count + 1) {
        return;
    }
    window.acquireReference();
    try {
        int oldpos = getPosition();
        int pos = position;
        window.clear();
        window.setStartPosition(position);
        int columnNum = getColumnCount();
        window.setNumColumns(columnNum);
        while (moveToPosition(pos) && window.allocRow()) {
            for (int i = 0; i < columnNum; i++) {
                String field = getString(i);
                if (field != null) {
                    if (!window.putString(field, pos, i)) {
                        window.freeLastRow();
                        break;
                    }
                } else {
                    if (!window.putNull(pos, i)) {
                        window.freeLastRow();
                        break;
                    }
                }
            }
            ++pos;
        }
        moveToPosition(oldpos);
    } catch (IllegalStateException e){
        // simply ignore it
    } finally {
        window.releaseReference();
    }
}
 
開發者ID:CommonQ,項目名稱:sms_DualCard,代碼行數:38,代碼來源:SuggestionsProvider.java

示例3: fillWindow

import android.database.CursorWindow; //導入方法依賴的package包/類
@Override
public void fillWindow(int position, CursorWindow window) {
    if (position < 0 || position > getCount()) {
        return;
    }
    window.acquireReference();
    try {
        moveToPosition(position - 1);
        window.clear();
        window.setStartPosition(position);
        int columnNum = getColumnCount();
        window.setNumColumns(columnNum);
        boolean isFull = false;
        int numRows = 10;
        
        while (!isFull && --numRows > 0 && moveToNext() && window.allocRow()) {
            for (int i = 0; i < columnNum; i++) {
                String field = getString(i);
                if (field != null) {
                    if (!window.putString(field, getPosition(), i)) {
                        window.freeLastRow();
                        isFull = true;
                        break;
                    }
                } else {
                    if (!window.putNull(getPosition(), i)) {
                        window.freeLastRow();
                        isFull = true;
                        break;
                    }
                }
            }
        }
    } catch (IllegalStateException e) {
        // simply ignore it
    } finally {
        window.releaseReference();
    }
}
 
開發者ID:prive,項目名稱:prive-android,代碼行數:40,代碼來源:ImpsProvider.java

示例4: cursorFillWindow

import android.database.CursorWindow; //導入方法依賴的package包/類
/**
 * Fills the specified cursor window by iterating over the contents of the cursor.
 * The window is filled until the cursor is exhausted or the window runs out
 * of space.
 *
 * The original position of the cursor is left unchanged by this operation.
 *
 * @param cursor The cursor that contains the data to put in the window.
 * @param position The start position for filling the window.
 * @param window The window to fill.
 * @hide
 */
public static void cursorFillWindow(final Cursor cursor,
        int position, final CursorWindow window) {
    if (position < 0 || position >= cursor.getCount()) {
        return;
    }
    final int oldPos = cursor.getPosition();
    final int numColumns = cursor.getColumnCount();
    window.clear();
    window.setStartPosition(position);
    window.setNumColumns(numColumns);
    if (cursor.moveToPosition(position)) {
        do {
            if (!window.allocRow()) {
                break;
            }
            for (int i = 0; i < numColumns; i++) {
                boolean success = putToWindow(cursor, i, window, position);
                if (!success) {
                    window.freeLastRow();
                    break;
                }
            }
            position += 1;
        } while (cursor.moveToNext());
    }
    cursor.moveToPosition(oldPos);
}
 
開發者ID:jasta,項目名稱:android-sqlite-server,代碼行數:40,代碼來源:MoreDatabaseUtils.java

示例5: fillWindow

import android.database.CursorWindow; //導入方法依賴的package包/類
@Override
public void fillWindow(int position, CursorWindow window) {
    if (position < 0 || position > getCount()) {
        return;
    }
    window.acquireReference();
    try {
        int oldpos = getPosition();
        moveToPosition(position - 1);
        window.clear();
        window.setStartPosition(position);
        int columnNum = getColumnCount();
        window.setNumColumns(columnNum);
        while (moveToNext() && window.allocRow()) {
            int pos = getPosition();
            for (int i = 0; i < columnNum; i++) {
                boolean hasRoom = true;
                switch (getColumnType(i)) {
                    case Types.DOUBLE:
                        hasRoom = fillRow(window, Double.valueOf(getDouble(i)), pos, i);
                        break;
                    case Types.NUMERIC:
                        hasRoom = fillRow(window, Long.valueOf(getLong(i)), pos, i);
                        break;
                    case Types.BLOB:
                        hasRoom = fillRow(window, getBlob(i), pos, i);
                        break;
                    case Types.LONGVARCHAR:
                        hasRoom = fillRow(window, getString(i), pos, i);
                        break;
                    case Types.NULL:
                        hasRoom = fillRow(window, null, pos, i);
                        break;
                    default:
                        // Ignore an unknown type.
                }
                if (!hasRoom) {
                    break;
                }
            }
        }
        moveToPosition(oldpos);
    } catch (IllegalStateException e) {
        // simply ignore it
    } finally {
        window.releaseReference();
    }
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:49,代碼來源:SQLiteCursor.java

示例6: executeForCursorWindow

import android.database.CursorWindow; //導入方法依賴的package包/類
/**
 * Executes a statement and populates the specified {@link CursorWindow}
 * with a range of results.  Returns the number of rows that were counted
 * during query execution.
 *
 * @param sql The SQL statement to execute.
 * @param bindArgs The arguments to bind, or null if none.
 * @param window The cursor window to clear and fill.
 * @param startPos The start position for filling the window.
 * @param requiredPos The position of a row that MUST be in the window.
 * If it won't fit, then the query should discard part of what it filled
 * so that it does.  Must be greater than or equal to <code>startPos</code>.
 * @param countAllRows True to count all rows that the query would return
 * regagless of whether they fit in the window.
 * @param cancellationSignal A signal to cancel the operation in progress, or null if none.
 * @return The number of rows that were counted during query execution.  Might
 * not be all rows in the result set unless <code>countAllRows</code> is true.
 *
 * @throws SQLiteException if an error occurs, such as a syntax error
 * or invalid number of bind arguments.
 * @throws OperationCanceledException if the operation was canceled.
 */
public int executeForCursorWindow(String sql, Object[] bindArgs,
        CursorWindow window, int startPos, int requiredPos, boolean countAllRows,
        CancellationSignal cancellationSignal) {
    if (sql == null) {
        throw new IllegalArgumentException("sql must not be null.");
    }
    if (window == null) {
        throw new IllegalArgumentException("window must not be null.");
    }

    window.acquireReference();
    try {
        int actualPos = -1;
        int countedRows = -1;
        int filledRows = -1;
        final int cookie = mRecentOperations.beginOperation("executeForCursorWindow",
                sql, bindArgs);
        try {
            final PreparedStatement statement = acquirePreparedStatement(sql);
            try {
                throwIfStatementForbidden(statement);
                bindArguments(statement, bindArgs);
                applyBlockGuardPolicy(statement);
                attachCancellationSignal(cancellationSignal);
                try {
                    final long result = nativeExecuteForCursorWindow(
                            mConnectionPtr, statement.mStatementPtr, window.mWindowPtr,
                            startPos, requiredPos, countAllRows);
                    actualPos = (int)(result >> 32);
                    countedRows = (int)result;
                    filledRows = window.getNumRows();
                    window.setStartPosition(actualPos);
                    return countedRows;
                } finally {
                    detachCancellationSignal(cancellationSignal);
                }
            } finally {
                releasePreparedStatement(statement);
            }
        } catch (RuntimeException ex) {
            mRecentOperations.failOperation(cookie, ex);
            throw ex;
        } finally {
            if (mRecentOperations.endOperationDeferLog(cookie)) {
                mRecentOperations.logOperation(cookie, "window='" + window
                        + "', startPos=" + startPos
                        + ", actualPos=" + actualPos
                        + ", filledRows=" + filledRows
                        + ", countedRows=" + countedRows);
            }
        }
    } finally {
        window.releaseReference();
    }
}
 
開發者ID:doppllib,項目名稱:core-doppl,代碼行數:78,代碼來源:SQLiteConnection.java

示例7: fillWindow

import android.database.CursorWindow; //導入方法依賴的package包/類
@Override
public void fillWindow(int position, CursorWindow window) {
    if (position < 0 || position > getCount()) {
        return;
    }
    window.acquireReference();
    try {
        int oldpos = mPos;
        mPos = position - 1;
        window.clear();
        window.setStartPosition(position);
        int columnNum = getColumnCount();
        window.setNumColumns(columnNum);
        while (moveToNext() && window.allocRow()) {
            for (int i = 0; i < columnNum; i++) {
                boolean hasRoom = true;
                switch (getColumnType(i)) {
                    case Types.DOUBLE:
                        hasRoom = fillRow(window, Double.valueOf(getDouble(i)), mPos, i);
                        break;
                    case Types.NUMERIC:
                        hasRoom = fillRow(window, Long.valueOf(getLong(i)), mPos, i);
                        break;
                    case Types.BLOB:
                        hasRoom = fillRow(window, getBlob(i), mPos, i);
                        break;
                    case Types.LONGVARCHAR:
                        hasRoom = fillRow(window, getString(i), mPos, i);
                        break;
                    case Types.NULL:
                        hasRoom = fillRow(window, null, mPos, i);
                        break;
                    default:
                        // Ignore an unknown type.
                }
                if (!hasRoom) {
                    break;
                }
            }
        }
        mPos = oldpos;
    } catch (IllegalStateException e) {
        // simply ignore it
    } finally {
        window.releaseReference();
    }
}
 
開發者ID:Smalinuxer,項目名稱:Vafrinn,代碼行數:48,代碼來源:SQLiteCursor.java

示例8: executeForCursorWindow

import android.database.CursorWindow; //導入方法依賴的package包/類
/**
 * Executes a statement and populates the specified {@link CursorWindow}
 * with a range of results.  Returns the number of rows that were counted
 * during query execution.
 *
 * @param sql The SQL statement to execute.
 * @param bindArgs The arguments to bind, or null if none.
 * @param window The cursor window to clear and fill.
 * @param startPos The start position for filling the window.
 * @param requiredPos The position of a row that MUST be in the window.
 * If it won't fit, then the query should discard part of what it filled
 * so that it does.  Must be greater than or equal to <code>startPos</code>.
 * @param countAllRows True to count all rows that the query would return
 * regagless of whether they fit in the window.
 * @param cancellationSignal A signal to cancel the operation in progress, or null if none.
 * @return The number of rows that were counted during query execution.  Might
 * not be all rows in the result set unless <code>countAllRows</code> is true.
 *
 * @throws SQLiteException if an error occurs, such as a syntax error
 * or invalid number of bind arguments.
 * @throws OperationCanceledException if the operation was canceled.
 */
public int executeForCursorWindow(String sql, Object[] bindArgs,
        CursorWindow window, int startPos, int requiredPos, boolean countAllRows,
        CancellationSignal cancellationSignal) {
    if (sql == null) {
        throw new IllegalArgumentException("sql must not be null.");
    }
    if (window == null) {
        throw new IllegalArgumentException("window must not be null.");
    }

    window.acquireReference();
    try {
        int actualPos = -1;
        int countedRows = -1;
        int filledRows = -1;
        final int cookie = mRecentOperations.beginOperation("executeForCursorWindow",
                sql, bindArgs);
        try {
            final PreparedStatement statement = acquirePreparedStatement(sql);
            try {
                throwIfStatementForbidden(statement);
                bindArguments(statement, bindArgs);
                applyBlockGuardPolicy(statement);
                attachCancellationSignal(cancellationSignal);
                try {
                    final long result = nativeExecuteForCursorWindow(
                            mConnectionPtr, statement.mStatementPtr, window,
                            startPos, requiredPos, countAllRows);
                    actualPos = (int)(result >> 32);
                    countedRows = (int)result;
                    filledRows = window.getNumRows();
                    window.setStartPosition(actualPos);
                    return countedRows;
                } finally {
                    detachCancellationSignal(cancellationSignal);
                }
            } finally {
                releasePreparedStatement(statement);
            }
        } catch (RuntimeException ex) {
            mRecentOperations.failOperation(cookie, ex);
            throw ex;
        } finally {
            if (mRecentOperations.endOperationDeferLog(cookie)) {
                mRecentOperations.logOperation(cookie, "window='" + window
                        + "', startPos=" + startPos
                        + ", actualPos=" + actualPos
                        + ", filledRows=" + filledRows
                        + ", countedRows=" + countedRows);
            }
        }
    } finally {
        window.releaseReference();
    }
}
 
開發者ID:yahoo,項目名稱:squidb,代碼行數:78,代碼來源:SQLiteConnection.java

示例9: cursorFillWindow

import android.database.CursorWindow; //導入方法依賴的package包/類
/**
 * Fills the specified cursor window by iterating over the contents of the cursor.
 * The window is filled until the cursor is exhausted or the window runs out
 * of space.
 * 
 * The original position of the cursor is left unchanged by this operation.
 * 
 * @param cursor
 *            The cursor that contains the data to put in the window.
 * @param position
 *            The start position for filling the window.
 * @param window
 *            The window to fill.
 */
@TargetApi(11)
private static void cursorFillWindow(final Cursor cursor, int position,
		final CursorWindow window) {
	if (position < 0 || position >= cursor.getCount()) {
		return;
	}
	final int oldPos = cursor.getPosition();
	final int numColumns = cursor.getColumnCount();
	window.clear();
	window.setStartPosition(position);
	window.setNumColumns(numColumns);
	if (cursor.moveToPosition(position)) {
		do {
			if (!window.allocRow()) {
				break;
			}
			for (int i = 0; i < numColumns; i++) {
				// Cursor.getType() is only available from API 11 on, throw at least a
				// meaningful error message.
				if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
					throw new UnsupportedOperationException(
							"This method is only availble on devices running Honeycomb (API 11) or higher");
				}
				final int type = cursor.getType(i);
				final boolean success;
				switch (type) {
				case Cursor.FIELD_TYPE_NULL:
					success = window.putNull(position, i);
					break;

				case Cursor.FIELD_TYPE_INTEGER:
					success = window.putLong(cursor.getLong(i), position, i);
					break;

				case Cursor.FIELD_TYPE_FLOAT:
					success = window.putDouble(cursor.getDouble(i), position, i);
					break;

				case Cursor.FIELD_TYPE_BLOB:
					byte[] blob = cursor.getBlob(i);
					success = blob != null ? window.putBlob(blob, position, i) : window
							.putNull(position, i);
					break;

				default: // assume value is convertible to String
				case Cursor.FIELD_TYPE_STRING:
					String string = cursor.getString(i);
					success = string != null ? window.putString(string, position, i) : window
							.putNull(position, i);
					break;
				}
				if (!success) {
					window.freeLastRow();
					break;
				}
			}
			position++;
		} while (cursor.moveToNext());
	}
	cursor.moveToPosition(oldPos);
}
 
開發者ID:ProjectMAXS,項目名稱:maxs,代碼行數:76,代碼來源:CrossProcessCursorWrapper.java

示例10: fillWindow

import android.database.CursorWindow; //導入方法依賴的package包/類
@Override
public void fillWindow(int position, CursorWindow window) {
    if (position < 0 || position > getCount()) {
        return;
    }
    window.acquireReference();
    try {
        int oldpos = mPos;
        mPos = position - 1;
        window.clear();
        window.setStartPosition(position);
        int columnNum = getColumnCount();
        window.setNumColumns(columnNum);
        while (moveToNext() && window.allocRow()) {
            for (int i = 0; i < columnNum; i++) {
                boolean hasRoom = true;
                switch (getColumnType(i)) {
                    case Types.DOUBLE:
                        hasRoom = fillRow(window, Double.valueOf(getDouble(i)), mPos, i);
                        break;
                    case Types.NUMERIC:
                        hasRoom = fillRow(window, Long.valueOf(getLong(i)), mPos, i);
                        break;
                    case Types.BLOB:
                        hasRoom = fillRow(window, getBlob(i), mPos, i);
                        break;
                    case Types.LONGVARCHAR:
                        hasRoom = fillRow(window, getString(i), mPos, i);
                        break;
                    case Types.NULL:
                        hasRoom = fillRow(window, null, mPos, i);
                        break;
                }
                if (!hasRoom) {
                    break;
                }
            }
        }
        mPos = oldpos;
    } catch (IllegalStateException e) {
        // simply ignore it
    } finally {
        window.releaseReference();
    }
}
 
開發者ID:morristech,項目名稱:android-chromium,代碼行數:46,代碼來源:SQLiteCursor.java

示例11: fillWindow

import android.database.CursorWindow; //導入方法依賴的package包/類
@Override
public void fillWindow(int aRowPosition, CursorWindow aDataWindow) {
    if (aRowPosition<0 || aRowPosition>=getCount()) {
        return;
    }
    aDataWindow.acquireReference();
    try {
        int oldRowPos = mPos;
        mPos = aRowPosition - 1;
        aDataWindow.clear();
        aDataWindow.setStartPosition(aRowPosition);
        int theNumCols = getColumnCount();
        aDataWindow.setNumColumns(theNumCols);
        while (moveToNext() && aDataWindow.allocRow()) {
            for (int theColIdx=0; theColIdx<theNumCols; theColIdx++) {
                boolean bPutNull = false;
                boolean bPutFail = false;
            	switch (getColumnType(theColIdx)) {
            		case COLUMN_TYPE_STRING:
                    case COLUMN_TYPE_INTEGER:
                        String strField = getString(theColIdx);
                        if (strField != null)
                            bPutFail = (!aDataWindow.putString(strField,mPos,theColIdx));
                        else
                        	bPutNull = true;
                        break;
                    case COLUMN_TYPE_LONG:
                        Long longField = getLong(theColIdx);
                        if (longField != null)
                            bPutFail = (!aDataWindow.putLong(longField,mPos,theColIdx));
                        else
                        	bPutNull = true;
                        break;
            		case COLUMN_TYPE_FLOAT:
                        Double floatField = getDouble(theColIdx);
                        if (floatField != null)
                            bPutFail = (!aDataWindow.putDouble(floatField,mPos,theColIdx));
                        else
                        	bPutNull = true;
                        break;
            		case COLUMN_TYPE_BLOB:
                        byte[] blobField = getBlob(theColIdx);
                        if (blobField != null)
                            bPutFail = (!aDataWindow.putBlob(blobField,mPos,theColIdx));
                        else
                        	bPutNull = true;
                        break;
            		default:
            			bPutNull = true;
            	}
            	if (bPutNull) {
            		bPutFail = (!aDataWindow.putNull(mPos,theColIdx));
            	}
            	if (bPutFail) {
                    aDataWindow.freeLastRow();
                    break;
            	}
            }
        }

        mPos = oldRowPos;
    } catch (IllegalStateException e) {
        // simply ignore it
    } finally {
        aDataWindow.releaseReference();
    }
}
 
開發者ID:baracudda,項目名稱:androidBits,代碼行數:68,代碼來源:TypedMatrixCursor.java


注:本文中的android.database.CursorWindow.setStartPosition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。