Android Custom Alert Dialogs + Kotlin extension functions + Kotlin Higher Order functions = Life become Easier! — Kotlin DSL
Being an Android developer, tech enthusiast, I always like to explore/experiment/implement all new stuffs in my day to day professional life. I was thinking to write a re-usable Alert Dialog classes in Kotlin to be used across app, as a result, I found an elegant way, and sharing that with you all.
Prerequisites,
- You need to be aware of Kotlin Extension functions.
- Kotlin Higher Order functions.
Let’s get started,
Step 1,
An abstract base class, I won’t go into much detail, since code is self-explanatory.
Step 2,
after extending the above class,
Step 3,
Extension functions, make sure to be able to call from both Activity & Fragment.
Step 4,
And call from “SomeFragment.kt”,
Sharing another example as bonus,
And, WTH is
showVLog(“ — — — — ”) ?
Again, its another extension function.
That’s it, how else can we improve this from here? suggestions are invited.
Happy Coding!