本文整理汇总了Java中android.content.ContentProviderOperation.Builder类的典型用法代码示例。如果您正苦于以下问题:Java Builder类的具体用法?Java Builder怎么用?Java Builder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Builder类属于android.content.ContentProviderOperation包,在下文中一共展示了Builder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showNotification
import android.content.ContentProviderOperation.Builder; //导入依赖的package包/类
/** 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);
}
示例2: buildOrganization
import android.content.ContentProviderOperation.Builder; //导入依赖的package包/类
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());
}
示例3: buildAssert
import android.content.ContentProviderOperation.Builder; //导入依赖的package包/类
/**
* 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());
}
}
示例4: buildDiff
import android.content.ContentProviderOperation.Builder; //导入依赖的package包/类
/**
* 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;
}
示例5: resolveBackRefs
import android.content.ContentProviderOperation.Builder; //导入依赖的package包/类
@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());
}
示例6: 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();
}
}
}
示例7: addDelete
import android.content.ContentProviderOperation.Builder; //导入依赖的package包/类
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;
}
}
示例8: deleteAllExceptRemoteIds
import android.content.ContentProviderOperation.Builder; //导入依赖的package包/类
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());
}
示例9: deleteAllExceptUIDs
import android.content.ContentProviderOperation.Builder; //导入依赖的package包/类
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());
}
示例10: populateReminders
import android.content.ContentProviderOperation.Builder; //导入依赖的package包/类
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);
}
}
示例11: 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);
}
示例12: buildReminder
import android.content.ContentProviderOperation.Builder; //导入依赖的package包/类
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);
}
示例13: 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);
}
示例14: deleteAllExceptRemoteIds
import android.content.ContentProviderOperation.Builder; //导入依赖的package包/类
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());
}
示例15: deleteAllExceptUIDs
import android.content.ContentProviderOperation.Builder; //导入依赖的package包/类
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());
}