anvil icon indicating copy to clipboard operation
anvil copied to clipboard

Anvil event listeners don't handle focus properly

Open aem opened this issue 8 years ago • 1 comments

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.

aem avatar Feb 03 '17 14:02 aem

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.

Martori avatar Jul 28 '17 18:07 Martori