首先没有显示Bundle Cover

时间:2013-10-27 22:41:38

标签: google-mirror-api google-glass

我有一张带有时间线卡的套装。我想成为封面的主时间轴卡被设置为封面(isBundleCover = true)。然而,当插入卡并且用户点击以查看或查看以激活显示器时,首先显示内部包卡(不是封面)。有没有办法首先显示封面?这是否符合预期?我已经尝试改变插入的卡的顺序,并没有什么区别。

            Credential credential = AuthUtil.getCredential(id);
            Mirror service = MirrorClient.getMirror(credential);

            boolean newNotification = false;
            TimelineItem timelineItem = null;
            TimelineItem notesTimelineItem = null;
            List<TimelineItem> oldCards = null;
                oldCards = service.timeline().list()
                        .setBundleId(String.valueOf(call.getId()))
                        .execute().getItems();


            if (oldCards != null)

            if (oldCards.size() < 1) {

                timelineItem = new TimelineItem();
                notesTimelineItem = new TimelineItem();
                timelineItem.setId(String.valueOf(call.getId()));
                timelineItem.setBundleId(String.valueOf(call.getId()));
                notesTimelineItem.setBundleId(String.valueOf(call.getId()));
                timelineItem.setIsBundleCover(true);
                newNotification = true;
                timelineItem.setHtml(TimeLineHTMLFactory.getDispatchCard(               call.getType(), call.getAddress(), call.getUnits(),String.valueOf(call.getLat() / 1E6), String.valueOf(call.getLongi() / 1E6)));
                if (call.getNotes().contentEquals("")) {
                    notesTimelineItem.setText("Notes not available");
                } else {
                    notesTimelineItem.setText(call.getNotes());
                    notesTimelineItem.setTitle("Notes");
                }
                notesTimelineItem.setSourceItemId("notes");
                Location incident = new Location();
                incident.setLatitude(call.getLat() / 1E6);

                incident.setLongitude(call.getLongi() / 1E6);
                notesTimelineItem.setLocation(incident);
                List<MenuItem> menuItemList = new ArrayList<MenuItem>();

                menuItemList.add(new MenuItem().setAction("NAVIGATE"));
                menuItemList.add(new MenuItem().setAction("TOGGLE_PINNED"));

                notesTimelineItem.setMenuItems(menuItemList);
            } else {
                for (int i = 0; i < oldCards.size(); ++i) {
                    log.log(Level.WARNING, "updating oldCard: "
                            + oldCards.get(i).getId());
                    log.log(Level.WARNING,"sourceItemId: "+oldCards.get(i).getSourceItemId());
                    boolean isCover=false;
                    try{
                        isCover=oldCards.get(i).getIsBundleCover();
                    }catch(Exception e){
                        log.log(Level.WARNING,"Exception getting isBundleCover: "+e.getMessage());
                    }
                    if (isCover) {
                        // MAIN DISPATCH CARD

                        oldCards.get(i)
                                .setHtml(
                                        TimeLineHTMLFactory.getDispatchCard(
                                                call.getType(), call
                                                        .getAddress(), call
                                                        .getUnits(),
                                                String.valueOf(call
                                                        .getLat() / 1E6),
                                                String.valueOf(call
                                                        .getLongi() / 1E6)));

                    } else if (oldCards.get(i).getSourceItemId()
                            .contains("notes")) {

                        if (call.getNotes().contentEquals("")) {
                            oldCards.get(i).setText("Notes not available");
                        } else {
                            oldCards.get(i).setText(call.getNotes());

                        }
                        oldCards.get(i).setTitle("Notes");
                        Location incident = new Location();
                        incident.setLatitude(call.getLat() / 1E6);
                        incident.setLongitude(call.getLongi() / 1E6);

                        if(incident!=null){
                        oldCards.get(i).setLocation(incident);
                        }
                        List<MenuItem> menuItemList = new ArrayList<MenuItem>();

                        menuItemList.add(new MenuItem()
                                .setAction("NAVIGATE"));
                        menuItemList.add(new MenuItem()
                                .setAction("TOGGLE_PINNED"));

                        oldCards.get(i).setMenuItems(menuItemList);
                    }
                }
            }

                if (oldCards.size() > 0) {
                    for (TimelineItem card : oldCards) {

                        log.log(Level.WARNING,
                                "oldCard id: " + card.getId()
                                        + " bundleid: "
                                        + card.getBundleId());
                        service.timeline().update(card.getId(), card)
                                .execute();
                    }
                } else {
                log.log(Level.INFO, "New notification here");
    timelineItem.setNotification(new NotificationConfig().setLevel("DEFAULT"));
    MirrorClient.insertTimelineItem(credential, notesTimelineItem);
    MirrorClient.insertTimelineItem(credential, timelineItem);
}

封面卡的JSON:

  

{     “kind”:“镜像#timelineItem”,     “id”:“710a9f44-92e7-463e-801d-940b59aebb8e”,     “bundleId”:“5808701407494144”,     “isBundleCover”:是的,     “创造”:“2013-10-28T13:30:19.160Z”,     “更新”:“2013-10-28T13:30:19.160Z”,     “etag”:“1382967019160”,     “html”:“\ n \ n \ n \ n \ n \ n \ n EMS \ n \ n 741 PARK AVE \ n \ n

\ n \ n \ n“,     “通知”:{       “级别”:“默认”     }   }

Notes Card的JSON:

{
  "kind": "mirror#timelineItem",
  "id": "cfd7173f-4757-4e2e-9f2e-fbcbba2c0e99",
  "bundleId": "5948571312455680",
  "created": "2013-10-28T13:30:09.904Z",
  "updated": "2013-10-28T13:30:09.904Z",
  "etag": "1382967009904",
  "title": "Notes",
  "text": "Notes go in here...",
  "location": {
  "kind": "mirror#location",
  "latitude": 37.922223,
  "longitude": -87.805731
},
  "menuItems": [
{
  "action": "NAVIGATE"
},
{
    "action": "TOGGLE_PINNED"
}
]
}

3 个答案:

答案 0 :(得分:0)

我认为你已经到了一半,我会在最后添加捆绑封面,然后是theBundleCover = True。

见下文。

要捆绑时间轴项目,请使用bundleId的相同值创建它们。最近添加的项目是捆绑的封面卡。

注意:要将特定时间轴项目设置为捆绑封面卡,请将其isBundleCover属性设置为true。

答案 1 :(得分:0)

出现这个错误。在跟踪器上创建票证:

https://code.google.com/p/google-glass-api/issues/detail?id=233

答案 2 :(得分:0)

这是预期的行为。插入捆绑包时,您将在捆绑包中显示最近插入的卡片。

如果您想要显示一组卡片,请考虑使用HTML Pagination。您对卡的标记可能如下所示:

<article class="cover-only">
 <section>
   <p>Cover page</p>
 </section>
</article>

<article>
 <section>
   <p>Second page</p>
 </section>
</article>

<article>
 <section>
   <p>Third page</p>
 </section>
</article>