Java Code Examples for android.content.ContentProviderOperation
The following are top voted examples for showing how to use
android.content.ContentProviderOperation. These examples are extracted from open source projects.
You can vote up the examples you like and your votes will be used in our system to generate
more good examples.
Example 1
Project: iosched-reader File: SpeakersHandler.java View source code | 7 votes |
private void buildSpeaker(boolean isInsert, Speaker speaker, ArrayList<ContentProviderOperation> list) { Uri allSpeakersUri = ScheduleContractHelper.setUriAsCalledFromSyncAdapter( ScheduleContract.Speakers.CONTENT_URI); Uri thisSpeakerUri = ScheduleContractHelper.setUriAsCalledFromSyncAdapter( ScheduleContract.Speakers.buildSpeakerUri(speaker.id)); ContentProviderOperation.Builder builder; if (isInsert) { builder = ContentProviderOperation.newInsert(allSpeakersUri); } else { builder = ContentProviderOperation.newUpdate(thisSpeakerUri); } list.add(builder.withValue(ScheduleContract.SyncColumns.UPDATED, System.currentTimeMillis()) .withValue(ScheduleContract.Speakers.SPEAKER_ID, speaker.id) .withValue(ScheduleContract.Speakers.SPEAKER_NAME, speaker.name) .withValue(ScheduleContract.Speakers.SPEAKER_ABSTRACT, speaker.bio) .withValue(ScheduleContract.Speakers.SPEAKER_COMPANY, speaker.company) .withValue(ScheduleContract.Speakers.SPEAKER_IMAGE_URL, speaker.thumbnailUrl) .withValue(ScheduleContract.Speakers.SPEAKER_PLUSONE_URL, speaker.plusoneUrl) .withValue(ScheduleContract.Speakers.SPEAKER_TWITTER_URL, speaker.twitterUrl) .withValue(ScheduleContract.Speakers.SPEAKER_IMPORT_HASHCODE, speaker.getImportHashcode()) .build()); }
Example 2
Project: ContentPal File: RowSnapshotReferenceTest.java View source code | 6 votes |
@Test public void testAssertOperationBuilder() throws Exception { ContentProviderOperation.Builder dummyResultBuilder = dummy(ContentProviderOperation.Builder.class); SoftRowReference<Object> dummyOriginalReference = dummy(SoftRowReference.class); RowReference<Object> mockResolvedReference = failingMock(RowReference.class); RowSnapshot<Object> mockSnapshot = failingMock(RowSnapshot.class); TransactionContext mockTransactionContext = failingMock(TransactionContext.class); doReturn(dummyOriginalReference).when(mockSnapshot).reference(); doReturn(mockResolvedReference).when(mockTransactionContext).resolved(dummyOriginalReference); doReturn(dummyResultBuilder).when(mockResolvedReference).assertOperationBuilder(mockTransactionContext); assertThat(new RowSnapshotReference<>(mockSnapshot).assertOperationBuilder(mockTransactionContext), sameInstance(dummyResultBuilder)); }
Example 3
Project: Linphone4Android File: LinphoneContact.java View source code | 6 votes |
public void setPhoto(byte[] photo) { if (photo != null) { if (isAndroidContact()) { if (androidRawId != null) { changesToCommit.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI) .withValue(ContactsContract.Data.RAW_CONTACT_ID, androidRawId) .withValue(ContactsContract.Data.MIMETYPE, CommonDataKinds.Photo.CONTENT_ITEM_TYPE) .withValue(CommonDataKinds.Photo.PHOTO, photo) .withValue(ContactsContract.Data.IS_PRIMARY, 1) .withValue(ContactsContract.Data.IS_SUPER_PRIMARY, 1) .build()); } else { changesToCommit.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI) .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0) .withValue(ContactsContract.Data.MIMETYPE, CommonDataKinds.Photo.CONTENT_ITEM_TYPE) .withValue(CommonDataKinds.Photo.PHOTO, photo) .build()); } } } }
Example 4
Project: ContentPal File: BulkAssertTest.java View source code | 6 votes |
@Test public void testContentOperationBuilder_ctor_table_data() { Table<Object> mockTable = failingMock(Table.class); Operation<Object> mockAssertOperation = failingMock(Operation.class); doReturn(mockAssertOperation).when(mockTable).assertOperation(same(EmptyUriParams.INSTANCE), predicateWithSelection("1")); doReturn(ContentProviderOperation.newAssertQuery(Uri.EMPTY)).when(mockAssertOperation).contentOperationBuilder(any(TransactionContext.class)); assertThat(new BulkAssert<>(mockTable, new CharSequenceRowData<>("key", "value")), builds( assertOperation(), withoutExpectedCount(), withYieldNotAllowed(), withValuesOnly( containing("key", "value")))); }
Example 5
Project: ContentPal File: BulkAssertTest.java View source code | 6 votes |
@Test public void testContentOperationBuilder_ctor_table() { Table<Object> mockTable = failingMock(Table.class); Operation<Object> mockAssertOperation = failingMock(Operation.class); doReturn(mockAssertOperation).when(mockTable).assertOperation(same(EmptyUriParams.INSTANCE), predicateWithSelection("1")); doReturn(ContentProviderOperation.newAssertQuery(Uri.EMPTY)).when(mockAssertOperation).contentOperationBuilder(any(TransactionContext.class)); assertThat(new BulkAssert<>(mockTable), builds( assertOperation(), withoutExpectedCount(), withYieldNotAllowed(), withoutValues())); }
Example 6
Project: iosched-reader File: BlocksHandler.java View source code | 6 votes |
private static void outputBlock(Block block, ArrayList<ContentProviderOperation> list) { Uri uri = ScheduleContractHelper.setUriAsCalledFromSyncAdapter( ScheduleContract.Blocks.CONTENT_URI); ContentProviderOperation.Builder builder = ContentProviderOperation.newInsert(uri); String title = block.title != null ? block.title : ""; String meta = block.subtitle != null ? block.subtitle : ""; String type = block.type; if ( ! ScheduleContract.Blocks.isValidBlockType(type)) { LOGW(TAG, "block from "+block.start+" to "+block.end+" has unrecognized type (" +type+"). Using "+ ScheduleContract.Blocks.BLOCK_TYPE_BREAK +" instead."); type = ScheduleContract.Blocks.BLOCK_TYPE_BREAK; } long startTimeL = ParserUtils.parseTime(block.start); long endTimeL = ParserUtils.parseTime(block.end); final String blockId = ScheduleContract.Blocks.generateBlockId(startTimeL, endTimeL); builder.withValue(ScheduleContract.Blocks.BLOCK_ID, blockId); builder.withValue(ScheduleContract.Blocks.BLOCK_TITLE, title); builder.withValue(ScheduleContract.Blocks.BLOCK_START, startTimeL); builder.withValue(ScheduleContract.Blocks.BLOCK_END, endTimeL); builder.withValue(ScheduleContract.Blocks.BLOCK_TYPE, type); builder.withValue(ScheduleContract.Blocks.BLOCK_SUBTITLE, meta); list.add(builder.build()); }
Example 7
Project: LaunchEnr File: ImportDataTask.java View source code | 6 votes |
@Override public long insertAndCheck(SQLiteDatabase db, ContentValues values) { if (mExistingItems.size() >= mRequiredSize) { // No need to add more items. return 0; } Intent intent; try { intent = Intent.parseUri(values.getAsString(Favorites.INTENT), 0); } catch (URISyntaxException e) { return 0; } String pkg = getPackage(intent); if (pkg == null || mExisitingApps.contains(pkg)) { // The item does not target an app or is already in hotseat. return 0; } mExisitingApps.add(pkg); // find next vacant spot. long screen = 0; while (mExistingItems.get(screen) != null) { screen++; } mExistingItems.put(screen, intent); values.put(Favorites.SCREEN, screen); mOutOps.add(ContentProviderOperation.newInsert(Favorites.CONTENT_URI).withValues(values).build()); return 0; }
Example 8
Project: xyz-reader-2 File: ItemsProvider.java View source code | 6 votes |
/** * 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(); } }
Example 9
Project: mobile-store File: RepoPersister.java View source code | 6 votes |
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); } }
Example 10
Project: ContentPal File: DeleteTest.java View source code | 6 votes |
@Test public void testContentOperationBuilder() throws Exception { RowSnapshot<Object> mockRowSnapshot = failingMock(RowSnapshot.class); SoftRowReference<Object> rowReference = failingMock(SoftRowReference.class); doReturn(rowReference).when(mockRowSnapshot).reference(); doReturn(ContentProviderOperation.newDelete(Uri.EMPTY)).when(rowReference).deleteOperationBuilder(any(TransactionContext.class)); assertThat( new Delete<>(mockRowSnapshot), builds( deleteOperation(), withYieldNotAllowed(), withoutExpectedCount(), withoutValues())); }
Example 11
Project: aos-MediaLib File: MusicProvider.java View source code | 6 votes |
@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; }
Example 12
Project: Phoenix-for-VK File: DialogsStore.java View source code | 6 votes |
@Override public Completable insertDialogs(int accountId, List<DialogEntity> dbos, boolean clearBefore) { return Completable.create(emitter -> { final long start = System.currentTimeMillis(); final Uri uri = MessengerContentProvider.getDialogsContentUriFor(accountId); final ArrayList<ContentProviderOperation> operations = new ArrayList<>(); if(clearBefore){ operations.add(ContentProviderOperation.newDelete(uri).build()); } for(DialogEntity dbo : dbos){ ContentValues cv = createCv(dbo); operations.add(ContentProviderOperation.newInsert(uri).withValues(cv).build()); MessagesStore.appendDboOperation(accountId, dbo.getMessage(), operations, null, null); } getContentResolver().applyBatch(MessengerContentProvider.AUTHORITY, operations); emitter.onComplete(); Exestime.log("DialogsStore.insertDialogs", start, "count: " + dbos.size() + ", clearBefore: " + clearBefore); }); }
Example 13
Project: ContentPal File: PutTest.java View source code | 6 votes |
@Test public void testContentOperationBuilderWithData() throws Exception { RowSnapshot<Object> mockRowSnapshot = failingMock(RowSnapshot.class); SoftRowReference<Object> mockRowReference = failingMock(SoftRowReference.class); doReturn(mockRowReference).when(mockRowSnapshot).reference(); doReturn(ContentProviderOperation.newUpdate(Uri.EMPTY)).when(mockRowReference).putOperationBuilder(any(TransactionContext.class)); assertThat(new Put<>(mockRowSnapshot, new CharSequenceRowData<>("x", "y")), builds( updateOperation(), withYieldNotAllowed(), withoutExpectedCount(), withValuesOnly( containing("x", "y")))); }
Example 14
Project: Phoenix-for-VK File: DatabaseStore.java View source code | 6 votes |
@Override public Completable storeCountries(int accountId, List<CountryEntity> dbos) { return Completable.create(emitter -> { Uri uri = MessengerContentProvider.getCountriesContentUriFor(accountId); ArrayList<ContentProviderOperation> operations = new ArrayList<>(dbos.size() + 1); operations.add(ContentProviderOperation.newUpdate(uri).build()); for (CountryEntity dbo : dbos) { ContentValues cv = new ContentValues(); cv.put(CountriesColumns._ID, dbo.getId()); cv.put(CountriesColumns.NAME, dbo.getTitle()); operations.add(ContentProviderOperation.newInsert(uri) .withValues(cv) .build()); } getContentResolver().applyBatch(MessengerContentProvider.AUTHORITY, operations); emitter.onComplete(); }); }
Example 15
Project: ContentPal File: AggregationException.java View source code | 6 votes |
@NonNull @Override public ContentProviderOperation.Builder contentOperationBuilder(@NonNull TransactionContext transactionContext) throws UnsupportedOperationException { // updating Aggregation exceptions works a bit strange. Instead of selecting a specific entry, we have to refer to them in the values. return mRawContact2.builderWithReferenceData( transactionContext, mRawContact1.builderWithReferenceData( transactionContext, AggregationExceptions.INSTANCE.updateOperation( EmptyUriParams.INSTANCE, new AnyOf() ).contentOperationBuilder(transactionContext), ContactsContract.AggregationExceptions.RAW_CONTACT_ID1), ContactsContract.AggregationExceptions.RAW_CONTACT_ID2); }
Example 16
Project: ContentPal File: SingleEventData.java View source code | 6 votes |
@NonNull @Override public ContentProviderOperation.Builder updatedBuilder(TransactionContext transactionContext, @NonNull ContentProviderOperation.Builder builder) { return builder.withValue(CalendarContract.Events.DTSTART, mStart.getTimestamp()) .withValue(CalendarContract.Events.EVENT_TIMEZONE, mStart.isAllDay() ? "UTC" : mStart.getTimeZone().getID()) .withValue(CalendarContract.Events.ALL_DAY, mStart.isAllDay() ? 1 : 0) .withValue(CalendarContract.Events.DTEND, mEnd.getTimestamp()) .withValue(CalendarContract.Events.EVENT_END_TIMEZONE, mEnd.isAllDay() ? "UTC" : mEnd.getTimeZone().getID()) .withValue(CalendarContract.Events.TITLE, mTitle.toString()) // explicitly (re-)set all recurring event values to null .withValue(CalendarContract.Events.RRULE, null) .withValue(CalendarContract.Events.RDATE, null) .withValue(CalendarContract.Events.EXDATE, null) .withValue(CalendarContract.Events.DURATION, null); }
Example 17
Project: Phoenix-for-VK File: RelativeshipStore.java View source code | 6 votes |
private Completable completableStoreForType(int accountId, List<UserEntity> userEntities, int objectId, int relationType, boolean clear) { return Completable.create(emitter -> { Uri uri = MessengerContentProvider.getRelativeshipContentUriFor(accountId); ArrayList<ContentProviderOperation> operations = new ArrayList<>(); if (clear) { operations.add(clearOperationFor(accountId, objectId, relationType)); } appendInsertHeaders(uri, operations, objectId, userEntities, relationType); OwnersRepositiry.appendUsersInsertOperation(operations, accountId, userEntities); getContentResolver().applyBatch(MessengerContentProvider.AUTHORITY, operations); emitter.onComplete(); }); }
Example 18
Project: iosched-reader File: SessionsHandler.java View source code | 6 votes |
private void buildSessionSpeakerMapping(Session session, ArrayList<ContentProviderOperation> list) { final Uri uri = ScheduleContractHelper.setUriAsCalledFromSyncAdapter( ScheduleContract.Sessions.buildSpeakersDirUri(session.id)); // delete any existing relationship between this session and speakers list.add(ContentProviderOperation.newDelete(uri).build()); // add relationship records to indicate the speakers for this session if (session.speakers != null) { for (String speakerId : session.speakers) { list.add(ContentProviderOperation.newInsert(uri) .withValue(ScheduleDatabase.SessionsSpeakers.SESSION_ID, session.id) .withValue(ScheduleDatabase.SessionsSpeakers.SPEAKER_ID, speakerId) .build()); } } }
Example 19
Project: ContentPal File: RecurringEventData.java View source code | 6 votes |
@NonNull @Override public ContentProviderOperation.Builder updatedBuilder(TransactionContext transactionContext, @NonNull ContentProviderOperation.Builder builder) { return builder.withValue(CalendarContract.Events.DTSTART, mStart.getTimestamp()) .withValue(CalendarContract.Events.EVENT_TIMEZONE, mStart.isAllDay() ? "UTC" : mStart.getTimeZone().getID()) .withValue(CalendarContract.Events.ALL_DAY, mStart.isAllDay() ? 1 : 0) .withValue(CalendarContract.Events.DURATION, mDuration.toString()) .withValue(CalendarContract.Events.TITLE, mTitle.toString()) .withValue(CalendarContract.Events.RRULE, TextUtils.join("\n", mRules)) .withValue(CalendarContract.Events.RDATE, TextUtils.join(",", new Mapped<>(mRDates, mUtcDate))) .withValue(CalendarContract.Events.EXDATE, TextUtils.join(",", new Mapped<>(mExDates, mUtcDate))) // explicitly (re-)set DTEND to null .withValue(CalendarContract.Events.DTEND, null) .withValue(CalendarContract.Events.EVENT_END_TIMEZONE, null); }
Example 20
Project: ContentPal File: PutTest.java View source code | 6 votes |
@Test public void testContentOperationBuilder() throws Exception { RowSnapshot<Object> mockRowSnapshot = failingMock(RowSnapshot.class); SoftRowReference<Object> mockRowReference = failingMock(SoftRowReference.class); doReturn(mockRowReference).when(mockRowSnapshot).reference(); doReturn(ContentProviderOperation.newUpdate(Uri.EMPTY)).when(mockRowReference).putOperationBuilder(any(TransactionContext.class)); assertThat(new Put<>(mockRowSnapshot), builds( updateOperation(), withYieldNotAllowed(), withoutExpectedCount(), withoutValues() ) ); }
Example 21
Project: orgzly-android File: Provider.java View source code | 6 votes |
@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; }
Example 22
Project: orgzly-android File: ReposClient.java View source code | 6 votes |
/** * 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; }
Example 23
Project: orgzly-android File: CurrentRooksClient.java View source code | 6 votes |
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(); } }
Example 24
Project: EasyAppleSyncAdapter File: LocalEvent.java View source code | 6 votes |
@Override protected void buildEvent(Event recurrence, ContentProviderOperation.Builder builder) { super.buildEvent(recurrence, builder); boolean buildException = recurrence != null; Event eventToBuild = buildException ? recurrence : event; builder.withValue(COLUMN_UID, event.uid) .withValue(COLUMN_SEQUENCE, eventToBuild.sequence) .withValue(CalendarContract.Events.DIRTY, 0) .withValue(CalendarContract.Events.DELETED, 0); if (buildException) { builder.withValue(CalendarContract.Events.ORIGINAL_SYNC_ID, fileName); } else { builder.withValue(CalendarContract.Events._SYNC_ID, fileName) .withValue(COLUMN_ETAG, eTag); } }
Example 25
Project: VirtualAPK File: RemoteContentProvider.java View source code | 6 votes |
@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]; }
Example 26
Project: iosched-reader File: ScheduleProvider.java View source code | 6 votes |
/** * 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(); } }
Example 27
Project: FlickLauncher File: LauncherModel.java View source code | 6 votes |
static void updateItemsInDatabaseHelper(Context context, final ArrayList<ContentValues> valuesList, final ArrayList<ItemInfo> items, final String callingFunction) { final ContentResolver cr = context.getContentResolver(); final StackTraceElement[] stackTrace = new Throwable().getStackTrace(); Runnable r = new Runnable() { public void run() { ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); int count = items.size(); for (int i = 0; i < count; i++) { ItemInfo item = items.get(i); final long itemId = item.id; final Uri uri = LauncherSettings.Favorites.getContentUri(itemId); ContentValues values = valuesList.get(i); ops.add(ContentProviderOperation.newUpdate(uri).withValues(values).build()); updateItemArrays(item, itemId, stackTrace); } try { cr.applyBatch(LauncherProvider.AUTHORITY, ops); } catch (Exception e) { e.printStackTrace(); } } }; runOnWorkerThread(r); }
Example 28
Project: react-native-videoplayer File: APEZProvider.java View source code | 5 votes |
@Override public ContentProviderResult[] applyBatch( ArrayList<ContentProviderOperation> operations) throws OperationApplicationException { initIfNecessary(); return super.applyBatch(operations); }
Example 29
Project: ContentPal File: TitleData.java View source code | 5 votes |
@NonNull @Override public ContentProviderOperation.Builder updatedBuilder(TransactionContext transactionContext, @NonNull ContentProviderOperation.Builder builder) { return mDelegate.updatedBuilder(transactionContext, builder) .withValue(ContactsContract.CommonDataKinds.Organization.TITLE, mTitle == null ? null : mTitle.toString()); }
Example 30
Project: Linphone4Android File: LinphoneContact.java View source code | 5 votes |
public void setOrganization(String org) { if (isAndroidContact()) { if (androidRawId != null) { String select = ContactsContract.Data.CONTACT_ID + "=? AND " + ContactsContract.Data.MIMETYPE + "='" + CommonDataKinds.Organization.CONTENT_ITEM_TYPE + "'"; String[] args = new String[]{ getAndroidId() }; if (organization != null) { changesToCommit.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI) .withSelection(select, args) .withValue(ContactsContract.Data.MIMETYPE, CommonDataKinds.Organization.CONTENT_ITEM_TYPE) .withValue(CommonDataKinds.Organization.COMPANY, org) .build()); } else { changesToCommit.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI) .withValue(ContactsContract.Data.RAW_CONTACT_ID, androidRawId) .withValue(ContactsContract.Data.MIMETYPE, CommonDataKinds.Organization.CONTENT_ITEM_TYPE) .withValue(CommonDataKinds.Organization.COMPANY, org) .build()); } } else { changesToCommit.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI) .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0) .withValue(ContactsContract.Data.MIMETYPE, CommonDataKinds.Organization.CONTENT_ITEM_TYPE) .withValue(CommonDataKinds.Organization.COMPANY, org) .build()); } } organization = org; }
Example 31
Project: Linphone4Android File: LinphoneContact.java View source code | 5 votes |
private void createLinphoneContactTag() { ArrayList<ContentProviderOperation> batch = new ArrayList<ContentProviderOperation>(); batch.add(ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI) .withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, ContactsManager.getInstance().getString(R.string.sync_account_type)) .withValue(ContactsContract.RawContacts.ACCOUNT_NAME, ContactsManager.getInstance().getString(R.string.sync_account_name)) .withValue(ContactsContract.RawContacts.AGGREGATION_MODE, ContactsContract.RawContacts.AGGREGATION_MODE_DEFAULT) .build()); batch.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI) .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0) .withValue(ContactsContract.Data.MIMETYPE, CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE) .withValue(CommonDataKinds.StructuredName.DISPLAY_NAME, getFullName()) .build()); batch.add(ContentProviderOperation.newUpdate(ContactsContract.AggregationExceptions.CONTENT_URI) .withValue(ContactsContract.AggregationExceptions.TYPE, ContactsContract.AggregationExceptions.TYPE_KEEP_TOGETHER) .withValue(ContactsContract.AggregationExceptions.RAW_CONTACT_ID1, androidRawId) .withValueBackReference(ContactsContract.AggregationExceptions.RAW_CONTACT_ID2, 0) .build()); if (changesToCommit2.size() > 0) { for(ContentProviderOperation cpo : changesToCommit2) { batch.add(cpo); } } try { ContactsManager.getInstance().getContentResolver().applyBatch(ContactsContract.AUTHORITY, batch); androidTagId = findLinphoneRawContactId(); } catch (Exception e) { Log.e(e); } }
Example 32
Project: LaunchEnr File: GridSizeMigrationTask.java View source code | 5 votes |
/** * Updates an item in the DB. */ protected void update(DbEntry item) { mTempValues.clear(); item.addToContentValues(mTempValues); mUpdateOperations.add(ContentProviderOperation .newUpdate(LauncherSettings.Favorites.getContentUri(item.id)) .withValues(mTempValues).build()); }
Example 33
Project: LaunchEnr File: ImportDataTask.java View source code | 5 votes |
private boolean importWorkspace() throws Exception { ArrayList<Long> allScreens = LauncherDbUtils.getScreenIdsFromCursor( mContext.getContentResolver().query(mOtherScreensUri, null, null, null, LauncherSettings.WorkspaceScreens.SCREEN_RANK)); // During import we reset the screen IDs to 0-indexed values. if (allScreens.isEmpty()) { // No thing to migrate return false; } mHotseatSize = mMaxGridSizeX = mMaxGridSizeY = 0; // Build screen update ArrayList<ContentProviderOperation> screenOps = new ArrayList<>(); int count = allScreens.size(); LongSparseArray<Long> screenIdMap = new LongSparseArray<>(count); for (int i = 0; i < count; i++) { ContentValues v = new ContentValues(); v.put(LauncherSettings.WorkspaceScreens._ID, i); v.put(LauncherSettings.WorkspaceScreens.SCREEN_RANK, i); screenIdMap.put(allScreens.get(i), (long) i); screenOps.add(ContentProviderOperation.newInsert( LauncherSettings.WorkspaceScreens.CONTENT_URI).withValues(v).build()); } mContext.getContentResolver().applyBatch(ProviderConfig.AUTHORITY, screenOps); importWorkspaceItems(allScreens.get(0), screenIdMap); GridSizeMigrationTask.markForMigration(mContext, mMaxGridSizeX, mMaxGridSizeY, mHotseatSize); // Create empty DB flag. LauncherSettings.Settings.call(mContext.getContentResolver(), LauncherSettings.Settings.METHOD_CLEAR_EMPTY_DB_FLAG); return true; }
Example 34
Project: LaunchEnr File: ImportDataTask.java View source code | 5 votes |
HotseatParserCallback( HashSet<String> existingApps, LongArrayMap<Object> existingItems, ArrayList<ContentProviderOperation> outOps, int startItemId, int requiredSize) { mExisitingApps = existingApps; mExistingItems = existingItems; mOutOps = outOps; mRequiredSize = requiredSize; mStartItemId = startItemId; }
Example 35
Project: SimpleUILauncher File: ImportDataTask.java View source code | 5 votes |
HotseatParserCallback( HashSet<String> existingApps, LongArrayMap<Object> existingItems, ArrayList<ContentProviderOperation> outOps, int startItemId, int requiredSize) { mExisitingApps = existingApps; mExistingItems = existingItems; mOutOps = outOps; mRequiredSize = requiredSize; mStartItemId = startItemId; }
Example 36
Project: ContentPal File: Prefixed.java View source code | 5 votes |
@NonNull @Override public ContentProviderOperation.Builder updatedBuilder(TransactionContext transactionContext, @NonNull ContentProviderOperation.Builder builder) { return mDelegate.updatedBuilder(transactionContext, builder) .withValue(ContactsContract.CommonDataKinds.StructuredName.PREFIX, mPrefix == null ? null : mPrefix.toString()); }
Example 37
Project: ContentPal File: RegionData.java View source code | 5 votes |
@NonNull @Override public ContentProviderOperation.Builder updatedBuilder(TransactionContext transactionContext, @NonNull ContentProviderOperation.Builder builder) { return mDelegate.updatedBuilder(transactionContext, builder) .withValue(ContactsContract.CommonDataKinds.StructuredPostal.REGION, mRegion == null ? null : mRegion.toString()); }
Example 38
Project: ContentPal File: SipAddressData.java View source code | 5 votes |
@NonNull @Override public ContentProviderOperation.Builder updatedBuilder(TransactionContext transactionContext, @NonNull ContentProviderOperation.Builder builder) { return builder .withValue(ContactsContract.CommonDataKinds.SipAddress.MIMETYPE, ContactsContract.CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE) .withValue(ContactsContract.CommonDataKinds.SipAddress.SIP_ADDRESS, mSipAddress.toString()); }
Example 39
Project: ContentPal File: MultiInsertBatchTest.java View source code | 5 votes |
@Test public void testSingleComposite() { InsertOperation<Object> mockOp = mock(InsertOperation.class); when(mockOp.contentOperationBuilder(any(TransactionContext.class))).then(new Answer<ContentProviderOperation.Builder>() { @Override public ContentProviderOperation.Builder answer(InvocationOnMock invocation) throws Throwable { return ContentProviderOperation.newInsert(Uri.EMPTY); } }); assertThat(new MultiInsertBatch<>(mockOp, new Composite<>( new CharSequenceRowData<>("key", "value"), new CharSequenceRowData<>("key2", "value2"), new CharSequenceRowData<>("key3", "value3"))), Matchers.contains( builds( insertOperation(), withValuesOnly( containing("key", "value"), containing("key2", "value2"), containing("key3", "value3")), withoutExpectedCount(), withYieldNotAllowed()))); }
Example 40
Project: Phoenix-for-VK File: LongPollOperation.java View source code | 5 votes |
/** * Получение списка операций для сохранения уведомлений о том, * что для сообщений были ОТМЕНЕНЫ атрибуты * * @param updates уведомления * @return список операций */ public static ArrayList<ContentProviderOperation> forMessagesFlagReset(int accountId, @NonNull List<MessageFlagsResetUpdate> updates) { ArrayList<ContentProviderOperation> operations = new ArrayList<>(updates.size()); for (MessageFlagsResetUpdate update : updates) { ContentValues cv = new ContentValues(); if(hasFlag(update.mask, VKApiMessage.FLAG_DELETED)){ cv.put(MessageColumns.DELETED, 0); } if(hasFlag(update.mask, VKApiMessage.FLAG_IMPORTANT)){ cv.put(MessageColumns.IMPORTANT, 0); } if(hasFlag(update.mask, VKApiMessage.FLAG_UNREAD)){ cv.put(MessageColumns.READ_STATE, 1); } if(cv.size() > 0){ String where = MessageColumns._ID + " = ?"; String[] args = {String.valueOf(update.message_id)}; operations.add(ContentProviderOperation .newUpdate(MessengerContentProvider.getMessageContentUriFor(accountId)) .withSelection(where, args) .withValues(cv) .build()); } } return operations; }