Last active
August 17, 2020 03:02
-
-
Save yuriyskulskiy/ba8f1f3bfce906758c70bc93860c22aa to your computer and use it in GitHub Desktop.
AnimatedLayout part 3: implement fling end listener
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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