Utility extensions for master-koin#60
Conversation
Sync master from origin repo
Sync Master-koin from original repo
| paint.isFakeBoldText = true | ||
| } | ||
| if (fake and Typeface.ITALIC != 0) { | ||
| paint.textSkewX = -0.25f |
There was a problem hiding this comment.
What's the meaning of 0.25 ? can be a constant ?
There was a problem hiding this comment.
Yeah it is the skew factor needed to simulate an italic typeface. You can think of it as the angle the letters are moved to look like this
I created a constant for it so it's not a magic number anymore
| * > Just appending a trailing "," and adding a new Pair allows you to collect an additional | ||
| * flow per pair | ||
| */ | ||
| fun <T> Fragment.collectOnLifeCycle( |
There was a problem hiding this comment.
Thanks! :D It simplifies a lot the fragment's code haha
| val animation: ObjectAnimator = ObjectAnimator | ||
| .ofInt(this, "progress", progress, newlyProgress) | ||
| animation.duration = timeInMillis | ||
| animation.interpolator = DecelerateInterpolator() | ||
| animation.setAutoCancel(true) |
There was a problem hiding this comment.
use scope function here.
There was a problem hiding this comment.
Done. Thanks!
Used apply as suggested by the official kotlin docs to configure objects
| import com.rootstrap.android.R | ||
| import com.rootstrap.android.ui.custom.CustomTypefaceSpan | ||
|
|
||
| fun TextView.setClickableKeyword( |
There was a problem hiding this comment.
add a comment description here. //** ...... *//
There was a problem hiding this comment.
Added a KDoc with an example usage 👍🏼
| text = span | ||
| } | ||
|
|
||
| fun TextView.setColoredKeyword( |
There was a problem hiding this comment.
Added a KDoc here too. Thanks! 👍🏼
73898e5 to
9b71ae8
Compare
Description
Preview
CustomTypeFaceSpanthat allows to set a custom font to parts of a text.Fragment.collectOnLifeCycle(...)extension to reduce the boiler plate code and annoying indentation when collecting flows from a fragment. (It can be easily adapted to activities)ProgressBar.progressTo(...)extension to animate progress updates in one line with ease and good support for older android versions.TextView.setClickableKeyword(...)extension to add clickable functions to words or prhases inside a Textview, allowing to also change their color, font (for example, to bold the keyword), and underline. It recycles the LinkMovementMethod if the TextView already have it.TextView.setColoredKeyword(...)to change the color of a word or prhase to a Textview.These two last functions uses the
getTextAsSpannable()private extension to avoid creating unuseful spannables.