anvil-ui/anvil

Anvil.render() and ripple effect drawable problem

Closed this issue · 1 comments

I have detected a problem with Anvil rendering of views and the ripple drawable. I have some buttons that on api >= 21 have a ripple effect when the user presses them.
The problem is if that the action of the button triggers an Anvil.render() this ripple effect is not displayed. If the button doesn't trigger any render on part of anvil the animation plays normally.

What I tested:

  • no click listener whatsoever -> proper animation
  • Anvil's onClick() with code that changes some view state -> no animation
  • Anvil's onClick() with empty listener -> no animation
  • Anvil's init() with Android setOnClickListener() with empty listener -> proper animation
  • Anvil's init() with Android setOnClickListener() with listener that changes some view state without Anvil.render() -> proper animation but no view change
  • Anvil's init() with Android setOnClickListener() with listener with only Anvil.render() -> no animation
  • Anvil's init() with Android setOnClickListener() with listener that changes some view state with Anvil.render() but view changes properly -> no animation

This is because Anvil use simple java equals() mechanism for comparing values. You probably set RippleDrawable to DSL.background, and Anvil sets every render cycle new RippleDrawable object.
As workaround you can use backgroundResource(R.drawable.yourripple), and ripple will be shown just fine.