本文整理匯總了Java中com.facebook.react.bridge.WritableArray.pushInt方法的典型用法代碼示例。如果您正苦於以下問題:Java WritableArray.pushInt方法的具體用法?Java WritableArray.pushInt怎麽用?Java WritableArray.pushInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.facebook.react.bridge.WritableArray
的用法示例。
在下文中一共展示了WritableArray.pushInt方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: jsonToReact
import com.facebook.react.bridge.WritableArray; //導入方法依賴的package包/類
public static WritableArray jsonToReact(JSONArray jsonArray) throws JSONException {
WritableArray writableArray = Arguments.createArray();
for(int i=0; i < jsonArray.length(); i++) {
Object value = jsonArray.get(i);
if (value instanceof Float || value instanceof Double) {
writableArray.pushDouble(jsonArray.getDouble(i));
} else if (value instanceof Number) {
writableArray.pushInt(jsonArray.getInt(i));
} else if (value instanceof String) {
writableArray.pushString(jsonArray.getString(i));
} else if (value instanceof JSONObject) {
writableArray.pushMap(jsonToReact(jsonArray.getJSONObject(i)));
} else if (value instanceof JSONArray){
writableArray.pushArray(jsonToReact(jsonArray.getJSONArray(i)));
} else if (value == JSONObject.NULL){
writableArray.pushNull();
}
}
return writableArray;
}
示例2: pushObject
import com.facebook.react.bridge.WritableArray; //導入方法依賴的package包/類
public static void pushObject(WritableArray a, Object v) {
if (v == null) {
a.pushNull();
} else if (v instanceof String) {
a.pushString((String) v);
} else if (v instanceof Bundle) {
a.pushMap(fromBundle((Bundle) v));
} else if (v instanceof Byte) {
a.pushInt(((Byte) v) & 0xff);
} else if (v instanceof Integer) {
a.pushInt((Integer) v);
} else if (v instanceof Float) {
a.pushDouble((Float) v);
} else if (v instanceof Double) {
a.pushDouble((Double) v);
} else if (v instanceof Boolean) {
a.pushBoolean((Boolean) v);
} else {
throw new IllegalArgumentException("Unknown type " + v.getClass());
}
}
示例3: onRequestError
import com.facebook.react.bridge.WritableArray; //導入方法依賴的package包/類
public static void onRequestError(
RCTDeviceEventEmitter eventEmitter,
int requestId,
String error,
IOException e) {
WritableArray args = Arguments.createArray();
args.pushInt(requestId);
args.pushString(error);
if ((e != null) && (e.getClass() == SocketTimeoutException.class)) {
args.pushBoolean(true); // last argument is a time out boolean
}
eventEmitter.emit("didCompleteNetworkResponse", args);
}
示例4: onRequestComplete
import com.facebook.react.bridge.WritableArray; //導入方法依賴的package包/類
private void onRequestComplete(int requestId, @Nullable String error) {
WritableArray args = Arguments.createArray();
args.pushInt(requestId);
args.pushString(error);
getEventEmitter().emit("didCompleteNetworkResponse", args);
}
示例5: jsonArrayToWritableArray
import com.facebook.react.bridge.WritableArray; //導入方法依賴的package包/類
public static WritableArray jsonArrayToWritableArray(JSONArray jsonArray) {
WritableArray writableArray = new WritableNativeArray();
try {
if (jsonArray == null) {
return null;
}
if (jsonArray.length() <= 0) {
return null;
}
for (int i = 0 ; i < jsonArray.length(); i++) {
Object value = jsonArray.get(i);
if (value == null) {
writableArray.pushNull();
} else if (value instanceof Boolean) {
writableArray.pushBoolean((Boolean) value);
} else if (value instanceof Integer) {
writableArray.pushInt((Integer) value);
} else if (value instanceof Double) {
writableArray.pushDouble((Double) value);
} else if (value instanceof String) {
writableArray.pushString((String) value);
} else if (value instanceof JSONObject) {
writableArray.pushMap(jsonToWritableMap((JSONObject) value));
} else if (value instanceof JSONArray) {
writableArray.pushArray(jsonArrayToWritableArray((JSONArray) value));
}
}
} catch (JSONException e) {
// Do nothing and fail silently
}
return writableArray;
}
示例6: sendTouchEvent
import com.facebook.react.bridge.WritableArray; //導入方法依賴的package包/類
/**
* Generate and send touch event to RCTEventEmitter JS module associated with the given
* {@param context}. Touch event can encode multiple concurrent touches (pointers).
*
* @param rctEventEmitter Event emitter used to execute JS module call
* @param type type of the touch event (see {@link TouchEventType})
* @param reactTarget target view react id associated with this gesture
* @param touchEvent native touch event to read pointers count and coordinates from
*/
public static void sendTouchEvent(
RCTEventEmitter rctEventEmitter,
TouchEventType type,
int reactTarget,
TouchEvent touchEvent) {
WritableArray pointers = createsPointersArray(reactTarget, touchEvent);
MotionEvent motionEvent = touchEvent.getMotionEvent();
// For START and END events send only index of the pointer that is associated with that event
// For MOVE and CANCEL events 'changedIndices' array should contain all the pointers indices
WritableArray changedIndices = Arguments.createArray();
if (type == TouchEventType.MOVE || type == TouchEventType.CANCEL) {
for (int i = 0; i < motionEvent.getPointerCount(); i++) {
changedIndices.pushInt(i);
}
} else if (type == TouchEventType.START || type == TouchEventType.END) {
changedIndices.pushInt(motionEvent.getActionIndex());
} else {
throw new RuntimeException("Unknown touch type: " + type);
}
rctEventEmitter.receiveTouches(
type.getJSEventName(),
pointers,
changedIndices);
}
示例7: onByteArraysStream
import com.facebook.react.bridge.WritableArray; //導入方法依賴的package包/類
private void onByteArraysStream(byte[] bytes) {
WritableMap params = Arguments.createMap();
WritableArray data = new WritableNativeArray();
for (byte b : bytes) {
data.pushInt(UnsignedBytes.toInt(b));
}
params.putArray("payload", data);
sendEventToJs(BT_RECEIVED_DATA, params);
}
示例8: _convertIds
import com.facebook.react.bridge.WritableArray; //導入方法依賴的package包/類
private WritableArray _convertIds(int[] ids) {
WritableArray resultArray = new WritableNativeArray();
for (int i = 0; i < ids.length; i++) {
resultArray.pushInt(ids[i]);
}
return resultArray;
}
示例9: replaceExistingNonRootView
import com.facebook.react.bridge.WritableArray; //導入方法依賴的package包/類
/**
* Replaces the View specified by oldTag with the View specified by newTag within oldTag's parent.
*/
public void replaceExistingNonRootView(int oldTag, int newTag) {
if (mShadowNodeRegistry.isRootNode(oldTag) || mShadowNodeRegistry.isRootNode(newTag)) {
throw new IllegalViewOperationException("Trying to add or replace a root tag!");
}
ReactShadowNode oldNode = mShadowNodeRegistry.getNode(oldTag);
if (oldNode == null) {
throw new IllegalViewOperationException("Trying to replace unknown view tag: " + oldTag);
}
ReactShadowNode parent = oldNode.getParent();
if (parent == null) {
throw new IllegalViewOperationException("Node is not attached to a parent: " + oldTag);
}
int oldIndex = parent.indexOf(oldNode);
if (oldIndex < 0) {
throw new IllegalStateException("Didn't find child tag in parent");
}
WritableArray tagsToAdd = Arguments.createArray();
tagsToAdd.pushInt(newTag);
WritableArray addAtIndices = Arguments.createArray();
addAtIndices.pushInt(oldIndex);
WritableArray indicesToRemove = Arguments.createArray();
indicesToRemove.pushInt(oldIndex);
manageChildren(parent.getReactTag(), null, null, tagsToAdd, addAtIndices, indicesToRemove);
}
示例10: onDataReceived
import com.facebook.react.bridge.WritableArray; //導入方法依賴的package包/類
private void onDataReceived(int requestId, String data) {
WritableArray args = Arguments.createArray();
args.pushInt(requestId);
args.pushString(data);
getEventEmitter().emit("didReceiveNetworkData", args);
}
示例11: onDataReceivedProgress
import com.facebook.react.bridge.WritableArray; //導入方法依賴的package包/類
public static void onDataReceivedProgress(
RCTDeviceEventEmitter eventEmitter,
int requestId,
long progress,
long total) {
WritableArray args = Arguments.createArray();
args.pushInt(requestId);
args.pushInt((int) progress);
args.pushInt((int) total);
eventEmitter.emit("didReceiveNetworkDataProgress", args);
}
示例12: onResponseReceived
import com.facebook.react.bridge.WritableArray; //導入方法依賴的package包/類
private void onResponseReceived(int requestId, int code, WritableMap headers) {
WritableArray args = Arguments.createArray();
args.pushInt(requestId);
args.pushInt(code);
args.pushMap(headers);
getEventEmitter().emit("didReceiveNetworkResponse", args);
}
示例13: onDataReceived
import com.facebook.react.bridge.WritableArray; //導入方法依賴的package包/類
public static void onDataReceived(
RCTDeviceEventEmitter eventEmitter,
int requestId,
String data) {
WritableArray args = Arguments.createArray();
args.pushInt(requestId);
args.pushString(data);
eventEmitter.emit("didReceiveNetworkData", args);
}
示例14: onResponseReceived
import com.facebook.react.bridge.WritableArray; //導入方法依賴的package包/類
public static void onResponseReceived(
RCTDeviceEventEmitter eventEmitter,
int requestId,
int statusCode,
WritableMap headers,
String url) {
WritableArray args = Arguments.createArray();
args.pushInt(requestId);
args.pushInt(statusCode);
args.pushMap(headers);
args.pushString(url);
eventEmitter.emit("didReceiveNetworkResponse", args);
}
示例15: doFrame
import com.facebook.react.bridge.WritableArray; //導入方法依賴的package包/類
/**
* Calls all timers that have expired since the last time this frame callback was called.
*/
@Override
public void doFrame(long frameTimeNanos) {
if (isPaused.get() && !isRunningTasks.get()) {
return;
}
long frameTimeMillis = frameTimeNanos / 1000000;
synchronized (mTimerGuard) {
while (!mTimers.isEmpty() && mTimers.peek().mTargetTime < frameTimeMillis) {
Timer timer = mTimers.poll();
WritableArray timersForContext = mTimersToCall.get(timer.mExecutorToken);
if (timersForContext == null) {
timersForContext = Arguments.createArray();
mTimersToCall.put(timer.mExecutorToken, timersForContext);
}
timersForContext.pushInt(timer.mCallbackID);
if (timer.mRepeat) {
timer.mTargetTime = frameTimeMillis + timer.mInterval;
mTimers.add(timer);
} else {
SparseArray<Timer> timers = mTimerIdsToTimers.get(timer.mExecutorToken);
if (timers != null) {
timers.remove(timer.mCallbackID);
if (timers.size() == 0) {
mTimerIdsToTimers.remove(timer.mExecutorToken);
}
}
}
}
}
for (Map.Entry<ExecutorToken, WritableArray> entry : mTimersToCall.entrySet()) {
getReactApplicationContext().getJSModule(entry.getKey(), JSTimersExecution.class)
.callTimers(entry.getValue());
}
mTimersToCall.clear();
Assertions.assertNotNull(mReactChoreographer)
.postFrameCallback(ReactChoreographer.CallbackType.TIMERS_EVENTS, this);
}