Exemple #1
1
  public void startApp() {
    // Create Record Store
    try {
      rs = RecordStore.openRecordStore("myrs", true);
    } catch (RecordStoreException e) {
    }

    dsp = Display.getDisplay(this);
    listMenu.setCommandListener(this);
    listMenu.addCommand(cmdExit);
    dsp.setCurrent(listMenu);
  }
 // #ifdef includeSorting
 // [EF] Added in the scenario 02
 private void incrementCountViews(String selectedImageName) {
   try {
     MediaData image = getAlbumData().getMediaInfo(selectedImageName);
     image.increaseNumberOfViews();
     updateMedia(image);
     System.out.println(
         "<* BaseController.handleCommand() *> Image = "
             + selectedImageName
             + "; # views = "
             + image.getNumberOfViews());
   } catch (ImageNotFoundException e) {
     Alert alert =
         new Alert(
             "Error",
             "The selected photo was not found in the mobile device",
             null,
             AlertType.ERROR);
     Display.getDisplay(midlet).setCurrent(alert, Display.getDisplay(midlet).getCurrent());
   } catch (InvalidImageDataException e) {
     Alert alert = new Alert("Error", "The image data is not valid", null, AlertType.ERROR);
     alert.setTimeout(5000);
   } catch (PersistenceMechanismException e) {
     Alert alert =
         new Alert(
             "Error", "It was not possible to recovery the selected image", null, AlertType.ERROR);
     alert.setTimeout(5000);
   }
 }
 public void commandAction(Command c, Displayable d) {
   if (c == backCmd) {
     display = Display.getDisplay(midlet);
     display.setCurrent(query);
   } else if (c == saveCmd) {
     display = Display.getDisplay(midlet);
     display.setCurrent(query);
     // save();
   }
 }
Exemple #4
0
  public WMouseXP() {
    curInstance = this;

    if (checBTAPISupport()) {
      maincanvas = new MainCanvas(false);
      Display.getDisplay(this).setCurrent(maincanvas);
    } else {
      Display.getDisplay(this).setCurrent(get_NoBTAPIForm());
    }
  }
  // #ifdef includePhoto
  // [NC] Added in the scenario 07
  public void showImage(String name) {
    // [EF] Instead of replicating this code, I change to use the method "getSelectedImageName()".
    Image storedImage = null;
    try {
      storedImage =
          ((ImageAlbumData) getAlbumData()).getImageFromRecordStore(getCurrentStoreName(), name);
    } catch (ImageNotFoundException e) {
      Alert alert =
          new Alert(
              "Error",
              "The selected photo was not found in the mobile device",
              null,
              AlertType.ERROR);
      Display.getDisplay(midlet).setCurrent(alert, Display.getDisplay(midlet).getCurrent());
      return;
    } catch (PersistenceMechanismException e) {
      Alert alert =
          new Alert("Error", "The mobile database can open this photo", null, AlertType.ERROR);
      Display.getDisplay(midlet).setCurrent(alert, Display.getDisplay(midlet).getCurrent());
      return;
    }

    // We can pass in the image directly here, or just the name/model pair and have it loaded
    PhotoViewScreen canv = new PhotoViewScreen(storedImage);
    canv.setCommandListener(this);
    AbstractController nextcontroller = this;
    // #if includeCopyMedia || includeSmsFeature
    // [NC] Changed in the scenario 07: just the first line below to support generic
    // AbstractController
    PhotoViewController controller =
        new PhotoViewController(
            midlet, getAlbumData(), (AlbumListScreen) getAlbumListScreen(), name);
    controller.setNextController(nextcontroller);
    canv.setCommandListener(controller);
    nextcontroller = controller;
    // #endif

    // #ifdef includeSmsFeature
    /* [NC] Added in scenario 06 */
    // [NC] Changed in the scenario 07: just the first line below to support generic
    // AbstractController
    SmsSenderController smscontroller =
        new SmsSenderController(
            midlet, getAlbumData(), (AlbumListScreen) getAlbumListScreen(), name);
    // this.setNextController(smscontroller);
    smscontroller.setNextController(nextcontroller);
    canv.setCommandListener(smscontroller);
    nextcontroller = smscontroller;
    // #endif

    setCurrentScreen(canv);
  }
Exemple #6
0
 public void startApp() {
   if (mForm == null) {
     mForm = new Form(mAppID);
     mNumberEntry = new TextField("Connect To:", null, 256, TextField.PHONENUMBER);
     try {
       mInitialImage = Image.createImage(DEFAULT_IMAGE);
     } catch (Exception e) {
       System.out.println("start app err");
       e.printStackTrace();
     }
     mColorSquare =
         new ImageItem(null, mInitialImage, ImageItem.LAYOUT_DEFAULT, "waiting for image");
     mForm.append(mNumberEntry);
     mForm.append(mColorSquare);
     mForm.addCommand(mRedCommand);
     mForm.addCommand(mExitCommand);
     mForm.addCommand(mBlueCommand);
     mForm.setCommandListener(this);
   }
   Display.getDisplay(this).setCurrent(mForm);
   try {
     conn = (MessageConnection) Connector.open("mms://:" + mAppID);
     conn.setMessageListener(this);
   } catch (Exception e) {
     System.out.println("" + e);
   }
   if (conn != null) {
     startReceive();
   }
 }
 public void startApp() {
   display = Display.getDisplay(this);
   Form form = new Form("Date Field");
   form.append(datein);
   form.append(dateout);
   display.setCurrent(form);
 }
  /**
   * Starts application and shows the list of samples. The user can select a sample for execution
   * and return to the selection screen.
   */
  public void startApp() {

    M3GCanvas mCanvas = new M3GCanvas();
    mCanvas.addCommand(exitCommand);
    mCanvas.setCommandListener(this);
    Display.getDisplay(this).setCurrent(mCanvas);
  }
  /**
   * We have to provide this method due to "do not do network operation in command listener method"
   * restriction, which is caused by crooked midp design.
   *
   * <p>This method is called by BTImageClient after it is done with bluetooth initialization and
   * next screen is ready to appear.
   */
  void completeInitialization(boolean isBTReady) {
    // bluetooth was initialized successfully.
    if (isBTReady) {
      StringItem si = new StringItem("Ready for images search!", null);
      si.setLayout(StringItem.LAYOUT_CENTER | StringItem.LAYOUT_VCENTER);
      mainScreen.append(si);
      Display.getDisplay(parent).setCurrent(mainScreen);

      return;
    }

    // something wrong
    Alert al = new Alert("Error", "Can't initialize bluetooth", null, AlertType.ERROR);
    al.setTimeout(DemoMIDlet.ALERT_TIMEOUT);
    Display.getDisplay(parent).setCurrent(al, parent.getDisplayable());
  }
Exemple #10
0
 public boolean onOptionsItemSelected(MenuItem item) {
   Displayable d = Display.getDisplay(midlet).getCurrent();
   if (d != null) {
     return d.onOptionsItemSelected(item);
   }
   return super.onOptionsItemSelected(item);
 }
Exemple #11
0
 protected void startApp() throws MIDletStateChangeException {
   if (soletrandoCanvas == null) {
     soletrandoCanvas = new SoletrandoCanvas(this);
     display = Display.getDisplay(this);
     display.setCurrent(soletrandoCanvas);
   }
 }
Exemple #12
0
 /**
  * @see javax.microedition.lcdui.CommandListener#commandAction(javax.microedition.lcdui.Command,
  *     javax.microedition.lcdui.Displayable)
  */
 public void commandAction(Command c, Displayable d) {
   if (c == back) {
     Display.getDisplay(midlet).setCurrent(backScreen);
   } else if (c == select) {
     listTweets();
   }
 }
Exemple #13
0
 public void startApp() {
   this.gameCanvas = new MobileBoard();
   this.t = new Thread(gameCanvas);
   t.start();
   d = Display.getDisplay(this);
   d.setCurrent(gameCanvas);
 }
Exemple #14
0
 public boolean onPrepareOptionsMenu(Menu menu) {
   Displayable d = Display.getDisplay(midlet).getCurrent();
   if (d != null) {
     return d.onPrepareOptionsMenu(menu);
   }
   return false;
 }
Exemple #15
0
  public void startApp() {
    Traces.addLine("Midlet::startApp");

    Displayable current = Display.getDisplay(this).getCurrent();
    if (current == null) {
      this.showListScreen();
    }
  }
Exemple #16
0
 public void commandAction(Command c, Displayable d) {
   try {
     if (c == this.recordScreenCommand) {
       Display.getDisplay(this.midlet).setCurrent(this.midlet.myForm);
     } else if (c == this.meterScreenCommand) {
       Display.getDisplay(this.midlet).setCurrent(this.midlet.myCanvas);
       this.midlet.myCanvas.start();
     } else if (c == this.enableUploadCommand) {
       this.enableUploadCommandCB();
     } else if (c == this.disableUploadCommand) {
       this.disableUploadCommandCB();
     } else if (c == this.exitCommand) {
       this.midlet.notifyDestroyed();
     }
   } catch (RuntimeException e) {
     this.midlet.alertError("commandAction Exception:" + e.getMessage());
   }
 }
Exemple #17
0
 public Help(JBDoc midlet) {
   this.midlet = midlet;
   display = Display.getDisplay(midlet);
   addCommand(gotoCmd);
   addCommand(booksCmd);
   addCommand(aboutCmd);
   addCommand(exitCmd);
   setCommandListener(this);
 }
  // #ifdef includeVideo
  // [NC] Added in the scenario 07
  private boolean playVideoMedia(String selectedMediaName) {
    InputStream storedMusic = null;
    try {
      MediaData mymedia = getAlbumData().getMediaInfo(selectedMediaName);

      // #ifdef includeSorting
      // [EF] Added in the scenario 02
      incrementCountViews(selectedMediaName);
      // #endif
      //			if (mymedia instanceof MultiMediaData) {
      if (mymedia.getTypeMedia().equals(MediaData.VIDEO)) {
        storedMusic =
            ((VideoAlbumData) getAlbumData())
                .getVideoFromRecordStore(getCurrentStoreName(), selectedMediaName);
        PlayVideoScreen playscree =
            new PlayVideoScreen(midlet, storedMusic, mymedia.getTypeMedia(), this);
        playscree.setVisibleVideo();
        PlayVideoController controller =
            new PlayVideoController(
                midlet, getAlbumData(), (AlbumListScreen) getAlbumListScreen(), playscree);
        // #ifdef includeCopyMedia
        // [NC] Added in the scenario 07
        controller.setMediaName(selectedMediaName);
        // #endif

        this.setNextController(controller);
      }
      return true;
    } catch (ImageNotFoundException e) {
      Alert alert =
          new Alert(
              "Error",
              "The selected item was not found in the mobile device",
              null,
              AlertType.ERROR);
      Display.getDisplay(midlet).setCurrent(alert, Display.getDisplay(midlet).getCurrent());
      return false;
    } catch (PersistenceMechanismException e) {
      Alert alert =
          new Alert("Error", "The mobile database can open this item 1", null, AlertType.ERROR);
      Display.getDisplay(midlet).setCurrent(alert, Display.getDisplay(midlet).getCurrent());
      return false;
    }
  }
 /** Shows the downloaded image. */
 void showImage(Image img, String imgName) {
   imageScreen.deleteAll();
   imageScreen.append(
       new ImageItem(
           imgName,
           img,
           ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_VCENTER,
           "Downloaded image: " + imgName));
   Display.getDisplay(parent).setCurrent(imageScreen);
 }
Exemple #20
0
  public void startApp() {
    // Don't request the foreground on the first startApp call.
    if (!firstStart) {
      Alert a = new Alert("MIDlet 1");
      a.setTimeout(Alert.FOREVER);
      Display.getDisplay(this).setCurrent(a);
    }

    firstStart = false;
  }
Exemple #21
0
 protected void startApp() throws MIDletStateChangeException {
   this.display = Display.getDisplay(this);
   try {
     demoInactiveTableElements();
   } catch (Exception e) {
     // #debug error
     System.out.println("Unable to initialize table completely");
   }
   this.display.setCurrent(this.form);
 }
Exemple #22
0
 public boolean onKeyUp(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) {
     Displayable d = Display.getDisplay(midlet).getCurrent();
     if (d != null && d instanceof Canvas) {
       ((Canvas) d).fakeKeyReleased(keyCode);
       return true;
     }
   }
   return super.onKeyUp(keyCode, event);
 }
Exemple #23
0
 public void commandAction(Command command, Displayable disp) {
   // TODO Auto-generated method stub
   if (command == home) {
     mDisplay.setCurrent(mCanvas);
   } else if (command == videos) {
     VideoAlbum mVideos = new VideoAlbum(this);
   } else if (command == backCommand) {
     Display.getDisplay(this).setCurrent(mCanvas);
   } else if (command == mPbackCommand) {
     Display.getDisplay(this).setCurrent(mCanvas);
   } else if (command == photos) {
     PhotoAlbums mPhotos = new PhotoAlbums(this);
   } else if (command == team) {
     Teams mTeams = new Teams(this);
   } else if (command == ownerlounge) {
     OwnersLounge lounge = new OwnersLounge(this);
   } else if (command == schedule) {
     Schedule schedule = new Schedule(this);
   }
 }
Exemple #24
0
  public Triade() {
    this.canvas = GameDisplay.getInstance();
    this.canvas.setFullScreenMode(true);
    this.engine = new Engine(this.canvas);

    this.display = Display.getDisplay(this);

    this.canvas.addCommand(Commands.exitCommand);
    this.canvas.addCommand(Commands.menuCommand);
    this.canvas.setCommandListener(this);
  }
Exemple #25
0
  /**
   * Create and initialize a new discovery application MIDlet. The saved URL is retrieved and the
   * list of MIDlets are retrieved.
   */
  public DiscoveryApp() {
    String storageName;

    display = Display.getDisplay(this);

    GraphicalInstaller.initSettings();
    restoreSettings();

    // get the URL of a list of suites to install
    getUrl();
  }
Exemple #26
0
 public CCL() {
   // Initialization
   mDisplay = Display.getDisplay(this);
   photos = new Command("PHOTOS", Command.SCREEN, 1);
   mList = new List("Photos album", List.EXCLUSIVE);
   team = new Command("TEAMS", Command.SCREEN, 1);
   backCommand = new Command("Back", Command.EXIT, 2);
   videos = new Command("VIDEOS", Command.SCREEN, 1);
   schedule = new Command("SCHEDULE", Command.SCREEN, 1);
   ownerlounge = new Command("OWNER'S LOUNGE", Command.SCREEN, 1);
   home = new Command("HOME", Command.SCREEN, 1);
 }
Exemple #27
0
 public void show() {
   Display.getDisplay(midlet).setCurrent(listUI);
   //
   new Thread() {
     public void run() {
       fetchLists();
     };
   }.start();
   //
   Tracker tracker = Tracker.getInstance("UA-3518295-5");
   tracker.addToQueue(new PageView("Lists3", "lists32.html"));
 }
 public void startApp() {
   display = Display.getDisplay(this);
   try {
     form.append(img);
   } catch (Exception e) {
   }
   form.append(userName);
   form.append(password);
   form.addCommand(cancel);
   form.addCommand(login);
   form.setCommandListener(this);
   display.setCurrent(form);
 }
Exemple #29
0
 /**
  * Creates an alert message on the phone.
  *
  * @param message The message to display.
  */
 public void alertError(String message) {
   Alert alert = new Alert("Alert", message, null, AlertType.CONFIRMATION);
   Display display = Display.getDisplay(this.midlet);
   Displayable current = display.getCurrent();
   if (!(current instanceof Alert)) {
     // This next call can't be done when current is an Alert
     display.setCurrent(alert, current);
   }
   try {
     Thread.sleep(2000);
   } catch (InterruptedException e) {
     e.printStackTrace();
   }
 }
Exemple #30
0
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK) {
     Displayable d = Display.getDisplay(midlet).getCurrent();
     if (d != null) {
       if (d instanceof Canvas) {
         ((Canvas) d).fakeKeyPressed(keyCode);
         return true;
       }
       Command c = d.getBackCommand();
       CommandListener cl = d.getCommandListener();
       if (c != null && cl != null) {
         cl.commandAction(c, d);
         return true;
       }
     }
   } else if (keyCode == KeyEvent.KEYCODE_MENU) {
     Displayable d = Display.getDisplay(midlet).getCurrent();
     if (d != null && d instanceof Canvas) {
       ((Canvas) d).fakeKeyPressed(keyCode);
       return true;
     }
   }
   return super.onKeyDown(keyCode, event);
 }