Real talk: Data binding | Zarah Dominguez & Hugo Visser

  Рет қаралды 704

AsyncAndroid

AsyncAndroid

Күн бұрын

Пікірлер
@HoggsvilleAdventures
@HoggsvilleAdventures 4 жыл бұрын
Great informative video, keep it up guys.
@ManishPatel3030
@ManishPatel3030 4 жыл бұрын
Thanks for cool discussion on Data Binding 🙏
@Zhuinden
@Zhuinden 4 жыл бұрын
inline fun EditText.onTextChanged(crossinline textChangeListener: (String) -> Unit): TextWatcher { val textWatcher = object : TextWatcher { override fun afterTextChanged(s: Editable?) { } override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { } override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { textChangeListener(s.toString()) } } this.addTextChangedListener(textWatcher) return textWatcher } Now I can do editText.onTextChanged { viewModel.onTextChanged(it) }
@HugoVisser
@HugoVisser 4 жыл бұрын
Not sure what you are trying to point out, but you can obviously call that code from a binding adapter too if you like. In both cases you need to write that code, either as an extension function, in a binding adapter or a combination of both. Then if you can just use that in your view as if Android had this already implemented that on EditText. There are other ways to track changes to texts too by the way. You can use a MutableLiveData too for example. In that case there's no binding adapter to write, you just bind that MutableLiveData in your view model to your view.
@Zhuinden
@Zhuinden 4 жыл бұрын
@@HugoVisser Just that if the issue is that you want a method to exist but instead you get this TextWatcher with a bloated interface, Kotlin extension functions can also solve that issue
@Zhuinden
@Zhuinden 4 жыл бұрын
Apparently it's also in Ktx, except it's called `doOnTextChanged`.
@coreflodev
@coreflodev 4 жыл бұрын
that's terrible code, why are people writing so much code? A textView is enough to implement the warning/error/info component
Deep Dive into Room Flows | Eric Maxwell
26:12
AsyncAndroid
Рет қаралды 1,2 М.
Getting Started with MotionLayout in Android | Rebecca Franks
28:46
AsyncAndroid
Рет қаралды 2,3 М.
ССЫЛКА НА ИГРУ В КОММЕНТАХ #shorts
0:36
Паша Осадчий
Рет қаралды 8 МЛН
Intro to the Zig Programming Language • Andrew Kelley • GOTO 2022
50:14
Reducing UI Test Flakiness With BusyBee | Michael Bailey
21:24
Room Relationship Recap | Adam McNeilly
21:56
AsyncAndroid
Рет қаралды 2 М.
DHH discusses SQLite (and Stoicism)
54:00
Aaron Francis
Рет қаралды 104 М.
Про Kafka (основы)
49:23
Владимир Богдановский
Рет қаралды 421 М.
ССЫЛКА НА ИГРУ В КОММЕНТАХ #shorts
0:36
Паша Осадчий
Рет қаралды 8 МЛН