diff options
author | 2012-06-29 16:32:45 +0900 | |
---|---|---|
committer | 2012-06-29 17:56:31 +0900 | |
commit | 56853c1e48deb71367104060b49b7b1f0344a476 (patch) | |
tree | 4fd1c738e7f91834d291277350ca8a816907ce78 /java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java | |
parent | 1333579b4b4f392c73409b9a3fbfb428a0f8a9ed (diff) | |
download | latinime-56853c1e48deb71367104060b49b7b1f0344a476.tar.gz latinime-56853c1e48deb71367104060b49b7b1f0344a476.tar.xz latinime-56853c1e48deb71367104060b49b7b1f0344a476.zip |
Use SparseArray<E> instead of HashMap<Integer,E>
Change-Id: Id962e670ee1a5164e6c69deb84625139bf5e7974
Diffstat (limited to 'java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java')
-rw-r--r-- | java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java index 23acb8b74..5ffd94a43 100644 --- a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java +++ b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java @@ -19,6 +19,7 @@ package com.android.inputmethod.accessibility; import android.content.Context; import android.text.TextUtils; import android.util.Log; +import android.util.SparseIntArray; import android.view.inputmethod.EditorInfo; import com.android.inputmethod.keyboard.Key; @@ -39,8 +40,8 @@ public class KeyCodeDescriptionMapper { // Map of key labels to spoken description resource IDs private final HashMap<CharSequence, Integer> mKeyLabelMap; - // Map of key codes to spoken description resource IDs - private final HashMap<Integer, Integer> mKeyCodeMap; + // Sparse array of spoken description resource IDs indexed by key codes + private final SparseIntArray mKeyCodeMap; public static void init() { sInstance.initInternal(); @@ -52,7 +53,7 @@ public class KeyCodeDescriptionMapper { private KeyCodeDescriptionMapper() { mKeyLabelMap = new HashMap<CharSequence, Integer>(); - mKeyCodeMap = new HashMap<Integer, Integer>(); + mKeyCodeMap = new SparseIntArray(); } private void initInternal() { @@ -60,7 +61,7 @@ public class KeyCodeDescriptionMapper { mKeyLabelMap.put(":-)", R.string.spoken_description_smiley); // Symbols that most TTS engines can't speak - mKeyCodeMap.put((int) ' ', R.string.spoken_description_space); + mKeyCodeMap.put(' ', R.string.spoken_description_space); // Special non-character codes defined in Keyboard mKeyCodeMap.put(Keyboard.CODE_DELETE, R.string.spoken_description_delete); @@ -273,7 +274,8 @@ public class KeyCodeDescriptionMapper { return context.getString(OBSCURED_KEY_RES_ID); } - if (mKeyCodeMap.containsKey(code)) { + final int resId = mKeyCodeMap.get(code); + if (resId != 0) { return context.getString(mKeyCodeMap.get(code)); } else if (isDefinedNonCtrl) { return Character.toString((char) code); |