aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2010-09-22 22:57:13 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-09-22 22:57:13 -0700
commitfc66213d9efb4c5b22e6105d83665576ef4a66f1 (patch)
tree12cda6708923e69a24b7e146cf95ff460d422f19 /java/src
parent437cabe0df4c031037afaff62cfeb2d24b250012 (diff)
parent4fab9f2fee9cfb1a67d805c1598deae02fa4d8cc (diff)
downloadlatinime-fc66213d9efb4c5b22e6105d83665576ef4a66f1.tar.gz
latinime-fc66213d9efb4c5b22e6105d83665576ef4a66f1.tar.xz
latinime-fc66213d9efb4c5b22e6105d83665576ef4a66f1.zip
am 4fab9f2f: am b75dee4b: Merge "Fix ArrayIndexOutOfBoundsException in WordComposer" into gingerbread
Merge commit '4fab9f2fee9cfb1a67d805c1598deae02fa4d8cc' * commit '4fab9f2fee9cfb1a67d805c1598deae02fa4d8cc': Fix ArrayIndexOutOfBoundsException in WordComposer
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/WordComposer.java26
1 files changed, 10 insertions, 16 deletions
diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java
index 6772d53ea..fe4c68576 100644
--- a/java/src/com/android/inputmethod/latin/WordComposer.java
+++ b/java/src/com/android/inputmethod/latin/WordComposer.java
@@ -25,14 +25,14 @@ public class WordComposer {
/**
* The list of unicode values for each keystroke (including surrounding keys)
*/
- private ArrayList<int[]> mCodes;
+ private final ArrayList<int[]> mCodes;
/**
* The word chosen from the candidate list, until it is committed.
*/
private String mPreferredWord;
- private StringBuilder mTypedWord;
+ private final StringBuilder mTypedWord;
private int mCapsCount;
@@ -116,11 +116,14 @@ public class WordComposer {
* Delete the last keystroke as a result of hitting backspace.
*/
public void deleteLast() {
- mCodes.remove(mCodes.size() - 1);
- final int lastPos = mTypedWord.length() - 1;
- char last = mTypedWord.charAt(lastPos);
- mTypedWord.deleteCharAt(lastPos);
- if (Character.isUpperCase(last)) mCapsCount--;
+ final int codesSize = mCodes.size();
+ if (codesSize > 0) {
+ mCodes.remove(codesSize - 1);
+ final int lastPos = mTypedWord.length() - 1;
+ char last = mTypedWord.charAt(lastPos);
+ mTypedWord.deleteCharAt(lastPos);
+ if (Character.isUpperCase(last)) mCapsCount--;
+ }
}
/**
@@ -132,15 +135,6 @@ public class WordComposer {
if (wordSize == 0) {
return null;
}
-// StringBuffer sb = new StringBuffer(wordSize);
-// for (int i = 0; i < wordSize; i++) {
-// char c = (char) mCodes.get(i)[0];
-// if (i == 0 && mIsCapitalized) {
-// c = Character.toUpperCase(c);
-// }
-// sb.append(c);
-// }
-// return sb;
return mTypedWord;
}