fix#81
This commit is contained in:
@@ -246,6 +246,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -302,6 +306,7 @@ public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,Capture
|
||||
}
|
||||
});
|
||||
cameraManager.setOnSensorListener((torch, tooDark, ambientLightLux) -> {
|
||||
Log.d(TAG,"ambientLightLux:" + ambientLightLux);
|
||||
if(tooDark){
|
||||
if(ivTorch.getVisibility() != View.VISIBLE){
|
||||
ivTorch.setVisibility(View.VISIBLE);
|
||||
|
||||
@@ -155,6 +155,10 @@ public final class CameraManager {
|
||||
framingRect = null;
|
||||
framingRectInPreview = null;
|
||||
}
|
||||
isTorch = false;
|
||||
if(onTorchListener!=null){
|
||||
onTorchListener.onTorchChanged(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,6 +186,7 @@ public final class CameraManager {
|
||||
previewCallback.setHandler(null, 0);
|
||||
previewing = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.support.annotation.FloatRange;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.BinaryBitmap;
|
||||
@@ -41,6 +42,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;
|
||||
@@ -182,7 +184,7 @@ public final class CodeUtils {
|
||||
|
||||
return bitmap;
|
||||
} catch (WriterException e) {
|
||||
e.printStackTrace();
|
||||
Log.w(CaptureHelper.TAG,e.getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -230,7 +232,7 @@ public final class CodeUtils {
|
||||
canvas.restore();
|
||||
} catch (Exception e) {
|
||||
bitmap = null;
|
||||
e.printStackTrace();
|
||||
Log.w(CaptureHelper.TAG,e.getMessage());
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
@@ -244,6 +246,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);
|
||||
}
|
||||
|
||||
@@ -317,7 +320,7 @@ public final class CodeUtils {
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
Log.w(CaptureHelper.TAG,e.getMessage());
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -338,6 +341,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);
|
||||
@@ -414,7 +418,7 @@ public final class CodeUtils {
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
Log.w(CaptureHelper.TAG,e.getMessage());
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -604,7 +608,7 @@ public final class CodeUtils {
|
||||
}
|
||||
return bitmap;
|
||||
} catch (WriterException e) {
|
||||
e.printStackTrace();
|
||||
Log.w(CaptureHelper.TAG,e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -647,7 +651,7 @@ public final class CodeUtils {
|
||||
canvas.restore();
|
||||
} catch (Exception e) {
|
||||
bitmap = null;
|
||||
e.printStackTrace();
|
||||
Log.w(CaptureHelper.TAG,e.getMessage());
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
|
||||
Reference in New Issue
Block a user