当前位置: 首页>>代码示例>>Java>>正文


Java OperationApplicationException类代码示例

本文整理汇总了Java中android.content.OperationApplicationException的典型用法代码示例。如果您正苦于以下问题:Java OperationApplicationException类的具体用法?Java OperationApplicationException怎么用?Java OperationApplicationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OperationApplicationException类属于android.content包,在下文中一共展示了OperationApplicationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyBatch

import android.content.OperationApplicationException; //导入依赖的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.OperationApplicationException; //导入依赖的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: flushApksToDbInBatch

import android.content.OperationApplicationException; //导入依赖的package包/类
private void flushApksToDbInBatch(Map<String, Long> appIds) throws RepoUpdater.UpdateException {
    List<Apk> apksToSaveList = new ArrayList<>();
    for (Map.Entry<String, List<Apk>> entries : apksToSave.entrySet()) {
        for (Apk apk : entries.getValue()) {
            apk.appId = appIds.get(apk.packageName);
        }
        apksToSaveList.addAll(entries.getValue());
    }

    calcApkCompatibilityFlags(apksToSaveList);

    ArrayList<ContentProviderOperation> apkOperations = insertApks(apksToSaveList);

    try {
        context.getContentResolver().applyBatch(TempApkProvider.getAuthority(), apkOperations);
    } catch (RemoteException | OperationApplicationException e) {
        throw new RepoUpdater.UpdateException(repo, "An internal error occurred while updating the database", e);
    }
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:20,代码来源:RepoPersister.java

示例4: updateContactsDatabase

import android.content.OperationApplicationException; //导入依赖的package包/类
private static @NonNull RefreshResult updateContactsDatabase(@NonNull Context context,
                                                             @NonNull String localNumber,
                                                             @NonNull List<ContactTokenDetails> activeTokens,
                                                             boolean removeMissing)
{
  Optional<AccountHolder> account = getOrCreateAccount(context);

  if (account.isPresent()) {
    try {
      List<String> newUsers = DatabaseFactory.getContactsDatabase(context)
                                             .setRegisteredUsers(account.get().getAccount(), localNumber, activeTokens, removeMissing);

      return new RefreshResult(newUsers, account.get().isFresh());
    } catch (RemoteException | OperationApplicationException e) {
      Log.w(TAG, e);
    }
  }

  return new RefreshResult(new LinkedList<String>(), false);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:21,代码来源:DirectoryHelper.java

示例5: applyBatch

import android.content.OperationApplicationException; //导入依赖的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: updateUrl

import android.content.OperationApplicationException; //导入依赖的package包/类
/**
 * Since old repository URL could be used, do not actually update the existing record,
 * but create a new one.
 */
public static int updateUrl(Context mContext, long id, String url) {
    ArrayList<ContentProviderOperation> ops = new ArrayList<>();

    ops.add(ContentProviderOperation
                    .newDelete(ContentUris.withAppendedId(ProviderContract.Repos.ContentUri.repos(), id))
                    .build());

    ops.add(ContentProviderOperation
                    .newInsert(ProviderContract.Repos.ContentUri.repos())
                    .withValue(ProviderContract.Repos.Param.REPO_URL, url)
                    .build());

    try {
        mContext.getContentResolver().applyBatch(ProviderContract.AUTHORITY, ops);
    } catch (RemoteException | OperationApplicationException e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }

    return 1;
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:26,代码来源:ReposClient.java

示例7: set

import android.content.OperationApplicationException; //导入依赖的package包/类
public static void set(Context context, List<VersionedRook> books) {
    ArrayList<ContentProviderOperation> ops = new ArrayList<>();

    /* Delete all previous. */
    ops.add(ContentProviderOperation
            .newDelete(ProviderContract.CurrentRooks.ContentUri.currentRooks())
            .build());

    /* Insert each one. */
    for (VersionedRook book: books) {
        ContentValues values = new ContentValues();
        CurrentRooksClient.toContentValues(values, book);

        ops.add(ContentProviderOperation
                .newInsert(ProviderContract.CurrentRooks.ContentUri.currentRooks())
                .withValues(values)
                .build());
    }

    try {
        context.getContentResolver().applyBatch(ProviderContract.AUTHORITY, ops);
    } catch (RemoteException | OperationApplicationException e) {
        e.printStackTrace();
    }
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:26,代码来源:CurrentRooksClient.java

示例8: delete

import android.content.OperationApplicationException; //导入依赖的package包/类
public static int delete(Context context, long[] noteIds) {
    int deleted = 0;

    ArrayList<ContentProviderOperation> ops = new ArrayList<>();

    for (long noteId: noteIds) {
        ops.add(ContentProviderOperation
                .newDelete(ProviderContract.Notes.ContentUri.notes())
                .withSelection(ProviderContract.Notes.UpdateParam._ID + "=" + noteId, null)
                .build()
        );
    }

    try {
        context.getContentResolver().applyBatch(ProviderContract.AUTHORITY, ops);
    } catch (RemoteException | OperationApplicationException e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }

    if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, "Deleted " + deleted + " notes");

    return deleted;
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:25,代码来源:NotesClient.java

示例9: applyBatch

import android.content.OperationApplicationException; //导入依赖的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

示例10: applyBatch

import android.content.OperationApplicationException; //导入依赖的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

示例11: cheese_applyBatch

import android.content.OperationApplicationException; //导入依赖的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

示例12: applyBatch

import android.content.OperationApplicationException; //导入依赖的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

示例13: applyBatch

import android.content.OperationApplicationException; //导入依赖的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

示例14: applyBatch

import android.content.OperationApplicationException; //导入依赖的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

示例15: transactionSuccess

import android.content.OperationApplicationException; //导入依赖的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


注:本文中的android.content.OperationApplicationException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。