本文整理汇总了Java中android.content.ContentProviderOperation.newInsert方法的典型用法代码示例。如果您正苦于以下问题:Java ContentProviderOperation.newInsert方法的具体用法?Java ContentProviderOperation.newInsert怎么用?Java ContentProviderOperation.newInsert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.ContentProviderOperation
的用法示例。
在下文中一共展示了ContentProviderOperation.newInsert方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildSpeaker
import android.content.ContentProviderOperation; //导入方法依赖的package包/类
private void buildSpeaker(boolean isInsert, Speaker speaker,
ArrayList<ContentProviderOperation> list) {
Uri allSpeakersUri = ScheduleContractHelper.setUriAsCalledFromSyncAdapter(
ScheduleContract.Speakers.CONTENT_URI);
Uri thisSpeakerUri = ScheduleContractHelper.setUriAsCalledFromSyncAdapter(
ScheduleContract.Speakers.buildSpeakerUri(speaker.id));
ContentProviderOperation.Builder builder;
if (isInsert) {
builder = ContentProviderOperation.newInsert(allSpeakersUri);
} else {
builder = ContentProviderOperation.newUpdate(thisSpeakerUri);
}
list.add(builder.withValue(ScheduleContract.SyncColumns.UPDATED, System.currentTimeMillis())
.withValue(ScheduleContract.Speakers.SPEAKER_ID, speaker.id)
.withValue(ScheduleContract.Speakers.SPEAKER_NAME, speaker.name)
.withValue(ScheduleContract.Speakers.SPEAKER_ABSTRACT, speaker.bio)
.withValue(ScheduleContract.Speakers.SPEAKER_COMPANY, speaker.company)
.withValue(ScheduleContract.Speakers.SPEAKER_IMAGE_URL, speaker.thumbnailUrl)
.withValue(ScheduleContract.Speakers.SPEAKER_PLUSONE_URL, speaker.plusoneUrl)
.withValue(ScheduleContract.Speakers.SPEAKER_TWITTER_URL, speaker.twitterUrl)
.withValue(ScheduleContract.Speakers.SPEAKER_IMPORT_HASHCODE,
speaker.getImportHashcode())
.build());
}
示例2: buildMarkers
import android.content.ContentProviderOperation; //导入方法依赖的package包/类
private void buildMarkers(ArrayList<ContentProviderOperation> list) {
Uri uri = ScheduleContractHelper
.setUriAsCalledFromSyncAdapter(ScheduleContract.MapMarkers.CONTENT_URI);
list.add(ContentProviderOperation.newDelete(uri).build());
for (String floor : mMarkers.keySet()) {
for (Marker marker : mMarkers.get(floor)) {
ContentProviderOperation.Builder builder = ContentProviderOperation.newInsert(uri);
builder.withValue(ScheduleContract.MapMarkers.MARKER_ID, marker.id);
builder.withValue(ScheduleContract.MapMarkers.MARKER_FLOOR, floor);
builder.withValue(ScheduleContract.MapMarkers.MARKER_LABEL, marker.title);
builder.withValue(ScheduleContract.MapMarkers.MARKER_LATITUDE, marker.lat);
builder.withValue(ScheduleContract.MapMarkers.MARKER_LONGITUDE, marker.lng);
builder.withValue(ScheduleContract.MapMarkers.MARKER_TYPE, marker.type);
list.add(builder.build());
}
}
}
示例3: outputBlock
import android.content.ContentProviderOperation; //导入方法依赖的package包/类
private static void outputBlock(Block block, ArrayList<ContentProviderOperation> list) {
Uri uri = ScheduleContractHelper.setUriAsCalledFromSyncAdapter(
ScheduleContract.Blocks.CONTENT_URI);
ContentProviderOperation.Builder builder = ContentProviderOperation.newInsert(uri);
String title = block.title != null ? block.title : "";
String meta = block.subtitle != null ? block.subtitle : "";
String type = block.type;
if ( ! ScheduleContract.Blocks.isValidBlockType(type)) {
LOGW(TAG, "block from "+block.start+" to "+block.end+" has unrecognized type ("
+type+"). Using "+ ScheduleContract.Blocks.BLOCK_TYPE_BREAK +" instead.");
type = ScheduleContract.Blocks.BLOCK_TYPE_BREAK;
}
long startTimeL = ParserUtils.parseTime(block.start);
long endTimeL = ParserUtils.parseTime(block.end);
final String blockId = ScheduleContract.Blocks.generateBlockId(startTimeL, endTimeL);
builder.withValue(ScheduleContract.Blocks.BLOCK_ID, blockId);
builder.withValue(ScheduleContract.Blocks.BLOCK_TITLE, title);
builder.withValue(ScheduleContract.Blocks.BLOCK_START, startTimeL);
builder.withValue(ScheduleContract.Blocks.BLOCK_END, endTimeL);
builder.withValue(ScheduleContract.Blocks.BLOCK_TYPE, type);
builder.withValue(ScheduleContract.Blocks.BLOCK_SUBTITLE, meta);
list.add(builder.build());
}
示例4: makeContentProviderOperations
import android.content.ContentProviderOperation; //导入方法依赖的package包/类
@Override
public void makeContentProviderOperations(ArrayList<ContentProviderOperation> list) {
Uri uri = ScheduleContractHelper.setUriAsCalledFromSyncAdapter(
ScheduleContract.Tags.CONTENT_URI);
// since the number of tags is very small, for simplicity we delete them all and reinsert
list.add(ContentProviderOperation.newDelete(uri).build());
for (Tag tag : mTags.values()) {
ContentProviderOperation.Builder builder = ContentProviderOperation.newInsert(uri);
builder.withValue(ScheduleContract.Tags.TAG_ID, tag.tag);
builder.withValue(ScheduleContract.Tags.TAG_CATEGORY, tag.category);
builder.withValue(ScheduleContract.Tags.TAG_NAME, tag.name);
builder.withValue(ScheduleContract.Tags.TAG_ORDER_IN_CATEGORY, tag.order_in_category);
builder.withValue(ScheduleContract.Tags.TAG_ABSTRACT, tag._abstract);
builder.withValue(ScheduleContract.Tags.TAG_COLOR, tag.color==null ?
Color.LTGRAY : Color.parseColor(tag.color));
list.add(builder.build());
}
}
示例5: makeContentProviderOperations
import android.content.ContentProviderOperation; //导入方法依赖的package包/类
@Override
public void makeContentProviderOperations(ArrayList<ContentProviderOperation> list) {
LOGD(TAG, "makeContentProviderOperations");
Uri uri = ScheduleContractHelper.setUriAsCalledFromSyncAdapter(
ScheduleContract.Hashtags.CONTENT_URI);
// Remove all the current entries
list.add(ContentProviderOperation.newDelete(uri).build());
// Insert hashtags
for (Hashtag hashtag : mHashtags.values()) {
ContentProviderOperation.Builder builder = ContentProviderOperation.newInsert(uri);
builder.withValue(ScheduleContract.Hashtags.HASHTAG_NAME, hashtag.name);
builder.withValue(ScheduleContract.Hashtags.HASHTAG_DESCRIPTION, hashtag.description);
try {
builder.withValue(ScheduleContract.Hashtags.HASHTAG_COLOR,
Color.parseColor(hashtag.color));
} catch (IllegalArgumentException e) {
builder.withValue(ScheduleContract.Hashtags.HASHTAG_COLOR, Color.BLACK);
}
builder.withValue(ScheduleContract.Hashtags.HASHTAG_ORDER, hashtag.order);
list.add(builder.build());
}
LOGD(TAG, "Hashtags: " + mHashtags.size());
}
示例6: buildTiles
import android.content.ContentProviderOperation; //导入方法依赖的package包/类
private void buildTiles(ArrayList<ContentProviderOperation> list) {
Uri uri = ScheduleContractHelper
.setUriAsCalledFromSyncAdapter(ScheduleContract.MapTiles.CONTENT_URI);
list.add(ContentProviderOperation.newDelete(uri).build());
for (String floor : mTileOverlays.keySet()) {
Tile tileOverlay = mTileOverlays.get(floor);
ContentProviderOperation.Builder builder = ContentProviderOperation.newInsert(uri);
builder.withValue(ScheduleContract.MapTiles.TILE_FLOOR, floor);
builder.withValue(ScheduleContract.MapTiles.TILE_FILE, tileOverlay.filename);
builder.withValue(ScheduleContract.MapTiles.TILE_URL, tileOverlay.url);
list.add(builder.build());
}
}
示例7: makeContentProviderOperations
import android.content.ContentProviderOperation; //导入方法依赖的package包/类
@Override
public void makeContentProviderOperations(ArrayList<ContentProviderOperation> list) {
Uri uri = ScheduleContractHelper.setUriAsCalledFromSyncAdapter(
ScheduleContract.Rooms.CONTENT_URI);
// The list of rooms is not large, so for simplicity we delete all of them and repopulate
list.add(ContentProviderOperation.newDelete(uri).build());
for (Room room : mRooms.values()) {
ContentProviderOperation.Builder builder = ContentProviderOperation.newInsert(uri);
builder.withValue(ScheduleContract.Rooms.ROOM_ID, room.id);
builder.withValue(ScheduleContract.Rooms.ROOM_NAME, room.name);
builder.withValue(ScheduleContract.Rooms.ROOM_FLOOR, room.floor);
list.add(builder.build());
}
}
示例8: buildVideo
import android.content.ContentProviderOperation; //导入方法依赖的package包/类
private void buildVideo(boolean isInsert, Video video,
ArrayList<ContentProviderOperation> list) {
Uri allVideosUri = ScheduleContractHelper.setUriAsCalledFromSyncAdapter(
ScheduleContract.Videos.CONTENT_URI);
Uri thisVideoUri = ScheduleContractHelper.setUriAsCalledFromSyncAdapter(
ScheduleContract.Videos.buildVideoUri(video.id));
ContentProviderOperation.Builder builder;
if (isInsert) {
builder = ContentProviderOperation.newInsert(allVideosUri);
} else {
builder = ContentProviderOperation.newUpdate(thisVideoUri);
}
if (TextUtils.isEmpty(video.vid)) {
LOGW(TAG, "Ignoring video with missing video ID.");
return;
}
String thumbUrl = video.thumbnailUrl;
if (TextUtils.isEmpty(thumbUrl)) {
// Oops, missing thumbnail URL. Let's improvise.
// NOTE: this method of obtaining a thumbnail URL from the video ID
// is unofficial and might not work in the future; that's why we use
// it only as a fallback in case we don't get a thumbnail URL in the incoming data.
thumbUrl = String.format(Locale.US, Config.VIDEO_LIBRARY_FALLBACK_THUMB_URL_FMT, video.vid);
LOGW(TAG, "Video with missing thumbnail URL: " + video.vid
+ ". Using fallback: " + thumbUrl);
}
list.add(builder.withValue(ScheduleContract.Videos.VIDEO_ID, video.id)
.withValue(ScheduleContract.Videos.VIDEO_YEAR, video.year)
.withValue(ScheduleContract.Videos.VIDEO_TITLE, video.title.trim())
.withValue(ScheduleContract.Videos.VIDEO_DESC, video.desc)
.withValue(ScheduleContract.Videos.VIDEO_VID, video.vid)
.withValue(ScheduleContract.Videos.VIDEO_TOPIC, video.topic)
.withValue(ScheduleContract.Videos.VIDEO_SPEAKERS, video.speakers)
.withValue(ScheduleContract.Videos.VIDEO_THUMBNAIL_URL, thumbUrl)
.withValue(ScheduleContract.Videos.VIDEO_IMPORT_HASHCODE,
video.getImportHashcode())
.build());
}
示例9: addSaveOperation
import android.content.ContentProviderOperation; //导入方法依赖的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());
}
}