mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Slightly friendlier, more generic error message when no barcode is found
git-svn-id: https://zxing.googlecode.com/svn/trunk@149 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
a9b85ab5b3
commit
1ec82dd376
|
@ -19,6 +19,7 @@ package com.google.zxing.client.j2me;
|
|||
import com.google.zxing.MonochromeBitmapSource;
|
||||
import com.google.zxing.MultiFormatReader;
|
||||
import com.google.zxing.Reader;
|
||||
import com.google.zxing.ReaderException;
|
||||
import com.google.zxing.Result;
|
||||
|
||||
import javax.microedition.lcdui.Image;
|
||||
|
@ -56,6 +57,9 @@ final class SnapshotThread extends Thread {
|
|||
Reader reader = new MultiFormatReader();
|
||||
Result result = reader.decode(source);
|
||||
zXingMIDlet.handleDecodedText(result.getText());
|
||||
} catch (ReaderException re) {
|
||||
// Show a friendlier message on a mere failure to read the barcode
|
||||
zXingMIDlet.showError("No barcode was detected in this image. Try again.");
|
||||
} catch (Throwable t) {
|
||||
zXingMIDlet.showError(t);
|
||||
} finally {
|
||||
|
|
|
@ -143,9 +143,13 @@ public final class ZXingMIDlet extends MIDlet {
|
|||
}
|
||||
|
||||
void showError(Throwable t) {
|
||||
showAlert(new Alert("Error", t.getMessage(), null, AlertType.ERROR));
|
||||
showError(t.getMessage());
|
||||
}
|
||||
|
||||
void showError(String message) {
|
||||
showAlert(new Alert("Error", message, null, AlertType.ERROR));
|
||||
}
|
||||
|
||||
private void showAlert(Alert alert) {
|
||||
Display display = Display.getDisplay(this);
|
||||
display.setCurrent(alert, canvas);
|
||||
|
|
Loading…
Reference in a new issue