diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2021-06-17 01:03:42 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2021-06-17 01:03:42 +0000 |
commit | cb5b64b85433c3d6e4c37f5d691bf3dc2165e71a (patch) | |
tree | 05fe4bbf03603703931670dfb2e19f7173e88ef9 | |
parent | 02ec643ca425435a340a68f8e48b86eb4704a8fc (diff) | |
parent | 8ded831b9255a5807bc24a1455d332963f333232 (diff) | |
download | lottie-android12-d1-s3-release.tar.gz |
Snap for 7464903 from 8ded831b9255a5807bc24a1455d332963f333232 to sc-d1-releaseandroid-12.0.0_r7android-12.0.0_r6android-12.0.0_r5android-12.0.0_r4android-12.0.0_r15android-12.0.0_r14android-12.0.0_r13android-12.0.0_r12android12-d1-s6-releaseandroid12-d1-s5-releaseandroid12-d1-s4-releaseandroid12-d1-s3-releaseandroid12-d1-s2-releaseandroid12-d1-s1-releaseandroid12-d1-release
Change-Id: Ia918dbee2774cf2289d7084adbbc60fa6713b6b5
-rw-r--r-- | lottie/src/main/java/com/airbnb/lottie/parser/KeyframeParser.java | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/lottie/src/main/java/com/airbnb/lottie/parser/KeyframeParser.java b/lottie/src/main/java/com/airbnb/lottie/parser/KeyframeParser.java index 8cd45bac..5ba38ba6 100644 --- a/lottie/src/main/java/com/airbnb/lottie/parser/KeyframeParser.java +++ b/lottie/src/main/java/com/airbnb/lottie/parser/KeyframeParser.java @@ -137,8 +137,27 @@ class KeyframeParser { interpolator = interpolatorRef.get(); } if (interpolatorRef == null || interpolator == null) { - interpolator = PathInterpolatorCompat.create( - cp1.x / scale, cp1.y / scale, cp2.x / scale, cp2.y / scale); + cp1.x /= scale; + cp1.y /= scale; + cp2.x /= scale; + cp2.y /= scale; + try { + interpolator = PathInterpolatorCompat.create(cp1.x, cp1.y, cp2.x, cp2.y); + } catch (IllegalArgumentException e) { + if (e.getMessage().equals("The Path cannot loop back on itself.")) { + // If a control point extends beyond the previous/next point then it + // will cause the value of the interpolator to no longer monotonously + // increase. This clips the control point bounds to prevent that from + // happening. + // NOTE: this will make the rendered animation behave slightly differently + // than the original. + interpolator = PathInterpolatorCompat.create( + Math.min(cp1.x, 1f), cp1.y, Math.max(cp2.x, 0f), cp2.y); + } else { + // We failed to create the interpolator. Fall back to linear. + interpolator = new LinearInterpolator(); + } + } try { putInterpolator(hash, new WeakReference<>(interpolator)); } catch (ArrayIndexOutOfBoundsException e) { |