📄 smartticket.java
字号:
/* * Copyright 1999-2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * - Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * This software is provided "AS IS," without a warranty of any * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * * You acknowledge that Software is not designed, licensed or intended * for use in the design, construction, operation or maintenance of * any nuclear facility. */package st;import javax.microedition.midlet.*;import javax.microedition.lcdui.*;import javax.microedition.rms.*;import java.io.*;import java.util.Hashtable;import shared.MessageConstants;/** * Main application. */public class SmartTicket extends MIDlet implements CommandListener { Session session; static String[] msgTab; String servlet; String posterURL; String locale; String splashURL; Display display; GaugeForm gaugeForm; ImageCanvas splashCanvas; AccountForm accountForm; Form signedInForm; MovieList movieList; ImageCanvas posterCanvas; LocationList locationList; ShowtimeList showtimeList; SeatingCanvas seatingCanvas; ConfirmForm confirmForm; LocaleList localeList; Alert alertScreen; Displayable nextScreen; Displayable previousScreen; Command backCmd; Command cancelCmd; Command confirmCmd; Command nextCmd; Command reserveCmd; Command saveCmd; Command signInCmd; Command startCmd; Command localeCmd; /* Overridden methods. */ public void startApp() { session = new Session(this); session.open(); servlet = getBaseServletURL(); posterURL = getAppProperty("SMARTicket-Poster-URL"); locale = getAppProperty("SMARTicket-Locale"); if (msgTab == null) { initMsg(); } backCmd = new Command(getMsg(MessageConstants.BACK), Command.BACK, 10); cancelCmd = new Command(getMsg(MessageConstants.CANCEL), Command.CANCEL, 10); confirmCmd = new Command(getMsg(MessageConstants.CONFIRM), Command.SCREEN, 5); nextCmd = new Command(getMsg(MessageConstants.NEXT), Command.SCREEN, 5); reserveCmd = new Command(getMsg(MessageConstants.RESERVE), Command.SCREEN, 5); saveCmd = new Command(getMsg(MessageConstants.SAVE), Command.SCREEN, 5); signInCmd = new Command(getMsg(MessageConstants.SIGN_IN), Command.SCREEN, 5); startCmd = new Command(getMsg(MessageConstants.START), Command.SCREEN, 5); localeCmd = new Command(getMsg(MessageConstants.LOCALE), Command.SCREEN, 5); display = Display.getDisplay(this); Image i = null; try { i = Image.createImage("/st/icons/smarticket.png"); } catch (IOException e) { } splashCanvas = new ImageCanvas(i); splashCanvas.addCommand(localeCmd); splashCanvas.addCommand(signInCmd); splashCanvas.setCommandListener(this); localeList = new LocaleList(locale); localeList.addCommand(nextCmd); localeList.addCommand(backCmd); localeList.setCommandListener(this); signedInForm = new Form(getMsg(MessageConstants.SMART_TICKET)); StringItem signedInMessage = new StringItem(null, getMsg(MessageConstants.SIGNED_IN)); signedInForm.append(signedInMessage); signedInForm.addCommand(startCmd); signedInForm.setCommandListener(this); accountForm = new AccountForm(); accountForm.addCommand(cancelCmd); accountForm.addCommand(saveCmd); accountForm.setCommandListener(this); movieList = new MovieList(); movieList.addCommand(backCmd); movieList.addCommand(nextCmd); movieList.setCommandListener(this); posterCanvas = new ImageCanvas(); posterCanvas.addCommand(backCmd); posterCanvas.addCommand(nextCmd); posterCanvas.setCommandListener(this); locationList = new LocationList(); locationList.addCommand(backCmd); locationList.addCommand(nextCmd); locationList.setCommandListener(this); showtimeList = new ShowtimeList(); showtimeList.addCommand(backCmd); showtimeList.addCommand(nextCmd); showtimeList.setCommandListener(this); seatingCanvas = new SeatingCanvas(display, reserveCmd); seatingCanvas.addCommand(cancelCmd); seatingCanvas.addCommand(reserveCmd); seatingCanvas.setCommandListener(this); confirmForm = new ConfirmForm(); confirmForm.addCommand(cancelCmd); confirmForm.addCommand(confirmCmd); confirmForm.setCommandListener(this); gaugeForm = new GaugeForm("", false); display.setCurrent(splashCanvas); } public void pauseApp() { session.close(); } public void destroyApp(boolean unconditional) { session.close(); } public void commandAction(Command c, Displayable d) { if (d == splashCanvas) { if (c == localeCmd) { // retrieve the list of supported locales session.message = MessageConstants.DISPLAY_LOCALES; nextScreen = localeList; previousScreen = splashCanvas; startLoading(true, getMsg(MessageConstants.LOADING_LOCALES)); } else { if (session.isNewUser()) { Alert a = createAlert(getMsg(MessageConstants.NO_ACCOUNT)); display.setCurrent(a, accountForm); return; } session.message = MessageConstants.LOGIN_USER; nextScreen = signedInForm; previousScreen = splashCanvas; startLoading(false, getMsg(MessageConstants.SIGNING_IN)); } } else if (d == localeList) { if (c == nextCmd) { session.message = MessageConstants.LOAD_MESSAGES; nextScreen = splashCanvas; previousScreen = splashCanvas; alertScreen = createAlert(getMsg(MessageConstants.LOCALE_CHANGED)); startLoading(false, getMsg(MessageConstants.MESSAGES)); } else { display.setCurrent(splashCanvas); return; } } else if (d == signedInForm) { session.message = MessageConstants.DISPLAY_MOVIES; nextScreen = movieList; previousScreen = signedInForm;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -