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


Java TimelineItem类代码示例

本文整理汇总了Java中com.google.api.services.mirror.model.TimelineItem的典型用法代码示例。如果您正苦于以下问题:Java TimelineItem类的具体用法?Java TimelineItem怎么用?Java TimelineItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TimelineItem类属于com.google.api.services.mirror.model包,在下文中一共展示了TimelineItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: insertMultiHtmlTimelineItem

import com.google.api.services.mirror.model.TimelineItem; //导入依赖的package包/类
public static void insertMultiHtmlTimelineItem( ServletContext ctx,
                                                 HttpServletRequest req )
    throws IOException, ServletException
{
  Mirror mirror = MirrorUtils.getMirror( req );
  Timeline timeline = mirror.timeline();

  // START:insertMultiHtmlTimelineItem
  // Generate a unique Lunch Roulette bundle id
  String bundleId = "lunchRoulette" + UUID.randomUUID();

  // First Cuisine Option
  TimelineItem timelineItem1 = new TimelineItem()
    .setHtml( renderRandomCuisine( ctx ) )
    .setBundleId( bundleId )
    .setIsBundleCover( true );
  timeline.insert( timelineItem1 ).execute();

  // Alternate Cuisine Option
  TimelineItem timelineItem2 = new TimelineItem()
    .setHtml( renderRandomCuisine( ctx ) )
    .setBundleId( bundleId );
  timeline.insert( timelineItem2 ).execute();
  // END:insertMultiHtmlTimelineItem
}
 
开发者ID:coderoshi,项目名称:glass,代码行数:26,代码来源:LunchRoulette.java

示例2: insertAndSaveSimpleHtmlTimelineItem

import com.google.api.services.mirror.model.TimelineItem; //导入依赖的package包/类
public static void insertAndSaveSimpleHtmlTimelineItem( ServletContext ctx,
                                                        String userId )
    throws IOException, ServletException
{
  Mirror mirror = MirrorUtils.getMirror( userId );
  Timeline timeline = mirror.timeline();

  // START:insertSimpleHtmlTimelineItem
  // get a cuisine, populate an object, and render the template
  String cuisine = getRandomCuisine();
  Map<String, String> data = Collections.singletonMap( "food", cuisine );
  String html = render( ctx, "glass/cuisine.ftl", data );

  TimelineItem timelineItem = new TimelineItem()
    .setTitle( "Lunch Roulette" )
    .setHtml( html )
    .setSpeakableText( "You should eat "+cuisine+" for lunch" );

  TimelineItem tiResp = timeline.insert( timelineItem ).execute();
  // END:insertSimpleHtmlTimelineItem

  setLunchRouletteId( userId, tiResp.getId() );
}
 
开发者ID:coderoshi,项目名称:glass,代码行数:24,代码来源:LunchRoulette.java

示例3: insertAndSaveSimpleTextTimelineItem

import com.google.api.services.mirror.model.TimelineItem; //导入依赖的package包/类
public static void insertAndSaveSimpleTextTimelineItem( HttpServletRequest req )
    throws IOException
{
  String userId = SessionUtils.getUserId( req );
  Credential credential = AuthUtils.getCredential( userId );
  Mirror mirror = MirrorUtils.getMirror( credential );

  Timeline timeline = mirror.timeline();

  // START:insertAndSaveSimpleTimelineItem
  TimelineItem timelineItem = new TimelineItem()
    .setTitle( "Lunch Roulette" )
    .setText( getRandomCuisine() );

  TimelineItem tiResp = timeline.insert( timelineItem ).execute();
  
  setLunchRouletteId( userId, tiResp.getId() );
  // END:insertAndSaveSimpleTimelineItem
}
 
开发者ID:coderoshi,项目名称:glass,代码行数:20,代码来源:LunchRoulette.java

示例4: welcome

import com.google.api.services.mirror.model.TimelineItem; //导入依赖的package包/类
@RequestMapping(value = "/greet")
public ModelAndView welcome(HttpServletRequest req, @RequestParam("greeting") String greeting) {

	// subscribe (only works deployed to production)
	String message = "";
	ModelAndView mav = new ModelAndView("info");
	try {

		mav.setViewName("greeting");
		mav.addObject("greeting", greeting);
		TimelineItem timelineItem  = mirrorTemplate.render(mav);			
		timelineItem.setNotification(new NotificationConfig().setLevel("DEFAULT"));
		TimelineItem insertedItem = mirrorTemplate.insertTimelineItem(timelineItem);
		message = "Inserted welcome message: " + insertedItem.getText();
		logger.info("Inserted welcome message " + greeting);
	} catch (Exception e) {
		logger.error("Could not send welcome  because " + e.getMessage(), e);
		message = "Could not send welcome. Check your log for details";
	}

	mav = new ModelAndView("info");
	mav.addObject("message", message);
	return mav;
}
 
开发者ID:eteration,项目名称:glassmaker,代码行数:25,代码来源:MainController.java

示例5: insertPaginatedItem

import com.google.api.services.mirror.model.TimelineItem; //导入依赖的package包/类
@RequestMapping(value = "/insertPaginatedItem")
public ModelAndView insertPaginatedItem(HttpServletRequest req, @RequestParam("message") String message, @RequestParam("imageUrl") String imageUrl, @RequestParam("contentType") String contentType) throws Exception {

	String info = "";
	logger.info("Inserting Timeline Item");
	ModelAndView mav = new ModelAndView("samplePage");
	mav.addObject("hello", "Merhaba!");
	TimelineItem timelineItem = mirrorTemplate.render(mav);
	List<MenuItem> menuItemList = new ArrayList<MenuItem>();
	menuItemList.add(new MenuItem().setAction("OPEN_URI").setPayload(WebUtil.buildUrl(req, "/demo")));
	timelineItem.setMenuItems(menuItemList);

	// Triggers an audible tone when the timeline item is received
	timelineItem.setNotification(new NotificationConfig().setLevel("DEFAULT"));

	mirrorTemplate.insertTimelineItem(timelineItem);

	info = "A timeline item has been inserted.";
	mav = new ModelAndView("info");
	mav.addObject("message", info);
	return mav;
}
 
开发者ID:eteration,项目名称:glassmaker,代码行数:23,代码来源:MainController.java

示例6: previewOnGlass

import com.google.api.services.mirror.model.TimelineItem; //导入依赖的package包/类
private void previewOnGlass() {
	try {
		Credential cred = GoogleLogin.getInstance().getCredential();
		cred.getAccessToken();
		Mirror m = new Mirror.Builder(GoogleNetHttpTransport.newTrustedTransport(), new JacksonFactory(), cred)
		.setApplicationName("Glassmaker Plugin")
		.build();

		String editorText = getDocumentProvider().getDocument(textEditor.getEditorInput()).get();
		deletePreviewFiles();
		TimelineItem timelineItem =  CardUtil.createTimeline(editorText);			
		Mirror.Timeline timeline = m.timeline();
		timeline.insert(timelineItem).execute();
		
	} catch (Exception e) {
		GlassmakerUIPlugin.logError(e.getMessage(), e);
	}
}
 
开发者ID:eteration,项目名称:glassmaker,代码行数:19,代码来源:CardEditor.java

示例7: 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;
}
 
开发者ID:MarcosBermudez,项目名称:java-mirror-api-emulator,代码行数:34,代码来源:EmulatorUtil.java

示例8: insertSimpleTextTimelineItem

import com.google.api.services.mirror.model.TimelineItem; //导入依赖的package包/类
public static void insertSimpleTextTimelineItem( HttpServletRequest req )
    throws IOException
{
  Mirror mirror = MirrorUtils.getMirror( req );
  Timeline timeline = mirror.timeline();
  
  TimelineItem timelineItem = new TimelineItem()
    .setText( getRandomCuisine() );
  
  timeline.insert( timelineItem ).executeAndDownloadTo( System.out );
}
 
开发者ID:coderoshi,项目名称:glass,代码行数:12,代码来源:LunchRoulette.java

示例9: getLastSavedTimelineItem

import com.google.api.services.mirror.model.TimelineItem; //导入依赖的package包/类
public static TimelineItem getLastSavedTimelineItem( String userId )
    throws IOException
{
  Credential credential = AuthUtils.getCredential( userId );
  Mirror mirror = MirrorUtils.getMirror( credential );
  Timeline timeline = mirror.timeline();

  // START:getLastSavedTimelineItem
  String id = getLunchRouletteId( userId );

  TimelineItem timelineItem = timeline.get( id ).execute();
  // END:getLastSavedTimelineItem

  return timelineItem;
}
 
开发者ID:coderoshi,项目名称:glass,代码行数:16,代码来源:LunchRoulette.java

示例10: setSimpleMenuItems

import com.google.api.services.mirror.model.TimelineItem; //导入依赖的package包/类
public static void setSimpleMenuItems( TimelineItem ti, boolean hasRestaurant ) {
  // Add blank menu list
  ti.setMenuItems( new LinkedList<MenuItem>() );
  
  ti.getMenuItems().add( new MenuItem().setAction( "READ_ALOUD" ) );
  ti.getMenuItems().add( new MenuItem().setAction( "DELETE" ) );
}
 
开发者ID:coderoshi,项目名称:glass,代码行数:8,代码来源:LunchRoulette.java

示例11: 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" );
}
 
开发者ID:coderoshi,项目名称:glass,代码行数:29,代码来源:LunchRouletteServlet.java

示例12: buildRandomRestaurantTimelineItem

import com.google.api.services.mirror.model.TimelineItem; //导入依赖的package包/类
public static TimelineItem buildRandomRestaurantTimelineItem(
                               ServletContext ctx, String userId )
    throws IOException, ServletException
{
  Mirror mirror = MirrorUtils.getMirror( userId );

  Location location = mirror.locations().get("latest").execute();

  double latitude = location.getLatitude();
  double longitude = location.getLongitude();

  // START:insertRandomRestaurantTimelineItem
  // get a nearby restaurant from Google Places
  Place restaurant = getRandomRestaurant(latitude, longitude);
  // create a timeline item with restaurant information
  TimelineItem timelineItem = new TimelineItem()
    .setHtml( render( ctx, "glass/restaurant.ftl", restaurant ) )
    .setTitle( "Lunch Roulette" )
    .setMenuItems( new LinkedList<MenuItem>() )
    .setLocation(
      new Location()
        .setLatitude( restaurant.getLatitude() )
        .setLongitude( restaurant.getLongitude() )
        .setAddress( restaurant.getAddress() )
        .setDisplayName( restaurant.getName() )
        .setKind( restaurant.getKind() ) );
  // Add the NAVIGATE menu item
  timelineItem.getMenuItems().add(
    new MenuItem().setAction( "NAVIGATE" )
  );
  // END:insertRandomRestaurantTimelineItem
  timelineItem.getMenuItems().add(
    new MenuItem().setAction( "DELETE" )
  );

  return timelineItem;
}
 
开发者ID:coderoshi,项目名称:glass,代码行数:38,代码来源:LunchRoulette.java

示例13: pushPost

import com.google.api.services.mirror.model.TimelineItem; //导入依赖的package包/类
/**
 * Create a timeline item for every follower of this blog
 */
// START:pushPost
private static void pushPost( Blog blog, Post post )
  throws IOException
{
  // find every user that follows that nickname
  List<User> users = blog.getFollowers();
  for (User user : users) {
    String userId = user.getId();
    Mirror mirror = MirrorUtils.getMirror( userId );
    TimelineItem timelineItem = new TimelineItem()
      .setText( post.getBody() );
    mirror.timeline().insert( timelineItem ).execute();
  }
}
 
开发者ID:coderoshi,项目名称:glass,代码行数:18,代码来源:BlogHelper.java

示例14: addDeleteMenuItem

import com.google.api.services.mirror.model.TimelineItem; //导入依赖的package包/类
/**
 * Adds the "delete" menu option to the given {@link TimelineItem}<br>
 * to allow users to delete the item while using their Glass.
 */
public static void addDeleteMenuItem(TimelineItem timelineItem) {
	List<MenuItem> existingMenuItems = timelineItem.getMenuItems();
	if (existingMenuItems == null) {
		existingMenuItems = new ArrayList<MenuItem>();
		timelineItem.setMenuItems(existingMenuItems);
	}
	existingMenuItems.add(new MenuItem().setAction("DELETE"));
}
 
开发者ID:jwilsoncredera,项目名称:spring-boot-glass,代码行数:13,代码来源:MirrorClient.java

示例15: 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);
}
 
开发者ID:mimming,项目名称:kitty-compass,代码行数:45,代码来源:NewUserBootstrapper.java


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