【发布时间】: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