Skip to content

Commit

Permalink
adds type checking to Animated toValue and iterations key values to m… (
Browse files Browse the repository at this point in the history
#23812)

Summary:
…ake sure Android does not crash from bad params when using useNativeDriver

Android apps crash when using Animated useNativeDriver: true and the toValue is not a number.  See issue here with test case.  [Issue](#23810)

[Android] [fixed] - Fix crash when using Animated with useNativeDriver and a non Number toValue
Pull Request resolved: #23812

Differential Revision: D14436113

Pulled By: cpojer

fbshipit-source-id: 89fb3180c08cc5ffb817b3984dacda0a80b4f703
  • Loading branch information
Andrew Schenk authored and facebook-github-bot committed Mar 13, 2019
1 parent e3a3231 commit 25d3976
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableType;

/**
* Implementation of {@link AnimationDriver} which provides a support for simple time-based
Expand Down Expand Up @@ -41,8 +42,17 @@ public void resetConfig(ReadableMap config) {
for (int i = 0; i < numberOfFrames; i++) {
mFrames[i] = frames.getDouble(i);
}
mToValue = config.hasKey("toValue") ? config.getDouble("toValue") : 0;
mIterations = config.hasKey("iterations") ? config.getInt("iterations") : 1;
if(config.hasKey("toValue")) {
mToValue = config.getType("toValue") == ReadableType.Number ? config.getDouble("toValue") : 0;
} else {
mToValue = 0;
}
if(config.hasKey("iterations")) {
mIterations = config.getType("iterations") == ReadableType.Number ?
config.getInt("iterations") : 1;
} else {
mIterations = 1;
}
mCurrentLoop = 1;
mHasFinished = mIterations == 0;
mStartFrameTimeNanos = -1;
Expand Down

0 comments on commit 25d3976

Please sign in to comment.