These kind of things shouln't go overboard, but ex...
# android
d
These kind of things shouln't go overboard, but extensions are such a good way to make the android api a bit more readable (especially the 'old' classes like many things in android.graphics)
k
ferranis: Yea. I usually find myself writing a number of extension functions on top of those good 'ol classes. Context, View and co. Makes life a lot easier
d
View in particular... why is there no view.show() method? setVisibility(View.VISIBLE) is so obscure and long
💯 1
k
ferranis: A good example is something like this:
Copy code
var View.isVisible: Boolean
    get () = visibility == View.VISIBLE
    set(value) { 
        visibility = if (value) View.VISIBLE else View.GONE 
    }
...Given INVISIBLE isn't a state I use so often
d
Thats just the methods (directly on the view) that make things very readable. Also one i found useful in my project:
fun View.isTranslucent() = alpha < 1.0f
Extensions are just a great way to add domain specific things without cluttering the android api
k
I have a couple of them actually. Extension functions/properties just makes Android dev great again
I find it difficult getting much productivity out of a no-kotlin project these days
d
Kotlin in particular makes android dev great again!. Its just so much things you don't need to write or things you can express in much less code. Java has just too much boilerplate code.
k
Haha. *Kotlin. Yes ☺️
d
Also a very, very important plus for kolin: It makes tests more readable and expressive