This commit is contained in:
Jenly
2020-03-29 17:21:43 +08:00
parent d3d98a3e90
commit 86dac6216b
7 changed files with 33 additions and 16 deletions

View File

@@ -247,6 +247,10 @@ public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,Capture
if (!hasSurface) {
surfaceHolder.removeCallback(this);
}
if(ivTorch != null && ivTorch.getVisibility() == View.VISIBLE){
ivTorch.setSelected(false);
ivTorch.setVisibility(View.INVISIBLE);
}
}

View File

@@ -156,6 +156,10 @@ public final class CameraManager {
framingRect = null;
framingRectInPreview = null;
}
isTorch = false;
if(onTorchListener!=null){
onTorchListener.onTorchChanged(false);
}
}
/**

View File

@@ -22,6 +22,7 @@ import android.graphics.Color;
import android.graphics.Paint;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.Log;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.BinaryBitmap;
@@ -39,6 +40,7 @@ import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.qrcode.QRCodeReader;
import com.google.zxing.qrcode.QRCodeWriter;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.king.zxing.CaptureHelper;
import com.king.zxing.DecodeFormatManager;
import java.util.HashMap;
@@ -184,7 +186,7 @@ public final class CodeUtils {
return bitmap;
} catch (WriterException e) {
e.printStackTrace();
Log.w(CaptureHelper.TAG,e.getMessage());
}
return null;
@@ -232,7 +234,7 @@ public final class CodeUtils {
canvas.restore();
} catch (Exception e) {
bitmap = null;
e.printStackTrace();
Log.w(CaptureHelper.TAG,e.getMessage());
}
return bitmap;
@@ -246,6 +248,7 @@ public final class CodeUtils {
public static String parseQRCode(String bitmapPath) {
Map<DecodeHintType, Object> hints = new HashMap<>();
hints.put(DecodeHintType.CHARACTER_SET, "utf-8");
hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
return parseQRCode(bitmapPath,hints);
}
@@ -319,7 +322,7 @@ public final class CodeUtils {
}
}catch (Exception e){
e.printStackTrace();
Log.w(CaptureHelper.TAG,e.getMessage());
}
return result;
@@ -340,6 +343,7 @@ public final class CodeUtils {
decodeFormats.addAll(DecodeFormatManager.AZTEC_FORMATS);
decodeFormats.addAll(DecodeFormatManager.PDF417_FORMATS);
hints.put(DecodeHintType.CHARACTER_SET, "utf-8");
hints.put(DecodeHintType.TRY_HARDER,Boolean.TRUE);
hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);
return parseCode(bitmapPath,hints);
@@ -416,7 +420,7 @@ public final class CodeUtils {
}
}catch (Exception e){
e.printStackTrace();
Log.w(CaptureHelper.TAG,e.getMessage());
}
return result;
@@ -606,7 +610,7 @@ public final class CodeUtils {
}
return bitmap;
} catch (WriterException e) {
e.printStackTrace();
Log.w(CaptureHelper.TAG,e.getMessage());
}
return null;
}
@@ -649,7 +653,7 @@ public final class CodeUtils {
canvas.restore();
} catch (Exception e) {
bitmap = null;
e.printStackTrace();
Log.w(CaptureHelper.TAG,e.getMessage());
}
return bitmap;