Aghajari / AXEmojiView

an advanced library which adds emoji,sticker,... support to your Android application.
Apache License 2.0
179 stars 45 forks source link

Emojis icon sizes Not Working in CustomRecycleAdapter #5

Closed pcshedeur closed 4 years ago

pcshedeur commented 4 years ago

device-2020-08-28-011802

I have gone through so many libraries and this is the first one I was able to implement successfully so thank you. Just a little challenge. I am unable to increase the icon size in for emojis inside a custom recycle adapter. I tried holder.textView.setEmojiSize(40, true); but the icons remain the same size. Please any suggestion?

Aghajari commented 4 years ago

Hi @pcshedeur , That's right, I will fix this as soon as its possible

Aghajari commented 4 years ago

Hi @pcshedeur , check out the AXEmojiView v1.2.1! bugs have been fixed.

Warning: if you wanna set an EditText text into a TextView, try textView.setText(edt.getText().toString()); instead of textView.setText(edt.getText());

Main sample has been updated.

pcshedeur commented 4 years ago

Thank you. The size is working now. Please do you have any example implementation for a custom RecyclerAdapter. Here is my implementation of the onBindView

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        ObjectChats messages = messageList.get(position);
        String message = messages.getMessage();
        final int res;
        int emoji_counter = AXEmojiUtils.getEmojisCount(message);
        if(emoji_counter == 1) {
            res = R.dimen.emoji_size_single_emoji;
        }
        else if(emoji_counter < 1) {
            res = R.dimen.emoji_size_default;
        }
        else {
            res = R.dimen.emoji_size_multiple_emoji;
        }
        if (messages.getSender().equals("1")) {
            holder.messageSelf.setBackgroundResource(R.drawable.chat_send);
            holder.messageSelf.setEmojiSizeRes(res, false);
            holder.messageSelf.setText(message);
        }
        else {
            holder.messageOther.setBackgroundResource(R.drawable.chat_receive);
            holder.messageOther.setEmojiSizeRes(res, false);
            holder.messageOther.setText(message);
        }
        TimeAgo t = new TimeAgo(context);
        String time = t.timeAgo(Long.parseLong(messages.getDate()));
        holder.date.setText(time);
    }

With this, when the view is first rendered, none of the emojis appear. But when I scroll up and down, the emojis appear as expect after.

BEFORE SCROLLING THROUGH device-2020-08-29-002116

AFTER SCROLLING device-2020-08-29-002125

Aghajari commented 4 years ago

Hi @pcshedeur , You need add a listener for this to your onBind, when emoji loaded invalidate textView,

I've handle this for EmojiImageView in lib. I'll fix this for other views as soon as its possible, wait for next version..

Aghajari commented 4 years ago

Done!

Check out AXEmojiView v1.2.2

pcshedeur commented 4 years ago

Thank you. Works perfectly. Your response time is impressive.