More small static analysis stuff

git-svn-id: https://zxing.googlecode.com/svn/trunk@1945 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2011-09-28 18:27:53 +00:00
parent 6a2c4e8d2f
commit eda536772b
5 changed files with 23 additions and 14 deletions

View file

@ -83,19 +83,24 @@ final class DecodeHandler extends Handler {
multiFormatReader.reset(); multiFormatReader.reset();
} }
Handler handler = activity.getHandler();
if (rawResult != null) { if (rawResult != null) {
// Don't log the barcode contents for security. // Don't log the barcode contents for security.
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
Log.d(TAG, "Found barcode in " + (end - start) + " ms"); Log.d(TAG, "Found barcode in " + (end - start) + " ms");
Message message = Message.obtain(activity.getHandler(), R.id.decode_succeeded, rawResult); if (handler != null) {
Message message = Message.obtain(handler, R.id.decode_succeeded, rawResult);
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putParcelable(DecodeThread.BARCODE_BITMAP, source.renderCroppedGreyscaleBitmap()); bundle.putParcelable(DecodeThread.BARCODE_BITMAP, source.renderCroppedGreyscaleBitmap());
message.setData(bundle); message.setData(bundle);
message.sendToTarget(); message.sendToTarget();
}
} else { } else {
Message message = Message.obtain(activity.getHandler(), R.id.decode_failed); if (handler != null) {
Message message = Message.obtain(handler, R.id.decode_failed);
message.sendToTarget(); message.sendToTarget();
} }
} }
}
} }

View file

@ -43,6 +43,7 @@ public final class ViewfinderView extends View {
private static final long ANIMATION_DELAY = 80L; private static final long ANIMATION_DELAY = 80L;
private static final int CURRENT_POINT_OPACITY = 0xA0; private static final int CURRENT_POINT_OPACITY = 0xA0;
private static final int MAX_RESULT_POINTS = 20; private static final int MAX_RESULT_POINTS = 20;
private static final int POINT_SIZE = 6;
private final Paint paint; private final Paint paint;
private Bitmap resultBitmap; private Bitmap resultBitmap;
@ -127,7 +128,7 @@ public final class ViewfinderView extends View {
for (ResultPoint point : currentPossible) { for (ResultPoint point : currentPossible) {
canvas.drawCircle(frameLeft + (int) (point.getX() * scaleX), canvas.drawCircle(frameLeft + (int) (point.getX() * scaleX),
frameTop + (int) (point.getY() * scaleY), frameTop + (int) (point.getY() * scaleY),
6.0f, paint); POINT_SIZE, paint);
} }
} }
} }
@ -138,14 +139,18 @@ public final class ViewfinderView extends View {
for (ResultPoint point : currentLast) { for (ResultPoint point : currentLast) {
canvas.drawCircle(frameLeft + (int) (point.getX() * scaleX), canvas.drawCircle(frameLeft + (int) (point.getX() * scaleX),
frameTop + (int) (point.getY() * scaleY), frameTop + (int) (point.getY() * scaleY),
3.0f, paint); POINT_SIZE / 2, paint);
} }
} }
} }
// Request another update at the animation interval, but only repaint the laser line, // Request another update at the animation interval, but only repaint the laser line,
// not the entire viewfinder mask. // not the entire viewfinder mask.
postInvalidateDelayed(ANIMATION_DELAY, frame.left, frame.top, frame.right, frame.bottom); postInvalidateDelayed(ANIMATION_DELAY,
frame.left - POINT_SIZE,
frame.top - POINT_SIZE,
frame.right + POINT_SIZE,
frame.bottom + POINT_SIZE);
} }
} }

View file

@ -59,7 +59,7 @@ final class BookmarkAdapter extends BaseAdapter {
public View getView(int index, View view, ViewGroup viewGroup) { public View getView(int index, View view, ViewGroup viewGroup) {
LinearLayout layout; LinearLayout layout;
if (view == null || !(view instanceof LinearLayout)) { if (!(view instanceof LinearLayout)) {
LayoutInflater factory = LayoutInflater.from(context); LayoutInflater factory = LayoutInflater.from(context);
layout = (LinearLayout) factory.inflate(R.layout.bookmark_picker_list_item, viewGroup, false); layout = (LinearLayout) factory.inflate(R.layout.bookmark_picker_list_item, viewGroup, false);
} else { } else {

View file

@ -125,7 +125,7 @@ final class DecodedBitStreamParser {
throw FormatException.getFormatInstance(); throw FormatException.getFormatInstance();
} else if (oneByte <= 128) { // ASCII data (ASCII value + 1) } else if (oneByte <= 128) { // ASCII data (ASCII value + 1)
oneByte = upperShift ? oneByte + 128 : oneByte; oneByte = upperShift ? oneByte + 128 : oneByte;
upperShift = false; //upperShift = false;
result.append((char) (oneByte - 1)); result.append((char) (oneByte - 1));
return ASCII_ENCODE; return ASCII_ENCODE;
} else if (oneByte == 129) { // Pad } else if (oneByte == 129) { // Pad

View file

@ -91,8 +91,7 @@ final class DecodeThread extends Thread {
} }
} else { } else {
try { try {
Result result = decode(new URI(input), config.getHints()); if (decode(new URI(input), config.getHints()) != null) {
if (result != null) {
successful++; successful++;
} }
} catch (Exception e) { } catch (Exception e) {