Java Code Examples for com.facebook.react.bridge.ReadableMap#isNull()
The following examples show how to use
com.facebook.react.bridge.ReadableMap#isNull() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReactPickerManager.java From react-native-GPay with MIT License | 6 votes |
private View getView(int position, View convertView, ViewGroup parent, boolean isDropdown) { ReadableMap item = getItem(position); if (convertView == null) { int layoutResId = isDropdown ? android.R.layout.simple_spinner_dropdown_item : android.R.layout.simple_spinner_item; convertView = mInflater.inflate(layoutResId, parent, false); } TextView textView = (TextView) convertView; textView.setText(item.getString("label")); if (!isDropdown && mPrimaryTextColor != null) { textView.setTextColor(mPrimaryTextColor); } else if (item.hasKey("color") && !item.isNull("color")) { textView.setTextColor(item.getInt("color")); } return convertView; }
Example 2
Source File: ReactBaseTextShadowNode.java From react-native-GPay with MIT License | 6 votes |
@ReactProp(name = PROP_SHADOW_OFFSET) public void setTextShadowOffset(ReadableMap offsetMap) { mTextShadowOffsetDx = 0; mTextShadowOffsetDy = 0; if (offsetMap != null) { if (offsetMap.hasKey(PROP_SHADOW_OFFSET_WIDTH) && !offsetMap.isNull(PROP_SHADOW_OFFSET_WIDTH)) { mTextShadowOffsetDx = PixelUtil.toPixelFromDIP(offsetMap.getDouble(PROP_SHADOW_OFFSET_WIDTH)); } if (offsetMap.hasKey(PROP_SHADOW_OFFSET_HEIGHT) && !offsetMap.isNull(PROP_SHADOW_OFFSET_HEIGHT)) { mTextShadowOffsetDy = PixelUtil.toPixelFromDIP(offsetMap.getDouble(PROP_SHADOW_OFFSET_HEIGHT)); } } markUpdated(); }
Example 3
Source File: TimePickerDialogModule.java From react-native-GPay with MIT License | 6 votes |
private Bundle createFragmentArguments(ReadableMap options) { final Bundle args = new Bundle(); if (options.hasKey(ARG_HOUR) && !options.isNull(ARG_HOUR)) { args.putInt(ARG_HOUR, options.getInt(ARG_HOUR)); } if (options.hasKey(ARG_MINUTE) && !options.isNull(ARG_MINUTE)) { args.putInt(ARG_MINUTE, options.getInt(ARG_MINUTE)); } if (options.hasKey(ARG_IS24HOUR) && !options.isNull(ARG_IS24HOUR)) { args.putBoolean(ARG_IS24HOUR, options.getBoolean(ARG_IS24HOUR)); } if (options.hasKey(ARG_MODE) && !options.isNull(ARG_MODE)) { args.putString(ARG_MODE, options.getString(ARG_MODE)); } return args; }
Example 4
Source File: DatePickerDialogModule.java From react-native-GPay with MIT License | 6 votes |
private Bundle createFragmentArguments(ReadableMap options) { final Bundle args = new Bundle(); if (options.hasKey(ARG_DATE) && !options.isNull(ARG_DATE)) { args.putLong(ARG_DATE, (long) options.getDouble(ARG_DATE)); } if (options.hasKey(ARG_MINDATE) && !options.isNull(ARG_MINDATE)) { args.putLong(ARG_MINDATE, (long) options.getDouble(ARG_MINDATE)); } if (options.hasKey(ARG_MAXDATE) && !options.isNull(ARG_MAXDATE)) { args.putLong(ARG_MAXDATE, (long) options.getDouble(ARG_MAXDATE)); } if (options.hasKey(ARG_MODE) && !options.isNull(ARG_MODE)) { args.putString(ARG_MODE, options.getString(ARG_MODE)); } return args; }
Example 5
Source File: StackTraceHelper.java From react-native-GPay with MIT License | 6 votes |
/** * Convert a JavaScript stack trace (see {@code parseErrorStack} JS module) to an array of * {@link StackFrame}s. */ public static StackFrame[] convertJsStackTrace(@Nullable ReadableArray stack) { int size = stack != null ? stack.size() : 0; StackFrame[] result = new StackFrame[size]; for (int i = 0; i < size; i++) { ReadableType type = stack.getType(i); if (type == ReadableType.Map) { ReadableMap frame = stack.getMap(i); String methodName = frame.getString("methodName"); String fileName = frame.getString("file"); int lineNumber = -1; if (frame.hasKey(LINE_NUMBER_KEY) && !frame.isNull(LINE_NUMBER_KEY)) { lineNumber = frame.getInt(LINE_NUMBER_KEY); } int columnNumber = -1; if (frame.hasKey(COLUMN_KEY) && !frame.isNull(COLUMN_KEY)) { columnNumber = frame.getInt(COLUMN_KEY); } result[i] = new StackFrameImpl(fileName, methodName, lineNumber, columnNumber); } else if (type == ReadableType.String) { result[i] = new StackFrameImpl(null, stack.getString(i), -1, -1); } } return result; }
Example 6
Source File: JSStackTrace.java From react-native-GPay with MIT License | 6 votes |
public static String format(String message, ReadableArray stack) { StringBuilder stringBuilder = new StringBuilder(message).append(", stack:\n"); for (int i = 0; i < stack.size(); i++) { ReadableMap frame = stack.getMap(i); stringBuilder .append(frame.getString("methodName")) .append("@") .append(stackFrameToModuleId(frame)) .append(frame.getInt("lineNumber")); if (frame.hasKey("column") && !frame.isNull("column") && frame.getType("column") == ReadableType.Number) { stringBuilder .append(":") .append(frame.getInt("column")); } stringBuilder.append("\n"); } return stringBuilder.toString(); }
Example 7
Source File: JSStackTrace.java From react-native-GPay with MIT License | 5 votes |
private static String stackFrameToModuleId(ReadableMap frame) { if (frame.hasKey("file") && !frame.isNull("file") && frame.getType("file") == ReadableType.String) { final Matcher matcher = mJsModuleIdPattern.matcher(frame.getString("file")); if (matcher.find()) { return matcher.group(1) + ":"; } } return ""; }
Example 8
Source File: NavBarStyle.java From react-native-turbolinks with MIT License | 5 votes |
private NavBarStyle(ReadableMap rp) { ReadableMap menuIcon = rp.hasKey(MENU_ICON) ? rp.getMap(MENU_ICON) : null; this.titleTextColor = rp.hasKey(TITLE_TEXT_COLOR) && !rp.isNull(TITLE_TEXT_COLOR) ? rp.getInt(TITLE_TEXT_COLOR) : null; this.subtitleTextColor = rp.hasKey(SUBTITLE_TEXT_COLOR) && !rp.isNull(SUBTITLE_TEXT_COLOR) ? rp.getInt(SUBTITLE_TEXT_COLOR) : null; this.barTintColor = rp.hasKey(BAR_TINT_COLOR) && !rp.isNull(BAR_TINT_COLOR) ? rp.getInt(BAR_TINT_COLOR) : null; this.menuIcon = menuIcon != null ? Arguments.toBundle(menuIcon) : null; }
Example 9
Source File: ViewProps.java From react-native-GPay with MIT License | 4 votes |
public static boolean isLayoutOnly(ReadableMap map, String prop) { if (LAYOUT_ONLY_PROPS.contains(prop)) { return true; } else if (POINTER_EVENTS.equals(prop)) { String value = map.getString(prop); return AUTO.equals(value) || BOX_NONE.equals(value); } switch (prop) { case OPACITY: // null opacity behaves like opacity = 1 // Ignore if explicitly set to default opacity. return map.isNull(OPACITY) || map.getDouble(OPACITY) == 1d; case BORDER_RADIUS: // Without a background color or border width set, a border won't show. if (map.hasKey(BACKGROUND_COLOR) && map.getInt(BACKGROUND_COLOR) != Color.TRANSPARENT) { return false; } if (map.hasKey(BORDER_WIDTH) && !map.isNull(BORDER_WIDTH) && map.getDouble(BORDER_WIDTH) != 0d) { return false; } return true; case BORDER_LEFT_COLOR: return map.getInt(BORDER_LEFT_COLOR) == Color.TRANSPARENT; case BORDER_RIGHT_COLOR: return map.getInt(BORDER_RIGHT_COLOR) == Color.TRANSPARENT; case BORDER_TOP_COLOR: return map.getInt(BORDER_TOP_COLOR) == Color.TRANSPARENT; case BORDER_BOTTOM_COLOR: return map.getInt(BORDER_BOTTOM_COLOR) == Color.TRANSPARENT; case BORDER_WIDTH: return map.isNull(BORDER_WIDTH) || map.getDouble(BORDER_WIDTH) == 0d; case BORDER_LEFT_WIDTH: return map.isNull(BORDER_LEFT_WIDTH) || map.getDouble(BORDER_LEFT_WIDTH) == 0d; case BORDER_TOP_WIDTH: return map.isNull(BORDER_TOP_WIDTH) || map.getDouble(BORDER_TOP_WIDTH) == 0d; case BORDER_RIGHT_WIDTH: return map.isNull(BORDER_RIGHT_WIDTH) || map.getDouble(BORDER_RIGHT_WIDTH) == 0d; case BORDER_BOTTOM_WIDTH: return map.isNull(BORDER_BOTTOM_WIDTH) || map.getDouble(BORDER_BOTTOM_WIDTH) == 0d; case OVERFLOW: return map.isNull(OVERFLOW) || VISIBLE.equals(map.getString(OVERFLOW)); default: return false; } }
Example 10
Source File: FabricTwitterKitModule.java From react-native-fabric-twitterkit with MIT License | 4 votes |
private boolean hasValidKey(String key, ReadableMap options) { return options.hasKey(key) && !options.isNull(key); }
Example 11
Source File: ReactNativeNotificationHubModule.java From react-native-azurenotificationhub with MIT License | 4 votes |
@ReactMethod public void register(ReadableMap config, Promise promise) { ReactNativeNotificationHubUtil notificationHubUtil = ReactNativeNotificationHubUtil.getInstance(); String connectionString = config.getString(KEY_REGISTRATION_CONNECTIONSTRING); if (connectionString == null) { promise.reject(ERROR_INVALID_ARGUMENTS, ERROR_INVALID_CONNECTION_STRING); return; } String hubName = config.getString(KEY_REGISTRATION_HUBNAME); if (hubName == null) { promise.reject(ERROR_INVALID_ARGUMENTS, ERROR_INVALID_HUBNAME); return; } String senderID = config.getString(KEY_REGISTRATION_SENDERID); if (senderID == null) { promise.reject(ERROR_INVALID_ARGUMENTS, ERROR_INVALID_SENDER_ID); return; } String[] tags = null; if (config.hasKey(KEY_REGISTRATION_TAGS) && !config.isNull(KEY_REGISTRATION_TAGS)) { ReadableArray tagsJson = config.getArray(KEY_REGISTRATION_TAGS); tags = new String[tagsJson.size()]; for (int i = 0; i < tagsJson.size(); ++i) { tags[i] = tagsJson.getString(i); } } ReactContext reactContext = getReactApplicationContext(); notificationHubUtil.setConnectionString(reactContext, connectionString); notificationHubUtil.setHubName(reactContext, hubName); notificationHubUtil.setSenderID(reactContext, senderID); notificationHubUtil.setTemplated(reactContext, false); notificationHubUtil.setTags(reactContext, tags); if (config.hasKey(KEY_REGISTRATION_CHANNELNAME)) { String channelName = config.getString(KEY_REGISTRATION_CHANNELNAME); notificationHubUtil.setChannelName(reactContext, channelName); } if (config.hasKey(KEY_REGISTRATION_CHANNELDESCRIPTION)) { String channelDescription = config.getString(KEY_REGISTRATION_CHANNELDESCRIPTION); notificationHubUtil.setChannelDescription(reactContext, channelDescription); } if (config.hasKey(KEY_REGISTRATION_CHANNELIMPORTANCE)) { int channelImportance = config.getInt(KEY_REGISTRATION_CHANNELIMPORTANCE); notificationHubUtil.setChannelImportance(reactContext, channelImportance); } if (config.hasKey(KEY_REGISTRATION_CHANNELSHOWBADGE)) { boolean channelShowBadge = config.getBoolean(KEY_REGISTRATION_CHANNELSHOWBADGE); notificationHubUtil.setChannelShowBadge(reactContext, channelShowBadge); } if (config.hasKey(KEY_REGISTRATION_CHANNELENABLELIGHTS)) { boolean channelEnableLights = config.getBoolean(KEY_REGISTRATION_CHANNELENABLELIGHTS); notificationHubUtil.setChannelEnableLights(reactContext, channelEnableLights); } if (config.hasKey(KEY_REGISTRATION_CHANNELENABLEVIBRATION)) { boolean channelEnableVibration = config.getBoolean(KEY_REGISTRATION_CHANNELENABLEVIBRATION); notificationHubUtil.setChannelEnableVibration(reactContext, channelEnableVibration); } String uuid = notificationHubUtil.getUUID(reactContext); if (uuid == null) { uuid = ReactNativeUtil.genUUID(); notificationHubUtil.setUUID(reactContext, uuid); } GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); int resultCode = apiAvailability.isGooglePlayServicesAvailable(reactContext); if (resultCode != ConnectionResult.SUCCESS) { if (apiAvailability.isUserResolvableError(resultCode)) { UiThreadUtil.runOnUiThread( new GoogleApiAvailabilityRunnable( getCurrentActivity(), apiAvailability, resultCode)); promise.reject(ERROR_PLAY_SERVICES, ERROR_PLAY_SERVICES_DISABLED); } else { promise.reject(ERROR_PLAY_SERVICES, ERROR_PLAY_SERVICES_UNSUPPORTED); } return; } Intent intent = ReactNativeNotificationHubUtil.IntentFactory.createIntent( reactContext, ReactNativeRegistrationIntentService.class); ReactNativeRegistrationIntentService.enqueueWork(reactContext, intent); WritableMap res = Arguments.createMap(); res.putString(KEY_PROMISE_RESOLVE_UUID, uuid); promise.resolve(res); }
Example 12
Source File: ShareIntent.java From react-native-share with MIT License | 4 votes |
public static boolean hasValidKey(String key, ReadableMap options) { return options != null && options.hasKey(key) && !options.isNull(key); }