Skip to content

Commit

Permalink
stopScanning functionality - big fix for issue #23
Browse files Browse the repository at this point in the history
  • Loading branch information
KingsMentor committed Aug 14, 2017
1 parent 5393225 commit fda0354
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ android {
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "xyz.belvi.mobilevisionbarcodesample"
minSdkVersion 11
minSdkVersion 14
targetSdkVersion 24
versionCode 1
versionName "1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ public class MainActivity extends AppCompatActivity implements BarcodeRetriever
CheckBox fromXMl;
SwitchCompat drawRect, autoFocus, supportMultiple, touchBack, drawText, flash, frontCam;

BarcodeCapture barcodeCapture;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


final BarcodeCapture barcodeCapture = (BarcodeCapture) getSupportFragmentManager().findFragmentById(barcode);
barcodeCapture = (BarcodeCapture) getSupportFragmentManager().findFragmentById(barcode);
barcodeCapture.setRetrieval(this);

fromXMl = (CheckBox) findViewById(R.id.from_xml);
Expand All @@ -71,7 +73,7 @@ protected void onCreate(Bundle savedInstanceState) {
findViewById(R.id.stop).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

barcodeCapture.stopScanning();
}
});

Expand All @@ -86,7 +88,7 @@ public void onClick(View view) {
.setTouchAsCallback(touchBack.isChecked())
.shouldAutoFocus(autoFocus.isChecked())
.setShowFlash(flash.isChecked())
.setBarcodeFormat(Barcode.ISBN | Barcode.CODABAR)
.setBarcodeFormat(Barcode.ALL_FORMATS)
.setCameraFacing(frontCam.isChecked() ? CameraSource.CAMERA_FACING_FRONT : CameraSource.CAMERA_FACING_BACK)
.setShouldShowText(drawText.isChecked());
barcodeCapture.refresh();
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
app:gvb_auto_focus="true"
app:gvb_code_format="all_format"
app:gvb_code_format="code_39|aztec"
app:gvb_flash="false"
app:gvb_rect_colors="@array/rect_color" />
</RelativeLayout>
Expand Down
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ buildscript {
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions mobilevisionbarcodescanner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ android {
buildToolsVersion "24.0.2"

defaultConfig {
minSdkVersion 11
minSdkVersion 14
targetSdkVersion 24
versionCode 1
versionName "1.0"
Expand All @@ -20,7 +20,7 @@ android {
}

dependencies {
compile 'com.google.android.gms:play-services-vision:9.6.1'
compile 'com.google.android.gms:play-services-vision:11.0.4'
compile 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.1@aar'
compile 'io.reactivex.rxjava2:rxjava:2.0.5'
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public final class BarcodeCapture extends BarcodeFragment {
// helper objects for detecting taps and pinches.
private ScaleGestureDetector scaleGestureDetector;
private GestureDetector gestureDetector;
private BarcodeDetector barcodeDetector;


/**
Expand Down Expand Up @@ -155,7 +156,7 @@ private void createCameraSource(boolean autoFocus, boolean useFlash) {
// is set to receive the barcode detection results, track the barcodes, and maintain
// graphics for each barcode on screen. The factory is used by the multi-processor to
// create a separate tracker instance for each barcode.
BarcodeDetector barcodeDetector = new BarcodeDetector.Builder(getContext())
barcodeDetector = new BarcodeDetector.Builder(getContext())
.setBarcodeFormats(getBarcodeFormat())
.build();

Expand Down Expand Up @@ -441,4 +442,11 @@ public void onScaleEnd(ScaleGestureDetector detector) {
mCameraSource.doZoom(detector.getScaleFactor());
}
}

@Override
public void stopScanning() {
super.stopScanning();
barcodeDetector.release();

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,7 @@ protected BarcodeFragment setBarcodeFormatUpdate(boolean barcodeFormatUpdate) {
public boolean isBarcodeFormatUpdate() {
return barcodeFormatUpdate;
}

public void stopScanning() {
}
}
2 changes: 1 addition & 1 deletion mobilevisionbarcodescanner/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<enum name="back" value="0"></enum>
<enum name="front" value="0"></enum>
</attr>
<attr name="gvb_code_format" format="flag">
<attr name="gvb_code_format">
<flag name="all_format" value="0"></flag>
<flag name="code_128" value="1"></flag>
<flag name="code_39" value="2"></flag>
Expand Down

0 comments on commit fda0354

Please sign in to comment.