How to optimize Emoji rendering in android?

Viewed 214

I am trying to make an emoji keyboard. I loaded some 1500 emojis in a RecyclerView using EmojiTextView as the item layout. However, I found that even simple scrolling was very slow by this simple approach.

I have initialized EmojiCompat library as below:

EmojiCompat.Config config = new BundledEmojiCompatConfig(this).setReplaceAll(true);
EmojiCompat emojiCompat = EmojiCompat.init(config);

The ViewHolder contains a single item i.e. androidx.emoji.widget.EmojiTextView and holder.emojiTextView.setText(emojis.get(position).unicode); sets the emoji in the holder.

I explored other emoji keyboards in github https://github.com/vanniktech/Emoji. This repository uses a custom extended class from AppCompatImageView and Async-task to load drawable in background. It also optimizes loading by caching emoji's drawable using LRU cache.

However, these optimizations require a lot of boilerplate code.

So, my question is what all optimizations I can implement to load emojis smoothly while scrolling without building variants of imageView/textView from scratch and without handling the rendering of emojis myself.

How does android system handles the rendering and why it is not already optimized by default?

Can you also please point out some resources to learn more about caching/loading of emojis and ways to optimize using custom UI classes.

0 Answers
Related