diff options
author | 2011-10-14 12:23:20 -0700 | |
---|---|---|
committer | 2011-10-14 12:23:20 -0700 | |
commit | 432fa42cb0c30ea38168e80d56203239c143bedc (patch) | |
tree | 87a942daf73a472cd7c75190a2ab0b97c2c8401e /java/src/com/android | |
parent | 7d3f77b6edfb2a241842b8a3d58199b918688e32 (diff) | |
parent | 75c4b5fe1bbc7736d05abd7940825a30339c65fc (diff) | |
download | latinime-432fa42cb0c30ea38168e80d56203239c143bedc.tar.gz latinime-432fa42cb0c30ea38168e80d56203239c143bedc.tar.xz latinime-432fa42cb0c30ea38168e80d56203239c143bedc.zip |
am 75c4b5fe: am 5ad37baf: Merge "Release bitmap buffer when KeyboardView is detached from Window" into ics-mr0
* commit '75c4b5fe1bbc7736d05abd7940825a30339c65fc':
Release bitmap buffer when KeyboardView is detached from Window
Diffstat (limited to 'java/src/com/android')
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/KeyboardView.java | 4 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/LatinKeyboard.java | 16 |
2 files changed, 12 insertions, 8 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index 6af4123c9..e69dc581b 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -974,5 +974,9 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { if (mPreviewPlacer != null) { mPreviewPlacer.removeAllViews(); } + if (mBuffer != null) { + mBuffer.recycle(); + mBuffer = null; + } } } diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java index 345272044..c51f1849b 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java @@ -59,8 +59,8 @@ public class LatinKeyboard extends Keyboard { private final int mSpacebarTextColor; private final int mSpacebarTextShadowColor; private float mSpacebarTextFadeFactor = 0.0f; - private final HashMap<Integer, SoftReference<BitmapDrawable>> mSpaceDrawableCache = - new HashMap<Integer, SoftReference<BitmapDrawable>>(); + private final HashMap<Integer, BitmapDrawable> mSpaceDrawableCache = + new HashMap<Integer, BitmapDrawable>(); private final boolean mIsSpacebarTriggeringPopupByLongPress; /* Shortcut key and its icons if available */ @@ -249,13 +249,13 @@ public class LatinKeyboard extends Keyboard { private BitmapDrawable getSpaceDrawable(Locale locale, boolean isAutoCorrection) { final Integer hashCode = Arrays.hashCode( new Object[] { locale, isAutoCorrection, mSpacebarTextFadeFactor }); - final SoftReference<BitmapDrawable> ref = mSpaceDrawableCache.get(hashCode); - BitmapDrawable drawable = (ref == null) ? null : ref.get(); - if (drawable == null) { - drawable = new BitmapDrawable(mRes, drawSpacebar( - locale, isAutoCorrection, mSpacebarTextFadeFactor)); - mSpaceDrawableCache.put(hashCode, new SoftReference<BitmapDrawable>(drawable)); + final BitmapDrawable cached = mSpaceDrawableCache.get(hashCode); + if (cached != null) { + return cached; } + final BitmapDrawable drawable = new BitmapDrawable(mRes, drawSpacebar( + locale, isAutoCorrection, mSpacebarTextFadeFactor)); + mSpaceDrawableCache.put(hashCode, drawable); return drawable; } |