use of com.codename1.ext.codescan.ScanResult in project CodenameOne by codenameone.
the class BarCodeScanner method startScaning.
private void startScaning(ScanResult callback) {
this.callback = callback;
try {
// Add the listener for scan and cancel
Container cmdContainer = new Container(new FlowLayout(Component.CENTER));
Button scanButton = new Button(new Command("Scan") {
public void actionPerformed(ActionEvent evt) {
cameraForm.repaint();
if (snapshotThread != null) {
snapshotThread.continueRun();
}
}
});
Button cancelButton = new Button(new Command("Cancel") {
public void actionPerformed(ActionEvent evt) {
if (snapshotThread != null) {
snapshotThread.stop();
cancelScan();
}
}
});
cmdContainer.addComponent(scanButton);
cmdContainer.addComponent(cancelButton);
cameraForm = new Form();
cameraForm.setScrollable(false);
cameraForm.setLayout(new BorderLayout());
cameraForm.addComponent(BorderLayout.CENTER, media.getVideoComponent());
cameraForm.addComponent(BorderLayout.SOUTH, cmdContainer);
} catch (Exception e) {
// throw new AppException("Image/video capture not supported on this phone", e).setCode(97);
e.printStackTrace();
}
startScan();
}
use of com.codename1.ext.codescan.ScanResult in project CodenameOne by codenameone.
the class ComponentTest method start.
public void start() {
if (current != null) {
current.show();
return;
}
Form hi = new Form("Hi World", BoxLayout.y());
hi.add(new Label("Hi World"));
hi.show();
if (System.currentTimeMillis() < 100) {
QRScanner.scanQRCode(new ScanResult() {
public void scanCompleted(String contents, String formatName, byte[] rawBytes) {
Dialog.show("Completed", contents, "OK", null);
}
public void scanCanceled() {
Dialog.show("Cancelled", "Scan Cancelled", "OK", null);
}
public void scanError(int errorCode, String message) {
Dialog.show("Error", message, "OK", null);
}
});
}
}
Aggregations