August 2017
Intermediate to advanced
440 pages
10h
English
When we use Model-View-Presenter (MVP) in the project, then we need to make all the changes in View using the Presenter. Thus, we are forced to create multiple functions on the View, such as:
override fun getName(): String {
return nameView.text.toString()
}
override fun setName(name: String) {
nameView.text = name
}
We also have to define the functions in the following interface:
interface MainView {
fun getName(): String
fun setName(name: String)
}
We may simplify the preceding code and reduce the need for setter/getter methods by using property binding. We can bind the property to view element. This is the result we would like to achieve:
override var name: String by bindToTex(R.id.textView)
And here is interface:
Read now
Unlock full access