微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android.content.ContentProviderOperation.Builder的实例源码

项目:aos-MediaLib    文件NetworkScannerServiceMusic.java   
/** 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);
}
项目:CucumberSync    文件LocalAddressBook.java   
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());
}
项目:silent-contacts-android    文件RawContactDelta.java   
/**
 * 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());
    }
}
项目:silent-contacts-android    文件RawContactDelta.java   
/**
 * 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;
}
项目:android-db-commons    文件BatcherImpl.java   
@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());
}
项目:scrumchatter    文件DBImport.java   
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);
    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();
        }
    }

}
项目:aos-MediaLib    文件NetworkScannerServiceVideo.java   
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;
    }
}
项目:aos-MediaLib    文件NetworkScannerServiceVideo.java   
/** shows a notification */
private void showNotification(notificationmanager nm,n);
}
项目:CucumberSync    文件LocalCalendar.java   
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());
}
项目:CucumberSync    文件LocalCalendar.java   
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());
}
项目:CucumberSync    文件LocalCalendar.java   
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);
    }
}
项目:CucumberSync    文件LocalCalendar.java   
@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);
}
项目:CucumberSync    文件LocalCalendar.java   
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);
}
项目:CucumberSync    文件LocalCollection.java   
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);
}
项目:CucumberSync    文件LocalAddressBook.java   
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());
}
项目:CucumberSync    文件LocalAddressBook.java   
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());
}
项目:CucumberSync    文件LocalAddressBook.java   
@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());
}
项目:CucumberSync    文件LocalAddressBook.java   
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());
}
项目:CucumberSync    文件LocalAddressBook.java   
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;
}
项目:CucumberSync    文件LocalAddressBook.java   
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()));
}
项目:MindBody    文件SessionType.java   
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;
}
项目:MindBody    文件Location.java   
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;
}
项目:ContactMerger    文件ContactDataMapper.java   
/**
 * 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());
    }
}
项目:silent-contacts-android    文件RawContactDelta.java   
/**
 * 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());
    }
}
项目:android-db-commons    文件BatcherImpl.java   
@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;
}
项目:bikey    文件DatabaseImporter.java   
/**
 * 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(),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,LogColumns.TABLE_NAME,operations);
    dbImport.close();
}
项目:mobile-client    文件NewsHandler.java   
/**
 * 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());
}
项目:aos-MediaLib    文件NetworkScannerServiceVideo.java   
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());
}
项目:aos-MediaLib    文件EpisodeTags.java   
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());
    }
}
项目:CucumberSync    文件LocalCalendar.java   
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;
}
项目:CucumberSync    文件LocalCollection.java   
protected void queueOperation(Builder builder) {
    if (builder != null)
        pendingOperations.add(builder.build());
}
项目:CucumberSync    文件LocalAddressBook.java   
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;
}
项目:CucumberSync    文件LocalAddressBook.java   
protected Builder buildPhoto(Builder builder,byte[] photo) {
    return builder
        .withValue(Data.MIMETYPE,Photo.CONTENT_ITEM_TYPE)
        .withValue(Photo.PHOTO,photo);
}
项目:CucumberSync    文件LocalAddressBook.java   
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,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;
}
项目:CucumberSync    文件LocalAddressBook.java   
protected Builder buildNickName(Builder builder,String nickName) {
    return builder
        .withValue(Data.MIMETYPE,Nickname.CONTENT_ITEM_TYPE)
        .withValue(Nickname.NAME,nickName);
}
项目:CucumberSync    文件LocalAddressBook.java   
protected Builder buildNote(Builder builder,String note) {
    return builder
        .withValue(Data.MIMETYPE,Note.CONTENT_ITEM_TYPE)
        .withValue(Note.NOTE,note);
}
项目:CucumberSync    文件LocalAddressBook.java   
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;
}
项目:CucumberSync    文件LocalAddressBook.java   
protected Builder buildURL(Builder builder,String url) {
    return builder
        .withValue(Data.MIMETYPE,Website.CONTENT_ITEM_TYPE)
        .withValue(Website.URL,url);
}
项目:CucumberSync    文件LocalAddressBook.java   
private Builder newDataInsertBuilder(long raw_contact_id,Integer backrefIdx) {
    return newDataInsertBuilder(dataURI(),Data.RAW_CONTACT_ID,raw_contact_id,backrefIdx);
}
项目:MindBody    文件Program.java   
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;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。