本文整理汇总了Java中com.google.api.services.mirror.Mirror类的典型用法代码示例。如果您正苦于以下问题:Java Mirror类的具体用法?Java Mirror怎么用?Java Mirror使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Mirror类属于com.google.api.services.mirror包,在下文中一共展示了Mirror类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: 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:mimming,项目名称:kitty-compass,代码行数:11,代码来源:MirrorClient.java
示例17: getContact
import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
public Contact getContact(String id) throws IOException {
try {
Mirror.Contacts contacts = getMirror().contacts();
return contacts.get(id).execute();
} catch (GoogleJsonResponseException e) {
logger.warn("Could not find contact with ID " + id);
return null;
}
}
开发者ID:eteration,项目名称:glassmaker,代码行数:10,代码来源:MirrorTemplate.java
示例18: getAttachmentInputStream
import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
public InputStream getAttachmentInputStream(String timelineItemId, String attachmentId) throws IOException {
Mirror mirrorService = getMirror();
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:eteration,项目名称:glassmaker,代码行数:8,代码来源:MirrorTemplate.java
示例19: doGet
import com.google.api.services.mirror.Mirror; //导入依赖的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
示例20: insertRandomRestaurantTimelineItem
import com.google.api.services.mirror.Mirror; //导入依赖的package包/类
public static void insertRandomRestaurantTimelineItem( ServletContext ctx, String userId )
throws IOException, ServletException
{
Mirror mirror = MirrorUtils.getMirror( userId );
// START:location
Location location = mirror.locations().get("latest").execute();
double latitude = location.getLatitude();
double longitude = location.getLongitude();
// END:location
// 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
// START:altMenuValues
// Set up two menu values for DEFAULT and PENDING
List<MenuValue> menuValues = new ArrayList<MenuValue>(2);
menuValues.add( new MenuValue()
.setState( "DEFAULT" )
.setDisplayName( "Alternative" ) );
menuValues.add( new MenuValue()
.setState( "PENDING" )
.setDisplayName( "Generating Alternative" ) );
// Add new CUSTOM menu item
timelineItem.getMenuItems().add( new MenuItem()
.setAction( "CUSTOM" )
.setValues( menuValues )
);
// END:altMenuValues
timelineItem.getMenuItems().add(
new MenuItem().setAction( "DELETE" )
);
mirror.timeline().insert( timelineItem ).execute();
}
开发者ID:coderoshi,项目名称:glass,代码行数:55,代码来源:LunchRoulette.java
注:本文中的com.google.api.services.mirror.Mirror类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论