|
@@ -33,7 +33,7 @@ import java.util.Map;
|
|
import me.yoqi.android.zxingscanview.R;
|
|
import me.yoqi.android.zxingscanview.R;
|
|
|
|
|
|
|
|
|
|
-/**
|
|
|
|
|
|
+/**扫码框
|
|
* @author liuyuqi.gov@msn.cn
|
|
* @author liuyuqi.gov@msn.cn
|
|
* @date 11/15/2020
|
|
* @date 11/15/2020
|
|
*/
|
|
*/
|
|
@@ -217,7 +217,7 @@ public class ZxingScanView extends SurfaceView {
|
|
(mScanHeight > getHeight() ? getHeight() : mScanHeight);
|
|
(mScanHeight > getHeight() ? getHeight() : mScanHeight);
|
|
mCameraManager.setManualFramingRect(width, height);
|
|
mCameraManager.setManualFramingRect(width, height);
|
|
try {
|
|
try {
|
|
- mCameraManager.openDriver(surfaceHolder);
|
|
|
|
|
|
+ mCameraManager.openDriver(surfaceHolder); //打开摄像头
|
|
mCameraManager.startPreview();
|
|
mCameraManager.startPreview();
|
|
mScanHandler = new ScanHandler(resultListener, mBarcodeType, mBaseHints,
|
|
mScanHandler = new ScanHandler(resultListener, mBarcodeType, mBaseHints,
|
|
mCharacterSet, mCameraManager,
|
|
mCharacterSet, mCameraManager,
|
|
@@ -277,6 +277,12 @@ public class ZxingScanView extends SurfaceView {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 扫描结果通知Activity
|
|
|
|
+ * @param result
|
|
|
|
+ * @param barcode
|
|
|
|
+ * @param scaleFactor
|
|
|
|
+ */
|
|
private void notifyListenerResult(Result result, Bitmap barcode, float scaleFactor) {
|
|
private void notifyListenerResult(Result result, Bitmap barcode, float scaleFactor) {
|
|
for (OnScanListener listener : mListeners) {
|
|
for (OnScanListener listener : mListeners) {
|
|
listener.onResult(this, result, barcode, scaleFactor);
|
|
listener.onResult(this, result, barcode, scaleFactor);
|
|
@@ -535,9 +541,9 @@ public class ZxingScanView extends SurfaceView {
|
|
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
|
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
|
if (mCameraManager != null) {
|
|
if (mCameraManager != null) {
|
|
final int scanWidth = mScanWidth == ViewGroup.LayoutParams.MATCH_PARENT ? width :
|
|
final int scanWidth = mScanWidth == ViewGroup.LayoutParams.MATCH_PARENT ? width :
|
|
- (mScanWidth > width ? width : mScanWidth);
|
|
|
|
|
|
+ (Math.min(mScanWidth, width));
|
|
final int scanHeight = mScanHeight == ViewGroup.LayoutParams.MATCH_PARENT ? height :
|
|
final int scanHeight = mScanHeight == ViewGroup.LayoutParams.MATCH_PARENT ? height :
|
|
- (mScanHeight > height ? height : mScanHeight);
|
|
|
|
|
|
+ (Math.min(mScanHeight, height));
|
|
mCameraManager.setManualFramingRect(scanWidth, scanHeight);
|
|
mCameraManager.setManualFramingRect(scanWidth, scanHeight);
|
|
}
|
|
}
|
|
}
|
|
}
|