Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ public void addKeyLast(final Key usedKey) {
public void removeAllKeys() {
synchronized (mLock) {
mGridKeys.clear();
// also drop keys typed while viewing the recents tab that haven't been flushed yet,
// otherwise they get re-added on the next flushPendingRecentKeys() after a clear-all
mPendingKeys.clear();
mCachedGridKeys = null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,16 @@ private static RecyclerView getRecyclerView(View view) {
return view.findViewById(R.id.emoji_keyboard_list);
}

/** Rebuild the recents page while it is the currently visible page. notifyItemChanged does not
* rebind the current ViewPager2 page, so refresh its inner adapter directly (same as the
* tab-change path in onViewDetachedFromWindow). No-op if recents is not currently bound. */
void refreshVisibleRecents() {
final RecyclerView recyclerView = mViews.get(mEmojiCategory.getRecentTabId());
if (recyclerView != null && recyclerView.getAdapter() != null) {
recyclerView.getAdapter().notifyDataSetChanged();
}
}

private void updateState(@NonNull RecyclerView recyclerView, long categoryId) {
if (categoryId != mEmojiCategory.getCurrentCategory().ordinal()) {
return;
Expand Down Expand Up @@ -333,6 +343,10 @@ public void onRemoveRecentsKey(Key key)
private void clearRecentKeys() {
RecentEmojis.clear();
getRecentsKeyboard().removeAllKeys();
// clearing happens while the recents tab is visible (its icon is long-pressed), where a plain
// notifyItemChanged does not rebind the current page - refresh the visible recents grid directly
if (initialized && mPager.getAdapter() instanceof PagerAdapter adapter)
adapter.refreshVisibleRecents();
}

@Override
Expand Down