Code Monkey home page Code Monkey logo

Comments (13)

bryancallahan avatar bryancallahan commented on July 26, 2024

I don't believe it is supported just yet. I agree it would be great for feature parity. :)

from android-iconify.

rampatra avatar rampatra commented on July 26, 2024

Cool! Will wait for it 👍

from android-iconify.

mikepenz avatar mikepenz commented on July 26, 2024

I don't think this can be done with the current implementation.

If someone got an idea how to implement such behavior please submit a pull-request.

from android-iconify.

guilhermesgb avatar guilhermesgb commented on July 26, 2024

So it seems it eventually got implemented (as per the README.md).
So I was wondering: Is it possible to make an IconDrawable spin (programatically)?

from android-iconify.

JoanZapata avatar JoanZapata commented on July 26, 2024

Spin only works in IconTextView, IconButton and IconToggleButton for now.

I guess it wouldn't be very complicated to make a SpinningIconDrawable, but I'm concerned about memory leaks: I'm not sure a Drawable can know when it's not displayed anymore, so the refresh-loop wouldn't know when to stop. Could be based on the context, but that's not accurate. I'll see what I can do.

I'm opening a new issue for this.

from android-iconify.

guilhermesgb avatar guilhermesgb commented on July 26, 2024

That's great, man. And thanks for the response!

I don't really know the inner workings of rendering drawables, but maybe there's another approach that could work. If there's a way to force a drawable to be rendered continuously while it is within viewport bounds, maybe you could keep state on it's current rotation and on every draw step, increase it just a bit before rendering it. Then I'd try evolving from there (so that the rotation is smooth / not dependent on the "clock"/draw steps / happening at a stable pace).

from android-iconify.

JoanZapata avatar JoanZapata commented on July 26, 2024

That's actually how {fa-cog spin} works inside an IconTextView. It's continuously invalidated and redrawn, and stops when the IconTextView is detached from the window.

But I don't think there's a way to know when a Drawable is not anymore displayed on the screen, so there's no way no know when to stop continuously rendering it. If it's attached to an ImageView then it depends on this ImageView, but a Drawable can be used (and reused) in many other ways.

What is your usecase? ImageView?

from android-iconify.

guilhermesgb avatar guilhermesgb commented on July 26, 2024

I understand… thanks. Yeah, it's tricky if it depends heavily on where the
Drawable's used.
I'm using it alongside/attached to an EditText, as its drawableEnd
drawable.
On Aug 20, 2015 12:46 PM, "Joan Zapata" [email protected] wrote:

That's actually how {fa-cog spin} works inside a IconTextView. It's
continuously invalidated and redrawn, and stops when the IconTextView is
detached from the window.

But I don't think there's a way to know when a Drawable is not anymore
displayed on the screen, so there's no way no know when to stop
continuously rendering it. If it's attached to an ImageView then it
depends on this ImageView, but a Drawable can be used (and reused) in
many other ways.

What is your usecase? ImageView?


Reply to this email directly or view it on GitHub
#56 (comment)
.

from android-iconify.

JoanZapata avatar JoanZapata commented on July 26, 2024

Can't you just use IconEditText and put {fa-something spin} at the end of the text?

from android-iconify.

guilhermesgb avatar guilhermesgb commented on July 26, 2024

Yeah, that's the other approach I considered taking but was too lazy to go ahead and build it myself last night, as I think I'd have to perform a major copy-and-pasting of the EditText's source and have this new class extend IconTextView, and I really hate copy-and-pasting. I couldn't think of a better approach for building it but maybe later I could sit down and start learning from IconTextView and make a new class that simply extends EditText and then does the same things that IconTextView does.

(And I actually don't need a spinning IconDrawable - I'm just experimenting with this library to see how powerful it just for curiosity's sake right now, I plan on using it in future projects. Thanks for this, it's really convenient!)

EDIT: Oops, just noticed it's rather easy to implement IconEditText by extending EditText. Almost just a matter of overriding setText.

@Override
public void setText(CharSequence text, BufferType type) {
    super.setText(Iconify.compute(getContext(), text, this), type);
}

I'm sorry for being so lazy and actually not reading through IconTextView's source until now. :(
I was thinking that maybe it could be a good PR in the future but... not really haha

from android-iconify.

JoanZapata avatar JoanZapata commented on July 26, 2024

Oh my bad, I just realized you were talking about an EditText and not a TextView!
There's actually a convenient lib based on Iconify which does just that!
https://github.com/DayS/EnhancedEditText/

from android-iconify.

guilhermesgb avatar guilhermesgb commented on July 26, 2024

That's cool, and thanks for referring me to that library! In the meanwhile I attempted building IconEditText. That approach I mentioned above works great (spinning doesn't work maybe EditText doesn't allow the invalidation approach) unless you want to apply icons to hint's as well (my case). Unfortunatelly setHint is final and thus cannot be overriden.

I need that because I want to use EditText in conjunction with TextInputLayout. Apparently it's not supported by EnhancedEditText as well, at least from what I could tell by quickly skimming through the source. So that's potentially a cool PR I could try sending them, thanks! :)

from android-iconify.

 avatar commented on July 26, 2024

@JoanZapata can I change spinning speed?

from android-iconify.

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.