Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize BarcodeDetector #20

Open
punksta opened this issue Jul 16, 2016 · 4 comments
Open

Customize BarcodeDetector #20

punksta opened this issue Jul 16, 2016 · 4 comments

Comments

@punksta
Copy link
Contributor

punksta commented Jul 16, 2016

What do you think about features:

  • 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.

@nisrulz
Copy link
Owner

nisrulz commented Jul 17, 2016

@punksta I donot fully understand what you are proposing here. Can you provide me with more details.

@punksta
Copy link
Contributor Author

punksta commented Jul 18, 2016

@nisrulz added samples;

@nisrulz
Copy link
Owner

nisrulz commented Jul 18, 2016

@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.

Would love to hear your thoughts on this too.

@punksta
Copy link
Contributor Author

punksta commented Jul 18, 2016

@nisrulz
I agree. Where is another case of supporting external BarcodeDetector: using one instance for scanning of locally images and using in your reader.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants