@Test public void onMeasureTest() { cameraKitView.onMeasure(TEST_WIDTH, TEST_HEIGHT); }
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (mAdjustViewBounds) { ViewGroup.LayoutParams layoutParams = getLayoutParams(); if (layoutParams.width == WRAP_CONTENT && layoutParams.height == WRAP_CONTENT) { throw new CameraException("android:adjustViewBounds=true while both layout_width and layout_height are setView to wrap_content - only 1 is allowed."); } else if (layoutParams.width == WRAP_CONTENT) { int width = 0; int height = MeasureSpec.getSize(heightMeasureSpec); if (mAspectRatio > 0) { width = (int) (height * mAspectRatio); widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY); } else if (mCameraPreview != null && mCameraPreview.getSurfaceSize().area() > 0) { CameraSize previewSize = mCameraPreview.getSurfaceSize(); width = (int) (((float) height / (float) previewSize.getHeight()) * previewSize.getWidth()); widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY); } } else if (layoutParams.height == WRAP_CONTENT) { int width = MeasureSpec.getSize(widthMeasureSpec); int height = 0; if (mAspectRatio > 0) { height = (int) (width * mAspectRatio); heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY); } else if (mCameraPreview != null && mCameraPreview.getSurfaceSize().area() > 0) { CameraSize previewSize = mCameraPreview.getSurfaceSize(); height = (int) (((float) width / (float) previewSize.getWidth()) * previewSize.getHeight()); heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY); } } } super.onMeasure(widthMeasureSpec, heightMeasureSpec); }
CameraKitView extends GestureLayout { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (mAdjustViewBounds) { ViewGroup.LayoutParams layoutParams = getLayoutParams(); if (layoutParams.width == WRAP_CONTENT && layoutParams.height == WRAP_CONTENT) { throw new CameraException("android:adjustViewBounds=true while both layout_width and layout_height are setView to wrap_content - only 1 is allowed."); } else if (layoutParams.width == WRAP_CONTENT) { int width = 0; int height = MeasureSpec.getSize(heightMeasureSpec); if (mAspectRatio > 0) { width = (int) (height * mAspectRatio); widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY); } else if (mCameraPreview != null && mCameraPreview.getSurfaceSize().area() > 0) { CameraSize previewSize = mCameraPreview.getSurfaceSize(); width = (int) (((float) height / (float) previewSize.getHeight()) * previewSize.getWidth()); widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY); } } else if (layoutParams.height == WRAP_CONTENT) { int width = MeasureSpec.getSize(widthMeasureSpec); int height = 0; if (mAspectRatio > 0) { height = (int) (width * mAspectRatio); heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY); } else if (mCameraPreview != null && mCameraPreview.getSurfaceSize().area() > 0) { CameraSize previewSize = mCameraPreview.getSurfaceSize(); height = (int) (((float) width / (float) previewSize.getWidth()) * previewSize.getHeight()); heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY); } } } super.onMeasure(widthMeasureSpec, heightMeasureSpec); } }
CameraKitView extends GestureLayout { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (mAdjustViewBounds) { ViewGroup.LayoutParams layoutParams = getLayoutParams(); if (layoutParams.width == WRAP_CONTENT && layoutParams.height == WRAP_CONTENT) { throw new CameraException("android:adjustViewBounds=true while both layout_width and layout_height are setView to wrap_content - only 1 is allowed."); } else if (layoutParams.width == WRAP_CONTENT) { int width = 0; int height = MeasureSpec.getSize(heightMeasureSpec); if (mAspectRatio > 0) { width = (int) (height * mAspectRatio); widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY); } else if (mCameraPreview != null && mCameraPreview.getSurfaceSize().area() > 0) { CameraSize previewSize = mCameraPreview.getSurfaceSize(); width = (int) (((float) height / (float) previewSize.getHeight()) * previewSize.getWidth()); widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY); } } else if (layoutParams.height == WRAP_CONTENT) { int width = MeasureSpec.getSize(widthMeasureSpec); int height = 0; if (mAspectRatio > 0) { height = (int) (width * mAspectRatio); heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY); } else if (mCameraPreview != null && mCameraPreview.getSurfaceSize().area() > 0) { CameraSize previewSize = mCameraPreview.getSurfaceSize(); height = (int) (((float) width / (float) previewSize.getWidth()) * previewSize.getHeight()); heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY); } } } super.onMeasure(widthMeasureSpec, heightMeasureSpec); } CameraKitView(Context context);  CameraKitView(Context context, AttributeSet attrs);  CameraKitView(Context context, AttributeSet attrs, int defStyleAttr); }
CameraKitView extends GestureLayout { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (mAdjustViewBounds) { ViewGroup.LayoutParams layoutParams = getLayoutParams(); if (layoutParams.width == WRAP_CONTENT && layoutParams.height == WRAP_CONTENT) { throw new CameraException("android:adjustViewBounds=true while both layout_width and layout_height are setView to wrap_content - only 1 is allowed."); } else if (layoutParams.width == WRAP_CONTENT) { int width = 0; int height = MeasureSpec.getSize(heightMeasureSpec); if (mAspectRatio > 0) { width = (int) (height * mAspectRatio); widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY); } else if (mCameraPreview != null && mCameraPreview.getSurfaceSize().area() > 0) { CameraSize previewSize = mCameraPreview.getSurfaceSize(); width = (int) (((float) height / (float) previewSize.getHeight()) * previewSize.getWidth()); widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY); } } else if (layoutParams.height == WRAP_CONTENT) { int width = MeasureSpec.getSize(widthMeasureSpec); int height = 0; if (mAspectRatio > 0) { height = (int) (width * mAspectRatio); heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY); } else if (mCameraPreview != null && mCameraPreview.getSurfaceSize().area() > 0) { CameraSize previewSize = mCameraPreview.getSurfaceSize(); height = (int) (((float) width / (float) previewSize.getWidth()) * previewSize.getHeight()); heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY); } } } super.onMeasure(widthMeasureSpec, heightMeasureSpec); } CameraKitView(Context context);  CameraKitView(Context context, AttributeSet attrs);  CameraKitView(Context context, AttributeSet attrs, int defStyleAttr); void onStart(); void onStop(); void onResume(); void onPause(); void captureImage(final ImageCallback callback); void startVideo(); void stopVideo(); void captureVideo(VideoCallback callback); void captureFrame(FrameCallback callback); void setFrameCallback(FrameCallback callback); void setPermissionsListener(PermissionsListener permissionsListener); void requestPermissions(Activity activity); void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults); void setAdjustViewBounds(boolean adjustViewBounds); boolean getAdjustViewBounds(); void setAspectRatio(float aspectRatio); float getAspectRatio(); void setFacing(@CameraKit.Facing int facing); @CameraKit.Facing int getFacing(); void toggleFacing(); void setFlash(@CameraKit.Flash int flash); boolean hasFlash(); CameraFlash[] getSupportedFlashTypes(); @CameraKit.Flash int getFlash(); void setFocus(@CameraKit.Focus int focus); @CameraKit.Focus int getFocus(); void setZoomFactor(float zoomFactor); float getZoomFactor(); void setSensorPreset(@CameraKit.SensorPreset int sensorPreset); @CameraKit.SensorPreset int getSensorPreset(); void setPreviewEffect(@CameraKit.PreviewEffect int previewEffect); @CameraKit.PreviewEffect int getPreviewEffect(); void setPermissions(@Permission int permissions); @Permission int getPermissions(); void setImageMegaPixels(float imageMegaPixels); float getImageMegaPixels(); void setGestureListener(GestureListener gestureListener); GestureListener getGestureListener(); void setCameraListener(CameraListener cameraListener); CameraListener getCameraListener(); void removeCameraListener(); void setPreviewListener(PreviewListener previewListener); PreviewListener getPreviewListener(); void removePreviewListener(); void setErrorListener(ErrorListener errorListener); ErrorListener getErrorListener(); void removeErrorListener(); CameraSize getPreviewResolution(); CameraSize getPhotoResolution(); }
CameraKitView extends GestureLayout { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (mAdjustViewBounds) { ViewGroup.LayoutParams layoutParams = getLayoutParams(); if (layoutParams.width == WRAP_CONTENT && layoutParams.height == WRAP_CONTENT) { throw new CameraException("android:adjustViewBounds=true while both layout_width and layout_height are setView to wrap_content - only 1 is allowed."); } else if (layoutParams.width == WRAP_CONTENT) { int width = 0; int height = MeasureSpec.getSize(heightMeasureSpec); if (mAspectRatio > 0) { width = (int) (height * mAspectRatio); widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY); } else if (mCameraPreview != null && mCameraPreview.getSurfaceSize().area() > 0) { CameraSize previewSize = mCameraPreview.getSurfaceSize(); width = (int) (((float) height / (float) previewSize.getHeight()) * previewSize.getWidth()); widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY); } } else if (layoutParams.height == WRAP_CONTENT) { int width = MeasureSpec.getSize(widthMeasureSpec); int height = 0; if (mAspectRatio > 0) { height = (int) (width * mAspectRatio); heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY); } else if (mCameraPreview != null && mCameraPreview.getSurfaceSize().area() > 0) { CameraSize previewSize = mCameraPreview.getSurfaceSize(); height = (int) (((float) width / (float) previewSize.getWidth()) * previewSize.getHeight()); heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY); } } } super.onMeasure(widthMeasureSpec, heightMeasureSpec); } CameraKitView(Context context);  CameraKitView(Context context, AttributeSet attrs);  CameraKitView(Context context, AttributeSet attrs, int defStyleAttr); void onStart(); void onStop(); void onResume(); void onPause(); void captureImage(final ImageCallback callback); void startVideo(); void stopVideo(); void captureVideo(VideoCallback callback); void captureFrame(FrameCallback callback); void setFrameCallback(FrameCallback callback); void setPermissionsListener(PermissionsListener permissionsListener); void requestPermissions(Activity activity); void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults); void setAdjustViewBounds(boolean adjustViewBounds); boolean getAdjustViewBounds(); void setAspectRatio(float aspectRatio); float getAspectRatio(); void setFacing(@CameraKit.Facing int facing); @CameraKit.Facing int getFacing(); void toggleFacing(); void setFlash(@CameraKit.Flash int flash); boolean hasFlash(); CameraFlash[] getSupportedFlashTypes(); @CameraKit.Flash int getFlash(); void setFocus(@CameraKit.Focus int focus); @CameraKit.Focus int getFocus(); void setZoomFactor(float zoomFactor); float getZoomFactor(); void setSensorPreset(@CameraKit.SensorPreset int sensorPreset); @CameraKit.SensorPreset int getSensorPreset(); void setPreviewEffect(@CameraKit.PreviewEffect int previewEffect); @CameraKit.PreviewEffect int getPreviewEffect(); void setPermissions(@Permission int permissions); @Permission int getPermissions(); void setImageMegaPixels(float imageMegaPixels); float getImageMegaPixels(); void setGestureListener(GestureListener gestureListener); GestureListener getGestureListener(); void setCameraListener(CameraListener cameraListener); CameraListener getCameraListener(); void removeCameraListener(); void setPreviewListener(PreviewListener previewListener); PreviewListener getPreviewListener(); void removePreviewListener(); void setErrorListener(ErrorListener errorListener); ErrorListener getErrorListener(); void removeErrorListener(); CameraSize getPreviewResolution(); CameraSize getPhotoResolution(); static final int PERMISSION_CAMERA; static final int PERMISSION_MICROPHONE; static final int PERMISSION_STORAGE; static final int PERMISSION_LOCATION; }