Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay loading of emojis until emoji picker is opened #560

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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 @@ -111,12 +111,13 @@ public int getSpanSize(int position){
list.setPadding(V.dp(16), 0, V.dp(16), 0);
imgLoader=new ListImageLoaderWrapper(activity, list, new RecyclerViewDelegate(list), null);

List<Emoji> recentEmoji=new ArrayList<>(lp.recentCustomEmoji);
if(!recentEmoji.isEmpty())
adapter.addAdapter(new SingleCategoryAdapter(recentEmojiCategory=new EmojiCategory(activity.getString(R.string.mo_emoji_recent), recentEmoji)));

for(EmojiCategory category:emojis)
adapter.addAdapter(new SingleCategoryAdapter(category));
if (!forReaction){
List<Emoji> recentEmoji=new ArrayList<>(lp.recentCustomEmoji);
if(!recentEmoji.isEmpty())
adapter.addAdapter(new SingleCategoryAdapter(recentEmojiCategory=new EmojiCategory(activity.getString(R.string.mo_emoji_recent), recentEmoji)));
for(EmojiCategory category : emojis)
adapter.addAdapter(new SingleCategoryAdapter(category));
}
list.setAdapter(adapter);
list.addItemDecoration(new RecyclerView.ItemDecoration(){
@Override
Expand Down Expand Up @@ -229,6 +230,17 @@ public void onEmojiUpdated(EmojiUpdatedEvent ev){
}
}

public void customToggleKeyboardPopup(){
if (adapter.getAdapterCount() == 0){
List<Emoji> recentEmoji=new ArrayList<>(lp.recentCustomEmoji);
if(!recentEmoji.isEmpty())
adapter.addAdapter(new SingleCategoryAdapter(recentEmojiCategory=new EmojiCategory(activity.getString(R.string.mo_emoji_recent), recentEmoji)));
for(EmojiCategory category : emojis)
adapter.addAdapter(new SingleCategoryAdapter(category));
}
super.toggleKeyboardPopup(null);
}

private class SingleCategoryAdapter extends UsableRecyclerView.Adapter<RecyclerView.ViewHolder> implements ImageLoaderRecyclerAdapter, Filterable{
private EmojiCategory category;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ private void addEmojiReaction(String emoji, Emoji info) {
public void onBackspace() {}

private void onReactClick(View v){
emojiKeyboard.toggleKeyboardPopup(null);
emojiKeyboard.customToggleKeyboardPopup();
v.setSelected(emojiKeyboard.isVisible());
space.setVisibility(emojiKeyboard.isVisible() ? View.VISIBLE : View.GONE);
DisplayMetrics displayMetrics = new DisplayMetrics();
Expand Down