Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

Commit 8652217

Browse files
author
Mateusz Maziec
committed
Merge branch 'release/1.0.11'
2 parents af901a2 + 55b1b1b commit 8652217

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.2.40'
4+
ext.kotlin_version = '1.2.41'
55
repositories {
66
google()
77
jcenter()

scanner/src/main/java/com/bobekos/bobek/scanner/BarcodeView.kt

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,40 +72,69 @@ class BarcodeView : FrameLayout {
7272
fun getObservable(): Observable<Barcode> {
7373
return getSurfaceObservable()
7474
.flatMap { BarcodeScanner(context, cameraView.holder, config, it).getObservable() }
75-
.subscribeOn(Schedulers.io())
7675
}
7776

77+
/**
78+
* Set the preview size for the camera source.
79+
* The given size is calculated to the closet value from camera available sizes.
80+
* @param width default value is 640
81+
* @param height default value is 480
82+
*/
7883
fun setPreviewSize(width: Int, height: Int): BarcodeView {
7984
config.previewSize = Size(width, height)
8085

8186
return this
8287
}
8388

89+
/**
90+
* Enable autofocus.
91+
* @param enabled Default value is true
92+
*/
8493
fun setAutoFocus(enabled: Boolean): BarcodeView {
8594
config.isAutoFocus = enabled
8695

8796
return this
8897
}
8998

99+
/**
100+
* Set which barcode format should be detected.
101+
* @param formats Default value is Barcode.ALL_FORMATS
102+
* @see Barcode
103+
*/
90104
fun setBarcodeFormats(vararg formats: Int): BarcodeView {
91105
config.barcodeFormat = formats.sum()
92106

93107
return this
94108
}
95109

110+
/**
111+
* Set camera facing.
112+
* @param facing Default value is CameraSource.CAMERA_FACING_BACK
113+
* @see com.google.android.gms.vision.CameraSource
114+
*/
96115
fun setFacing(facing: Int): BarcodeView {
97116
config.facing = facing
98117

99118
return this
100119
}
101120

121+
/**
122+
* Draw a overlay view over the detected barcode.
123+
* For custom view visit the github documentation.
124+
* @param overlay Default overlay is a white rect
125+
* @see <a href="https://github.com/bobekos/SimpleBarcodeScanner#custom-overlay">Custom overlay</a>
126+
*/
102127
fun drawOverlay(overlay: BarcodeOverlay? = BarcodeRectOverlay(context)): BarcodeView {
103128
drawOverlay = overlay
104129
config.drawOverLay = true
105130

106131
return this
107132
}
108133

134+
/**
135+
* Enable camera flash.
136+
* @param enabled Default value is false
137+
*/
109138
fun setFlash(enabled: Boolean): BarcodeView {
110139
config.useFlash = enabled
111140

@@ -139,7 +168,7 @@ class BarcodeView : FrameLayout {
139168
if (cameraView.holder.surface.isValid && !emitter.isDisposed) {
140169
onSurfaceReady(emitter)
141170
}
142-
}
171+
}.subscribeOn(Schedulers.io())
143172
}
144173

145174
private fun onSurfaceReady(emitter: ObservableEmitter<Boolean>) {

scanner/src/main/java/com/bobekos/bobek/scanner/overlay/BarcodeOverlay.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,11 @@ import android.graphics.Rect
55

66
interface BarcodeOverlay {
77

8+
/**
9+
* Is called when barcode detection fired. Make sure to redraw you custom view
10+
* on each time. When no barcode is found the method calls with empty parameters.
11+
* @param posRect The position of the barcode on the screen
12+
* @param barcodeValue The 'displayValue' parameter of the google barcode class
13+
*/
814
fun onUpdate(posRect: Rect = Rect(), barcodeValue: String = "")
915
}

scanner/src/main/java/com/bobekos/bobek/scanner/scanner/BarcodeScanner.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.google.android.gms.vision.barcode.Barcode
1212
import com.google.android.gms.vision.barcode.BarcodeDetector
1313
import io.reactivex.Observable
1414
import io.reactivex.ObservableEmitter
15+
import io.reactivex.schedulers.Schedulers
1516

1617

1718
internal class BarcodeScanner(
@@ -51,7 +52,7 @@ internal class BarcodeScanner(
5152
}
5253
}
5354
}
54-
}
55+
}.subscribeOn(Schedulers.io())
5556
}
5657

5758
inner class BarcodeTracker(private val subscriber: ObservableEmitter<Barcode>) : Tracker<Barcode>() {

0 commit comments

Comments
 (0)