本文整理汇总了Java中com.google.api.services.mirror.model.TimelineItem.setText方法的典型用法代码示例。如果您正苦于以下问题:Java TimelineItem.setText方法的具体用法?Java TimelineItem.setText怎么用?Java TimelineItem.setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.api.services.mirror.model.TimelineItem
的用法示例。
在下文中一共展示了TimelineItem.setText方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bootstrapNewUser
import com.google.api.services.mirror.model.TimelineItem; //导入方法依赖的package包/类
/**
* Bootstrap a new user. Do all of the typical actions for a new user:
* <ul>
* <li>Creating a timeline subscription</li>
* <li>Inserting a contact</li>
* <li>Sending the user a welcome message</li>
* </ul>
*/
public static void bootstrapNewUser(HttpServletRequest req, String userId) throws IOException {
Credential credential = AuthUtil.newAuthorizationCodeFlow().loadCredential(userId);
try {
// Subscribe to locations updates
Subscription subscription =
MirrorClient.insertSubscription(credential, WebUtil.buildUrl(req, "/notify"), userId,
"locations");
LOG.info("Bootstrapper inserted subscription " + subscription
.getId() + " for user " + userId);
} catch (GoogleJsonResponseException e) {
LOG.warning("Failed to create locations subscription. Might be running on "
+ "localhost. Details:" + e.getDetails().toPrettyString());
}
// Send welcome timeline item
TimelineItem timelineItem = new TimelineItem();
timelineItem.setText("Welcome to Kitty Compass");
timelineItem.setNotification(new NotificationConfig().setLevel("DEFAULT"));
final HttpServletRequest finalReq = req;
timelineItem.setMenuItems(
Lists.newArrayList(new MenuItem()
.setAction("OPEN_URI")
.setPayload("kittycompass://open")
.setValues(Lists.newArrayList(new MenuValue()
.setDisplayName("Open")
.setIconUrl(WebUtil.buildUrl(finalReq, "/static/images/ic_compass.png"))
))
)
);
TimelineItem insertedItem = MirrorClient.insertTimelineItem(credential, timelineItem);
LOG.info("Bootstrapper inserted welcome message " + insertedItem.getId() + " for user "
+ userId);
}
示例2: insertItem
import com.google.api.services.mirror.model.TimelineItem; //导入方法依赖的package包/类
@RequestMapping(value = "/insertItem")
public ModelAndView insertItem(@RequestParam("message") String message, @RequestParam("imageUrl") String imageUrl, @RequestParam("contentType") String contentType) throws IOException {
String info = "";
logger.info("Inserting Timeline Item");
TimelineItem timelineItem = new TimelineItem();
if (message != null) {
timelineItem.setText(message);
}
// Triggers an audible tone when the timeline item is received
timelineItem.setNotification(new NotificationConfig().setLevel("DEFAULT"));
if (imageUrl != null) {
// Attach an image, if we have one
URL url = new URL(imageUrl);
mirrorTemplate.insertTimelineItem(timelineItem, contentType, url.openStream());
} else {
mirrorTemplate.insertTimelineItem(timelineItem);
}
info = "A timeline item has been inserted.";
ModelAndView mav = new ModelAndView("info");
mav.addObject("message", info);
return mav;
}
示例3: createTimeline
import com.google.api.services.mirror.model.TimelineItem; //导入方法依赖的package包/类
public static TimelineItem createTimeline(String htmlFragment) {
int indexOfArticle = htmlFragment.indexOf("<article");
boolean hasArticle = indexOfArticle >= 0;
TimelineItem timelineItem = new TimelineItem();
if(hasArticle){
timelineItem.setHtml(htmlFragment);
}else{
timelineItem.setText(htmlFragment);
}
// Triggers an audible tone when the timeline item is received
timelineItem.setNotification(new NotificationConfig().setLevel("DEFAULT"));
return timelineItem;
}
示例4: submitText
import com.google.api.services.mirror.model.TimelineItem; //导入方法依赖的package包/类
public void submitText(String text) throws IOException {
TimelineItem timelineItem = new TimelineItem();
timelineItem.setText(text);
MirrorClient.addDeleteMenuItem(timelineItem);
MirrorClient.insertTimelineItem(credential(), timelineItem);
}