本文整理匯總了Java中com.facebook.react.bridge.ReadableMap.getInt方法的典型用法代碼示例。如果您正苦於以下問題:Java ReadableMap.getInt方法的具體用法?Java ReadableMap.getInt怎麽用?Java ReadableMap.getInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.facebook.react.bridge.ReadableMap
的用法示例。
在下文中一共展示了ReadableMap.getInt方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: capture
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
@ReactMethod
public void capture(final ReadableMap options, final Promise promise) {
int orientation = options.hasKey("orientation") ? options.getInt("orientation") : RCTCamera.getInstance().getOrientation();
if (orientation == RCT_CAMERA_ORIENTATION_AUTO) {
_sensorOrientationChecker.onResume();
_sensorOrientationChecker.registerOrientationListener(new RCTSensorOrientationListener() {
@Override
public void orientationEvent() {
int deviceOrientation = _sensorOrientationChecker.getOrientation();
_sensorOrientationChecker.unregisterOrientationListener();
_sensorOrientationChecker.onPause();
captureWithOrientation(options, promise, deviceOrientation);
}
});
} else {
captureWithOrientation(options, promise, orientation);
}
}
示例2: mapGetByType
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
private void mapGetByType(ReadableMap map, String key, String typeToAskFor) {
if (typeToAskFor.equals("double")) {
map.getDouble(key);
} else if (typeToAskFor.equals("int")) {
map.getInt(key);
} else if (typeToAskFor.equals("string")) {
map.getString(key);
} else if (typeToAskFor.equals("array")) {
map.getArray(key);
} else if (typeToAskFor.equals("map")) {
map.getMap(key);
} else if (typeToAskFor.equals("boolean")) {
map.getBoolean(key);
} else {
throw new RuntimeException("Unknown type: " + typeToAskFor);
}
}
示例3: peerConnectionAddICECandidate
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
@ReactMethod
public void peerConnectionAddICECandidate(ReadableMap candidateMap, final int id, final Callback callback) {
boolean result = false;
PeerConnection peerConnection = getPeerConnection(id);
Log.d(TAG, "peerConnectionAddICECandidate() start");
if (peerConnection != null) {
IceCandidate candidate = new IceCandidate(
candidateMap.getString("sdpMid"),
candidateMap.getInt("sdpMLineIndex"),
candidateMap.getString("candidate")
);
result = peerConnection.addIceCandidate(candidate);
} else {
Log.d(TAG, "peerConnectionAddICECandidate() peerConnection is null");
}
callback.invoke(result);
Log.d(TAG, "peerConnectionAddICECandidate() end");
}
示例4: getPhotos
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
/**
* Get photos from {@link MediaStore.Images}, most recent first.
*
* @param params a map containing the following keys:
* <ul>
* <li>first (mandatory): a number representing the number of photos to fetch</li>
* <li>
* after (optional): a cursor that matches page_info[end_cursor] returned by a
* previous call to {@link #getPhotos}
* </li>
* <li>groupName (optional): an album name</li>
* <li>
* mimeType (optional): restrict returned images to a specific mimetype (e.g.
* image/jpeg)
* </li>
* </ul>
* @param promise the Promise to be resolved when the photos are loaded; for a format of the
* parameters passed to this callback, see {@code getPhotosReturnChecker} in CameraRoll.js
*/
@ReactMethod
public void getPhotos(final ReadableMap params, final Promise promise) {
int first = params.getInt("first");
String after = params.hasKey("after") ? params.getString("after") : null;
String groupName = params.hasKey("groupName") ? params.getString("groupName") : null;
ReadableArray mimeTypes = params.hasKey("mimeTypes")
? params.getArray("mimeTypes")
: null;
if (params.hasKey("groupTypes")) {
throw new JSApplicationIllegalArgumentException("groupTypes is not supported on Android");
}
new GetPhotosTask(
getReactApplicationContext(),
first,
after,
groupName,
mimeTypes,
promise)
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
示例5: setSource
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
/**
* 設置source屬性,包括是否是直播流,解碼類型,準備時長,是否有緩存等
*
* @param plVideoTextureView
* @param source
*/
@ReactProp(name = "source")
public void setSource(PLVideoTextureView plVideoTextureView, ReadableMap source) {
AVOptions avOptions = new AVOptions();
uri = source.getString("uri");//視頻連接地址
//得到解碼類型
int mediaCodec = source.hasKey("mediaCodec") ? source.getInt("mediaCodec") : AVOptions.MEDIA_CODEC_SW_DECODE;
//得到視頻準備時間
int timeout = source.hasKey("timeout") ? source.getInt("timeout") : 10 * 1000;
//得到是否是直播流
boolean liveStreaming = source.hasKey("liveStreaming") ? source.getBoolean("liveStreaming") : false;
//得到是否應用緩存
boolean cache = source.hasKey("cache") ? source.getBoolean("cache") : false;
boolean started=source.hasKey("started")?source.getBoolean("started"):true;
avOptions.setInteger(AVOptions.KEY_MEDIACODEC, mediaCodec);
avOptions.setInteger(AVOptions.KEY_PREPARE_TIMEOUT, timeout);
avOptions.setInteger(AVOptions.KEY_LIVE_STREAMING, liveStreaming ? 1 : 0);
if (!liveStreaming && cache) {
avOptions.setString(AVOptions.KEY_CACHE_DIR, Config.DEFAULT_CACHE_DIR);
}
plVideoTextureView.setAVOptions(avOptions);
//MediaController mediaController = new MediaController(themedReactContext, !liveStreaming, liveStreaming);
// plVideoTextureView.setMediaController(mediaController);
plVideoTextureView.setVideoPath(uri);
}
示例6: setProfile
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
@ReactProp(name = "profile")
public void setProfile(AspectFrameLayout view, @Nullable ReadableMap profile) {
ReadableMap video = profile.getMap("video");
ReadableMap audio = profile.getMap("audio");
int encodingSize = profile.getInt("encodingSize");
StreamingProfile.AudioProfile aProfile =
new StreamingProfile.AudioProfile(audio.getInt("rate"), audio.getInt("bitrate")); //audio sample rate, audio bitrate
StreamingProfile.VideoProfile vProfile =
new StreamingProfile.VideoProfile(video.getInt("fps"), video.getInt("bps"), video.getInt("maxFrameInterval"));//fps bps maxFrameInterval
StreamingProfile.AVProfile avProfile = new StreamingProfile.AVProfile(vProfile, aProfile);
mProfile.setAVProfile(avProfile);
mProfile.setEncodingSizeLevel(encodingSize);
mMediaStreamingManager.setStreamingProfile(mProfile);
}
示例7: SocketClient
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
SocketClient(ReadableMap params, ReactContext reactContext) {
//String addr, int port, boolean autoReconnect
mReactContext = reactContext;
dstAddress = params.getString("address");
dstPort = params.getInt("port");
if (params.hasKey("reconnect")) {
reconnectOnClose = params.getBoolean("reconnect");
}
if (params.hasKey("maxReconnectAttempts")) {
maxReconnectAttempts = params.getInt("maxReconnectAttempts");
}
if (params.hasKey("reconnectDelay")) {
reconnectDelay = params.getInt("reconnectDelay");
}
Thread socketClientThread = new Thread(new SocketClientThread());
socketClientThread.start();
}
示例8: convertJsStackTrace
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
/**
* 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++) {
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);
}
return result;
}
示例9: schedule
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
/**
* Main point of interaction from JS users - allows them to specify the scheduling etc for the
* background task.
*
* Default values are specified in JS (more accessible for the average user).
*
* @param config the config options passed in from JS:
* - period (required): how frequently to carry out the task in seconds
* - timeout (required): after how many seconds should the task be auto-killed
*/
@ReactMethod
public void schedule(final ReadableMap config) {
Log.d(TAG, "@ReactMethod BackgroundTask.schedule");
// Period can't be below 15m
int period = config.getInt("period");
if (period < 900) { period = 900; }
// Flex must be between 5m and 15m
int flex = config.getInt("flex");
if (flex < 300) { flex = 300; }
if (flex > 900) { flex = 900; }
// Extra info to store with the JobRequest
PersistableBundleCompat extras = new PersistableBundleCompat();
extras.putInt("timeout", config.getInt("timeout"));
mJobRequest = new JobRequest.Builder(RNJob.JOB_TAG)
.setPeriodic(TimeUnit.SECONDS.toMillis(period), TimeUnit.SECONDS.toMillis(flex))
.setPersisted(true)
.setExtras(extras)
.build();
if (!mForeground) {
commitSchedule();
}
}
示例10: setSource
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
@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_PREPARE_TIMEOUT, avFrameTimeout);
}
// Some optimization with buffering mechanism when be set to 1
options.setInteger(AVOptions.KEY_LIVE_STREAMING, 1);
// }
// 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);
// }
}
示例11: addAnimatedEventToView
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
public void addAnimatedEventToView(int viewTag, String eventName, ReadableMap eventMapping) {
int nodeTag = eventMapping.getInt("animatedValueTag");
AnimatedNode node = mAnimatedNodes.get(nodeTag);
if (node == null) {
throw new JSApplicationIllegalArgumentException("Animated node with tag " + nodeTag +
" does not exists");
}
if (!(node instanceof ValueAnimatedNode)) {
throw new JSApplicationIllegalArgumentException("Animated node connected to event should be" +
"of type " + ValueAnimatedNode.class.getName());
}
ReadableArray path = eventMapping.getArray("nativeEventPath");
List<String> pathList = new ArrayList<>(path.size());
for (int i = 0; i < path.size(); i++) {
pathList.add(path.getString(i));
}
EventAnimationDriver event = new EventAnimationDriver(pathList, (ValueAnimatedNode) node);
String key = viewTag + eventName;
if (mEventDrivers.containsKey(key)) {
mEventDrivers.get(key).add(event);
} else {
List<EventAnimationDriver> drivers = new ArrayList<>(1);
drivers.add(event);
mEventDrivers.put(key, drivers);
}
}
示例12: extractMapValue
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
private Object extractMapValue(ReadableMap params, HashMap<String, Object> paramsMap, String key) {
Object mapValue;
if (ReadableType.Number == params.getType(key)) {
try {
mapValue = params.getInt(key);
} catch (UnexpectedNativeTypeException e) {
mapValue = params.getDouble(key);
}
} else {
mapValue = paramsMap.get(key);
}
return mapValue;
}
示例13: onEventCallback
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
@Override
public void onEventCallback(final String name, final ReadableMap info, final MSREventBridgeReceiverCallback callback) {
Log.d(ReactConstants.TAG, this.getClass().getName() + ": Received event with callback: ".concat(name));
final String activityClassName = this.getClass().getSimpleName();
// Example how to load some async data
if (name.equals(LoadDataEventName)) {
final int count = info.getInt("count");
// Simulate some data loading delay
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
WritableArray array = new WritableNativeArray();
for (int i = 0; i < count; i++) {
// getSimpleName() does not work here for some reason
String className = this.getClass().getName();
array.pushString("Row " + i + " - " + activityClassName);
}
callback.onSuccess(array);
}
}, 2000);
return;
}
// Emit callback
WritableMap map = new WritableNativeMap();
map.putString("key", "value");
callback.onSuccess(map);
}
示例14: SpringAnimation
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
SpringAnimation(ReadableMap config) {
mSpringFriction = config.getDouble("friction");
mSpringTension = config.getDouble("tension");
mCurrentState.velocity = config.getDouble("initialVelocity");
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;
}
示例15: setSource
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
@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);
// }
}