feat(android): restore state when useCamera2api is enabled (#2603)

This commit is contained in:
Märt Lõhmus 2019-12-02 14:28:13 +02:00 committed by Sibelius Seraphini
parent fe8481158f
commit 1f8b863947
2 changed files with 4 additions and 2 deletions

View File

@ -436,7 +436,7 @@ class Camera2 extends CameraViewImpl implements MediaRecorder.OnInfoListener, Me
mStillImageReader.close();
}
if (size == null) {
if (mAspectRatio == null) {
if (mAspectRatio == null || mPictureSize == null) {
return;
}
mPictureSizes.sizes(mAspectRatio).last();

View File

@ -293,6 +293,8 @@ public class CameraView extends FrameLayout {
} else {
mImpl = new Camera2Api23(mCallbacks, mImpl.mPreview, mContext, mBgHandler);
}
onRestoreInstanceState(state);
} else {
if (mImpl instanceof Camera1) {
return;
@ -316,7 +318,7 @@ public class CameraView extends FrameLayout {
this.removeView(mImpl.getView());
}
//store the state and restore this state after fall back to Camera1
Parcelable state=onSaveInstanceState();
Parcelable state = onSaveInstanceState();
// Camera2 uses legacy hardware layer; fall back to Camera1
mImpl = new Camera1(mCallbacks, createPreviewImpl(getContext()), mBgHandler);
onRestoreInstanceState(state);