mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Issue 1044 maybe avoid NPE in onDraw() before CaptureActivity.onResume()
git-svn-id: https://zxing.googlecode.com/svn/trunk@2007 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
5d47b0f8d0
commit
6f5841d8bb
|
@ -75,7 +75,11 @@ public final class ViewfinderView extends View {
|
|||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas) {
|
||||
Rect frame = CameraManager.get().getFramingRect();
|
||||
CameraManager cameraManager = CameraManager.get();
|
||||
if (cameraManager == null) {
|
||||
return;
|
||||
}
|
||||
Rect frame = cameraManager.getFramingRect();
|
||||
if (frame == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -109,7 +113,7 @@ public final class ViewfinderView extends View {
|
|||
int middle = frame.height() / 2 + frame.top;
|
||||
canvas.drawRect(frame.left + 2, middle - 1, frame.right - 1, middle + 2, paint);
|
||||
|
||||
Rect previewFrame = CameraManager.get().getFramingRectInPreview();
|
||||
Rect previewFrame = cameraManager.getFramingRectInPreview();
|
||||
float scaleX = frame.width() / (float) previewFrame.width();
|
||||
float scaleY = frame.height() / (float) previewFrame.height();
|
||||
|
||||
|
|
Loading…
Reference in a new issue