aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2010-07-29 11:38:29 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-07-29 11:38:29 -0700
commitbc305c21bf840f2a2476e8df4995c9c2191659f3 (patch)
tree804f309dff5e371b922c875c75602371a126cf14 /java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
parent408165374491553ca821b7a61d4083389715954d (diff)
parent87fe3b8556e3cf91b3273caeddc6e2872e8ab991 (diff)
downloadlatinime-bc305c21bf840f2a2476e8df4995c9c2191659f3.tar.gz
latinime-bc305c21bf840f2a2476e8df4995c9c2191659f3.tar.xz
latinime-bc305c21bf840f2a2476e8df4995c9c2191659f3.zip
Merge "Fix NPE introduced by Change-Id: Ie482167b2ae2804fa1aa43ffb5067af47b7553f1"
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java26
1 files changed, 16 insertions, 10 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
index 9570da7ba..e7fbd22dd 100644
--- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
+++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
@@ -320,6 +320,8 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener
};
static class KeyDebouncer {
+ private Key[] mKeys;
+
// for move de-bouncing
private int mLastCodeX;
private int mLastCodeY;
@@ -334,7 +336,8 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener
private final int mKeyDebounceThresholdSquared;
- KeyDebouncer(float hysteresisPixel) {
+ KeyDebouncer(Key[] keys, float hysteresisPixel) {
+ mKeys = keys;
mKeyDebounceThresholdSquared = (int)(hysteresisPixel * hysteresisPixel);
}
@@ -373,11 +376,15 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener
mLastCodeY = mLastY;
}
- public boolean isMinorMoveBounce(int x, int y, Key newKey, Key curKey) {
- if (newKey == curKey)
+ public boolean isMinorMoveBounce(int x, int y, int newKey, int curKey) {
+ if (newKey == curKey) {
return true;
-
- return getSquareDistanceToKeyEdge(x, y, curKey) < mKeyDebounceThresholdSquared;
+ } else if (curKey == NOT_A_KEY) {
+ return false;
+ } else {
+ return getSquareDistanceToKeyEdge(x, y, mKeys[curKey])
+ < mKeyDebounceThresholdSquared;
+ }
}
private static int getSquareDistanceToKeyEdge(int x, int y, Key key) {
@@ -774,7 +781,7 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener
final float hysteresisPixel = getContext().getResources()
.getDimension(R.dimen.key_debounce_hysteresis_distance);
- mDebouncer = new KeyDebouncer(hysteresisPixel);
+ mDebouncer = new KeyDebouncer(keys, hysteresisPixel);
}
@Override
@@ -1368,8 +1375,8 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener
if (mCurrentKey == NOT_A_KEY) {
mCurrentKey = keyIndex;
mDebouncer.updateTimeDebouncing(eventTime);
- } else if (mDebouncer.isMinorMoveBounce(touchX, touchY, mKeys[keyIndex],
- mKeys[mCurrentKey])) {
+ } else if (mDebouncer.isMinorMoveBounce(touchX, touchY, keyIndex,
+ mCurrentKey)) {
mDebouncer.updateTimeDebouncing(eventTime);
continueLongPress = true;
} else if (mRepeatKeyIndex == NOT_A_KEY) {
@@ -1398,8 +1405,7 @@ public class LatinKeyboardBaseView extends View implements View.OnClickListener
case MotionEvent.ACTION_UP:
mHandler.cancelKeyTimersAndPopupPreview();
- if (mDebouncer.isMinorMoveBounce(touchX, touchY, mKeys[keyIndex],
- mKeys[mCurrentKey])) {
+ if (mDebouncer.isMinorMoveBounce(touchX, touchY, keyIndex, mCurrentKey)) {
mDebouncer.updateTimeDebouncing(eventTime);
} else {
resetMultiTap();