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();
}
Handler handler = activity.getHandler();
if (rawResult != null) {
// Don't log the barcode contents for security.
long end = System.currentTimeMillis();
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.putParcelable(DecodeThread.BARCODE_BITMAP, source.renderCroppedGreyscaleBitmap());
message.setData(bundle);
message.sendToTarget();
}
} 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();
}
}
}
}

View file

@ -43,6 +43,7 @@ public final class ViewfinderView extends View {
private static final long ANIMATION_DELAY = 80L;
private static final int CURRENT_POINT_OPACITY = 0xA0;
private static final int MAX_RESULT_POINTS = 20;
private static final int POINT_SIZE = 6;
private final Paint paint;
private Bitmap resultBitmap;
@ -127,7 +128,7 @@ public final class ViewfinderView extends View {
for (ResultPoint point : currentPossible) {
canvas.drawCircle(frameLeft + (int) (point.getX() * scaleX),
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) {
canvas.drawCircle(frameLeft + (int) (point.getX() * scaleX),
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,
// 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) {
LinearLayout layout;
if (view == null || !(view instanceof LinearLayout)) {
if (!(view instanceof LinearLayout)) {
LayoutInflater factory = LayoutInflater.from(context);
layout = (LinearLayout) factory.inflate(R.layout.bookmark_picker_list_item, viewGroup, false);
} else {

View file

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

View file

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