diff options
author | Chung-yih Wang <cywang@google.com> | 2011-11-16 22:07:47 +0800 |
---|---|---|
committer | Chung-yih Wang <cywang@google.com> | 2011-11-16 22:14:53 +0800 |
commit | 67bed66e355d37dd43a01f1d6f532d45dab18765 (patch) | |
tree | 0e42951ff0df49d2b77da29a4a61dbcdacf9f45d /src | |
parent | 77665404048135a5a96d709378d6f55518b868e2 (diff) | |
download | LegacyCamera-67bed66e355d37dd43a01f1d6f532d45dab18765.zip LegacyCamera-67bed66e355d37dd43a01f1d6f532d45dab18765.tar.gz LegacyCamera-67bed66e355d37dd43a01f1d6f532d45dab18765.tar.bz2 |
Fix the ArrayIndexOutOfBound issue.
bug:5619774
It was caused by the error of the radian computation for rotation of
the indicator wheel. Originally we assume the angle of the first and the last
indicator in the second-level settings should be the same as predefined
angles. In fact, there was some computational error during rotation.
Change-Id: I508f42c5224170ac721562e20be8ed638485e023
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/camera/ui/IndicatorControlWheel.java | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/com/android/camera/ui/IndicatorControlWheel.java b/src/com/android/camera/ui/IndicatorControlWheel.java index 90d8ba8..0948346 100644 --- a/src/com/android/camera/ui/IndicatorControlWheel.java +++ b/src/com/android/camera/ui/IndicatorControlWheel.java @@ -204,32 +204,36 @@ public class IndicatorControlWheel extends IndicatorControl implements if (mInAnimation) return -1; int count = getChildCountByLevel(mCurrentLevel); if (count == 0) return -1; - int startIndex = 0; int sectors = count - 1; + int startIndex = (mCurrentLevel == 0) ? 0 : mSecondLevelStartIndex; + int endIndex; + if (mCurrentLevel == 0) { + // Skip the first component if it is zoom control, as we will + // deal with it specifically. + if (mZoomControl != null) startIndex++; + endIndex = mSecondLevelStartIndex - 1; + } else { + endIndex = getChildCount() - 1; + } // Check which indicator is touched. - if ((delta >= (mStartVisibleRadians[mCurrentLevel] - HIGHLIGHT_RADIANS / 2)) && - (delta <= (mEndVisibleRadians[mCurrentLevel] + HIGHLIGHT_RADIANS / 2))) { + double halfTouchSectorRadians = mTouchSectorRadians[mCurrentLevel]; + if ((delta >= (mChildRadians[startIndex] - halfTouchSectorRadians)) && + (delta <= (mChildRadians[endIndex] + halfTouchSectorRadians))) { int index = 0; - if (mCurrentLevel == 0) { - // Skip the first component if it is zoom control, as we will - // deal with it specifically. - if (mZoomControl != null) startIndex++; - } else { - startIndex = mSecondLevelStartIndex; - index = (int) ((delta - mStartVisibleRadians[mCurrentLevel]) + if (mCurrentLevel == 1) { + index = (int) ((delta - mChildRadians[startIndex]) / mSectorRadians[mCurrentLevel]); // greater than the center of ending indicator if (index > sectors) return (startIndex + sectors); // less than the center of starting indicator if (index < 0) return startIndex; } - if (delta <= (mChildRadians[startIndex + index] - + mTouchSectorRadians[mCurrentLevel] / 2)) { + + halfTouchSectorRadians)) { return (startIndex + index); } if (delta >= (mChildRadians[startIndex + index + 1] - - mTouchSectorRadians[mCurrentLevel] / 2)) { + - halfTouchSectorRadians)) { return (startIndex + index + 1); } |