1

I have a bundle with a timeline card inside. The main timeline card which I want to be the cover is set to be the cover(isBundleCover=true). However when the cards are inserted and the user taps to see or looks up to activate the display the inner bundle card(not cover) is shown first. Is there a way to show the cover first? Is this acting as intended? I've tried changing the order of cards inserted and did not make a difference.

            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 for Cover card:

{ "kind": "mirror#timelineItem", "id": "710a9f44-92e7-463e-801d-940b59aebb8e", "bundleId": "5808701407494144", "isBundleCover": true, "created": "2013-10-28T13:30:19.160Z", "updated": "2013-10-28T13:30:19.160Z", "etag": "1382967019160", "html": "\n \n \n\n \n \n \n E M S\n \n741 PARK AVE\n\n

\n \n\n", "notification": { "level": "DEFAULT" } }

JSON for Notes Card:

{
  "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"
}
]
}
4

3 回答 3

0

看来这是一个错误。在跟踪器上创建工单:

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

于 2013-10-30T18:06:46.080 回答
0

这是预期的行为。插入捆绑包后,您将看到捆绑包中最近插入的卡。

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

<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>
于 2013-11-05T21:56:38.607 回答
0

我想你已经完成了一半,我会最后添加捆绑包封面,然后是 isBundleCover=True。

见下文。

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

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

于 2013-10-28T01:46:13.680 回答