Closed riclage closed 6 years ago
explicitly checks whether mState == state.
True. I missed that. Still, the problem applies. I updated the PR description.
Also, the same could be achieved by caching the latest value of newState externally, e.g.
Sure. That's how I'm currently doing. Just felt like it belonged in the lib instead.
@justasm Could you merge this?
Problem
Listeners of the
onStateChanged()
callback cannot know the previous state the behavior was in. Knowing the old state is useful to perform one time operations.For example, while the new state is
STATE_DRAGGING
theonStateChanged()
callback will be called ~several times~ and there is no way of knowing where it came from before without caching the value externally. But we might be interested in performing an action only when the state is changing fromSTATE_COLLAPSED
toSTATE_DRAGGING
.Solution
We add the param
oldState
to the callback.