Search in sources :

Example 1 with OperationInfo

use of com.android.calendar.AsyncQueryServiceHelper.OperationInfo in project Etar-Calendar by Etar-Group.

the class AsyncQueryServiceTest method testInsert.

@SmallTest
public void testInsert() throws Exception {
    int index = 0;
    final OperationInfo[] work = new OperationInfo[1];
    work[index] = new OperationInfo();
    work[index].op = Operation.EVENT_ARG_INSERT;
    work[index].token = ++mId;
    work[index].cookie = ++mId;
    work[index].uri = Uri.parse(AUTHORITY_URI + "blah");
    work[index].values = new ContentValues();
    work[index].values.put("key", ++mId);
    work[index].delayMillis = 0;
    work[index].result = Uri.parse(AUTHORITY_URI + "Result=" + ++mId);
    TestAsyncQueryService aqs = new TestAsyncQueryService(buildTestContext(work), work);
    aqs.startInsert(work[index].token, work[index].cookie, work[index].uri, work[index].values, work[index].delayMillis);
    Log.d(TAG, "testInsert Waiting >>>>>>>>>>>");
    assertEquals("Not all operations were executed.", work.length, aqs.waitForCompletion(BASE_TEST_WAIT_TIME));
    Log.d(TAG, "testInsert Done <<<<<<<<<<<<<<");
}
Also used : OperationInfo(com.android.calendar.AsyncQueryServiceHelper.OperationInfo) ContentValues(android.content.ContentValues) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 2 with OperationInfo

use of com.android.calendar.AsyncQueryServiceHelper.OperationInfo in project Etar-Calendar by Etar-Group.

the class AsyncQueryServiceTest method testBatch.

@SmallTest
public void testBatch() throws Exception {
    int index = 0;
    final OperationInfo[] work = new OperationInfo[1];
    work[index] = new OperationInfo();
    work[index].op = Operation.EVENT_ARG_BATCH;
    work[index].token = ++mId;
    work[index].cookie = ++mId;
    work[index].authority = AUTHORITY;
    work[index].cpo = new ArrayList<ContentProviderOperation>();
    work[index].cpo.add(ContentProviderOperation.newInsert(Uri.parse(AUTHORITY_URI + ++mId)).build());
    work[index].delayMillis = 0;
    ContentProviderResult[] resultArray = new ContentProviderResult[1];
    resultArray[0] = new ContentProviderResult(++mId);
    work[index].result = resultArray;
    TestAsyncQueryService aqs = new TestAsyncQueryService(buildTestContext(work), work);
    aqs.startBatch(work[index].token, work[index].cookie, work[index].authority, work[index].cpo, work[index].delayMillis);
    Log.d(TAG, "testBatch Waiting >>>>>>>>>>>");
    assertEquals("Not all operations were executed.", work.length, aqs.waitForCompletion(BASE_TEST_WAIT_TIME));
    Log.d(TAG, "testBatch Done <<<<<<<<<<<<<<");
}
Also used : OperationInfo(com.android.calendar.AsyncQueryServiceHelper.OperationInfo) ContentProviderResult(android.content.ContentProviderResult) ContentProviderOperation(android.content.ContentProviderOperation) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 3 with OperationInfo

use of com.android.calendar.AsyncQueryServiceHelper.OperationInfo in project Etar-Calendar by Etar-Group.

the class AsyncQueryService method handleMessage.

@Override
public void handleMessage(Message msg) {
    OperationInfo info = (OperationInfo) msg.obj;
    int token = msg.what;
    int op = msg.arg1;
    if (localLOGV) {
        Log.d(TAG, "AsyncQueryService.handleMessage: token=" + token + ", op=" + op + ", result=" + info.result);
    }
    // pass token back to caller on each callback.
    switch(op) {
        case Operation.EVENT_ARG_QUERY:
            onQueryComplete(token, info.cookie, (Cursor) info.result);
            break;
        case Operation.EVENT_ARG_INSERT:
            onInsertComplete(token, info.cookie, (Uri) info.result);
            break;
        case Operation.EVENT_ARG_UPDATE:
            onUpdateComplete(token, info.cookie, (Integer) info.result);
            break;
        case Operation.EVENT_ARG_DELETE:
            onDeleteComplete(token, info.cookie, (Integer) info.result);
            break;
        case Operation.EVENT_ARG_BATCH:
            onBatchComplete(token, info.cookie, (ContentProviderResult[]) info.result);
            break;
    }
}
Also used : OperationInfo(com.android.calendar.AsyncQueryServiceHelper.OperationInfo) ContentProviderResult(android.content.ContentProviderResult)

Example 4 with OperationInfo

use of com.android.calendar.AsyncQueryServiceHelper.OperationInfo in project Etar-Calendar by Etar-Group.

the class AsyncQueryService method startQuery.

/**
     * This method begins an asynchronous query. When the query is done
     * {@link #onQueryComplete} is called.
     *
     * @param token A token passed into {@link #onQueryComplete} to identify the
     *            query.
     * @param cookie An object that gets passed into {@link #onQueryComplete}
     * @param uri The URI, using the content:// scheme, for the content to
     *            retrieve.
     * @param projection A list of which columns to return. Passing null will
     *            return all columns, which is discouraged to prevent reading
     *            data from storage that isn't going to be used.
     * @param selection A filter declaring which rows to return, formatted as an
     *            SQL WHERE clause (excluding the WHERE itself). Passing null
     *            will return all rows for the given URI.
     * @param selectionArgs You may include ?s in selection, which will be
     *            replaced by the values from selectionArgs, in the order that
     *            they appear in the selection. The values will be bound as
     *            Strings.
     * @param orderBy How to order the rows, formatted as an SQL ORDER BY clause
     *            (excluding the ORDER BY itself). Passing null will use the
     *            default sort order, which may be unordered.
     */
public void startQuery(int token, Object cookie, Uri uri, String[] projection, String selection, String[] selectionArgs, String orderBy) {
    OperationInfo info = new OperationInfo();
    info.op = Operation.EVENT_ARG_QUERY;
    info.resolver = mContext.getContentResolver();
    info.handler = mHandler;
    info.token = token;
    info.cookie = cookie;
    info.uri = uri;
    info.projection = projection;
    info.selection = selection;
    info.selectionArgs = selectionArgs;
    info.orderBy = orderBy;
    AsyncQueryServiceHelper.queueOperation(mContext, info);
}
Also used : OperationInfo(com.android.calendar.AsyncQueryServiceHelper.OperationInfo)

Example 5 with OperationInfo

use of com.android.calendar.AsyncQueryServiceHelper.OperationInfo in project Etar-Calendar by Etar-Group.

the class AsyncQueryService method startBatch.

/**
     * This method begins an asynchronous {@link ContentProviderOperation}. When
     * the operation is done {@link #onBatchComplete} is called.
     *
     * @param token A token passed into {@link #onDeleteComplete} to identify
     *            the delete operation.
     * @param cookie An object that gets passed into {@link #onDeleteComplete}
     * @param authority the authority used for the
     *            {@link ContentProviderOperation}.
     * @param cpo the {@link ContentProviderOperation} to be executed.
     * @param delayMillis delay in executing the operation. This operation will
     *            execute before the delayed time when another operation is
     *            added. Useful for implementing single level undo.
     */
public void startBatch(int token, Object cookie, String authority, ArrayList<ContentProviderOperation> cpo, long delayMillis) {
    OperationInfo info = new OperationInfo();
    info.op = Operation.EVENT_ARG_BATCH;
    info.resolver = mContext.getContentResolver();
    info.handler = mHandler;
    info.token = token;
    info.cookie = cookie;
    info.authority = authority;
    info.cpo = cpo;
    info.delayMillis = delayMillis;
    AsyncQueryServiceHelper.queueOperation(mContext, info);
}
Also used : OperationInfo(com.android.calendar.AsyncQueryServiceHelper.OperationInfo)

Aggregations

OperationInfo (com.android.calendar.AsyncQueryServiceHelper.OperationInfo)16 SmallTest (android.test.suitebuilder.annotation.SmallTest)5 ContentProviderOperation (android.content.ContentProviderOperation)4 LargeTest (android.test.suitebuilder.annotation.LargeTest)3 Operation (com.android.calendar.AsyncQueryService.Operation)3 ContentProviderResult (android.content.ContentProviderResult)2 ContentValues (android.content.ContentValues)2 Smoke (android.test.suitebuilder.annotation.Smoke)1