mirror of
https://github.com/zxing/zxing.git
synced 2024-11-09 20:44:03 -08:00
"Fire" button now triggers decoding
git-svn-id: https://zxing.googlecode.com/svn/trunk@33 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
b01673fa29
commit
852bd08760
|
@ -23,6 +23,8 @@ import com.google.zxing.common.BlackPointEstimator;
|
|||
import javax.microedition.lcdui.Image;
|
||||
|
||||
/**
|
||||
* <p>An implementation based on Java ME's {@link Image} representation.</p>
|
||||
*
|
||||
* @author Sean Owen (srowen@google.com)
|
||||
*/
|
||||
final class LCDUIImageMonochromeBitmapSource implements MonochromeBitmapSource {
|
||||
|
|
|
@ -40,12 +40,11 @@ import javax.microedition.midlet.MIDletStateChangeException;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* <p>The actual reader application {@link MIDlet}.</p>
|
||||
*
|
||||
* @author Sean Owen (srowen@google.com)
|
||||
*/
|
||||
public final class ZXingMIDlet extends MIDlet implements CommandListener {
|
||||
|
||||
private static final Command DECODE = new Command("Decode", Command.SCREEN, 1);
|
||||
private static final Command EXIT = new Command("Exit", Command.EXIT, 1);
|
||||
public final class ZXingMIDlet extends MIDlet {
|
||||
|
||||
private Player player;
|
||||
private VideoControl videoControl;
|
||||
|
@ -74,9 +73,6 @@ public final class ZXingMIDlet extends MIDlet implements CommandListener {
|
|||
System.out.println("FocusControl not supported");
|
||||
}
|
||||
*/
|
||||
canvas.addCommand(DECODE);
|
||||
canvas.addCommand(EXIT);
|
||||
canvas.setCommandListener(this);
|
||||
Display.getDisplay(this).setCurrent(canvas);
|
||||
player.start();
|
||||
} catch (IOException ioe) {
|
||||
|
@ -86,15 +82,6 @@ public final class ZXingMIDlet extends MIDlet implements CommandListener {
|
|||
}
|
||||
}
|
||||
|
||||
public void commandAction(Command command, Displayable displayable) {
|
||||
if (command.equals(DECODE)) {
|
||||
new SnapshotThread().start();
|
||||
} else if (command.equals(EXIT)) {
|
||||
destroyApp(false);
|
||||
notifyDestroyed();
|
||||
}
|
||||
}
|
||||
|
||||
protected void pauseApp() {
|
||||
if (player != null) {
|
||||
try {
|
||||
|
@ -114,6 +101,8 @@ public final class ZXingMIDlet extends MIDlet implements CommandListener {
|
|||
}
|
||||
}
|
||||
|
||||
// Convenience methods to show dialogs
|
||||
|
||||
private void showAlert(String title, String text) {
|
||||
Alert alert = new Alert(title, text, null, AlertType.INFO);
|
||||
alert.setTimeout(Alert.FOREVER);
|
||||
|
@ -129,12 +118,33 @@ public final class ZXingMIDlet extends MIDlet implements CommandListener {
|
|||
display.setCurrent(alert, display.getCurrent());
|
||||
}
|
||||
|
||||
private static class VideoCanvas extends Canvas {
|
||||
private class VideoCanvas extends Canvas implements CommandListener {
|
||||
private final Command decode = new Command("Decode", Command.SCREEN, 1);
|
||||
private final Command exit = new Command("Exit", Command.EXIT, 1);
|
||||
private VideoCanvas() {
|
||||
addCommand(decode);
|
||||
addCommand(exit);
|
||||
setCommandListener(this);
|
||||
}
|
||||
protected void paint(Graphics graphics) {
|
||||
// do nothing
|
||||
}
|
||||
protected void keyPressed(int keyCode) {
|
||||
if (FIRE == getGameAction(keyCode)) {
|
||||
new SnapshotThread().start();
|
||||
}
|
||||
}
|
||||
public void commandAction(Command command, Displayable displayable) {
|
||||
if (command.equals(decode)) {
|
||||
new SnapshotThread().start();
|
||||
} else if (command.equals(exit)) {
|
||||
destroyApp(false);
|
||||
notifyDestroyed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO make sure we do not start two threads at once
|
||||
private class SnapshotThread extends Thread {
|
||||
public void run() {
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue