mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-10 09:29:39 +08:00
adds type checking to Animated toValue and iterations key values to m… (#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](https://github.com/facebook/react-native/issues/23810) [Android] [fixed] - Fix crash when using Animated with useNativeDriver and a non Number toValue Pull Request resolved: https://github.com/facebook/react-native/pull/23812 Differential Revision: D14436113 Pulled By: cpojer fbshipit-source-id: 89fb3180c08cc5ffb817b3984dacda0a80b4f703
This commit is contained in:
committed by
Facebook Github Bot
parent
e3a3231e2f
commit
25d397651e
@@ -9,6 +9,7 @@ package com.facebook.react.animated;
|
||||
|
||||
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
|
||||
@@ -41,8 +42,17 @@ class FrameBasedAnimationDriver extends AnimationDriver {
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user