OSDN Git Service

Fix NPE
authorDoris Liu <tianliu@google.com>
Thu, 30 Jan 2014 21:11:29 +0000 (13:11 -0800)
committerDoris Liu <tianliu@google.com>
Thu, 30 Jan 2014 21:19:31 +0000 (13:19 -0800)
This NPE is caused by not having a PreviewStatusListener in
photosphere module. Hooking up PreviewStatusListener in
photosphere requires a refactor which is non-trivial amount
of work.

So for now, a null check is added here to prevent NPE
and the logic of detecting and handling device flip will be
added into photosphere to properly handle device flp.

Part II at ag/412607

Bug: 12679997
Change-Id: I5392674e387800e6a2a3114ec3f834b439aed31e

src/com/android/camera/app/CameraAppUI.java

index aad2ee1..889a0f0 100644 (file)
@@ -564,7 +564,8 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
                 public void onDisplayChanged(int displayId) {
                     int rotation = CameraUtil.getDisplayRotation(
                             (Activity) mController.getAndroidContext());
-                    if ((rotation - mLastRotation + 360) % 360 == 180) {
+                    if ((rotation - mLastRotation + 360) % 360 == 180
+                            && mPreviewStatusListener != null) {
                         mPreviewStatusListener.onPreviewFlipped();
                     }
                     mLastRotation = rotation;