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


Java TimelineItem.setMenuItems方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: insertItemWithAction

import com.google.api.services.mirror.model.TimelineItem; //导入方法依赖的package包/类
@RequestMapping(value = "/insertItemWithAction")
public ModelAndView insertItemWithAction(HttpServletRequest req, @RequestParam("question") String question) 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>();
	// Built in actions
	menuItemList.add(new MenuItem().setAction("REPLY"));
	menuItemList.add(new MenuItem().setAction("READ_ALOUD"));

	// And custom actions
	List<MenuValue> menuValues = new ArrayList<MenuValue>();
	menuValues.add(new MenuValue().setIconUrl(WebUtil.buildUrl(req, "/assets/images/menu_icons/ic_person_50.png")).setDisplayName("Ask Us"));
	menuItemList.add(new MenuItem().setValues(menuValues).setId("askus").setAction("CUSTOM"));
	timelineItem.setMenuItems(menuItemList);
	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,代码行数:30,代码来源:MainController.java

示例6: doGet

import com.google.api.services.mirror.model.TimelineItem; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	// get Access to Mirror Api
	Mirror mirror = getMirror(req);
	
	// get TimeLine
	Timeline timeline = mirror.timeline();
		
	try {
	    JSONObject json = new JSONObject(retrieveIPool());
	    JSONArray arr = json.getJSONArray("documents");
	    JSONArray media = new JSONArray();
	    
	    String title = null;
	    String content = null;
	    String URL = null;
	    
	    for (int i = 0; i < arr.length(); i++) {
	        title = arr.getJSONObject(i).getString("title");
	        // maybe for future use but for tts needs to be stripped from html tags
	        //content = arr.getJSONObject(i).getString("content");
	        media = arr.getJSONObject(i).getJSONArray("contentReferences");   
	    }
	    		    
	    if (media.length()!=0){
		    for (int i = 0; i < media.length(); i++) {
		    	URL = media.getJSONObject(i).getString("externalUrl");   
		    }
	    }
    
	    String html = "<article class=\"photo\">\n  <img src=\""+URL+"\" width=\"100%\" height=\"100%\">\n  <div class=\"overlay-gradient-tall-dark\"/>\n  <section>\n    <p class=\"text-auto-size\">"+title+"</p>\n  </section>\n</article>";
	    
	 // create a timeline item
		TimelineItem timelineItem = new TimelineItem()
			//.setSpeakableText(content)
			.setSpeakableText(title)
			.setHtml(html)
			.setDisplayTime(new DateTime(new Date()))
			.setNotification(new NotificationConfig().setLevel("Default"));
		
		// add menu items with built-in actions
		List<MenuItem> menuItemList = new ArrayList<MenuItem>();
		menuItemList.add(new MenuItem().setAction("DELETE"));
		menuItemList.add(new MenuItem().setAction("READ_ALOUD"));
		menuItemList.add(new MenuItem().setAction("TOGGLE_PINNED"));
		timelineItem.setMenuItems(menuItemList);
		
		// insert the crad into the timeline
		timeline.insert(timelineItem).execute();
		
		//print out results on the web browser
		resp.setContentType("text/html; charset=utf-8");
		//resp.setCharacterEncoding("UTF-8");
		resp.getWriter().println(
				"<html><head><meta http-equiv=\"refresh\" content=\"3;url=/index.html\"></head> "
						+ "<body>"+html+"</body></html>");
	} catch (JSONException e) {
	    
	    StringWriter errors = new StringWriter();
	    e.printStackTrace(new PrintWriter(errors));
	    String error =  errors.toString();
	    
	    //resp.setContentType("text/html; charset=utf-8");
	    resp.setCharacterEncoding("UTF-8");
		resp.getWriter().println(
				"<html><head><meta http-equiv=\"refresh\" content=\"3;url=/index.html\"></head> "
						+ "<body>JSON Exception " +error+" </body></html>");
	}
}
 
开发者ID:ipool,项目名称:GlassPool,代码行数:70,代码来源:IpoolAPIClient.java

示例7: setAllMenuItems

import com.google.api.services.mirror.model.TimelineItem; //导入方法依赖的package包/类
public static void setAllMenuItems( 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( "SHARE" ) );

  if( hasRestaurant ) {
    // add custom menu item
    List<MenuValue> menuValues = new ArrayList<MenuValue>(2);
    menuValues.add( new MenuValue()
      .setState( "DEFAULT" )
      .setDisplayName( "Alternative" )
      // .setIconUrl( "" )
    );
    menuValues.add( new MenuValue()
      .setState( "PENDING" )
      .setDisplayName( "Generating Alternative" ) );

    ti.getMenuItems().add( new MenuItem()
      .setAction( "CUSTOM" )
        .setId( "ALT" )
        .setPayload( "ALT" )
        .setValues( menuValues )
    );

    ti.getMenuItems().add( new MenuItem()
    .setAction( "CUSTOM" )
      .setId( "ADD_CONTACT" )
      .setPayload( "ADD_CONTACT" )
      .setRemoveWhenSelected( true )
      .setValues( Collections.singletonList( new MenuValue()
        .setState( "DEFAULT" )
        .setDisplayName( "Add As Contact" ) ) 
      )
    );
  }
  
  ti.getMenuItems().add( new MenuItem().setAction( "TOGGLE_PINNED" ) );

  if( hasRestaurant ) {
    // Call and navigate to the restaurant, only if we have one
    ti.getMenuItems().add( new MenuItem().setAction( "VOICE_CALL" ) );
    ti.getMenuItems().add( new MenuItem().setAction( "NAVIGATE" ) );
    
    // only if we have a restaurant website
    // addMenuItem(ti, "VIEW_WEBSITE");
  }

  // It's good form to make DELETE the last item
  ti.getMenuItems().add( new MenuItem().setAction( "DELETE" ) );
}
 
开发者ID:coderoshi,项目名称:glass,代码行数:54,代码来源:LunchRoulette.java


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