本文整理汇总了Java中android.content.ContentProviderOperation.Builder.withValue方法的典型用法代码示例。如果您正苦于以下问题:Java Builder.withValue方法的具体用法?Java Builder.withValue怎么用?Java Builder.withValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.ContentProviderOperation.Builder
的用法示例。
在下文中一共展示了Builder.withValue方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildInsertOperations
import android.content.ContentProviderOperation.Builder; //导入方法依赖的package包/类
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();
}
}
}
示例2: buildAttendee
import android.content.ContentProviderOperation.Builder; //导入方法依赖的package包/类
@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);
}
示例3: newDataInsertBuilder
import android.content.ContentProviderOperation.Builder; //导入方法依赖的package包/类
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);
}
示例4: buildEmail
import android.content.ContentProviderOperation.Builder; //导入方法依赖的package包/类
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;
}
示例5: parseMessage
import android.content.ContentProviderOperation.Builder; //导入方法依赖的package包/类
/**
* 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());
}
示例6: addSaveOperation
import android.content.ContentProviderOperation.Builder; //导入方法依赖的package包/类
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());
}
}
示例7: buildPhoneNumber
import android.content.ContentProviderOperation.Builder; //导入方法依赖的package包/类
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;
}
示例8: buildIMPP
import android.content.ContentProviderOperation.Builder; //导入方法依赖的package包/类
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;
}
示例9: buildAddress
import android.content.ContentProviderOperation.Builder; //导入方法依赖的package包/类
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;
}
示例10: buildDiff
import android.content.ContentProviderOperation.Builder; //导入方法依赖的package包/类
/**
* Build a list of {@link ContentProviderOperation} that will transform the
* current "before" {link Entity} state into the modified state which this
* {@link RawContactDelta} represents.
*/
public void buildDiff(ArrayList<ContentProviderOperation> buildInto) {
final int firstIndex = buildInto.size();
final boolean isContactInsert = mValues.isInsert();
final boolean isContactDelete = mValues.isDelete();
final boolean isContactUpdate = !isContactInsert && !isContactDelete;
final Long beforeId = mValues.getId();
Builder builder;
// Build possible operation at Contact level
builder = mValues.buildDiff(mContactsQueryUri);
possibleAdd(buildInto, builder);
// Build operations for all children
for (ArrayList<ValuesDelta> mimeEntries : mEntries.values()) {
for (ValuesDelta child : mimeEntries) {
// Ignore children if parent was deleted
if (isContactDelete)
continue;
builder = child.buildDiff(Data.CONTENT_URI);
if (child.isInsert()) {
if (isContactInsert) {
// Parent is brand new insert, so back-reference _id
builder.withValueBackReference(Data.RAW_CONTACT_ID, firstIndex);
} else {
// Inserting under existing, so fill with known _id
builder.withValue(Data.RAW_CONTACT_ID, beforeId);
}
} else if (isContactInsert && builder != null) {
// Child must be insert when Contact insert
throw new IllegalArgumentException("When parent insert, child must be also");
}
possibleAdd(buildInto, builder);
}
}
}
示例11: shutEverybodyUp
import android.content.ContentProviderOperation.Builder; //导入方法依赖的package包/类
/**
* Stop the chronometers of all team members who are still talking. Update
* the duration for these team members.
*/
private void shutEverybodyUp() {
Log.v(TAG, "shutEverybodyUp");
// Query all team members who are still talking in this meeting.
Uri uri = Uri.withAppendedPath(MeetingMemberColumns.CONTENT_URI, String.valueOf(mId));
// Closing the cursorWrapper also closes the cursor
@SuppressLint("Recycle")
Cursor cursor = mContext.getContentResolver().query(uri,
new String[] { MeetingMemberColumns.MEMBER_ID, MeetingMemberColumns.DURATION, MeetingMemberColumns.TALK_START_TIME },
MeetingMemberColumns.TALK_START_TIME + ">0", null, null);
if (cursor != null) {
// Prepare some update statements to set the duration and reset the
// talk_start_time, for these members.
ArrayList<ContentProviderOperation> operations = new ArrayList<>();
MeetingMemberCursorWrapper cursorWrapper = new MeetingMemberCursorWrapper(cursor);
if (cursorWrapper.moveToFirst()) {
do {
// Prepare an update operation for one of these members.
Builder builder = ContentProviderOperation.newUpdate(MeetingMemberColumns.CONTENT_URI);
long memberId = cursorWrapper.getMemberId();
// Calculate the total duration the team member talked
// during this meeting.
long duration = cursorWrapper.getDuration();
long talkStartTime = cursorWrapper.getTalkStartTime();
long newDuration = duration + (System.currentTimeMillis() - talkStartTime) / 1000;
builder.withValue(MeetingMemberColumns.DURATION, newDuration);
builder.withValue(MeetingMemberColumns.TALK_START_TIME, 0);
builder.withSelection(MeetingMemberColumns.MEMBER_ID + "=? AND " + MeetingMemberColumns.MEETING_ID + "=?",
new String[] { String.valueOf(memberId), String.valueOf(mId) });
operations.add(builder.build());
} while (cursorWrapper.moveToNext());
}
cursorWrapper.close();
try {
// Batch update these team members.
mContext.getContentResolver().applyBatch(ScrumChatterProvider.AUTHORITY, operations);
} catch (Exception e) {
Log.v(TAG, "Couldn't close off meeting: " + e.getMessage(), e);
}
}
}
示例12: buildInsertOperations
import android.content.ContentProviderOperation.Builder; //导入方法依赖的package包/类
/**
* Read all cells from the given table from the dbImport database, and add corresponding insert operations to the operations parameter.
*/
private static void buildInsertOperations(Context context, SQLiteDatabase dbImport, Uri uri, String table, ArrayList<ContentProviderOperation> operations)
throws RemoteException, OperationApplicationException {
Log.d();
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);
// The distance and duration columns of the log table
// were renamed to log_distance and log_duration,
// in DB version 5.
if (LogColumns.TABLE_NAME.equals(table)) {
if ("distance".equals(columnName)) columnName = LogColumns.LOG_DISTANCE;
else if ("duration".equals(columnName)) columnName = LogColumns.LOG_DURATION;
}
builder.withValue(columnName, value);
}
if (RideColumns.TABLE_NAME.equals(table) && c.getColumnIndex(RideColumns.UUID) == -1) {
// The ride has no UUID column, but it became mandatory (not null constraint) in DB version 6.
// Add one now.
builder.withValue(RideColumns.UUID, UUID.randomUUID().toString());
}
operations.add(builder.build());
if (operations.size() >= 100) {
context.getContentResolver().applyBatch(BikeyProvider.AUTHORITY, operations);
operations.clear();
}
} while (c.moveToNext());
if (operations.size() > 0) context.getContentResolver().applyBatch(BikeyProvider.AUTHORITY, operations);
}
} finally {
c.close();
}
}
}