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

A fix to solve an issue while reading standard Barcodes like EAN13 //… #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions android/ZBarScannerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -408,18 +408,46 @@ public void onPreviewFrame(byte[] data, Camera camera) {
SymbolSet syms = scanner.getResults();
for (Symbol sym : syms) {
qrValue = sym.getData();

if(sym.getType()!=Symbol.QRCODE) { // we don't need this in QR codes
BarCodes.add(qrValue);
Redundancy_Check();
break;
}else
{
// Return 1st found QR code value to the calling Activity.
Intent result = new Intent ();
result.putExtra(EXTRA_QRVALUE, qrValue);
setResult(Activity.RESULT_OK, result);
finish();
}
}

}
}
};


private ArrayList<String> BarCodes = new ArrayList<String>();
private int numOfTries=0;
private void Redundancy_Check(){
// tired of getting partial reads
if(BarCodes.size()>2 )
{
numOfTries++;
if(BarCodes.get(BarCodes.size()-1).equals(BarCodes.get(BarCodes.size()-2)) && BarCodes.get(BarCodes.size()-2).equals(BarCodes.get(BarCodes.size()-3) )) {
Intent result = new Intent();
result.putExtra(EXTRA_QRVALUE, BarCodes.get(BarCodes.size()-1));
setResult(Activity.RESULT_OK, result);
finish();
}
if(numOfTries>10)
{
Intent result = new Intent();
result.putExtra(EXTRA_QRVALUE, "max number of tries reached");
setResult(Activity.RESULT_CANCELED,result);
finish();
}
}
}
// Misc ------------------------------------------------------------

// finish() due to error
Expand Down