Merge pull request #22 from dataticket/master

fix NPE crash with onMeasure when previewSize is null
pull/1/head
Dylan McIntyre 8 years ago committed by GitHub
commit c92c4e8a61
  1. 5
      camerakit/src/main/java/com/flurgle/camerakit/CameraView.java

@ -122,6 +122,7 @@ public class CameraView extends FrameLayout {
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (mAdjustViewBounds) { if (mAdjustViewBounds) {
Size previewSize = getPreviewSize(); Size previewSize = getPreviewSize();
if(previewSize != null) {
if (getLayoutParams().width == LayoutParams.WRAP_CONTENT) { if (getLayoutParams().width == LayoutParams.WRAP_CONTENT) {
int height = MeasureSpec.getSize(heightMeasureSpec); int height = MeasureSpec.getSize(heightMeasureSpec);
float ratio = (float) height / (float) previewSize.getWidth(); float ratio = (float) height / (float) previewSize.getWidth();
@ -141,6 +142,10 @@ public class CameraView extends FrameLayout {
); );
return; return;
} }
}else{
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
return;
}
} }
super.onMeasure(widthMeasureSpec, heightMeasureSpec); super.onMeasure(widthMeasureSpec, heightMeasureSpec);

Loading…
Cancel
Save