/* * Copyright © 2013 Nokia Corporation. All rights reserved. Nokia and Nokia * Connecting People are registered trademarks of Nokia Corporation. Oracle and * Java are trademarks or registered trademarks of Oracle and/or its affiliates. * Other product and company names mentioned herein may be trademarks or trade * names of their respective owners. See LICENSE.TXT for license information. */ package com.nokia.example.satsa; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.List; // Main UI screen showing the list of available messages class ListScreen extends List implements CommandListener { private final SATSAMIDlet midlet; private final Command commandExit = new Command("Exit", Command.EXIT, 1); private final Command commandNew = new Command("Create new", Command.SCREEN, 1); // changed from ITEM type ListScreen(SATSAMIDlet midlet) { super("Messages", List.IMPLICIT); this.midlet = midlet; createList(); } public void commandAction(Command c, Displayable d) { if (c == commandExit) { midlet.exitMIDlet(); } else if (c == commandNew) { midlet.showNewMessage(); } else if(this.getSelectedIndex()>-1) { midlet.showEncryptedMessage(getSelectedIndex()); } } void setNumber(int number) { deleteAll(); for (int i = 1; i <= number; i++) { append("Message " + i, null); } } private void createList() { addCommand(commandExit); addCommand(commandNew); setCommandListener(this); } }