epoxy
epoxy copied to clipboard
No animation when the switch is rebound
I am using Epoxy to make a list that contains the Switch. Scrolling the list, Recycler unbinds the View that contains the switch, and there is a phenomenon that the switch does not animate when it is rebound. I tried the same with RecyclerView.Adapter, but the switch was animated.
The switch uses AppCompat SwitchCompat, and the animation of the switch is realized by the following code.
if (getWindowToken() != null && ViewCompat.isLaidOut(this)) {
animateThumbToCheckedState(checked);
} else {
// Immediately move the thumb to the new position.
cancelPositionAnimator();
setThumbPosition(checked ? 1 : 0);
}
isLaidOut will return false
if the recycled View is rebound.
We cope by the following workaround now.
- RecyclerView#setItemViewCacheSize(0)
- recycledViewPool(NeverRecycleViewPool)
But, performance is very bad because inflate is done every time.
NeverReyclerViewPool is a self-made class. RecycledViewPool#getRecycledView returns null
for View that includes Switch.
Is there a way to make the switch animate even if it is recycled?
RecyclerView Adapter

Epoxy Adapter

The program has been uploaded to the following repository. https://github.com/beeete2/android-recyclerview-example/tree/animation
having a same issue
Do you have any other ideas for workaround or we should report it for google tracker?