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


Java Mirror类代码示例

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


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

示例1: insertMultiHtmlTimelineItem

import com.google.api.services.mirror.Mirror; //导入依赖的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.Mirror; //导入依赖的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.Mirror; //导入依赖的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: addAppAsContact

import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
public static void addAppAsContact( HttpServletRequest req, String userId )
    throws IOException
{
  Mirror mirror = MirrorUtils.getMirror(req);
  Contacts contacts = mirror.contacts();

  Contact contact = new Contact()
    .setId( "lunch-roulette" )
    .setDisplayName( "Lunch Roulette" )
    .setImageUrls( Collections.singletonList( 
        PROD_BASE_URL + "/static/images/roulette.png" ) )
    .setPriority( 0L )
    .setAcceptTypes( Collections.singletonList( "image/*" ) );
  
  contacts.insert( contact ).executeAndDownloadTo( System.out );
}
 
开发者ID:coderoshi,项目名称:glass,代码行数:17,代码来源:LunchRoulette.java

示例5: previewOnGlass

import com.google.api.services.mirror.Mirror; //导入依赖的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

示例6: getMirror

import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
private Mirror getMirror(HttpServletRequest req) throws IOException{
	Credential credential = AuthUtil.getCredential(req);

	// build access to Mirror API
	return new Mirror.Builder(
			new UrlFetchTransport(), new JacksonFactory(), credential)
				.setApplicationName("Hello World").build();
}
 
开发者ID:ipool,项目名称:GlassPool,代码行数:9,代码来源:IpoolAPIClient.java

示例7: getMirror

import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
public static Mirror getMirror( HttpServletRequest req )
    throws IOException
{
  String userId = SessionUtils.getUserId( req );
  Credential credential = AuthUtils.getCredential(userId);
  return getMirror(credential);
}
 
开发者ID:coderoshi,项目名称:glass,代码行数:8,代码来源:MirrorUtils.java

示例8: insertSimpleTextTimelineItem

import com.google.api.services.mirror.Mirror; //导入依赖的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.Mirror; //导入依赖的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: buildRandomRestaurantTimelineItem

import com.google.api.services.mirror.Mirror; //导入依赖的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

示例11: pushPost

import com.google.api.services.mirror.Mirror; //导入依赖的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

示例12: getContact

import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
public static Contact getContact(Credential credential, String id) throws IOException {
	try {
		Mirror.Contacts contacts = getMirror(credential).contacts();
		return contacts.get(id).execute();
	} catch (GoogleJsonResponseException e) {
		LOG.warning("Could not find contact with ID " + id);
		return null;
	}
}
 
开发者ID:jwilsoncredera,项目名称:spring-boot-glass,代码行数:10,代码来源:MirrorClient.java

示例13: getAttachmentInputStream

import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
public static InputStream getAttachmentInputStream(Credential credential, String timelineItemId, String attachmentId)
		throws IOException {
	Mirror mirrorService = getMirror(credential);
	Mirror.Timeline.Attachments attachments = mirrorService.timeline().attachments();
	Attachment attachmentMetadata = attachments.get(timelineItemId, attachmentId).execute();
	HttpResponse resp = mirrorService.getRequestFactory().buildGetRequest(new GenericUrl(attachmentMetadata.getContentUrl())).execute();
	return resp.getContent();
}
 
开发者ID:jwilsoncredera,项目名称:spring-boot-glass,代码行数:9,代码来源:MirrorClient.java

示例14: getContact

import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
public static Contact getContact(Credential credential, String id) throws IOException {
  try {
    Mirror.Contacts contacts = getMirror(credential).contacts();
    return contacts.get(id).execute();
  } catch (GoogleJsonResponseException e) {
    LOG.warning("Could not find contact with ID " + id);
    return null;
  }
}
 
开发者ID:mimming,项目名称:kitty-compass,代码行数:10,代码来源:MirrorClient.java

示例15: listItems

import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
public static TimelineListResponse listItems(Credential credential, long count)
    throws IOException {
  Mirror.Timeline timelineItems = getMirror(credential).timeline();
  Mirror.Timeline.List list = timelineItems.list();
  list.setMaxResults(count);
  return list.execute();
}
 
开发者ID:mimming,项目名称:kitty-compass,代码行数:8,代码来源:MirrorClient.java


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