anvil
anvil copied to clipboard
Anvil event listeners don't handle focus properly
Anvil version: 0.4.0
Trying to set a listener for onFocusChange
or onTextChanged
on an EditText
via Anvil does not work properly. Each time the listener gets called the EditText
loses focus, even with an empty handler body.
This has been isolated to an Anvil issue, as my workaround to manually set the listener via Anvil.currentView<EditText>().onFocusChangeListener = MyChangeListener()
works fine.
This is reproducible on multiple versions of Android on both physical and virtual devices.
I detected the same issue. My workaround is to set it on the init method:
init(() -> { Anvil.currentView().setOnFocusChangeListener((v, focus) -> { //my logic here }); });
With the onTextChanged I haven't found a passable solution yet. All the solution that come to my mind add to much boilerplate to the code.