}
Dialog.alert("Unread message was added to inbox");
// Notify folder
final ApplicationMessageFolder inboxFolder =
messageStore.getInboxFolder();
inboxFolder.fireElementAdded(message, true);
}
}));
mainScreen.addMenuItem(appendUnreadMessage);
final MenuItemWithIcon appendOpenedMessage =
new MenuItemWithIcon("Append Opened Message", 1,
"img/sm_add_message.png");
appendOpenedMessage.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
// Create a new message
final DemoMessage message = new DemoMessage();
message.setSender("Maria Rosevelt");
message.setSubject("How have you been?");
message.setMessage("Hi Chris. I haven't seen you in ages. Let's do lunch!");
message.setReceivedTime(System.currentTimeMillis() - 2 * 24
* 60 * 60 * 1000L);
message.setPreviewPicture(CommunicationSimulatorThread
.getRandomPhotoImage());
message.markRead();
// Store message
final MessageListDemoStore messageStore =
MessageListDemoStore.getInstance();
synchronized (messageStore) {
messageStore.addInboxMessage(message);
}
Dialog.alert("Opened message was added to inbox");
// Notify folder
messageStore.getInboxFolder().fireElementAdded(message);
}
}));
mainScreen.addMenuItem(appendOpenedMessage);
final MenuItemWithIcon appendMessagesInBulk =
new MenuItemWithIcon("Append Messages in Bulk", 2,
"sm_add_messages_bulk");
appendMessagesInBulk.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
final MessageListDemoStore messageStore =
MessageListDemoStore.getInstance();
synchronized (messageStore) {
for (int i = 1; i <= MAX_MSGS; i++) {
// Create a new message
final DemoMessage message = new DemoMessage();
message.setSender("Mark Duval");
message.setSubject(i + " of " + MAX_MSGS);
message.setMessage("Please pick up milk and bread on the way home.");
message.setReceivedTime(System.currentTimeMillis());
message.setPreviewPicture(CommunicationSimulatorThread
.getRandomPhotoImage());
// Store message in the runtime store
messageStore.addInboxMessage(message);
}
// Notify folder
final ApplicationMessageFolder inboxFolder =
messageStore.getInboxFolder();
inboxFolder.fireReset(true);
}
Dialog.alert("Bulk messages were added to inbox");
}
}));