1 package ubc.midp.mobilephoto.core.ui;
2
3 import javax.microedition.midlet.MIDlet;
4 import javax.microedition.midlet.MIDletStateChangeException;
5
6 import ubc.midp.mobilephoto.core.ui.controller.AlbumController;
7 import ubc.midp.mobilephoto.core.ui.controller.BaseController;
8 import ubc.midp.mobilephoto.core.ui.controller.PhotoListController;
9 import ubc.midp.mobilephoto.core.ui.datamodel.AlbumData;
10 import ubc.midp.mobilephoto.core.ui.screens.AlbumListScreen;
11
12 import ubc.midp.mobilephoto.sms.SmsReceiverController;
13 import ubc.midp.mobilephoto.sms.SmsReceiverThread;
14
15 //Following are pre-processor statements to include the required
16 //classes for device specific features. They must be commented out
17 //if they aren't used, otherwise it will throw exceptions trying to
18 //load classes that aren't available for a given platform.
19
20
21 /*
22 * @author trevor
23 *
24 * This is the main Midlet class for the core J2ME application
25 * It contains all the basic functionality that should be executable
26 * in any standard J2ME device that supports MIDP 1.0 or higher.
27 * Any additional J2ME features for this application that are dependent
28 * upon a particular device (ie. optional or proprietary library) are
29 * de-coupled from the core application so they can be conditionally included
30 * depending on the target platform
31 *
32 * This Application provides a basic Photo Album interface that allows a user to view
33 * images on their mobile device.
34 * */
35 public class MainUIMidlet extends MIDlet {
36
37 //(m v C) Controller
38 private BaseController rootController;
39
40 //Model (M v c)
41 private AlbumData model;
42
43 /**
44 * Constructor -
45 */
46 public MainUIMidlet() {
47 //do nothing
48 }
49
50 /**
51 * Start the MIDlet by creating new model and controller classes, and
52 * initialize them as necessary
53 */
54 public void startApp() throws MIDletStateChangeException {
55 model = new AlbumData();
56 AlbumListScreen album = new AlbumListScreen();
57 rootController = new BaseController(this, model, album);
58
59 PhotoListController photoListController = new PhotoListController(this, model, album);
60 photoListController.setNextController(rootController);
61
62 AlbumController albumController = new AlbumController(this, model, album);
63 albumController.setNextController(photoListController);
64 album.setCommandListener(albumController);
65
66
67
68 SmsReceiverController controller = new SmsReceiverController(this, model, album);
69 controller.setNextController(albumController);
70 SmsReceiverThread smsR = new SmsReceiverThread(this, model, album, controller);
71 System.out.println("SmsController::Starting SMSReceiver Thread");
72 new Thread(smsR).start();
73
74
75 //Only the first (last?) controller needs to be initialized (?)
76 rootController.init(model);
77 }
78
79 /**
80 * Pause the MIDlet
81 * This method does nothing at the moment.
82 */
83 public void pauseApp() {
84 //do nothing
85 }
86
87 /**
88 * Destroy the MIDlet
89 */
90 public void destroyApp(boolean unconditional) {
91 notifyDestroyed();
92 }
93 }
|