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


Java ContentProviderResult類代碼示例

本文整理匯總了Java中android.content.ContentProviderResult的典型用法代碼示例。如果您正苦於以下問題:Java ContentProviderResult類的具體用法?Java ContentProviderResult怎麽用?Java ContentProviderResult使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: applyBatch

import android.content.ContentProviderResult; //導入依賴的package包/類
/**
 * Apply the given set of {@link ContentProviderOperation}, executing inside
 * a {@link SQLiteDatabase} transaction. All changes will be rolled back if
 * any single one fails.
 */
public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations)
        throws OperationApplicationException {
    final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
    db.beginTransaction();
    try {
        final int numOperations = operations.size();
        final ContentProviderResult[] results = new ContentProviderResult[numOperations];
        for (int i = 0; i < numOperations; i++) {
            results[i] = operations.get(i).apply(this, results, i);
        }
        db.setTransactionSuccessful();
        return results;
    } finally {
        db.endTransaction();
    }
}
 
開發者ID:rashikaranpuria,項目名稱:xyz-reader-2,代碼行數:22,代碼來源:ItemsProvider.java

示例2: applyBatch

import android.content.ContentProviderResult; //導入依賴的package包/類
@NonNull
@Override
public ContentProviderResult[] applyBatch(@NonNull ArrayList<ContentProviderOperation> operations)
        throws OperationApplicationException {
    ContentProviderResult[] result = null;
    isApplyingBatch = true;
    final SQLiteDatabase db = db();
    db.beginTransaction();
    try {
        result = super.applyBatch(operations);
        db.setTransactionSuccessful();
    } finally {
        db.endTransaction();
        isApplyingBatch = false;
    }
    return result;
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:18,代碼來源:FDroidProvider.java

示例3: createFromContentProviderResults

import android.content.ContentProviderResult; //導入依賴的package包/類
@Nullable
public static DatabaseIdRange createFromContentProviderResults(ContentProviderResult[] results){
    Integer f = null;
    Integer l = null;

    for(ContentProviderResult result : results){
        if(result.uri != null && !result.uri.toString().isEmpty()){
            int dbid = Integer.parseInt(result.uri.getPathSegments().get(1));
            if(f == null || dbid < f){
                f = dbid;
            }

            if(l == null || dbid > l){
                l = dbid;
            }
        }
    }

    return nonNull(f) && nonNull(l) ? new DatabaseIdRange(f, l) : null;
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:21,代碼來源:DatabaseIdRange.java

示例4: attachDbos

import android.content.ContentProviderResult; //導入依賴的package包/類
@Override
public Single<int[]> attachDbos(int accountId, int attachToType, int attachToDbid, @NonNull List<Entity> entities) {
    return Single.create(emitter -> {
        ArrayList<ContentProviderOperation> operations = new ArrayList<>(entities.size());

        int[] indexes = new int[entities.size()];
        for (int i = 0; i < entities.size(); i++) {
            Entity entity = entities.get(i);
            indexes[i] = appendAttachOperationWithStableAttachToId(operations, accountId, attachToType, attachToDbid, entity);
        }

        ContentProviderResult[] results = getContentResolver().applyBatch(MessengerContentProvider.AUTHORITY, operations);

        int [] ids = new int[entities.size()];

        for (int i = 0; i < indexes.length; i++) {
            ContentProviderResult result = results[indexes[i]];
            int dbid = Integer.parseInt(result.uri.getPathSegments().get(1));
            ids[i] = dbid;
        }

        emitter.onSuccess(ids);
    });
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:25,代碼來源:AttachmentsStore.java

示例5: applyBatch

import android.content.ContentProviderResult; //導入依賴的package包/類
@Override
public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations) throws OperationApplicationException {
    ContentProviderResult[] results;

    SQLiteDatabase db = mOpenHelper.getWritableDatabase();

    db.beginTransaction();
    try {
        inBatch.set(true);
        results = super.applyBatch(operations);
        inBatch.set(false);

        db.setTransactionSuccessful();
    } finally {
        db.endTransaction();
    }

    notifyChange();

    return results;
}
 
開發者ID:orgzly,項目名稱:orgzly-android,代碼行數:22,代碼來源:Provider.java

示例6: applyBatch

import android.content.ContentProviderResult; //導入依賴的package包/類
@NonNull
@Override
public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations) throws OperationApplicationException {
    try {
        Field uriField = ContentProviderOperation.class.getDeclaredField("mUri");
        uriField.setAccessible(true);
        for (ContentProviderOperation operation : operations) {
            Uri pluginUri = Uri.parse(operation.getUri().getQueryParameter(KEY_URI));
            uriField.set(operation, pluginUri);
        }
    } catch (Exception e) {
        return new ContentProviderResult[0];
    }

    if (operations.size() > 0) {
        ContentProvider provider = getContentProvider(operations.get(0).getUri());
        if (provider != null) {
            return provider.applyBatch(operations);
        }
    }

    return new ContentProviderResult[0];
}
 
開發者ID:didi,項目名稱:VirtualAPK,代碼行數:24,代碼來源:RemoteContentProvider.java

示例7: applyBatch

import android.content.ContentProviderResult; //導入依賴的package包/類
@NonNull
@Override
public ContentProviderResult[] applyBatch(
        @NonNull ArrayList<ContentProviderOperation> operations)
        throws OperationApplicationException {
    final Context context = getContext();
    if (context == null) {
        return new ContentProviderResult[0];
    }
    final SampleDatabase database = SampleDatabase.getInstance(context);
    database.beginTransaction();
    try {
        final ContentProviderResult[] result = super.applyBatch(operations);
        database.setTransactionSuccessful();
        return result;
    } finally {
        database.endTransaction();
    }
}
 
開發者ID:googlesamples,項目名稱:android-architecture-components,代碼行數:20,代碼來源:SampleContentProvider.java

示例8: cheese_applyBatch

import android.content.ContentProviderResult; //導入依賴的package包/類
@Test
public void cheese_applyBatch() throws RemoteException, OperationApplicationException {
    final ArrayList<ContentProviderOperation> operations = new ArrayList<>();
    operations.add(ContentProviderOperation
            .newInsert(SampleContentProvider.URI_CHEESE)
            .withValue(Cheese.COLUMN_NAME, "Peynir")
            .build());
    operations.add(ContentProviderOperation
            .newInsert(SampleContentProvider.URI_CHEESE)
            .withValue(Cheese.COLUMN_NAME, "Queso")
            .build());
    final ContentProviderResult[] results = mContentResolver.applyBatch(
            SampleContentProvider.AUTHORITY, operations);
    assertThat(results.length, is(2));
    final Cursor cursor = mContentResolver.query(SampleContentProvider.URI_CHEESE,
            new String[]{Cheese.COLUMN_NAME}, null, null, null);
    assertThat(cursor, notNullValue());
    assertThat(cursor.getCount(), is(2));
    assertThat(cursor.moveToFirst(), is(true));
    cursor.close();
}
 
開發者ID:googlesamples,項目名稱:android-architecture-components,代碼行數:22,代碼來源:SampleContentProviderTest.java

示例9: applyBatch

import android.content.ContentProviderResult; //導入依賴的package包/類
/**
 * Apply the given set of {@link ContentProviderOperation}, executing inside
 * a {@link SQLiteDatabase} transaction. All changes will be rolled back if
 * any single one fails.
 */
@Override
public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations)
        throws OperationApplicationException {
    final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
    db.beginTransaction();
    try {
        final int numOperations = operations.size();
        final ContentProviderResult[] results = new ContentProviderResult[numOperations];
        for (int i = 0; i < numOperations; i++) {
            results[i] = operations.get(i).apply(this, results, i);
        }
        db.setTransactionSuccessful();
        return results;
    } finally {
        db.endTransaction();
    }
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:23,代碼來源:ScheduleProvider.java

示例10: applyBatch

import android.content.ContentProviderResult; //導入依賴的package包/類
@Override
public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations)
        throws OperationApplicationException {
    if (DBG) Log.d(TAG, "applyBatch");
    ContentProviderResult[] result = null;
    SQLiteDatabase db = mDbHolder.get();
    db.beginTransaction();
    try {
         result = super.applyBatch(operations);
         db.setTransactionSuccessful();
    } finally {
        db.endTransaction();
    }
    if (result != null) {
        mCr.notifyChange(MusicStore.ALL_CONTENT_URI, null);
    }
    return result;
}
 
開發者ID:archos-sa,項目名稱:aos-MediaLib,代碼行數:19,代碼來源:MusicProvider.java

示例11: applyBatch

import android.content.ContentProviderResult; //導入依賴的package包/類
@Override
public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations)
        throws OperationApplicationException {
    SQLiteDatabase db = mDbHolder.get();
    db.beginTransaction();
    ContentProviderResult[] result = null;
    try {
        result = super.applyBatch(operations);
        db.setTransactionSuccessful();
        ContentResolver res = mCr;
        res.notifyChange(ScraperStore.ALL_CONTENT_URI, null);
        return result;
    } finally {
        db.endTransaction();
    }
}
 
開發者ID:archos-sa,項目名稱:aos-MediaLib,代碼行數:17,代碼來源:ScraperProvider.java

示例12: transactionSuccess

import android.content.ContentProviderResult; //導入依賴的package包/類
@Override
public void transactionSuccess() {
    try {
        ContentProviderResult[] cpr = context.getContentResolver().applyBatch(
                dsUri.getAuthority(), trans);
        if(cpr == null || cpr.length != trans.size()){
            throw new DaoException();
        }
        for (int i = 0; i < cpr.length; i++) {
            if (cpr[i] == null || ( cpr[i].count == null && cpr[i].uri == null)) {
                throw new DaoException();
            }
        }
    } catch (RemoteException | OperationApplicationException e) {
        throw new DaoException();
    } finally {
        trans = null;
    }
}
 
開發者ID:joker535,項目名稱:sorm,代碼行數:20,代碼來源:ContentProviderEngine.java

示例13: applyBatch

import android.content.ContentProviderResult; //導入依賴的package包/類
@Override
public ContentProviderResult[] applyBatch( ArrayList<ContentProviderOperation> operations )
        throws OperationApplicationException {

    ContentProviderResult[] contentProviderResults;
    try {
        getWritableDatabase().beginTransaction();
        contentProviderResults = new ContentProviderResult[operations
                .size()];
        
        int i = 0;
        for (ContentProviderOperation cpo : operations) {
            contentProviderResults[i] = cpo.apply(this, contentProviderResults, i);
            if(contentProviderResults[i] == null || (contentProviderResults[i].count == null && contentProviderResults[i].uri == null)){
                throw new DaoException();
            }
            i++;
        }
        getWritableDatabase().setTransactionSuccessful();
    } finally{
        if (getWritableDatabase().inTransaction()) {
            getWritableDatabase().endTransaction();
        }            
    }
    return contentProviderResults;
}
 
開發者ID:joker535,項目名稱:sorm,代碼行數:27,代碼來源:OrmProvider.java

示例14: applyBatch

import android.content.ContentProviderResult; //導入依賴的package包/類
/**
 * Apply the given set of {@link ContentProviderOperation}, executing inside
 * a {@link SQLiteDatabase} transaction. All changes will be rolled back if
 * any single one fails.
 */
@Override
public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations)
        throws OperationApplicationException {
    final SQLiteDatabase db = mDatabaseHelper.getWritableDatabase();
    db.beginTransaction();
    try {
        final int numOperations = operations.size();
        final ContentProviderResult[] results = new ContentProviderResult[numOperations];
        for (int i = 0; i < numOperations; i++) {
            results[i] = operations.get(i).apply(this, results, i);
        }
        db.setTransactionSuccessful();
        return results;
    } finally {
        db.endTransaction();
    }
}
 
開發者ID:timothymiko,項目名稱:narrate-android,代碼行數:23,代碼來源:DataProvider.java

示例15: applyBatch

import android.content.ContentProviderResult; //導入依賴的package包/類
/**
 * Apply the given set of {@link ContentProviderOperation}, executing inside
 * a {@link SQLiteDatabase} transaction. All changes will be rolled back if
 * any single one fails.
 */
@NonNull
@Override
public ContentProviderResult[] applyBatch(@NonNull ArrayList<ContentProviderOperation> operations)
        throws OperationApplicationException {
    final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
    db.beginTransaction();
    try {
        final int numOperations = operations.size();
        final ContentProviderResult[] results = new ContentProviderResult[numOperations];
        for (int i = 0; i < numOperations; i++) {
            results[i] = operations.get(i).apply(this, results, i);
        }
        db.setTransactionSuccessful();
        return results;
    } finally {
        db.endTransaction();
    }
}
 
開發者ID:mozilla,項目名稱:Jisort,代碼行數:24,代碼來源:DsoProvider.java


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