import java.util.Hashtable;
import java.util.Vector;
+import java.util.concurrent.CountDownLatch;
/**
* This thread does all the heavy lifting of decoding the images.
private final CaptureActivity activity;
private final Hashtable<DecodeHintType, Object> hints;
private Handler handler;
+ private final CountDownLatch handlerInitLatch;
DecodeThread(CaptureActivity activity,
Vector<BarcodeFormat> decodeFormats,
ResultPointCallback resultPointCallback) {
this.activity = activity;
+ handlerInitLatch = new CountDownLatch(1);
hints = new Hashtable<DecodeHintType, Object>(3);
boolean decode1D = prefs.getBoolean(PreferencesActivity.KEY_DECODE_1D, true);
boolean decodeQR = prefs.getBoolean(PreferencesActivity.KEY_DECODE_QR, true);
if (decode1D && decodeQR) {
- hints.put(DecodeHintType.POSSIBLE_FORMATS, CaptureActivity.ALL_FORMATS);
+ hints.put(DecodeHintType.POSSIBLE_FORMATS, DecodeFormatManager.ALL_FORMATS);
} else if (decode1D) {
- hints.put(DecodeHintType.POSSIBLE_FORMATS, CaptureActivity.ONE_D_FORMATS);
+ hints.put(DecodeHintType.POSSIBLE_FORMATS, DecodeFormatManager.ONE_D_FORMATS);
} else if (decodeQR) {
- hints.put(DecodeHintType.POSSIBLE_FORMATS, CaptureActivity.QR_CODE_FORMATS);
+ hints.put(DecodeHintType.POSSIBLE_FORMATS, DecodeFormatManager.QR_CODE_FORMATS);
}
} else {
hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);
}
Handler getHandler() {
+ try {
+ handlerInitLatch.await();
+ } catch (InterruptedException ie) {
+ // continue?
+ }
return handler;
}
@Override
public void run() {
Looper.prepare();
- handler = new DecodeHandler(activity, hints);
+ handler = new DecodeHandler(activity, hints);
+ handlerInitLatch.countDown();
Looper.loop();
}