统一日志管理

This commit is contained in:
Jenly
2020-04-27 21:14:05 +08:00
parent aba5fcadf2
commit a9c04fb310
19 changed files with 492 additions and 155 deletions

View File

@@ -24,7 +24,6 @@ import android.graphics.RectF;
import android.hardware.Camera;
import android.support.annotation.FloatRange;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
@@ -35,6 +34,7 @@ import com.google.zxing.DecodeHintType;
import com.google.zxing.Result;
import com.king.zxing.camera.CameraManager;
import com.king.zxing.camera.FrontLightMode;
import com.king.zxing.util.LogUtils;
import java.io.IOException;
import java.util.ArrayList;
@@ -48,8 +48,6 @@ import java.util.Map;
*/
public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,CaptureManager, SurfaceHolder.Callback {
public static final String TAG = CaptureHelper.class.getSimpleName();
private Activity activity;
private CaptureHandler captureHandler;
@@ -62,6 +60,7 @@ public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,Capture
private AmbientLightManager ambientLightManager;
private SurfaceView surfaceView;
private ViewfinderView viewfinderView;
private SurfaceHolder surfaceHolder;
private View ivTorch;
@@ -185,15 +184,16 @@ public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,Capture
*/
public CaptureHelper(Activity activity,SurfaceView surfaceView,ViewfinderView viewfinderView,View ivTorch){
this.activity = activity;
this.surfaceView = surfaceView;
this.viewfinderView = viewfinderView;
this.ivTorch = ivTorch;
surfaceHolder = surfaceView.getHolder();
hasSurface = false;
}
@Override
public void onCreate(){
surfaceHolder = surfaceView.getHolder();
hasSurface = false;
inactivityTimer = new InactivityTimer(activity);
beepManager = new BeepManager(activity);
ambientLightManager = new AmbientLightManager(activity);
@@ -237,7 +237,6 @@ public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,Capture
public void onPause(){
if (captureHandler != null) {
captureHandler.quitSynchronously();
captureHandler = null;
}
inactivityTimer.onPause();
ambientLightManager.stop();
@@ -331,7 +330,7 @@ public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,Capture
throw new IllegalStateException("No SurfaceHolder provided");
}
if (cameraManager.isOpen()) {
Log.w(TAG, "initCamera() while already open -- late SurfaceView callback?");
LogUtils.w("initCamera() while already open -- late SurfaceView callback?");
return;
}
try {
@@ -345,18 +344,18 @@ public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,Capture
captureHandler.setSupportLuminanceInvert(isSupportLuminanceInvert);
}
} catch (IOException ioe) {
Log.w(TAG, ioe);
LogUtils.w( ioe);
} catch (RuntimeException e) {
// Barcode Scanner has seen crashes in the wild of this variety:
// java.?lang.?RuntimeException: Fail to connect to camera service
Log.w(TAG, "Unexpected error initializing camera", e);
LogUtils.w( "Unexpected error initializing camera", e);
}
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
if (holder == null) {
Log.e(TAG, "*** WARNING *** surfaceCreated() gave us a null surface!");
LogUtils.w( "*** WARNING *** surfaceCreated() gave us a null surface!");
}
if (!hasSurface) {
hasSurface = true;
@@ -392,7 +391,7 @@ public class CaptureHelper implements CaptureLifecycle,CaptureTouchEvent,Capture
params.setZoom(zoom);
camera.setParameters(params);
} else {
Log.i(TAG, "zoom not supported");
LogUtils.i( "zoom not supported");
}
}