Java Code Examples for com.facebook.react.bridge.ReadableMap#getBoolean()
The following examples show how to use
com.facebook.react.bridge.ReadableMap#getBoolean() .
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: RNGoogleSigninModule.java From google-signin with MIT License | 6 votes |
@ReactMethod public void configure( final ReadableMap config, final Promise promise ) { final ReadableArray scopes = config.hasKey("scopes") ? config.getArray("scopes") : Arguments.createArray(); final String webClientId = config.hasKey("webClientId") ? config.getString("webClientId") : null; final boolean offlineAccess = config.hasKey("offlineAccess") && config.getBoolean("offlineAccess"); final boolean forceCodeForRefreshToken = config.hasKey("forceCodeForRefreshToken") && config.getBoolean("forceCodeForRefreshToken"); final String accountName = config.hasKey("accountName") ? config.getString("accountName") : null; final String hostedDomain = config.hasKey("hostedDomain") ? config.getString("hostedDomain") : null; GoogleSignInOptions options = getSignInOptions(createScopesArray(scopes), webClientId, offlineAccess, forceCodeForRefreshToken, accountName, hostedDomain); _apiClient = GoogleSignIn.getClient(getReactApplicationContext(), options); promise.resolve(null); }
Example 2
Source File: SmartRefreshLayoutManager.java From react-native-SmartRefreshLayout with Apache License 2.0 | 6 votes |
/** * 是否启用自动刷新 * @param view * @param autoRefresh */ @ReactProp(name = "autoRefresh",defaultBoolean = false) public void setAutoRefresh(ReactSmartRefreshLayout view, ReadableMap autoRefresh){ boolean isAutoRefresh=false;Integer time=null; if(autoRefresh.hasKey("refresh")){ isAutoRefresh=autoRefresh.getBoolean("refresh"); } if(autoRefresh.hasKey("time")){ time=autoRefresh.getInt("time"); } if(isAutoRefresh==true){ if(time!=null && time>0){ view.autoRefresh(time); }else{ view.autoRefresh(); } } }
Example 3
Source File: TcpSocketServer.java From react-native-tcp-socket with MIT License | 6 votes |
public TcpSocketServer(final ConcurrentHashMap<Integer, TcpSocketClient> socketClients, final TcpReceiverTask.OnDataReceivedListener receiverListener, final Integer id, final ReadableMap options) throws IOException { super(id); // Get data from options int port = options.getInt("port"); String address = options.getString("host"); this.socketClients = socketClients; clientSocketIds = (1 + getId()) * 1000; // Get the addresses InetAddress localInetAddress = InetAddress.getByName(address); // Create the socket serverSocket = new ServerSocket(port, 50, localInetAddress); // setReuseAddress try { boolean reuseAddress = options.getBoolean("reuseAddress"); serverSocket.setReuseAddress(reuseAddress); } catch (Exception e) { // Default to true serverSocket.setReuseAddress(true); } mReceiverListener = receiverListener; listen(); }
Example 4
Source File: SpringAnimation.java From react-native-GPay with MIT License | 6 votes |
@Override public void resetConfig(ReadableMap config) { mSpringStiffness = config.getDouble("stiffness"); mSpringDamping = config.getDouble("damping"); mSpringMass = config.getDouble("mass"); mInitialVelocity = mCurrentState.velocity; mEndValue = config.getDouble("toValue"); mRestSpeedThreshold = config.getDouble("restSpeedThreshold"); mDisplacementFromRestThreshold = config.getDouble("restDisplacementThreshold"); mOvershootClampingEnabled = config.getBoolean("overshootClamping"); mIterations = config.hasKey("iterations") ? config.getInt("iterations") : 1; mHasFinished = mIterations == 0; mCurrentLoop = 0; mTimeAccumulator = 0; mSpringStarted = false; }
Example 5
Source File: ReactToolbar.java From react-native-GPay with MIT License | 6 votes |
void setActions(@Nullable ReadableArray actions) { Menu menu = getMenu(); menu.clear(); mActionsHolder.clear(); if (actions != null) { for (int i = 0; i < actions.size(); i++) { ReadableMap action = actions.getMap(i); MenuItem item = menu.add(Menu.NONE, Menu.NONE, i, action.getString(PROP_ACTION_TITLE)); if (action.hasKey(PROP_ACTION_ICON)) { setMenuItemIcon(item, action.getMap(PROP_ACTION_ICON)); } int showAsAction = action.hasKey(PROP_ACTION_SHOW) ? action.getInt(PROP_ACTION_SHOW) : MenuItem.SHOW_AS_ACTION_NEVER; if (action.hasKey(PROP_ACTION_SHOW_WITH_TEXT) && action.getBoolean(PROP_ACTION_SHOW_WITH_TEXT)) { showAsAction = showAsAction | MenuItem.SHOW_AS_ACTION_WITH_TEXT; } item.setShowAsAction(showAsAction); } } }
Example 6
Source File: RNAGSMapView.java From react-native-arcgis-mapview with MIT License | 5 votes |
public void showCallout(ReadableMap args) { ReadableMap rawPoint = args.getMap("point"); if (!rawPoint.hasKey("latitude") || !rawPoint.hasKey("longitude")) { return; } Double latitude = rawPoint.getDouble("latitude"); Double longitude = rawPoint.getDouble("longitude"); if (latitude == 0 || longitude == 0) { return; } String title = ""; String text = ""; Boolean shouldRecenter = false; if(args.hasKey("title")) { title = args.getString("title"); } if(args.hasKey("text")) { text = args.getString("text"); } if(args.hasKey("shouldRecenter")) { shouldRecenter = args.getBoolean("shouldRecenter"); } // Displaying the callout Point agsPoint = new Point(longitude, latitude, SpatialReferences.getWgs84()); // Set callout content View calloutContent = callout.getContent(); ((TextView) calloutContent.findViewById(R.id.title)).setText(title); ((TextView) calloutContent.findViewById(R.id.text)).setText(text); callout.setLocation(agsPoint); callout.show(); Log.i("AGS",callout.isShowing()+" " + calloutContent.getWidth() + " " + calloutContent.getHeight()); if (shouldRecenter) { mapView.setViewpointCenterAsync(agsPoint); } }
Example 7
Source File: DefaultNavigationImplementation.java From native-navigation with MIT License | 5 votes |
private void reconcileStatusBarStyle( Activity activity, ReadableMap prev, ReadableMap next, boolean firstCall ) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { reconcileStatusBarStyleOnM( activity, prev, next, firstCall ); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { reconcileStatusBarStyleOnLollipop( activity, prev, next, firstCall ); } if (firstCall || boolHasChanged("statusBarHidden", prev, next)) { boolean hidden = false; if (next.hasKey("statusBarHidden")) { hidden = next.getBoolean("statusBarHidden"); } if (hidden) { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); } else { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } } }
Example 8
Source File: RNLocationModule.java From react-native-gps with MIT License | 5 votes |
private static LocationOptions fromReactMap(ReadableMap map) { // precision might be dropped on timeout (double -> int conversion), but that's OK long timeout = map.hasKey("timeout") ? (long) map.getDouble("timeout") : Long.MAX_VALUE; double maximumAge = map.hasKey("maximumAge") ? map.getDouble("maximumAge") : Double.POSITIVE_INFINITY; boolean highAccuracy = !map.hasKey("enableHighAccuracy") || map.getBoolean("enableHighAccuracy"); float distanceFilter = map.hasKey("distanceFilter") ? (float) map.getDouble("distanceFilter") : RCT_DEFAULT_LOCATION_ACCURACY; return new LocationOptions(timeout, maximumAge, highAccuracy, distanceFilter); }
Example 9
Source File: ReactUtil.java From react-native-android-fragment with Apache License 2.0 | 5 votes |
/** * toObject extracts a value from a {@link ReadableMap} by its key, * and returns a POJO representing that object. * * @param readableMap The Map to containing the value to be converted * @param key The key for the value to be converted * @return The converted POJO */ public static Object toObject(@Nullable ReadableMap readableMap, String key) { if (readableMap == null) { return null; } Object result; ReadableType readableType = readableMap.getType(key); switch (readableType) { case Null: result = key; break; case Boolean: result = readableMap.getBoolean(key); break; case Number: // Can be int or double. double tmp = readableMap.getDouble(key); if (tmp == (int) tmp) { result = (int) tmp; } else { result = tmp; } break; case String: result = readableMap.getString(key); break; case Map: result = toMap(readableMap.getMap(key)); break; case Array: result = toList(readableMap.getArray(key)); break; default: throw new IllegalArgumentException("Could not convert object with key: " + key + "."); } return result; }
Example 10
Source File: TabLayoutManager.java From react-native-android-kit with MIT License | 5 votes |
private boolean addTabs(TabLayoutView view, ReadableArray tabsSettings) { if (view != null) { if (tabsSettings != null) { ReadableMap tabSettingsMap = null; view.removeAllTabs(); for (int i = 0; i < tabsSettings.size(); i++) { tabSettingsMap = tabsSettings.getMap(i); if (tabSettingsMap != null) { if (tabSettingsMap.hasKey("customView")) { boolean customView = tabSettingsMap.getBoolean("customView"); if (customView) { view.attachCustomTab(tabSettingsMap); } else { view.attachTab(tabSettingsMap); } } } else { return false; } } return true; } } return false; }
Example 11
Source File: VLCPlayerViewManager.java From react-native-vlc-player with MIT License | 5 votes |
@ReactProp(name = PROP_SOURCE) public void setPath(final VLCPlayerView playerView, ReadableMap map) { String path = map.getString("uri"); boolean autoPlay = map.getBoolean("autoplay"); playerView.setAutoPlay(autoPlay); playerView.setFilePath(path); }
Example 12
Source File: ReadableMapUtils.java From react-native-google-cast with MIT License | 5 votes |
public static @Nullable Boolean getBoolean(@NonNull ReadableMap map, @NonNull String key) { if (!map.hasKey(key)) { return null; } return map.getBoolean(key); }
Example 13
Source File: QimRNBModule.java From imsdk-android with MIT License | 5 votes |
/** * 群角色管理 * @param params * @param callback */ @ReactMethod public void setGroupAdmin(ReadableMap params, Callback callback){ Logger.i("setGroupAdmin:" + params.toString()); String groupId = params.getString("groupId"); String xmppid = params.getString("xmppid"); String name = params.getString("name"); boolean isAdmin = params.getBoolean("isAdmin"); ConnectionUtil.getInstance().setGroupAdmin(groupId,xmppid,name,isAdmin); }
Example 14
Source File: DefaultNavigationImplementation.java From native-navigation with MIT License | 5 votes |
public void makeTabItem( ReactBottomNavigation bottomNavigation, Menu menu, int index, Integer itemId, ReadableMap config ) { Log.d(TAG, "makeTabItem"); MenuItem item = menu.add( Menu.NONE, itemId, Menu.NONE, config.getString("title") ); if (config.hasKey("image")) { bottomNavigation.setMenuItemIcon(item, config.getMap("image")); } else { // TODO(lmr): this probably isn't the best default. item.setIcon(android.R.drawable.btn_radio); } if (config.hasKey("enabled")) { boolean enabled = config.getBoolean("enabled"); item.setEnabled(enabled); } // not sure if we want/need to set anything on the itemview itself. hacky. // BottomNavigationMenuView menuView = (BottomNavigationMenuView) bottomNavigation.getChildAt(0); // BottomNavigationItemView itemView = (BottomNavigationItemView)menuView.getChildAt(index); }
Example 15
Source File: RNFileSelectorModule.java From react-native-file-selector with Apache License 2.0 | 5 votes |
private void openFilePicker(final ReadableMap props, final Callback onDone, final Callback onCancel) { MaterialFilePicker picker = new MaterialFilePicker(); picker = picker.withActivity(getCurrentActivity()); picker = picker.withRequestCode(1); String filter = props.getString("filter"); boolean filterDirectories = props.getBoolean("filterDirectories"); String path = props.getString("path"); boolean hiddenFiles = props.getBoolean("hiddenFiles"); boolean closeMenu = props.getBoolean("closeMenu"); String title = props.getString("title"); if (filter.length() > 0) { picker = picker.withFilter(Pattern.compile(filter)); } picker = picker.withFilterDirectories(filterDirectories); if (path.length() > 0) { picker = picker.withRootPath(path); } picker = picker.withHiddenFiles(hiddenFiles); picker = picker.withCloseMenu(closeMenu); picker = picker.withTitle(title); this.onDone = onDone; this.onCancel = onCancel; picker.start(); }
Example 16
Source File: QTalkSearchCheckUpdate.java From imsdk-android with MIT License | 4 votes |
@ReactMethod public void update( ReadableMap param, final Callback callback) { WritableNativeMap map = new WritableNativeMap(); // @{@"is_ok": @YES, @"errorMsg": @""}; boolean is_ok = false; Activity activity = getCurrentActivity(); if(activity != null) { // TODO get param String fullpackageUrl = param.getString("bundleUrl"); String fullpackageMd5 = param.getString("zipMd5"); String patchUrl = param.getString("patchUrl"); String patchMd5 = param.getString("patchMd5"); String fullMd5 = param.getString("bundleMd5"); String bundleName = param.getString("bundleName"); // TODO switch update type if(param.getBoolean("new")){ String updateType = param.getString("update_type"); if(updateType.equalsIgnoreCase(FULL_UPDATE)){ // todo full update is_ok = QTalkPatchDownloadHelper.downloadFullPackageAndCheck(fullpackageUrl, fullpackageMd5, bundleName, QTalkSearchRNViewInstanceManager.JS_BUNDLE_NAME_ZIP_NAME, QTalkSearchRNViewInstanceManager.getLocalBundlePath(activity), QTalkSearchRNViewInstanceManager.CACHE_BUNDLE_NAME); } else if(updateType.equalsIgnoreCase(PATCH_UPDATE)) { // todo patch update is_ok = QTalkPatchDownloadHelper.downloadPatchAndCheck(patchUrl, patchMd5, fullMd5, QTalkSearchRNViewInstanceManager.getLocalBundlePath(activity), QTalkSearchRNViewInstanceManager.CACHE_BUNDLE_NAME, QTalkSearchRNViewInstanceManager.JS_BUNDLE_NAME); } else if(updateType.equalsIgnoreCase(AUTO_UPDATE)){ // todo auto update // first patch, if patch error full update is_ok = QTalkPatchDownloadHelper.downloadPatchAndCheck(patchUrl, patchMd5, fullMd5, QTalkSearchRNViewInstanceManager.getLocalBundlePath(activity), QTalkSearchRNViewInstanceManager.CACHE_BUNDLE_NAME, QTalkSearchRNViewInstanceManager.JS_BUNDLE_NAME); if(!is_ok){ is_ok = QTalkPatchDownloadHelper.downloadFullPackageAndCheck(fullpackageUrl, fullpackageMd5, bundleName, QTalkSearchRNViewInstanceManager.JS_BUNDLE_NAME_ZIP_NAME, QTalkSearchRNViewInstanceManager.getLocalBundlePath(activity), QTalkSearchRNViewInstanceManager.CACHE_BUNDLE_NAME); } } } } map.putBoolean("is_ok", is_ok); map.putString("errorMsg", ""); if(is_ok){ CommonConfig.mainhandler.post(new Runnable() { @Override public void run() { QTalkSearchActivity.clearBridge(); } }); } callback.invoke(map); }
Example 17
Source File: Utils.java From react-native-appmetrica with MIT License | 4 votes |
static YandexMetricaConfig toYandexMetricaConfig(ReadableMap configMap) { YandexMetricaConfig.Builder builder = YandexMetricaConfig.newConfigBuilder(configMap.getString("apiKey")); if (configMap.hasKey("appVersion")) { builder.withAppVersion(configMap.getString("appVersion")); } if (configMap.hasKey("crashReporting")) { builder.withCrashReporting(configMap.getBoolean("crashReporting")); } if (configMap.hasKey("firstActivationAsUpdate")) { builder.handleFirstActivationAsUpdate(configMap.getBoolean("firstActivationAsUpdate")); } if (configMap.hasKey("installedAppCollecting")) { builder.withInstalledAppCollecting(configMap.getBoolean("installedAppCollecting")); } if (configMap.hasKey("location")) { builder.withLocation(toLocation(configMap.getMap("location"))); } if (configMap.hasKey("locationTracking")) { builder.withLocationTracking(configMap.getBoolean("locationTracking")); } if (configMap.hasKey("logs") && configMap.getBoolean("logs")) { builder.withLogs(); } if (configMap.hasKey("maxReportsInDatabaseCount")) { builder.withMaxReportsInDatabaseCount(configMap.getInt("maxReportsInDatabaseCount")); } if (configMap.hasKey("nativeCrashReporting")) { builder.withNativeCrashReporting(configMap.getBoolean("nativeCrashReporting")); } if (configMap.hasKey("preloadInfo")) { builder.withPreloadInfo(toPreloadInfo(configMap.getMap("preloadInfo"))); } if (configMap.hasKey("sessionTimeout")) { builder.withSessionTimeout(configMap.getInt("sessionTimeout")); } if (configMap.hasKey("statisticsSending")) { builder.withStatisticsSending(configMap.getBoolean("statisticsSending")); } return builder.build(); }
Example 18
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 19
Source File: YAxisChartBase.java From react-native-mp-android-chart with MIT License | 4 votes |
protected void setYAxisConfig(YAxis axis, ReadableMap propMap) { if (BridgeUtils.validate(propMap, ReadableType.Number, "axisMaxValue")) { axis.setAxisMaxValue((float) propMap.getDouble("axisMaxValue")); } if (BridgeUtils.validate(propMap, ReadableType.Number, "axisMinValue")) { axis.setAxisMinValue((float) propMap.getDouble("axisMinValue")); } if (BridgeUtils.validate(propMap, ReadableType.Boolean, "inverted")) { axis.setInverted(propMap.getBoolean("inverted")); } if (BridgeUtils.validate(propMap, ReadableType.Number, "spaceTop")) { axis.setSpaceTop((float) propMap.getDouble("spaceTop")); } if (BridgeUtils.validate(propMap, ReadableType.Number, "spaceBottom")) { axis.setSpaceBottom((float) propMap.getDouble("spaceBottom")); } if (BridgeUtils.validate(propMap, ReadableType.Boolean, "showOnlyMinMax")) { axis.setShowOnlyMinMax(propMap.getBoolean("showOnlyMinMax")); } if (BridgeUtils.validate(propMap, ReadableType.Number, "labelCount")) { boolean labelCountForce = false; if (BridgeUtils.validate(propMap, ReadableType.Boolean, "labelCountForce")) { labelCountForce = propMap.getBoolean("labelCountForce"); } axis.setLabelCount(propMap.getInt("labelCount"), labelCountForce); } if (BridgeUtils.validate(propMap, ReadableType.String, "position")) { axis.setPosition(YAxis.YAxisLabelPosition.valueOf(propMap.getString("position"))); } if (BridgeUtils.validate(propMap, ReadableType.Number, "granularity")) { axis.setGranularity((float) propMap.getDouble("granularity")); } if (BridgeUtils.validate(propMap, ReadableType.Boolean, "granularityEnabled")) { axis.setGranularityEnabled(propMap.getBoolean("granularityEnabled")); } // formatting if (BridgeUtils.validate(propMap, ReadableType.String, "valueFormatter")) { String valueFormatter = propMap.getString("valueFormatter"); if ("largeValue".equals(valueFormatter)) { axis.setValueFormatter(new LargeValueFormatter()); } else if ("percent".equals(valueFormatter)) { axis.setValueFormatter(new PercentFormatter()); } else { axis.setValueFormatter(new CustomFormatter(valueFormatter)); } } // TODO docs says the remaining config needs to be applied before setting data. Test it // zero line if (BridgeUtils.validate(propMap, ReadableType.Map, "zeroLine")) { ReadableMap zeroLineConfig = propMap.getMap("zeroLine"); if (BridgeUtils.validate(zeroLineConfig, ReadableType.Boolean, "enabled")) { axis.setDrawZeroLine(zeroLineConfig.getBoolean("enabled")); } if (BridgeUtils.validate(zeroLineConfig, ReadableType.Number, "lineWidth")) { axis.setZeroLineWidth((float) zeroLineConfig.getDouble("lineWidth")); } if (BridgeUtils.validate(zeroLineConfig, ReadableType.String, "lineColor")) { axis.setZeroLineColor(Color.parseColor(zeroLineConfig.getString("lineColor"))); } } }
Example 20
Source File: PiliPlayerViewManager.java From react-native-pili with MIT License | 4 votes |
@ReactProp(name = "source") public void setSource(PLVideoView mVideoView, ReadableMap source) { AVOptions options = new AVOptions(); String uri = source.getString("uri"); boolean mediaController = source.hasKey("controller") && source.getBoolean("controller"); int avFrameTimeout = source.hasKey("timeout") ? source.getInt("timeout") : -1; //10 * 1000 ms boolean liveStreaming = source.hasKey("live") && source.getBoolean("live"); //1 or 0 // 1 -> live boolean codec = source.hasKey("hardCodec") && source.getBoolean("hardCodec"); //1 or 0 // 1 -> hw codec enable, 0 -> disable [recommended] // the unit of timeout is ms if (avFrameTimeout >= 0) { options.setInteger(AVOptions.KEY_GET_AV_FRAME_TIMEOUT, avFrameTimeout); } // Some optimization with buffering mechanism when be set to 1 if (liveStreaming) { options.setInteger(AVOptions.KEY_LIVE_STREAMING, 1); } else { options.setInteger(AVOptions.KEY_LIVE_STREAMING, 0); } // } // 1 -> hw codec enable, 0 -> disable [recommended] if (codec) { options.setInteger(AVOptions.KEY_MEDIACODEC, 1); } else { options.setInteger(AVOptions.KEY_MEDIACODEC, 0); } mVideoView.setAVOptions(options); // After setVideoPath, the play will start automatically // mVideoView.start() is not required mVideoView.setVideoPath(uri); // if (mediaController) { // // You can also use a custom `MediaController` widget // MediaController mMediaController = new MediaController(reactContext, false, isLiveStreaming(uri)); // mVideoView.setMediaController(mMediaController); // } }