Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 28d84153 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Release bitmap buffer when KeyboardView is detached from Window

Bug: 5450387
Change-Id: I3e60edd8c0ea70aff9e484f6e00dadcc8f8981f6
parent ed6bc82d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -974,5 +974,9 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
        if (mPreviewPlacer != null) {
            mPreviewPlacer.removeAllViews();
        }
        if (mBuffer != null) {
            mBuffer.recycle();
            mBuffer = null;
        }
    }
}
+8 −8
Original line number Diff line number Diff line
@@ -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;
    }