Mirror API custom menu and custom properties

五迷三道 提交于 2019-12-12 01:40:05

问题


In my app I have added custom menu items to user timeline items. I am creating the custom menus in iteration. Is there any way to append the custom properties to the custom menu item? , so that I can know which menu item is clicked.

ere is my code for custom menu,

// And custom actions
List<MenuValue> menuValues = new ArrayList<MenuValue>();
menuValues.add(new MenuValue().setIconUrl(WebUtil.buildUrl(req, "/static/images/drill.png")).setDisplayName("Found"));
menuItemList.add(new MenuItem().setValues(menuValues).setId("found").setAction("CUSTOM"));

timelineItem.setMenuItems(menuItemList);
timelineItem.setNotification(new NotificationConfig().setLevel("DEFAULT"));

Thanks in advance.


回答1:


You're already attaching a property to the menu item with the setId() method. The value in the id is ignored by Glass except to send it back to you when this menu item is selected. You can put anything you want here (within reason - there is a limit of a few hundred characters).

So, given your example above, if the menu item is selected, you'd get a notification looking something like this:

{ 
  "collection": "timeline",
  "itemId": "8a84302a-1da7-46f2-ac72-2c008fce2b4b",
  "operation": "UPDATE",
  "userToken": "12345678901234567890",
  "verifyToken": "shibboleet",
  "userActions": [ 
    { 
      "type": "CUSTOM", 
      "payload": "found" 
    }
  ]
}

You would examine the userActions.payload field and take action based on this.



来源:https://stackoverflow.com/questions/24255165/mirror-api-custom-menu-and-custom-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!