From 67bed66e355d37dd43a01f1d6f532d45dab18765 Mon Sep 17 00:00:00 2001 From: Chung-yih Wang Date: Wed, 16 Nov 2011 22:07:47 +0800 Subject: 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 --- .../android/camera/ui/IndicatorControlWheel.java | 30 ++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src') 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); } -- cgit v1.1