You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use com.google.android.gms.vision.barcode.BarcodeDetector as singleton by default instead of creating new instance inside init() function. Do we really need different detectors in different readers?
class BarcodeDetectorHolder {
private static BarcodeDetector detector;
static BarcodeDetector getBarcodeDetector(Context context) {
if (detector == null)
detector = new BarcodeDetector.Builder(context.getApplicationContext()).setBarcodeFormats(Barcode.QR_CODE).build();
return detector;
}
}
public QREader(final Builder builder) {
if (barcodeDetector == null)
barcodeDetector = BarcodeDetectorHolder.getBarcodeDetector(builder.context);
...
}
Allow to set external BarcodeDetector to Builder. It can be useful, if someone will want to scan not only qr codes.
BarcodeDetector myDetector = ...; //set few barcode formats.
QRReader r = QREader.Builder(MainActivity.this, surfaceView, listener).setDetector(myDetector)
I already made it in my project and can make PR. But I'm not sure about first case.
The text was updated successfully, but these errors were encountered:
@punksta I think using Singleton would be a nice change as cases of having multiple instances of the same QREader class are very less.
However I would not want to extend QREader to start supporting other reading capability just because I made it specifically to read QRCodes. However there is no harm in providing a config function that open ups the functionality if its desired. The way of implementation should be in such a way that it does not alienate the api to deviate from its core cause of reading QRCodes.
@nisrulz
I agree. Where is another case of supporting external BarcodeDetector: using one instance for scanning of locally images and using in your reader.
What do you think about features:
com.google.android.gms.vision.barcode.BarcodeDetector
as singleton by default instead of creating new instance inside init() function. Do we really need different detectors in different readers?I already made it in my project and can make PR. But I'm not sure about first case.
The text was updated successfully, but these errors were encountered: