Merge "Fix stale key drawing" into jb-dev

This commit is contained in:
Tadashi G. Takaoka 2012-05-17 02:02:53 -07:00 committed by Android (Google) Code Review
commit a8b1563d08
2 changed files with 17 additions and 0 deletions

View file

@ -197,6 +197,20 @@ public class Keyboard {
return null; return null;
} }
public boolean hasKey(Key aKey) {
if (mKeyCache.containsKey(aKey)) {
return true;
}
for (final Key key : mKeys) {
if (key == aKey) {
mKeyCache.put(key.mCode, key);
return true;
}
}
return false;
}
public static boolean isLetterCode(int code) { public static boolean isLetterCode(int code) {
return code >= MINIMUM_LETTER_CODE; return code >= MINIMUM_LETTER_CODE;
} }

View file

@ -487,6 +487,9 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
} else { } else {
// Draw invalidated keys. // Draw invalidated keys.
for (final Key key : mInvalidatedKeys) { for (final Key key : mInvalidatedKeys) {
if (!mKeyboard.hasKey(key)) {
continue;
}
final int x = key.mX + getPaddingLeft(); final int x = key.mX + getPaddingLeft();
final int y = key.mY + getPaddingTop(); final int y = key.mY + getPaddingTop();
mInvalidatedKeysRect.set(x, y, x + key.mWidth, y + key.mHeight); mInvalidatedKeysRect.set(x, y, x + key.mWidth, y + key.mHeight);