View: fix setTransientState
Following four steps with RecyclerView - CardView - ImageView:
a. fade in imageview in onBind:
calling imageView.setTransientState(true)
b. RecyclerView animate the item: calling
cardView.setTransientState(true)
c. fade-in finishes, calling imageView.setTransientState(false)
d. RecyclerView animation finishes: calling
cardView.setTransientState(false)
After these four steps, RecyclerView unexpectedly has transient
state.
The problem is in step b, when calling cardView.setTransientState()
it incorrectly calls parent.childHasTransientStateChanged(this, true)
which causes RecyclerView's mChildCountWithTransientState increased
to 2. And it's decreased to 1 in step d and stay as 1 forever.
The child should only call childHasTransientStateChanged() when
actual hasTransientState() changed.
Bug:
64235615
Test: ViewTransientStateTest
Change-Id: I99ed35cc9c49e54d36590d8f1d206501fd3288f2