本文整理匯總了Java中com.facebook.react.bridge.WritableArray.pushNull方法的典型用法代碼示例。如果您正苦於以下問題:Java WritableArray.pushNull方法的具體用法?Java WritableArray.pushNull怎麽用?Java WritableArray.pushNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.facebook.react.bridge.WritableArray
的用法示例。
在下文中一共展示了WritableArray.pushNull方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: toWritableArray
import com.facebook.react.bridge.WritableArray; //導入方法依賴的package包/類
public static WritableArray toWritableArray(Object[] array) {
WritableArray writableArray = Arguments.createArray();
for (int i = 0; i < array.length; i++) {
Object value = array[i];
if (value == null) {
writableArray.pushNull();
}
if (value instanceof Boolean) {
writableArray.pushBoolean((Boolean) value);
}
if (value instanceof Double) {
writableArray.pushDouble((Double) value);
}
if (value instanceof Integer) {
writableArray.pushInt((Integer) value);
}
if (value instanceof String) {
writableArray.pushString((String) value);
}
if (value instanceof Map) {
writableArray.pushMap(MapUtil.toWritableMap((Map<String, Object>) value));
}
if (value.getClass().isArray()) {
writableArray.pushArray(ArrayUtil.toWritableArray((Object[]) value));
}
}
return writableArray;
}
示例4: 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;
}
示例5: toWritableArray
import com.facebook.react.bridge.WritableArray; //導入方法依賴的package包/類
public static WritableArray toWritableArray(Object[] array) {
WritableArray writableArray = Arguments.createArray();
for (int i = 0; i < array.length; i++) {
Object value = array[i];
if (value == null) {
writableArray.pushNull();
}
if (value instanceof Boolean) {
writableArray.pushBoolean((Boolean) value);
}
if (value instanceof Double) {
writableArray.pushDouble((Double) value);
}
if (value instanceof Integer) {
writableArray.pushInt((Integer) value);
}
if (value instanceof String) {
writableArray.pushString((String) value);
}
if (value instanceof Map) {
writableArray.pushMap(MapUtil.toWritableMap((Map<String, Object>) value));
}
if (value.getClass().isArray()) {
writableArray.pushArray(ArrayUtil.toWritableArray((Object[]) value));
}
}
return writableArray;
}
示例6: onRequestSuccess
import com.facebook.react.bridge.WritableArray; //導入方法依賴的package包/類
public static void onRequestSuccess(RCTDeviceEventEmitter eventEmitter, int requestId) {
WritableArray args = Arguments.createArray();
args.pushInt(requestId);
args.pushNull();
eventEmitter.emit("didCompleteNetworkResponse", args);
}