Reduce memory of emoji palette
Bug: 10902556 Change-Id: I3c8da35a601de2bfb248292c7b59235fc1120988main
parent
2d3e121014
commit
0e01df9baf
|
@ -74,6 +74,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
ViewPager.OnPageChangeListener, View.OnClickListener,
|
ViewPager.OnPageChangeListener, View.OnClickListener,
|
||||||
ScrollKeyboardView.OnKeyClickListener {
|
ScrollKeyboardView.OnKeyClickListener {
|
||||||
private static final String TAG = EmojiPalettesView.class.getSimpleName();
|
private static final String TAG = EmojiPalettesView.class.getSimpleName();
|
||||||
|
private static final boolean DEBUG_PAGER = false;
|
||||||
private final int mKeyBackgroundId;
|
private final int mKeyBackgroundId;
|
||||||
private final int mEmojiFunctionalKeyBackgroundId;
|
private final int mEmojiFunctionalKeyBackgroundId;
|
||||||
private final KeyboardLayoutSet mLayoutSet;
|
private final KeyboardLayoutSet mLayoutSet;
|
||||||
|
@ -566,6 +567,20 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
// TODO:
|
// TODO:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void startEmojiPalettes() {
|
||||||
|
if (DEBUG_PAGER) {
|
||||||
|
Log.d(TAG, "allocate emoji palettes memory");
|
||||||
|
}
|
||||||
|
mEmojiPager.setAdapter(mEmojiPalettesAdapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopEmojiPalettes() {
|
||||||
|
if (DEBUG_PAGER) {
|
||||||
|
Log.d(TAG, "deallocate emoji palettes memory");
|
||||||
|
}
|
||||||
|
mEmojiPager.setAdapter(null);
|
||||||
|
}
|
||||||
|
|
||||||
public void setKeyboardActionListener(final KeyboardActionListener listener) {
|
public void setKeyboardActionListener(final KeyboardActionListener listener) {
|
||||||
mKeyboardActionListener = listener;
|
mKeyboardActionListener = listener;
|
||||||
mDeleteKeyOnTouchListener.setKeyboardActionListener(mKeyboardActionListener);
|
mDeleteKeyOnTouchListener.setKeyboardActionListener(mKeyboardActionListener);
|
||||||
|
@ -663,6 +678,9 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object instantiateItem(final ViewGroup container, final int position) {
|
public Object instantiateItem(final ViewGroup container, final int position) {
|
||||||
|
if (DEBUG_PAGER) {
|
||||||
|
Log.d(TAG, "instantiate item: " + position);
|
||||||
|
}
|
||||||
final ScrollKeyboardView oldKeyboardView = mActiveKeyboardViews.get(position);
|
final ScrollKeyboardView oldKeyboardView = mActiveKeyboardViews.get(position);
|
||||||
if (oldKeyboardView != null) {
|
if (oldKeyboardView != null) {
|
||||||
oldKeyboardView.deallocateMemory();
|
oldKeyboardView.deallocateMemory();
|
||||||
|
@ -694,6 +712,9 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
||||||
@Override
|
@Override
|
||||||
public void destroyItem(final ViewGroup container, final int position,
|
public void destroyItem(final ViewGroup container, final int position,
|
||||||
final Object object) {
|
final Object object) {
|
||||||
|
if (DEBUG_PAGER) {
|
||||||
|
Log.d(TAG, "destroy item: " + position + ", " + object.getClass().getSimpleName());
|
||||||
|
}
|
||||||
final ScrollKeyboardView keyboardView = mActiveKeyboardViews.get(position);
|
final ScrollKeyboardView keyboardView = mActiveKeyboardViews.get(position);
|
||||||
if (keyboardView != null) {
|
if (keyboardView != null) {
|
||||||
keyboardView.deallocateMemory();
|
keyboardView.deallocateMemory();
|
||||||
|
|
|
@ -260,12 +260,14 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
private void setMainKeyboardFrame() {
|
private void setMainKeyboardFrame() {
|
||||||
mMainKeyboardFrame.setVisibility(View.VISIBLE);
|
mMainKeyboardFrame.setVisibility(View.VISIBLE);
|
||||||
mEmojiPalettesView.setVisibility(View.GONE);
|
mEmojiPalettesView.setVisibility(View.GONE);
|
||||||
|
mEmojiPalettesView.stopEmojiPalettes();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements {@link KeyboardState.SwitchActions}.
|
// Implements {@link KeyboardState.SwitchActions}.
|
||||||
@Override
|
@Override
|
||||||
public void setEmojiKeyboard() {
|
public void setEmojiKeyboard() {
|
||||||
mMainKeyboardFrame.setVisibility(View.GONE);
|
mMainKeyboardFrame.setVisibility(View.GONE);
|
||||||
|
mEmojiPalettesView.startEmojiPalettes();
|
||||||
mEmojiPalettesView.setVisibility(View.VISIBLE);
|
mEmojiPalettesView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,6 +338,16 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
return mKeyboardView;
|
return mKeyboardView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deallocateMemory() {
|
||||||
|
if (mKeyboardView != null) {
|
||||||
|
mKeyboardView.cancelAllOngoingEvents();
|
||||||
|
mKeyboardView.deallocateMemory();
|
||||||
|
}
|
||||||
|
if (mEmojiPalettesView != null) {
|
||||||
|
mEmojiPalettesView.stopEmojiPalettes();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public View onCreateInputView(final boolean isHardwareAcceleratedDrawingEnabled) {
|
public View onCreateInputView(final boolean isHardwareAcceleratedDrawingEnabled) {
|
||||||
if (mKeyboardView != null) {
|
if (mKeyboardView != null) {
|
||||||
mKeyboardView.closing();
|
mKeyboardView.closing();
|
||||||
|
|
|
@ -1049,11 +1049,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
private void onFinishInputViewInternal(final boolean finishingInput) {
|
private void onFinishInputViewInternal(final boolean finishingInput) {
|
||||||
super.onFinishInputView(finishingInput);
|
super.onFinishInputView(finishingInput);
|
||||||
mKeyboardSwitcher.onFinishInputView();
|
mKeyboardSwitcher.onFinishInputView();
|
||||||
final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
|
mKeyboardSwitcher.deallocateMemory();
|
||||||
if (mainKeyboardView != null) {
|
|
||||||
mainKeyboardView.cancelAllOngoingEvents();
|
|
||||||
mainKeyboardView.deallocateMemory();
|
|
||||||
}
|
|
||||||
// Remove pending messages related to update suggestions
|
// Remove pending messages related to update suggestions
|
||||||
mHandler.cancelUpdateSuggestionStrip();
|
mHandler.cancelUpdateSuggestionStrip();
|
||||||
// Should do the following in onFinishInputInternal but until JB MR2 it's not called :(
|
// Should do the following in onFinishInputInternal but until JB MR2 it's not called :(
|
||||||
|
|
Loading…
Reference in New Issue