本文整理汇总了Java中com.google.api.services.mirror.model.TimelineItem.setHtml方法的典型用法代码示例。如果您正苦于以下问题:Java TimelineItem.setHtml方法的具体用法?Java TimelineItem.setHtml怎么用?Java TimelineItem.setHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.api.services.mirror.model.TimelineItem
的用法示例。
在下文中一共展示了TimelineItem.setHtml方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTimeLineItemWithAtachement
import com.google.api.services.mirror.model.TimelineItem; //导入方法依赖的package包/类
/**
* The real Mirror API supports Multipart-bodies to attach images to cards, Emulator not, we will transformt the
* card in one HTML TimeLineItem. https://github.com/Scarygami/mirror-api - REAMDME.md
*
* @param content The initial timeline item.
* @param mediaContent The attachement image.
* @return The initial timeline item modified to look like one HTML card with the atachement.
* @throws IOException
* @throws FileNotFoundException
*/
public static TimelineItem createTimeLineItemWithAtachement(TimelineItem content,
AbstractInputStreamContent mediaContent) throws IOException, FileNotFoundException {
// We are going to transform the card in one HTML card.
if (content.getHtml() != null && content.getHtml().isEmpty()) {
// If the card already contains html then we do nothing
LOG.log(Level.WARNING,
"Emulation limitation : Images are transformes in HTML card, you must choose, or HTML or Attachement. your attachement will be ignored. ");
} else {
// Store the image
String attachementURL = storeAttachement(mediaContent);
// Transform card in one HTML card
String cardText = content.getText() != null ? content.getText() : "";
String html = "<article class=\"photo\"> <img src="
+ attachementURL
+ " width=\"100%\" height=\"100%\"> <div class=\"photo-overlay\"></div> <section> <p class=\"text-auto-size\">"
+ cardText + "</p> </section></article>";
content.setHtml(html);
}
return content;
}
示例2: doGet
import com.google.api.services.mirror.model.TimelineItem; //导入方法依赖的package包/类
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException, ServletException
{
ServletContext ctx = getServletContext();
String userId = SessionUtils.getUserId( req );
TimelineItem timelineItem = LunchRoulette.getLastSavedTimelineItem(userId);
// If it exists, isn't deleted, and is pinned, then update
if (timelineItem != null
&& !(timelineItem.getIsDeleted() != null && timelineItem.getIsDeleted())
&& (timelineItem.getIsPinned() != null && timelineItem.getIsPinned()))
{
String html = LunchRoulette.renderRandomCuisine( ctx );
timelineItem.setHtml( html );
// update the old timeline item
Timeline timeline = MirrorUtils.getMirror( userId ).timeline();
timeline.patch( timelineItem.getId(), timelineItem ).execute();
}
// Otherwise, create a new one
else {
LunchRoulette.insertAndSaveSimpleHtmlTimelineItem( ctx, userId );
}
resp.setContentType("text/plain");
resp.getWriter().append( "Inserted Timeline Item" );
}
示例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: render
import com.google.api.services.mirror.model.TimelineItem; //导入方法依赖的package包/类
public TimelineItem render(ModelAndView mav) throws Exception {
TimelineItem timelineItem = new TimelineItem();
String article = templateMerger.merge(mav.getViewName(), mav.getModelMap());
timelineItem.setHtml(article);
return timelineItem;
}