Skip to content

Instantly share code, notes, and snippets.

@yuriyskulskiy
Last active August 17, 2020 03:02
Show Gist options
  • Save yuriyskulskiy/ba8f1f3bfce906758c70bc93860c22aa to your computer and use it in GitHub Desktop.
Save yuriyskulskiy/ba8f1f3bfce906758c70bc93860c22aa to your computer and use it in GitHub Desktop.
AnimatedLayout part 3: implement fling end listener
private void init() {
...
mFling.addEndListener(new DynamicAnimation.OnAnimationEndListener() {
@Override
public void onAnimationEnd(DynamicAnimation animation, boolean canceled, float value, float velocity) {
if (!canceled) {
if (mOffsetValue == 0 || mOffsetValue == getWidth()) {
//correct ending
mCurrentAnimation = IDLE_ANIMATION_STATE;
if (mOffsetValue == 0) {
mIdleState = WINTER_STATE;
applyWinter();
} else {
mIdleState = SUMMER_STATE;
applySummer();
}
} else {
applyIdleState();
}
} else {
if (!isTouching) {
applyIdleState();
}
}
invalidate();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment