I want to have a listener when a message is opened from the application messages folder. For this I make use of ApplicationMenuItem, but after registering it, the message could not be opened anymore.
ApplicationMessageFolderRegistry messagefolderRegistry = ApplicationMessageFolderRegistry.getInstance();
messaageMenuItemListener = new CVSMessaageMenuItemListener();
CVSApplicationMenuItem menuItem = new CVSApplicationMenuItem();
menuItem.registerMenuItemListener(messaageMenuItemListener);
messagefolderRegistry.registerMessageMenuItems(CVSApplicationMessage.TYPE_ALARMS, ApplicationMessage.Status.UNOPENED, new ApplicationMenuItem[]{menuItem});
messagefolderRegistry.registerMessageIcon(CVSApplicationMessage.TYPE_ALARMS, ApplicationMessage.Status.UNOPENED, alarmsIcon);
and the menuItem:
public class CVSApplicationMenuItem extends ApplicationMenuItem {
private CVSVector listeners;
CVSApplicationMenuItem(){
super(20);
}
public Object run(Object context) {
if(!(context instanceof CVSApplicationMessage))
return context;
CVSApplicationMessage applicationMessage = (CVSApplicationMessage)context;
if(listeners == null)
return context;
for (int i = 0; i < listeners.size(); i++) {
((ICVSApplicationMessageMenuItemListener)listeners.itemAt(i)).messageReaded(applicationMessage);
}
return context;
}
public void registerMenuItemListener(ICVSApplicationMessageMenuItemListener l){
if(listeners == null)
listeners = new CVSVector();
if(l != null)
listeners.addItem(l);
}
public String toString() {
return null;
}
}
I can see the message in the messages list (opened from home notification icon), but cannot open it. If I do the following it works, but then I have no callback when the message it's opened:
//messagefolderRegistry.registerMessageMenuItems(CVSApplicationMessage.TYPE_ALARMS, ApplicationMessage.Status.UNOPENED, new ApplicationMenuItem[]{menuItem});