BabushkaText icon indicating copy to clipboard operation
BabushkaText copied to clipboard

Support for custom spans

Open antonkrasov opened this issue 10 years ago • 3 comments

Hi,

First of all, thanks for your library, it looks really nice. But it will be much better to give an ability to add custom spans.

Thanks.

antonkrasov avatar Dec 07 '14 16:12 antonkrasov

Hey Anton, thanks for the feedback. I actually thought about adding this, but my main goal while developing this library was to completely abstract it from the idea of Spannables, and letting people attach their custom spans would kind of defeat this purpose. Since this is just a wrapper around Spannables, I guess the only way to give user 100% of the functionality of spans without having to expose them to Spannables themselves, would be to add the fews spans that the library's missing (drawables for example) and hopefully that would be enough and there wouldn't be the need to add customs spans. Unless you have a better approach of course, them I'm all ears :)

hboregio avatar Dec 07 '14 17:12 hboregio

I understand your idea to hide spans, they are awful, but it's always a good idea not to limit users of the library, as you don't know what they need :) Possibly it's possible to wrap some spans with own interface and give users an ability to implement onDraw method. For sure one more important this will be adding an ability to hand click on specific pieces.

For example I want to use this textview to display "Website: \nPhone: ", it's much better to have one TextView then 4, but I need to have an ability to handle clicks separately on website and phone.

Adding an ability to add custom spans is the most easy way to make it possibly. Adding own interfaces is another way, but it's more complex :)

antonkrasov avatar Dec 07 '14 17:12 antonkrasov

Yeah, definitely agree with being able to define click events for the different spans.

hboregio avatar Dec 08 '14 14:12 hboregio