【问题标题】:Bundle Cover not shown when first第一次时未显示捆绑包封面
【发布时间】:2013-11-06 05:56:38
【问题描述】:

我有一个包含时间线卡的捆绑包。我想成为封面的主时间线卡设置为封面(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": "mirror#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 E M S\n \n公园大道741号\n\n

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

备注卡的 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"
}
]
}

【问题讨论】:

  • 你能发布一些示例代码来说明问题吗?
  • 您介意发布捆绑包中所有时间线项目的代码或 JSON 吗?
  • 只是为了澄清一下,如果用户在时间线中滚动到卡片,它会按预期工作。但是,如果用户抬头或点击查看新通知,则会显示内部捆绑卡(便笺卡)。
  • 同时你在这里@JennyMurphy - getIsBundleCover() 将返回 null 如果该值未设置。这就是为什么我有异常处理。如果需要,我会在问题跟踪器上创建一个条目。

标签: google-mirror-api google-glass


【解决方案1】:

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

见下文。

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

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

【讨论】:

  • 我最后添加了捆绑包封面并设置了 isBundleCover=true。还是先显示内卡。
  • 我想你发现了一个错误!恭喜!我可以用捆绑的卡片 100% 重新创建。
  • 好像是这样!在此处创建错误:code.google.com/p/google-glass-api/issues/…
【解决方案2】:

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

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

【讨论】:

    【解决方案3】:

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

    如果您想显示一组卡片,请考虑改用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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-28
      • 2015-05-24
      • 2013-06-24
      • 1970-01-01
      • 1970-01-01
      • 2019-12-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多