diff options
author | Wei Huang <weih@google.com> | 2011-11-16 09:31:08 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-11-16 09:31:08 -0800 |
commit | 0d0c3896bfe72cf058d74d92de97e4c0922254d3 (patch) | |
tree | d0ed0137bb955d4298e471fbe614faeaec620860 /src/com/android/camera/ui/IndicatorControlWheel.java | |
parent | 99a0c0a018f4855028c03e43236c40066f8df5b2 (diff) | |
parent | 67bed66e355d37dd43a01f1d6f532d45dab18765 (diff) | |
download | packages_apps_LegacyCamera-0d0c3896bfe72cf058d74d92de97e4c0922254d3.zip packages_apps_LegacyCamera-0d0c3896bfe72cf058d74d92de97e4c0922254d3.tar.gz packages_apps_LegacyCamera-0d0c3896bfe72cf058d74d92de97e4c0922254d3.tar.bz2 |
Merge "Fix the ArrayIndexOutOfBound issue." into ics-mr1
Diffstat (limited to 'src/com/android/camera/ui/IndicatorControlWheel.java')
-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); } |