Focusing Hint EditText: A Picky requirement from UI Designer
If a property use huge resources when it’s initialized or doesn’t need to be initialized everytime, you could apply Lazy Initialization pattern.
For example, Pizza
class provide its dough. But it takes quite long time to make new dough. So let’s get dough only once when use it for the first time.
class Pizza() {
private var _dough: Dough? = null //Backing property of dough. It saves data.
val dough: Dough
get() {
if(_dough == null) {
_dough = getDough() //get dough only when initial approach
}
return _dough!! //if it has saved data, return the data.
}
}
Yes. You don’t need to write this whole code in Kotlin. Kotlin suggest lazy
.
class Pizza() {
val dough by lazy { getDough() }
}
lazy
internally delay initialization like above code. Moreover unlike the code above, it’s thread-safety.
If there’s a mistake, always welcome your opinion!
Last month, Jetpack Compose Beta was released! see Beta Overview Even if it’s beta, looks cool for some super advantages. In this posting, I will focus on L...
No doubt about that Clubhouse is the most hottest social media recently. There is no special UI/UX which is never have seen anywhere else. But I’m impressed ...
Almost every Android developers have tried passing data and getting response between two activities. Before Result API released, we passed data on startActi...
Let’s say you already know about getter and setter of Java. The Accessors are like this:
No doubt about that Clubhouse is the most hottest social media recently. There is no special UI/UX which is never have seen anywhere else. But I’m impressed ...
Last month, Jetpack Compose Beta was released! see Beta Overview Even if it’s beta, looks cool for some super advantages. In this posting, I will focus on L...