mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-09 22:50:21 +08:00
Static type check for int params + migrate colorInt to just int.
Differential Revision: D2475618 committer: Service User <svcscm@fb.com>
This commit is contained in:
committed by
facebook-github-bot-9
parent
944fa4d635
commit
6c3fb77f30
@@ -64,18 +64,7 @@ public class CatalystStylesDiffMap {
|
||||
}
|
||||
|
||||
public int getInt(String name, int restoreNullToDefaultValue) {
|
||||
return mBackingMap.isNull(name) ? restoreNullToDefaultValue : (int) mBackingMap.getDouble(name);
|
||||
}
|
||||
|
||||
// Colors have values between 0x00000000 and 0xFFFFFFFF, which fits in an integer, but is sent as
|
||||
// a double over the bridge. Because color values can be higher than Integer.MAX_VALUE, it is not
|
||||
// correct to convert doubles to int directly, since they can be truncated to Integer.MAX_VALUE
|
||||
// instead of being converted to negative values. Converting from double to long maintains the
|
||||
// initial value, and is then correctly converted to int. This is the expected behavior according
|
||||
// to the java spec, see http://stackoverflow.com/questions/10641559 for more.
|
||||
public int getColorInt(String name, int restoreNullToDefaultValue) {
|
||||
return mBackingMap.isNull(name) ? restoreNullToDefaultValue :
|
||||
(int) (long) mBackingMap.getDouble(name);
|
||||
return mBackingMap.isNull(name) ? restoreNullToDefaultValue : mBackingMap.getInt(name);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user