本文整理匯總了Java中com.facebook.react.bridge.ReadableArray.getArray方法的典型用法代碼示例。如果您正苦於以下問題:Java ReadableArray.getArray方法的具體用法?Java ReadableArray.getArray怎麽用?Java ReadableArray.getArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.facebook.react.bridge.ReadableArray
的用法示例。
在下文中一共展示了ReadableArray.getArray方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: arrayGetByType
import com.facebook.react.bridge.ReadableArray; //導入方法依賴的package包/類
private void arrayGetByType(ReadableArray array, int index, String typeToAskFor) {
if (typeToAskFor.equals("double")) {
array.getDouble(index);
} else if (typeToAskFor.equals("int")) {
array.getInt(index);
} else if (typeToAskFor.equals("string")) {
array.getString(index);
} else if (typeToAskFor.equals("array")) {
array.getArray(index);
} else if (typeToAskFor.equals("map")) {
array.getMap(index);
} else if (typeToAskFor.equals("boolean")) {
array.getBoolean(index);
} else {
throw new RuntimeException("Unknown type: " + typeToAskFor);
}
}
示例2: extractHeaders
import com.facebook.react.bridge.ReadableArray; //導入方法依賴的package包/類
/**
* Extracts the headers from the Array. If the format is invalid, this method will return null.
*/
private @Nullable Headers extractHeaders(
@Nullable ReadableArray headersArray,
@Nullable ReadableMap requestData) {
if (headersArray == null) {
return null;
}
Headers.Builder headersBuilder = new Headers.Builder();
for (int headersIdx = 0, size = headersArray.size(); headersIdx < size; headersIdx++) {
ReadableArray header = headersArray.getArray(headersIdx);
if (header == null || header.size() != 2) {
return null;
}
String headerName = header.getString(0);
String headerValue = header.getString(1);
if (headerName == null || headerValue == null) {
return null;
}
headersBuilder.add(headerName, headerValue);
}
if (headersBuilder.get(USER_AGENT_HEADER_NAME) == null && mDefaultUserAgent != null) {
headersBuilder.add(USER_AGENT_HEADER_NAME, mDefaultUserAgent);
}
// Sanitize content encoding header, supported only when request specify payload as string
boolean isGzipSupported = requestData != null && requestData.hasKey(REQUEST_BODY_KEY_STRING);
if (!isGzipSupported) {
headersBuilder.removeAll(CONTENT_ENCODING_HEADER_NAME);
}
return headersBuilder.build();
}
示例3: testNestedArray
import com.facebook.react.bridge.ReadableArray; //導入方法依賴的package包/類
public void testNestedArray() {
mCatalystInstance.getJSModule(TestJSToJavaParametersModule.class).returnNestedArray();
waitForBridgeAndUIIdle();
List<ReadableArray> calls = mRecordingTestModule.getArrayCalls();
assertEquals(1, calls.size());
ReadableArray array = calls.get(0);
assertNotNull(array);
assertEquals(2, array.size());
assertEquals("we", array.getString(0));
assertFalse(array.isNull(1));
ReadableArray subArray = array.getArray(1);
assertEquals(2, subArray.size());
assertEquals("have", subArray.getString(0));
subArray = subArray.getArray(1);
assertEquals(2, subArray.size());
assertEquals("to", subArray.getString(0));
subArray = subArray.getArray(1);
assertEquals(2, subArray.size());
assertEquals("go", subArray.getString(0));
subArray = subArray.getArray(1);
assertEquals(1, subArray.size());
assertEquals("deeper", subArray.getString(0));
}
示例4: testMapParameterWithArrays
import com.facebook.react.bridge.ReadableArray; //導入方法依賴的package包/類
public void testMapParameterWithArrays() throws InterruptedException {
mCatalystInstance.getJSModule(TestJSToJavaParametersModule.class).returnMapWithArrays();
waitForBridgeAndUIIdle();
List<ReadableMap> calls = mRecordingTestModule.getMapCalls();
assertEquals(1, calls.size());
ReadableMap map = calls.get(0);
assertNotNull(map);
ReadableArray arrayParameter;
assertTrue(map.hasKey("empty"));
arrayParameter = map.getArray("empty");
assertNotNull(arrayParameter);
assertEquals(0, arrayParameter.size());
assertTrue(map.hasKey("ints"));
assertFalse(map.isNull("ints"));
arrayParameter = map.getArray("ints");
assertNotNull(arrayParameter);
assertEquals(2, arrayParameter.size());
assertEquals(43, arrayParameter.getInt(0));
assertEquals(44, arrayParameter.getInt(1));
assertTrue(map.hasKey("mixed"));
arrayParameter = map.getArray("mixed");
assertNotNull(arrayParameter);
assertEquals(3, arrayParameter.size());
assertEquals(77, arrayParameter.getInt(0));
assertEquals("string", arrayParameter.getString(1));
ReadableArray nestedArray = arrayParameter.getArray(2);
assertEquals(2, nestedArray.size());
}