diff options
| author | Kiran Kumar H N <hurlisal@codeaurora.org> | 2013-07-27 17:27:04 +0530 |
|---|---|---|
| committer | Steve Kondik <shade@chemlab.org> | 2013-10-18 15:54:50 -0700 |
| commit | 4a1837d209f6d4e6419bf7a1f67be4c530a70fb8 (patch) | |
| tree | 10daca0c46ae6fbba45c3c5a9b3406db92645d4f | |
| parent | 41bdd69dbcd41a8975ddeab31cf895af4b5626fb (diff) | |
| download | android_packages_apps_Gallery2-4a1837d209f6d4e6419bf7a1f67be4c530a70fb8.tar.gz android_packages_apps_Gallery2-4a1837d209f6d4e6419bf7a1f67be4c530a70fb8.tar.bz2 android_packages_apps_Gallery2-4a1837d209f6d4e6419bf7a1f67be4c530a70fb8.zip | |
Gallery2: camera: Invoke camera UI functions only after initialization.
When switching from Panorama mode to Camera mode, the CameraActivity
invokes two functions openModule and onOrientationChanged.
openModule initializes PhotoModule. As part of the PhotoModule
initialization, the PhotoUI and PhotoMenu are initialized.
But this is acheived by posting a message to the handler. When the
message is read by the Handler, the PhotoUI's onCameraOpen is invoked
which initializes the PhotoMenu. But sometimes before this message
is read by the Handler, the onOrientationChanged is invoked, which
invokes couple of functions from PhotoUI class acting on the PhotoMenu.
But since the PhotoMenu is still not initialized, it throws up error in
the form of NullPointerExceptions.
Fix this by checking if the PhotoUI and PhotoMenu have been initialized.
If they have not yet been initialized, send a message to the Handler to
invoke these PhotoUI functionalities after the PhotoUI has been
initialized completely.
CRs-Fixed: 519055
Change-Id: I06ea54aa56da96459db6cacea92b02d0f8c23bcd
| -rw-r--r-- | src/com/android/camera/PhotoModule.java | 25 | ||||
| -rw-r--r-- | src/com/android/camera/PhotoUI.java | 5 |
2 files changed, 25 insertions, 5 deletions
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java index 5f7fc6a0a..cbfc385b2 100644 --- a/src/com/android/camera/PhotoModule.java +++ b/src/com/android/camera/PhotoModule.java @@ -113,6 +113,7 @@ public class PhotoModule private static final int OPEN_CAMERA_FAIL = 11; private static final int CAMERA_DISABLED = 12; private static final int CAPTURE_ANIMATION_DONE = 13; + private static final int SET_PHOTO_UI_PARAMS = 15; // The subset of parameters we need to update in setCameraParameters(). private static final int UPDATE_PARAM_INITIALIZE = 1; @@ -411,6 +412,13 @@ public class PhotoModule mUI.enablePreviewThumb(false); break; } + case SET_PHOTO_UI_PARAMS: { + setCameraParametersWhenIdle(UPDATE_PARAM_PREFERENCE); + resizeForPreviewAspectRatio(); + mUI.updateOnScreenIndicators(mParameters, mPreferenceGroup, + mPreferences); + break; + } } } } @@ -2100,10 +2108,19 @@ public class PhotoModule mActivity.updateStorageSpaceAndHint(); mActivity.reuseCameraScreenNail(!mIsImageCaptureIntent); } - - setCameraParametersWhenIdle(UPDATE_PARAM_PREFERENCE); - resizeForPreviewAspectRatio(); - mUI.updateOnScreenIndicators(mParameters, mPreferenceGroup, mPreferences); + /* Check if the PhotoUI Menu is initialized or not. This + * should be initialized during onCameraOpen() which should + * have been called by now. But for some reason that is not + * executed till now, then schedule these functionality for + * later by posting a message to the handler */ + if (mUI.mMenuInitialized) { + setCameraParametersWhenIdle(UPDATE_PARAM_PREFERENCE); + resizeForPreviewAspectRatio(); + mUI.updateOnScreenIndicators(mParameters, mPreferenceGroup, + mPreferences); + } else { + mHandler.sendEmptyMessage(SET_PHOTO_UI_PARAMS); + } } @Override diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java index ffa117642..dddf56292 100644 --- a/src/com/android/camera/PhotoUI.java +++ b/src/com/android/camera/PhotoUI.java @@ -94,6 +94,7 @@ public class PhotoUI implements PieListener, private int mPreviewWidth = 0; private int mPreviewHeight = 0; private View mPreviewThumb; + public boolean mMenuInitialized = false; private OnLayoutChangeListener mLayoutListener = new OnLayoutChangeListener() { @Override @@ -162,6 +163,7 @@ public class PhotoUI implements PieListener, mMenu.setListener(listener); } mMenu.initialize(prefGroup); + mMenuInitialized = true; if (mZoomRenderer == null) { mZoomRenderer = new ZoomRenderer(mActivity); @@ -305,12 +307,13 @@ public class PhotoUI implements PieListener, public void hideGpsOnScreenIndicator() { } public void overrideSettings(final String ... keyvalues) { + if (mMenu == null) return; mMenu.overrideSettings(keyvalues); } public void updateOnScreenIndicators(Camera.Parameters params, PreferenceGroup group, ComboPreferences prefs) { - if (params == null) return; + if (params == null || group == null) return; mOnScreenIndicators.updateSceneOnScreenIndicator(params.getSceneMode()); mOnScreenIndicators.updateExposureOnScreenIndicator(params, CameraSettings.readExposure(prefs)); |
