Java Code Examples for android.content.ContentProviderOperation.Builder
The following are top voted examples for showing how to use
android.content.ContentProviderOperation.Builder. 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: aos-MediaLib File: NetworkScannerServiceMusic.java View source code | 6 votes |
/** shows a notification */ private void showNotification(NotificationManager nm, String path, int titleId){ String notifyPath = path; Notification n = new Notification.Builder(this) .setContentTitle(getString(titleId)) .setContentText(notifyPath) .setSmallIcon(android.R.drawable.stat_notify_sync) .setOngoing(true) .getNotification(); nm.notify(NOTIFICATION_ID, n); }
Example 2
Project: CucumberSync File: LocalAddressBook.java View source code | 6 votes |
protected Builder buildOrganization(Builder builder, Contact contact) { if (contact.getOrganization() == null && contact.getJobTitle() == null && contact.getJobDescription() == null) return null; ezvcard.property.Organization organization = contact.getOrganization(); String company = null, department = null; if (organization != null) { Iterator<String> org = organization.getValues().iterator(); if (org.hasNext()) company = org.next(); if (org.hasNext()) department = org.next(); } return builder .withValue(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE) .withValue(Organization.COMPANY, company) .withValue(Organization.DEPARTMENT, department) .withValue(Organization.TITLE, contact.getJobTitle()) .withValue(Organization.JOB_DESCRIPTION, contact.getJobDescription()); }
Example 3
Project: silent-contacts-android File: RawContactDelta.java View source code | 6 votes |
/** * Build a list of {@link ContentProviderOperation} that will assert any * "before" state hasn't changed. This is maintained separately so that all * asserts can take place before any updates occur. */ public void buildAssert(ArrayList<ContentProviderOperation> buildInto) { final boolean isContactInsert = mValues.isInsert(); if (!isContactInsert) { // Assert version is consistent while persisting changes final Long beforeId = mValues.getId(); final Long beforeVersion = mValues.getAsLong(RawContacts.VERSION); if (beforeId == null || beforeVersion == null) return; final ContentProviderOperation.Builder builder = ContentProviderOperation .newAssertQuery(mContactsQueryUri); builder.withSelection(RawContacts._ID + "=" + beforeId, null); builder.withValue(RawContacts.VERSION, beforeVersion); buildInto.add(builder.build()); } }
Example 4
Project: silent-contacts-android File: RawContactDelta.java View source code | 6 votes |
/** * Build a {@link ContentProviderOperation} that will transform our * "before" state into our "after" state, using insert, update, or * delete as needed. */ public ContentProviderOperation.Builder buildDiff(Uri targetUri) { Builder builder = null; if (isInsert()) { // Changed values are "insert" back-referenced to Contact mAfter.remove(mIdColumn); builder = ContentProviderOperation.newInsert(targetUri); builder.withValues(mAfter); } else if (isDelete()) { // When marked for deletion and "before" exists, then "delete" builder = ContentProviderOperation.newDelete(targetUri); builder.withSelection(mIdColumn + "=" + getId(), null); } else if (isUpdate()) { // When has changes and "before" exists, then "update" builder = ContentProviderOperation.newUpdate(targetUri); builder.withSelection(mIdColumn + "=" + getId(), null); builder.withValues(mAfter); } return builder; }
Example 5
Project: android-db-commons File: BatcherImpl.java View source code | 6 votes |
@Override public void resolveBackRefs(ConvertibleToOperation convertible, Builder builder) { if (mValueBackRefs != null && mValueBackRefs.containsKey(convertible)) { ContentValues values = new ContentValues(); for (ValueBackRef valueBackRef : mValueBackRefs.get(convertible)) { values.put(valueBackRef.column, getParentPosition(valueBackRef.parent)); } builder.withValueBackReferences(values); } if (mSelectionBackRefs != null) { for (SelectionBackRef selectionBackRef : mSelectionBackRefs.get(convertible)) { builder.withSelectionBackReference( selectionBackRef.selectionArgumentIndex, getParentPosition(selectionBackRef.parent) ); } } mParentsPosition.put(convertible, mParentsPosition.size()); }
Example 6
Project: scrumchatter File: DBImport.java View source code | 6 votes |
private static void buildInsertOperations(SQLiteDatabase dbImport, Uri uri, String table, ArrayList<ContentProviderOperation> operations) { Log.v(TAG, "buildInsertOperations: uri = " + uri + ", table=" + table); Cursor c = dbImport.query(false, table, null, null, null, null, null, null, null); if (c != null) { try { if (c.moveToFirst()) { int columnCount = c.getColumnCount(); do { Builder builder = ContentProviderOperation.newInsert(uri); for (int i = 0; i < columnCount; i++) { String columnName = c.getColumnName(i); Object value = c.getString(i); builder.withValue(columnName, value); } operations.add(builder.build()); } while (c.moveToNext()); } } finally { c.close(); } } }
Example 7
Project: aos-MediaLib File: NetworkScannerServiceVideo.java View source code | 5 votes |
public void addDelete(DeleteString deletes) { int deleteCount = deletes.getCount(); if (deleteCount > 0) { Builder delete = ContentProviderOperation.newDelete(VideoStoreInternal.FILES_SCANNED); String deleteSelection = BaseColumns._ID + " IN (" + deletes.toString() + ")"; if (DBG) Log.d(TAG, "delete WHERE " + deleteSelection); delete.withSelection(deleteSelection, null); mUpdateExecutor.add(delete.build()); mDeletes += deleteCount; } }
Example 8
Project: aos-MediaLib File: NetworkScannerServiceVideo.java View source code | 5 votes |
/** shows a notification */ private void showNotification(NotificationManager nm, String path, int titleId){ String notifyPath = path; Notification n = new Notification.Builder(this) .setContentTitle(getString(titleId)) .setContentText(notifyPath) .setSmallIcon(android.R.drawable.stat_notify_sync) .setOngoing(true) .getNotification(); nm.notify(NOTIFICATION_ID, n); }
Example 9
Project: CucumberSync File: LocalCalendar.java View source code | 5 votes |
public void deleteAllExceptRemoteIds(String[] preserveIds) { String where; if (preserveIds.length != 0) { where = entryColumnRemoteId() + " NOT IN (" + SQLUtils.quoteArray(preserveIds) + ")"; } else where = entryColumnRemoteId() + " IS NOT NULL"; Builder builder = ContentProviderOperation.newDelete(entriesURI()) .withSelection(entryColumnParentID() + "=? AND (" + where + ")", new String[]{String.valueOf(id)}); pendingOperations.add(builder .withYieldAllowed(true) .build()); }
Example 10
Project: CucumberSync File: LocalCalendar.java View source code | 5 votes |
public void deleteAllExceptUIDs(String[] preserveUids) { String where; if (preserveUids.length != 0) { where = entryColumnUID() + " NOT IN (" + SQLUtils.quoteArray(preserveUids) + ")"; } else where = entryColumnUID() + " IS NOT NULL"; Builder builder = ContentProviderOperation.newDelete(entriesURI()) .withSelection(entryColumnParentID() + "=? AND (" + where + ")", new String[]{String.valueOf(id)}); pendingOperations.add(builder .withYieldAllowed(true) .build()); }
Example 11
Project: CucumberSync File: LocalCalendar.java View source code | 5 votes |
void populateReminders(Event e) throws RemoteException { // reminders Uri remindersUri = Reminders.CONTENT_URI.buildUpon() .appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true") .build(); @Cleanup Cursor c = providerClient.query(remindersUri, new String[]{ /* 0 */ Reminders.MINUTES, Reminders.METHOD }, Reminders.EVENT_ID + "=?", new String[]{String.valueOf(e.getLocalID())}, null); while (c != null && c.moveToNext()) { //Duration duration = new Duration.Builder().prior(true).minutes(c.getInt(0)).build(); Duration duration = new Duration.Builder().minutes(c.getInt(0)).build(); Trigger trigger = new Trigger(duration, Related.START); VAlarm alarm = VAlarm.display(trigger, e.getSummary()); e.addAlarm(alarm); } }
Example 12
Project: CucumberSync File: LocalCalendar.java View source code | 5 votes |
@SuppressLint("InlinedApi") protected Builder buildAttendee(Builder builder, Attendee attendee) { String email = attendee.getEmail(); String cn = attendee.getCommonName(); if (cn != null) builder = builder.withValue(Attendees.ATTENDEE_NAME, cn); int type = Attendees.TYPE_NONE; if (attendee.getCalendarUserType() == CalendarUserType.RESOURCE) type = Attendees.TYPE_RESOURCE; else { int relationship; if (attendee.getRole() == Role.CHAIR) relationship = Attendees.RELATIONSHIP_ORGANIZER; else { relationship = Attendees.RELATIONSHIP_ATTENDEE; } builder = builder.withValue(Attendees.ATTENDEE_RELATIONSHIP, relationship); } int status = Attendees.ATTENDEE_STATUS_NONE; ParticipationStatus partStat = attendee.getParticipationStatus(); if (partStat == null || partStat == ParticipationStatus.NEEDS_ACTION) status = Attendees.ATTENDEE_STATUS_INVITED; else if (partStat == ParticipationStatus.ACCEPTED) status = Attendees.ATTENDEE_STATUS_ACCEPTED; else if (partStat == ParticipationStatus.DECLINED) status = Attendees.ATTENDEE_STATUS_DECLINED; else if (partStat == ParticipationStatus.TENTATIVE) status = Attendees.ATTENDEE_STATUS_TENTATIVE; return builder .withValue(Attendees.ATTENDEE_EMAIL, email) .withValue(Attendees.ATTENDEE_TYPE, type) .withValue(Attendees.ATTENDEE_STATUS, status); }
Example 13
Project: CucumberSync File: LocalCalendar.java View source code | 5 votes |
protected Builder buildReminder(Builder builder, VAlarm alarm) { int minutes = 0; if (alarm.getTrigger() != null && alarm.getTrigger().getDuration() != null) //minutes = duration.getDays() * 24*60 + duration.getHours()*60 + duration.getMinutes(); minutes = (int)(alarm.getTrigger().getDuration().toMillis()/60000); Log.d(TAG, "Adding alarm " + minutes + " min before"); return builder .withValue(Reminders.METHOD, Reminders.METHOD_ALERT) .withValue(Reminders.MINUTES, minutes); }
Example 14
Project: CucumberSync File: LocalCollection.java View source code | 5 votes |
protected Builder newDataInsertBuilder(Uri dataUri, String refFieldName, long raw_ref_id, Integer backrefIdx) { Builder builder = ContentProviderOperation.newInsert(syncAdapterURI(dataUri)); if (backrefIdx != -1) return builder.withValueBackReference(refFieldName, backrefIdx); else return builder.withValue(refFieldName, raw_ref_id); }
Example 15
Project: CucumberSync File: LocalAddressBook.java View source code | 5 votes |
public void deleteAllExceptRemoteIds(String[] preserveIds) { String where; if (preserveIds.length != 0) { where = entryColumnRemoteId() + " NOT IN (" + SQLUtils.quoteArray(preserveIds) + ")"; } else where = entryColumnRemoteId() + " IS NOT NULL"; Builder builder = ContentProviderOperation.newDelete(entriesURI()).withSelection(where, null); pendingOperations.add(builder .withYieldAllowed(true) .build()); }
Example 16
Project: CucumberSync File: LocalAddressBook.java View source code | 5 votes |
public void deleteAllExceptUIDs(String[] preserveUids) { String where; if (preserveUids.length != 0) { where = entryColumnUID() + " NOT IN (" + SQLUtils.quoteArray(preserveUids) + ")"; } else where = entryColumnUID() + " IS NOT NULL"; Builder builder = ContentProviderOperation.newDelete(entriesURI()).withSelection(where, null); pendingOperations.add(builder .withYieldAllowed(true) .build()); }
Example 17
Project: CucumberSync File: LocalAddressBook.java View source code | 5 votes |
@Override protected Builder buildEntry(Builder builder, Resource resource) { Contact contact = (Contact)resource; return builder .withValue(RawContacts.ACCOUNT_NAME, account.name) .withValue(RawContacts.ACCOUNT_TYPE, account.type) .withValue(entryColumnRemoteId(), contact.getId()) .withValue(entryColumnUID(), contact.getUid()) .withValue(entryColumnETag(), contact.getETag()) .withValue(COLUMN_UNKNOWN_PROPERTIES, contact.getUnknownProperties()) .withValue(RawContacts.STARRED, contact.isStarred()); }
Example 18
Project: CucumberSync File: LocalAddressBook.java View source code | 5 votes |
protected Builder buildStructuredName(Builder builder, Contact contact) { return builder .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) .withValue(StructuredName.PREFIX, contact.getPrefix()) .withValue(StructuredName.DISPLAY_NAME, contact.getDisplayName()) .withValue(StructuredName.GIVEN_NAME, contact.getGivenName()) .withValue(StructuredName.MIDDLE_NAME, contact.getMiddleName()) .withValue(StructuredName.FAMILY_NAME, contact.getFamilyName()) .withValue(StructuredName.SUFFIX, contact.getSuffix()) .withValue(StructuredName.PHONETIC_GIVEN_NAME, contact.getPhoneticGivenName()) .withValue(StructuredName.PHONETIC_MIDDLE_NAME, contact.getPhoneticMiddleName()) .withValue(StructuredName.PHONETIC_FAMILY_NAME, contact.getPhoneticFamilyName()); }
Example 19
Project: CucumberSync File: LocalAddressBook.java View source code | 5 votes |
protected Builder buildEmail(Builder builder, ezvcard.property.Email email) { int typeCode = 0; String typeLabel = null; boolean is_primary = false; for (EmailType type : email.getTypes()) if (type == EmailType.PREF) is_primary = true; else if (type == EmailType.HOME) typeCode = Email.TYPE_HOME; else if (type == EmailType.WORK) typeCode = Email.TYPE_WORK; else if (type == Contact.EMAIL_TYPE_MOBILE) typeCode = Email.TYPE_MOBILE; if (typeCode == 0) { if (email.getTypes().isEmpty()) typeCode = Email.TYPE_OTHER; else { typeCode = Email.TYPE_CUSTOM; typeLabel = xNameToLabel(email.getTypes().iterator().next().getValue()); } } builder = builder .withValue(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE) .withValue(Email.ADDRESS, email.getValue()) .withValue(Email.TYPE, typeCode) .withValue(Email.IS_PRIMARY, is_primary ? 1 : 0) .withValue(Phone.IS_SUPER_PRIMARY, is_primary ? 1 : 0);; if (typeLabel != null) builder = builder.withValue(Email.LABEL, typeLabel); return builder; }
Example 20
Project: CucumberSync File: LocalAddressBook.java View source code | 5 votes |
protected Builder buildEvent(Builder builder, DateOrTimeProperty date, int type) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", Locale.US); if (date.getDate() == null) { Log.i(TAG, "Ignoring contact event without date"); return null; } return builder .withValue(Data.MIMETYPE, CommonDataKinds.Event.CONTENT_ITEM_TYPE) .withValue(CommonDataKinds.Event.TYPE, type) .withValue(CommonDataKinds.Event.START_DATE, formatter.format(date.getDate())); }
Example 21
Project: MindBody File: SessionType.java View source code | 5 votes |
public Builder addValues(Builder builder) { builder.withValue(Columns.SESSION_TYPE_ID.getName(), mID) .withValue(Columns.SESSION_TYPE_DEFAULT_TIME.getName(), mDefaultTimeLength) .withValue(Columns.SESSION_TYPE_PROGRAM_ID.getName(), mProgramID) .withValue(Columns.SESSION_TYPE_NAME.getName(), mName); return builder; }
Example 22
Project: MindBody File: Location.java View source code | 5 votes |
public Builder addValues(Builder builder) { builder.withValue(Columns.LOCATION_TAX1.getName(), mTax1) .withValue(Columns.LOCATION_TAX2.getName(), mTax2) .withValue(Columns.LOCATION_TAX3.getName(), mTax3) .withValue(Columns.LOCATION_TAX4.getName(), mTax4) .withValue(Columns.LOCATION_TAX5.getName(), mTax5) .withValue(Columns.LOCATION_TREAT_ROOM.getName(), mTreatmentRoom) .withValue(Columns.LOCATION_HAS_CLASSES.getName(), mHasClass ? 1:0) .withValue(Columns.LOCATION_LONGITUDE.getName(), mLongitude) .withValue(Columns.LOCATION_LATITUDE.getName(), mLatitude) .withValue(Columns.LOCATION_SITE_ID.getName(), mSiteID) .withValue(Columns.LOCATION_SQFT.getName(), mFacilitySquareFeet) .withValue(Columns.LOCATION_NAME.getName(), mName); return builder; }
Example 23
Project: ContactMerger File: ContactDataMapper.java View source code | 5 votes |
/** * Append all operations needed to store the current contact to a set of * operations. * @param contact The current contact with metadata. * @param operations A set of operations to be extended. */ public void persist(RawContact contact, ArrayList<ContentProviderOperation> operations) { int operationsStart = operations.size(); Builder operation; if (contact.getID() == -1) { operation = ContentProviderOperation.newInsert(RawContacts.CONTENT_URI); } else { operation = ContentProviderOperation.newUpdate(RawContacts.CONTENT_URI); operation.withSelection(RawContacts._ID + "=?", new String[]{Long.toString(contact.getID())}); } ContentValues values = new ContentValues(); put(values, contact); operation.withValues(values); operations.add(operation.build()); for (Metadata data: contact.getMetadata().values()) { values.clear(); put(values, data); if (data instanceof DeletedMetadata) { operation = ContentProviderOperation.newDelete(Data.CONTENT_URI); operation.withValues(values); operation.withSelection(Data._ID + "=?", new String[]{Long.toString(contact.getID())}); operations.add(operation.build()); continue; } if (data.getID() == -1) { operation = ContentProviderOperation.newInsert(Data.CONTENT_URI); } else { operation = ContentProviderOperation.newUpdate(Data.CONTENT_URI); operation.withSelection(Data._ID + "=?", new String[]{Long.toString(data.getID())}); } if (contact.getID() == -1) { operation.withValueBackReference(Data.RAW_CONTACT_ID, operationsStart); values.remove(Data.RAW_CONTACT_ID); } else { values.put(Data.RAW_CONTACT_ID, contact.getID()); } operation.withValues(values); operations.add(operation.build()); } }
Example 24
Project: silent-contacts-android File: RawContactDelta.java View source code | 5 votes |
/** * Consider building the given {@link ContentProviderOperation.Builder} and * appending it to the given list, which only happens if builder is valid. */ private void possibleAdd(ArrayList<ContentProviderOperation> diff, ContentProviderOperation.Builder builder) { if (builder != null) { diff.add(builder.build()); } }
Example 25
Project: android-db-commons File: BatcherImpl.java View source code | 5 votes |
@Override public ArrayList<ContentProviderOperation> operations() { ArrayList<ContentProviderOperation> providerOperations = Lists.newArrayListWithCapacity(operations.size()); BackRefResolver backRefResolver = getBackRefResolver(); for (ConvertibleToOperation convertible : operations) { final Builder builder = convertible.toContentProviderOperationBuilder(mUriDecorator); backRefResolver.resolveBackRefs(convertible, builder); providerOperations.add(builder.build()); } return providerOperations; }
Example 26
Project: bikey File: DatabaseImporter.java View source code | 5 votes |
/** * In a single database transaction, delete all the cells from the current database, read the data from the given importDb file, create a batch of * corresponding insert operations, and execute the inserts. */ private static void importDatabase(Context context, File importDb) throws RemoteException, OperationApplicationException { Log.d("importDb=" + importDb); SQLiteDatabase dbImport = SQLiteDatabase.openDatabase(importDb.getAbsolutePath(), null, SQLiteDatabase.OPEN_READONLY); ArrayList<ContentProviderOperation> operations = new ArrayList<>(); operations.add(ContentProviderOperation.newDelete(LogColumns.CONTENT_URI).build()); operations.add(ContentProviderOperation.newDelete(RideColumns.CONTENT_URI).build()); Uri insertUri = new Uri.Builder().authority(BikeyProvider.AUTHORITY).appendPath(RideColumns.TABLE_NAME) .appendQueryParameter(BikeyProvider.QUERY_NOTIFY, "false").build(); buildInsertOperations(context, dbImport, insertUri, RideColumns.TABLE_NAME, operations); insertUri = new Uri.Builder().authority(BikeyProvider.AUTHORITY).appendPath(LogColumns.TABLE_NAME) .appendQueryParameter(BikeyProvider.QUERY_NOTIFY, "false").build(); buildInsertOperations(context, dbImport, insertUri, LogColumns.TABLE_NAME, operations); dbImport.close(); }
Example 27
Project: mobile-client File: NewsHandler.java View source code | 5 votes |
/** * Parse a given {@link News} entry, building * {@link ContentProviderOperation} to define it locally. */ private static void parseMessage(JsonParser parser, ArrayList<ContentProviderOperation> batch, ContentResolver resolver) throws JsonParseException, IOException { Builder builder = ContentProviderOperation.newInsert(News.CONTENT_URI); builder.withValue(News.NEWS_NEW, 1); String fieldName = null; JsonToken token; while ((token = parser.nextToken()) != END_OBJECT) { if (token == FIELD_NAME) { fieldName = parser.getCurrentName(); } else if (token == VALUE_STRING) { final String text = parser.getText(); if (Fields.DATE.equals(fieldName)) { final String id = News.generateNewsId(text); builder.withValue(News.NEWS_ID, id); builder.withValue(News.NEWS_DATE, text); } else if (Fields.MESSAGE.equals(fieldName)) { builder.withValue(News.NEWS_TEXT, text); } } } batch.add(builder.build()); }
Example 28
Project: aos-MediaLib File: NetworkScannerServiceVideo.java View source code | 4 votes |
public void addUpdate(FileScanInfo update, long fileId) { Builder builder = ContentProviderOperation.newUpdate(VideoStoreInternal.FILES_SCANNED); builder.withValues(update.toContentValues()); builder.withSelection(SELECT_ID, new String[]{ String.valueOf(fileId) }); mUpdateExecutor.add(builder.build()); }
Example 29
Project: aos-MediaLib File: EpisodeTags.java View source code | 4 votes |
public void addSaveOperation(ArrayList<ContentProviderOperation> list, Map<String, Long> poster2IdMap) { if (list == null) return; // create ContentValues for this episode ContentValues values = new ContentValues(); values.put(ScraperStore.Episode.VIDEO_ID, Long.valueOf(mVideoId)); values.put(ScraperStore.Episode.NAME, mTitle); if(mAired != null) { values.put(ScraperStore.Episode.AIRED, Long.valueOf(mAired.getTime())); } values.put(ScraperStore.Episode.RATING, Float.valueOf(mRating)); values.put(ScraperStore.Episode.PLOT, mPlot); values.put(ScraperStore.Episode.SEASON, Integer.valueOf(mSeason)); values.put(ScraperStore.Episode.NUMBER, Integer.valueOf(mEpisode)); values.put(ScraperStore.Episode.SHOW, Long.valueOf(mShowId)); values.put(ScraperStore.Episode.IMDB_ID, mImdbId); values.put(ScraperStore.Episode.ONLINE_ID, Long.valueOf(mOnlineId)); values.put(ScraperStore.Episode.ACTORS_FORMATTED, getActorsFormatted()); values.put(ScraperStore.Episode.DIRECTORS_FORMATTED, getDirectorsFormatted()); ScraperImage pic = getEpisodePicture(); if(pic!=null && pic.getLargeFile()!=null) values.put(ScraperStore.Episode.PICTURE, pic.getLargeFile()); File cover = getCover(); String coverPath = (cover != null) ? cover.getPath() : null; if (coverPath != null && !coverPath.isEmpty()) values.put(ScraperStore.Episode.COVER, coverPath); // need to find the poster id in the database ScraperImage poster = getDefaultPoster(); if (poster != null) { Long posterId = poster2IdMap.get(poster.getLargeFile()); values.put(ScraperStore.Episode.POSTER_ID, posterId); } // build list of operations Builder cop = null; int firstIndex = list.size(); // first insert the episode base info - item 0 for backreferences cop = ContentProviderOperation.newInsert(ScraperStore.Episode.URI.BASE); cop.withValues(values); list.add(cop.build()); // then directors etc for(String director: mDirectors) { cop = ContentProviderOperation.newInsert(ScraperStore.Director.URI.EPISODE); cop.withValue(ScraperStore.Episode.Director.NAME, director); cop.withValueBackReference(ScraperStore.Episode.Director.EPISODE, firstIndex); list.add(cop.build()); } for(String actorName: mActors.keySet()) { cop = ContentProviderOperation.newInsert(ScraperStore.Actor.URI.EPISODE); cop.withValue(ScraperStore.Episode.Actor.NAME, actorName); cop.withValueBackReference(ScraperStore.Episode.Actor.EPISODE, firstIndex); cop.withValue(ScraperStore.Episode.Actor.ROLE, mActors.get(actorName)); list.add(cop.build()); } }
Example 30
Project: CucumberSync File: LocalCalendar.java View source code | 4 votes |
protected Recurrence parseRecurrence(String property, TimeZone tz) throws ParseException { RRule tmpRecRule = new RRule(property); Recurrence.Frequency freq = null; switch(tmpRecRule.getFreq()) { case DAILY: freq = Recurrence.Frequency.DAILY; break; case HOURLY: freq = Recurrence.Frequency.HOURLY; break; case MINUTELY: freq = Recurrence.Frequency.MINUTELY; break; case MONTHLY: freq = Recurrence.Frequency.MONTHLY; break; case SECONDLY: freq = Recurrence.Frequency.SECONDLY; break; case WEEKLY: freq = Recurrence.Frequency.WEEKLY; break; case YEARLY: freq = Recurrence.Frequency.YEARLY; break; default: //Fail quietly } List<Recurrence.DayOfWeek> dows = new ArrayList<Recurrence.DayOfWeek>(); for (WeekdayNum wday: tmpRecRule.getByDay()) { switch(wday.wday) { case MO: dows.add(Recurrence.DayOfWeek.MONDAY); break; case TU: dows.add(Recurrence.DayOfWeek.TUESDAY); break; case WE: dows.add(Recurrence.DayOfWeek.WEDNESDAY); break; case TH: dows.add(Recurrence.DayOfWeek.THURSDAY); break; case FR: dows.add(Recurrence.DayOfWeek.FRIDAY); break; case SA: dows.add(Recurrence.DayOfWeek.SATURDAY); break; case SU: dows.add(Recurrence.DayOfWeek.SUNDAY); break; default: //Fail quietly } } Recurrence tmpRec = new Recurrence.Builder(freq) .interval(tmpRecRule.getInterval()) .count(tmpRecRule.getCount()) .until(dateValueToDate(tmpRecRule.getUntil())) .byDay(dows) .byHour(new ArrayList<Integer>(Arrays.asList(ArrayUtils.toObject(tmpRecRule.getByHour())))) .byMinute(new ArrayList<Integer>(Arrays.asList(ArrayUtils.toObject(tmpRecRule.getByMinute())))) .byMonth(new ArrayList<Integer>(Arrays.asList(ArrayUtils.toObject(tmpRecRule.getByMonth())))) .byMonthDay(new ArrayList<Integer>(Arrays.asList(ArrayUtils.toObject(tmpRecRule.getByMonthDay())))) .bySecond(new ArrayList<Integer>(Arrays.asList(ArrayUtils.toObject(tmpRecRule.getBySecond())))) .byWeekNo(new ArrayList<Integer>(Arrays.asList(ArrayUtils.toObject(tmpRecRule.getByWeekNo())))) .byYearDay(new ArrayList<Integer>(Arrays.asList(ArrayUtils.toObject(tmpRecRule.getByYearDay())))) .build(); return tmpRec; }
Example 31
Project: CucumberSync File: LocalCollection.java View source code | 4 votes |
protected void queueOperation(Builder builder) { if (builder != null) pendingOperations.add(builder.build()); }
Example 32
Project: CucumberSync File: LocalAddressBook.java View source code | 4 votes |
protected Builder buildPhoneNumber(Builder builder, Telephone number) { int typeCode = Phone.TYPE_OTHER; String typeLabel = null; boolean is_primary = false; Set<TelephoneType> types = number.getTypes(); // preferred number? if (types.contains(TelephoneType.PREF)) is_primary = true; // 1 Android type <-> 2 VCard types: fax, cell, pager if (types.contains(TelephoneType.FAX)) { if (types.contains(TelephoneType.HOME)) typeCode = Phone.TYPE_FAX_HOME; else if (types.contains(TelephoneType.WORK)) typeCode = Phone.TYPE_FAX_WORK; else typeCode = Phone.TYPE_OTHER_FAX; } else if (types.contains(TelephoneType.CELL)) { if (types.contains(TelephoneType.WORK)) typeCode = Phone.TYPE_WORK_MOBILE; else typeCode = Phone.TYPE_MOBILE; } else if (types.contains(TelephoneType.PAGER)) { if (types.contains(TelephoneType.WORK)) typeCode = Phone.TYPE_WORK_PAGER; else typeCode = Phone.TYPE_PAGER; // types with 1:1 translation } else if (types.contains(TelephoneType.HOME)) { typeCode = Phone.TYPE_HOME; } else if (types.contains(TelephoneType.WORK)) { typeCode = Phone.TYPE_WORK; } else if (types.contains(Contact.PHONE_TYPE_CALLBACK)) { typeCode = Phone.TYPE_CALLBACK; } else if (types.contains(TelephoneType.CAR)) { typeCode = Phone.TYPE_CAR; } else if (types.contains(Contact.PHONE_TYPE_COMPANY_MAIN)) { typeCode = Phone.TYPE_COMPANY_MAIN; } else if (types.contains(TelephoneType.ISDN)) { typeCode = Phone.TYPE_ISDN; } else if (types.contains(TelephoneType.PREF)) { typeCode = Phone.TYPE_MAIN; } else if (types.contains(Contact.PHONE_TYPE_RADIO)) { typeCode = Phone.TYPE_RADIO; } else if (types.contains(TelephoneType.TEXTPHONE)) { typeCode = Phone.TYPE_TELEX; } else if (types.contains(TelephoneType.TEXT)) { typeCode = Phone.TYPE_TTY_TDD; } else if (types.contains(Contact.PHONE_TYPE_ASSISTANT)) { typeCode = Phone.TYPE_ASSISTANT; } else if (types.contains(Contact.PHONE_TYPE_MMS)) { typeCode = Phone.TYPE_MMS; } else if (!types.isEmpty()) { TelephoneType type = types.iterator().next(); typeCode = Phone.TYPE_CUSTOM; typeLabel = xNameToLabel(type.getValue()); } builder = builder .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE) .withValue(Phone.NUMBER, number.getText()) .withValue(Phone.TYPE, typeCode) .withValue(Phone.IS_PRIMARY, is_primary ? 1 : 0) .withValue(Phone.IS_SUPER_PRIMARY, is_primary ? 1 : 0); if (typeLabel != null) builder = builder.withValue(Phone.LABEL, typeLabel); return builder; }
Example 33
Project: CucumberSync File: LocalAddressBook.java View source code | 4 votes |
protected Builder buildPhoto(Builder builder, byte[] photo) { return builder .withValue(Data.MIMETYPE, Photo.CONTENT_ITEM_TYPE) .withValue(Photo.PHOTO, photo); }
Example 34
Project: CucumberSync File: LocalAddressBook.java View source code | 4 votes |
protected Builder buildIMPP(Builder builder, Impp impp) { int typeCode = 0; String typeLabel = null; for (ImppType type : impp.getTypes()) if (type == ImppType.HOME) typeCode = Im.TYPE_HOME; else if (type == ImppType.WORK || type == ImppType.BUSINESS) typeCode = Im.TYPE_WORK; if (typeCode == 0) if (impp.getTypes().isEmpty()) typeCode = Im.TYPE_OTHER; else { typeCode = Im.TYPE_CUSTOM; typeLabel = xNameToLabel(impp.getTypes().iterator().next().getValue()); } int protocolCode = 0; String protocolLabel = null; String protocol = impp.getProtocol(); if (protocol == null) { Log.w(TAG, "Ignoring IMPP address without protocol"); return null; } // SIP addresses are IMPP entries in the VCard but locally stored in SipAddress rather than Im boolean sipAddress = false; if (impp.isAim()) protocolCode = Im.PROTOCOL_AIM; else if (impp.isMsn()) protocolCode = Im.PROTOCOL_MSN; else if (impp.isYahoo()) protocolCode = Im.PROTOCOL_YAHOO; else if (impp.isSkype()) protocolCode = Im.PROTOCOL_SKYPE; else if (protocol.equalsIgnoreCase("qq")) protocolCode = Im.PROTOCOL_QQ; else if (protocol.equalsIgnoreCase("google-talk")) protocolCode = Im.PROTOCOL_GOOGLE_TALK; else if (impp.isIcq()) protocolCode = Im.PROTOCOL_ICQ; else if (impp.isXmpp() || protocol.equalsIgnoreCase("jabber")) protocolCode = Im.PROTOCOL_JABBER; else if (protocol.equalsIgnoreCase("netmeeting")) protocolCode = Im.PROTOCOL_NETMEETING; else if (protocol.equalsIgnoreCase("sip")) sipAddress = true; else { protocolCode = Im.PROTOCOL_CUSTOM; protocolLabel = protocol; } if (sipAddress) // save as SIP address builder = builder .withValue(Data.MIMETYPE, SipAddress.CONTENT_ITEM_TYPE) .withValue(Im.DATA, impp.getHandle()) .withValue(Im.TYPE, typeCode); else { // save as IM address builder = builder .withValue(Data.MIMETYPE, Im.CONTENT_ITEM_TYPE) .withValue(Im.DATA, impp.getHandle()) .withValue(Im.TYPE, typeCode) .withValue(Im.PROTOCOL, protocolCode); if (protocolLabel != null) builder = builder.withValue(Im.CUSTOM_PROTOCOL, protocolLabel); } if (typeLabel != null) builder = builder.withValue(Im.LABEL, typeLabel); return builder; }
Example 35
Project: CucumberSync File: LocalAddressBook.java View source code | 4 votes |
protected Builder buildNickName(Builder builder, String nickName) { return builder .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE) .withValue(Nickname.NAME, nickName); }
Example 36
Project: CucumberSync File: LocalAddressBook.java View source code | 4 votes |
protected Builder buildNote(Builder builder, String note) { return builder .withValue(Data.MIMETYPE, Note.CONTENT_ITEM_TYPE) .withValue(Note.NOTE, note); }
Example 37
Project: CucumberSync File: LocalAddressBook.java View source code | 4 votes |
protected Builder buildAddress(Builder builder, Address address) { /* street po.box (extended) * region * postal code city * country */ String formattedAddress = address.getLabel(); if (StringUtils.isEmpty(formattedAddress)) { String lineStreet = StringUtils.join(new String[] { address.getStreetAddress(), address.getPoBox(), address.getExtendedAddress() }, " "), lineLocality = StringUtils.join(new String[] { address.getPostalCode(), address.getLocality() }, " "); List<String> lines = new LinkedList<String>(); if (lineStreet != null) lines.add(lineStreet); if (address.getRegion() != null && !address.getRegion().isEmpty()) lines.add(address.getRegion()); if (lineLocality != null) lines.add(lineLocality); formattedAddress = StringUtils.join(lines, "\n"); } int typeCode = 0; String typeLabel = null; for (AddressType type : address.getTypes()) if (type == AddressType.HOME) typeCode = StructuredPostal.TYPE_HOME; else if (type == AddressType.WORK) typeCode = StructuredPostal.TYPE_WORK; if (typeCode == 0) if (address.getTypes().isEmpty()) typeCode = StructuredPostal.TYPE_OTHER; else { typeCode = StructuredPostal.TYPE_CUSTOM; typeLabel = xNameToLabel(address.getTypes().iterator().next().getValue()); } builder = builder .withValue(Data.MIMETYPE, StructuredPostal.CONTENT_ITEM_TYPE) .withValue(StructuredPostal.FORMATTED_ADDRESS, formattedAddress) .withValue(StructuredPostal.TYPE, typeCode) .withValue(StructuredPostal.STREET, address.getStreetAddress()) .withValue(StructuredPostal.POBOX, address.getPoBox()) .withValue(StructuredPostal.NEIGHBORHOOD, address.getExtendedAddress()) .withValue(StructuredPostal.CITY, address.getLocality()) .withValue(StructuredPostal.REGION, address.getRegion()) .withValue(StructuredPostal.POSTCODE, address.getPostalCode()) .withValue(StructuredPostal.COUNTRY, address.getCountry()); if (typeLabel != null) builder = builder.withValue(StructuredPostal.LABEL, typeLabel); return builder; }
Example 38
Project: CucumberSync File: LocalAddressBook.java View source code | 4 votes |
protected Builder buildURL(Builder builder, String url) { return builder .withValue(Data.MIMETYPE, Website.CONTENT_ITEM_TYPE) .withValue(Website.URL, url); }
Example 39
Project: CucumberSync File: LocalAddressBook.java View source code | 4 votes |
private Builder newDataInsertBuilder(long raw_contact_id, Integer backrefIdx) { return newDataInsertBuilder(dataURI(), Data.RAW_CONTACT_ID, raw_contact_id, backrefIdx); }
Example 40
Project: MindBody File: Program.java View source code | 4 votes |
public Builder addValues(Builder builder) { builder.withValue(Columns.PROGRAM_ID.getName(), mID) .withValue(Columns.PROGRAM_NAME.getName(), mName) .withValue(Columns.PROGRAM_SCHED_TYPE.getName(), mScheduleType); return builder; }