aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorsatok <satok@google.com>2012-03-05 04:08:23 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-03-05 04:08:23 -0800
commit433be45fce0b0991572d3b5275a74365f85eb3a4 (patch)
treec10db0a848f8a2c29e5cbe99fe4c74e5e65125f0 /java/src
parentd5b6360549c1e97958a2ec25e5c20ab4d8b455b1 (diff)
parent370674422a47f20979b1fd30aaaed4f2423b28a3 (diff)
downloadlatinime-433be45fce0b0991572d3b5275a74365f85eb3a4.tar.gz
latinime-433be45fce0b0991572d3b5275a74365f85eb3a4.tar.xz
latinime-433be45fce0b0991572d3b5275a74365f85eb3a4.zip
Merge "Refactor to suppress null worning"
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/ProximityInfo.java53
1 files changed, 26 insertions, 27 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
index 41e7ef435..f96f71e8a 100644
--- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
+++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
@@ -119,38 +119,37 @@ public class ProximityInfo {
sweetSpotCenterYs = new float[keyCount];
sweetSpotRadii = new float[keyCount];
calculateSweetSpotParams = true;
+ int i = 0;
+ for (final Key key : keys) {
+ keyXCoordinates[i] = key.mX;
+ keyYCoordinates[i] = key.mY;
+ keyWidths[i] = key.mWidth;
+ keyHeights[i] = key.mHeight;
+ keyCharCodes[i] = key.mCode;
+ if (calculateSweetSpotParams) {
+ final Rect hitBox = key.mHitBox;
+ final int row = hitBox.top / mKeyHeight;
+ if (row < touchPositionCorrection.mRadii.length) {
+ final float hitBoxCenterX = (hitBox.left + hitBox.right) * 0.5f;
+ final float hitBoxCenterY = (hitBox.top + hitBox.bottom) * 0.5f;
+ final float hitBoxWidth = hitBox.right - hitBox.left;
+ final float hitBoxHeight = hitBox.bottom - hitBox.top;
+ final float x = touchPositionCorrection.mXs[row];
+ final float y = touchPositionCorrection.mYs[row];
+ final float radius = touchPositionCorrection.mRadii[row];
+ sweetSpotCenterXs[i] = hitBoxCenterX + x * hitBoxWidth;
+ sweetSpotCenterYs[i] = hitBoxCenterY + y * hitBoxHeight;
+ sweetSpotRadii[i] = radius * (float) Math.sqrt(
+ hitBoxWidth * hitBoxWidth + hitBoxHeight * hitBoxHeight);
+ }
+ }
+ i++;
+ }
} else {
sweetSpotCenterXs = sweetSpotCenterYs = sweetSpotRadii = null;
calculateSweetSpotParams = false;
}
- int i = 0;
- for (final Key key : keys) {
- keyXCoordinates[i] = key.mX;
- keyYCoordinates[i] = key.mY;
- keyWidths[i] = key.mWidth;
- keyHeights[i] = key.mHeight;
- keyCharCodes[i] = key.mCode;
- if (calculateSweetSpotParams) {
- final Rect hitBox = key.mHitBox;
- final int row = hitBox.top / mKeyHeight;
- if (row < touchPositionCorrection.mRadii.length) {
- final float hitBoxCenterX = (hitBox.left + hitBox.right) * 0.5f;
- final float hitBoxCenterY = (hitBox.top + hitBox.bottom) * 0.5f;
- final float hitBoxWidth = hitBox.right - hitBox.left;
- final float hitBoxHeight = hitBox.bottom - hitBox.top;
- final float x = touchPositionCorrection.mXs[row];
- final float y = touchPositionCorrection.mYs[row];
- final float radius = touchPositionCorrection.mRadii[row];
- sweetSpotCenterXs[i] = hitBoxCenterX + x * hitBoxWidth;
- sweetSpotCenterYs[i] = hitBoxCenterY + y * hitBoxHeight;
- sweetSpotRadii[i] = radius * (float) Math.sqrt(
- hitBoxWidth * hitBoxWidth + hitBoxHeight * hitBoxHeight);
- }
- }
- i++;
- }
-
mNativeProximityInfo = setProximityInfoNative(MAX_PROXIMITY_CHARS_SIZE,
keyboardWidth, keyboardHeight, mGridWidth, mGridHeight, proximityCharsArray,
keyCount, keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,