Handle converting maps that are null or empty

This commit is contained in:
Hampton Maxwell 2018-06-22 19:20:25 -07:00 committed by GitHub
parent c67dd7b8ef
commit bb2b3eb306
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -641,14 +641,11 @@ public class ReactVideoView extends ScalableVideoView implements MediaPlayer.OnP
* @see 'Adapted from https://github.com/artemyarulin/react-native-eval/blob/master/android/src/main/java/com/evaluator/react/ConversionUtil.java' * @see 'Adapted from https://github.com/artemyarulin/react-native-eval/blob/master/android/src/main/java/com/evaluator/react/ConversionUtil.java'
*/ */
public static Map<String, String> toStringMap(@Nullable ReadableMap readableMap) { public static Map<String, String> toStringMap(@Nullable ReadableMap readableMap) {
Map<String, String> result = new HashMap<>();
if (readableMap == null) if (readableMap == null)
return null; return result;
com.facebook.react.bridge.ReadableMapKeySetIterator iterator = readableMap.keySetIterator(); com.facebook.react.bridge.ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
if (!iterator.hasNextKey())
return null;
Map<String, String> result = new HashMap<>();
while (iterator.hasNextKey()) { while (iterator.hasNextKey()) {
String key = iterator.nextKey(); String key = iterator.nextKey();
result.put(key, readableMap.getString(key)); result.put(key, readableMap.getString(key));