diff options
author | Chih-Chung Chang <chihchung@google.com> | 2009-09-14 11:40:12 +0800 |
---|---|---|
committer | Chih-Chung Chang <chihchung@google.com> | 2009-09-14 11:41:50 +0800 |
commit | 42be7712a3f114a7cba8f9e8adf33307509e3fc5 (patch) | |
tree | fa1534602d01bf716cec3a256b1f8e14060a2aea /src/com/android | |
parent | 78f160ee416ba27ba55954950473e17ba9d20052 (diff) | |
download | LegacyCamera-42be7712a3f114a7cba8f9e8adf33307509e3fc5.zip LegacyCamera-42be7712a3f114a7cba8f9e8adf33307509e3fc5.tar.gz LegacyCamera-42be7712a3f114a7cba8f9e8adf33307509e3fc5.tar.bz2 |
Fix 2117211: NPE in Camera.onFlashModeChanged
Change-Id: I80326d1f4556416bfb9bb42d69626df652e6b427
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/camera/Camera.java | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index 99e20a0..845ddf0 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -1782,12 +1782,14 @@ public class Camera extends Activity implements View.OnClickListener, return true; } - public void onFlashModeChanged(String modeString) { + public boolean onFlashModeChanged(String modeString) { + if (mPausing) return false; mParameters.setFlashMode(modeString); mCameraDevice.setParameters(mParameters); SharedPreferences.Editor editor = mPreferences.edit(); editor.putString(CameraSettings.KEY_FLASH_MODE, modeString); editor.commit(); + return true; } private void setCameraPictureSizeIfSupported(String sizeString) { @@ -1901,7 +1903,8 @@ class FlashButton extends ImageView implements View.OnClickListener { private ModeChangeListener mListener; public interface ModeChangeListener { - public void onFlashModeChanged(String modeString); + // Returns true if the listener agrees to change mode. + public boolean onFlashModeChanged(String modeString); } public FlashButton(Context context, AttributeSet attrs) { super(context, attrs); @@ -1937,10 +1940,9 @@ class FlashButton extends ImageView implements View.OnClickListener { } private void updateMode(int mode) { + if (mListener == null) return; + if (!mListener.onFlashModeChanged(MODE_STRINGS[mode])) return; mCurrentMode = mode; setImageResource(FLASH_IMAGES[mode]); - if (mListener != null) { - mListener.onFlashModeChanged(MODE_STRINGS[mode]); - } } } |