当前位置: 首页>>代码示例>>Java>>正文


Java Builder.withSelection方法代码示例

本文整理汇总了Java中android.content.ContentProviderOperation.Builder.withSelection方法的典型用法代码示例。如果您正苦于以下问题:Java Builder.withSelection方法的具体用法?Java Builder.withSelection怎么用?Java Builder.withSelection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.ContentProviderOperation.Builder的用法示例。


在下文中一共展示了Builder.withSelection方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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;
}
 
开发者ID:SilentCircle,项目名称:silent-contacts-android,代码行数:25,代码来源:RawContactDelta.java

示例2: 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;
    }
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:13,代码来源:NetworkScannerServiceVideo.java

示例3: persist

import android.content.ContentProviderOperation.Builder; //导入方法依赖的package包/类
/**
 * 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());
    }
}
 
开发者ID:rtreffer,项目名称:ContactMerger,代码行数:46,代码来源:ContactDataMapper.java

示例4: addUpdate

import android.content.ContentProviderOperation.Builder; //导入方法依赖的package包/类
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());
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:7,代码来源:NetworkScannerServiceVideo.java

示例5: 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);
        }
    }
}
 
开发者ID:caarmen,项目名称:scrumchatter,代码行数:45,代码来源:Meeting.java


注:本文中的android.content.ContentProviderOperation.Builder.withSelection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。