Merge "Release and register current key when emoji palette is hidden"
This commit is contained in:
commit
4905d83270
3 changed files with 18 additions and 9 deletions
|
@ -102,7 +102,7 @@ final class EmojiPageKeyboardView extends KeyboardView implements
|
|||
}
|
||||
final Key key = getKey(e);
|
||||
if (key != null && key != mCurrentKey) {
|
||||
releaseCurrentKey();
|
||||
releaseCurrentKey(false /* withKeyRegistering */);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ final class EmojiPageKeyboardView extends KeyboardView implements
|
|||
return mKeyDetector.detectHitKey(x, y);
|
||||
}
|
||||
|
||||
public void releaseCurrentKey() {
|
||||
public void releaseCurrentKey(final boolean withKeyRegistering) {
|
||||
mHandler.removeCallbacks(mPendingKeyDown);
|
||||
mPendingKeyDown = null;
|
||||
final Key currentKey = mCurrentKey;
|
||||
|
@ -128,13 +128,16 @@ final class EmojiPageKeyboardView extends KeyboardView implements
|
|||
}
|
||||
currentKey.onReleased();
|
||||
invalidateKey(currentKey);
|
||||
if (withKeyRegistering) {
|
||||
mListener.onReleaseKey(currentKey);
|
||||
}
|
||||
mCurrentKey = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDown(final MotionEvent e) {
|
||||
final Key key = getKey(e);
|
||||
releaseCurrentKey();
|
||||
releaseCurrentKey(false /* withKeyRegistering */);
|
||||
mCurrentKey = key;
|
||||
if (key == null) {
|
||||
return false;
|
||||
|
@ -163,7 +166,7 @@ final class EmojiPageKeyboardView extends KeyboardView implements
|
|||
final Key key = getKey(e);
|
||||
final Runnable pendingKeyDown = mPendingKeyDown;
|
||||
final Key currentKey = mCurrentKey;
|
||||
releaseCurrentKey();
|
||||
releaseCurrentKey(false /* withKeyRegistering */);
|
||||
if (key == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -189,14 +192,14 @@ final class EmojiPageKeyboardView extends KeyboardView implements
|
|||
@Override
|
||||
public boolean onScroll(final MotionEvent e1, final MotionEvent e2, final float distanceX,
|
||||
final float distanceY) {
|
||||
releaseCurrentKey();
|
||||
releaseCurrentKey(false /* withKeyRegistering */);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onFling(final MotionEvent e1, final MotionEvent e2, final float velocityX,
|
||||
final float velocityY) {
|
||||
releaseCurrentKey();
|
||||
releaseCurrentKey(false /* withKeyRegistering */);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,13 +68,18 @@ final class EmojiPalettesAdapter extends PagerAdapter {
|
|||
}
|
||||
|
||||
public void onPageScrolled() {
|
||||
releaseCurrentKey(false /* withKeyRegistering */);
|
||||
}
|
||||
|
||||
public void releaseCurrentKey(final boolean withKeyRegistering) {
|
||||
// Make sure the delayed key-down event (highlight effect and haptic feedback) will be
|
||||
// canceled.
|
||||
final EmojiPageKeyboardView currentKeyboardView =
|
||||
mActiveKeyboardViews.get(mActivePosition);
|
||||
if (currentKeyboardView != null) {
|
||||
currentKeyboardView.releaseCurrentKey();
|
||||
if (currentKeyboardView == null) {
|
||||
return;
|
||||
}
|
||||
currentKeyboardView.releaseCurrentKey(withKeyRegistering);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -90,7 +95,7 @@ final class EmojiPalettesAdapter extends PagerAdapter {
|
|||
}
|
||||
final EmojiPageKeyboardView oldKeyboardView = mActiveKeyboardViews.get(mActivePosition);
|
||||
if (oldKeyboardView != null) {
|
||||
oldKeyboardView.releaseCurrentKey();
|
||||
oldKeyboardView.releaseCurrentKey(false /* withKeyRegistering */);
|
||||
oldKeyboardView.deallocateMemory();
|
||||
}
|
||||
mActivePosition = position;
|
||||
|
|
|
@ -380,6 +380,7 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
|
|||
}
|
||||
|
||||
public void stopEmojiPalettes() {
|
||||
mEmojiPalettesAdapter.releaseCurrentKey(true /* withKeyRegistering */);
|
||||
mEmojiPalettesAdapter.flushPendingRecentKeys();
|
||||
mEmojiPager.setAdapter(null);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue