Giter VIP home page Giter VIP logo

Comments (7)

Aghajari avatar Aghajari commented on August 23, 2024 1

Hello @eemi2010,

You are right, i just checked it and after an hour finally i bypassed it!

This is the output:
AXrLottieEmojiEditText

This is the source-code:
AXrLottieEmoji-v2.zip

Explanation:
As you know, EditText extends TextView. But When you make a TextView Editable (instantiate android.widget.Editor which is hide in SDK), The Editor draws and caches the text rendering. So calling invalidate() doesn't redraw the text.
But there is another method in Editor called invalidateTextDisplayList(). Unfortunately you don't have access to that, Not even with reflection! (btw, reflection isn't a good choice here at all)
Some methods such as setTextColor(int), setEnabled(boolean) and setShadowLayer(float, float, float, int) will call invalidateTextDisplayList() because of the changes in the editor.
But almost all methods have an internal if-condition to invalidate only if the state has changed!
As far as I checked, setShadowLayer() is the only one that calls invalidateTextDisplayList() without checking any condition.
So here's the trick, instead of postInvalidate(), I call setShadowLayer() with the stored values and it does exactly what I want :)

Good Luck!

from axemojiview.

Aghajari avatar Aghajari commented on August 23, 2024

Hello @eemi2010, Nice question!

I just wrote a simple test project for this by creating a new TextView on top of AXEmojiTextView called AXrLottieTextView
And another class called AXrLottieEmoji (like AXPresetEmoji, It will create AXrLottieDrawable).
At the end AXrLottieEmojiManager maps all of your AXrLottieEmoji instances which AXEmojiTextView can show.

This is the output:

AXrLottieEmoji

Initializing (Application):

AXrLottie.init(this);

ArrayList<AXrLottieEmoji> emojis = new ArrayList<>();
emojis.add(new AXrLottieEmoji("\uD83D\uD83E\uD83F", "a.json"));
emojis.add(new AXrLottieEmoji("\uD83D\uD83E\uD84F", "b.json"));

AXrLottieEmojiManager.install(emojis);
AXEmojiManager.install(this, new AXAppleEmojiProvider(this));

And set the text (Activity)

AXrLottieTextView tv = findViewById(R.id.tv);
tv.setText("Hell😍 World \uD83D\uD83E\uD83F\uD83D\uD83E\uD84F");

The unicodes I set for LottieEmojis are just for testing and don't mean anything!

AXrLottieEmoji.zip

from axemojiview.

eemi2010 avatar eemi2010 commented on August 23, 2024

This is dope !!!!!. Let me try and come back to you. Hopefully this can actually make it to the library. Would be terrific. Thanks a lot for you quick answer.

from axemojiview.

eemi2010 avatar eemi2010 commented on August 23, 2024

This is working great on AXEmojiTextView. Please can you provide an example with AXEmojiEditText. I tried to to the same as with AXEmojiTextView but on the onTextChanged method. But the emojis and not appearing. Can you please point me in the right direction.

Thanks a lot.

from axemojiview.

eemi2010 avatar eemi2010 commented on August 23, 2024

Having a look. Will give you feedback in a few. Thanks man. You rock.

from axemojiview.

eemi2010 avatar eemi2010 commented on August 23, 2024

This is working great for our needs. Thanks a million for your help. Like you can suspect we are trying to mimic the latest Telegram update and I think we got it to work.

Would be awesome if this could make it to the next version of the library.

from axemojiview.

Aghajari avatar Aghajari commented on August 23, 2024

I'm glad it helped. πŸ™‚

This sample is more related to AXrLottie than AXEmojiView. It works like a bridge between these two libraries, so I don't have plan to add it to the library for now, but you can easily add and use these few simple classes to your project and customize it however you want. Like loading lottie files from a link.

from axemojiview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.