Fix Android Studio preview error using isInEditMode.

pull/1/head
Antonio Nicolás Pina 8 years ago
parent 4c2d2a271a
commit 5eff7e0eb4
  1. 6
      camerakit/src/main/java/com/flurgle/camerakit/CameraView.java

@ -110,6 +110,7 @@ public class CameraView extends FrameLayout {
setPermissions(mPermissions);
setVideoQuality(mVideoQuality);
if (!isInEditMode()) {
mDisplayOrientationDetector = new DisplayOrientationDetector(context) {
@Override
public void onDisplayOrientationChanged(int displayOrientation) {
@ -133,20 +134,25 @@ public class CameraView extends FrameLayout {
}
});
}
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (!isInEditMode()) {
mDisplayOrientationDetector.enable(
ViewCompat.isAttachedToWindow(this)
? DisplayManagerCompat.getInstance(getContext()).getDisplay(Display.DEFAULT_DISPLAY)
: null
);
}
}
@Override
protected void onDetachedFromWindow() {
if (!isInEditMode()) {
mDisplayOrientationDetector.disable();
}
super.onDetachedFromWindow();
}

Loading…
Cancel
Save