本文整理匯總了Java中com.facebook.react.bridge.ReadableArray類的典型用法代碼示例。如果您正苦於以下問題:Java ReadableArray類的具體用法?Java ReadableArray怎麽用?Java ReadableArray使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ReadableArray類屬於com.facebook.react.bridge包,在下文中一共展示了ReadableArray類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: stackTraceToString
import com.facebook.react.bridge.ReadableArray; //導入依賴的package包/類
private String stackTraceToString(String message, ReadableArray stack) {
StringBuilder stringBuilder = new StringBuilder(message).append(", stack:\n");
for (int i = 0; i < stack.size(); i++) {
ReadableMap frame = stack.getMap(i);
stringBuilder
.append(frame.getString("methodName"))
.append("@")
.append(stackFrameToModuleId(frame))
.append(frame.getInt("lineNumber"));
if (frame.hasKey("column") &&
!frame.isNull("column") &&
frame.getType("column") == ReadableType.Number) {
stringBuilder
.append(":")
.append(frame.getInt("column"));
}
stringBuilder.append("\n");
}
return stringBuilder.toString();
}
示例2: testArrayWithMaps
import com.facebook.react.bridge.ReadableArray; //導入依賴的package包/類
public void testArrayWithMaps() {
mCatalystInstance.getJSModule(TestJSToJavaParametersModule.class).returnArrayWithMaps();
waitForBridgeAndUIIdle();
List<ReadableArray> calls = mRecordingTestModule.getArrayCalls();
assertEquals(1, calls.size());
ReadableArray array = calls.get(0);
assertEquals(2, array.size());
assertFalse(array.isNull(0));
ReadableMap m1 = array.getMap(0);
ReadableMap m2 = array.getMap(1);
assertEquals("m1v1", m1.getString("m1k1"));
assertEquals("m1v2", m1.getString("m1k2"));
assertEquals("m2v1", m2.getString("m2k1"));
}
示例3: showPopupMenu
import com.facebook.react.bridge.ReadableArray; //導入依賴的package包/類
/**
* Show a {@link PopupMenu}.
*
* @param reactTag the tag of the anchor view (the PopupMenu is displayed next to this view); this
* needs to be the tag of a native view (shadow views can not be anchors)
* @param items the menu items as an array of strings
* @param success will be called with the position of the selected item as the first argument, or
* no arguments if the menu is dismissed
*/
public void showPopupMenu(int reactTag, ReadableArray items, Callback success) {
UiThreadUtil.assertOnUiThread();
View anchor = mTagsToViews.get(reactTag);
if (anchor == null) {
throw new JSApplicationIllegalArgumentException("Could not find view with tag " + reactTag);
}
PopupMenu popupMenu = new PopupMenu(getReactContextForView(reactTag), anchor);
Menu menu = popupMenu.getMenu();
for (int i = 0; i < items.size(); i++) {
menu.add(Menu.NONE, Menu.NONE, i, items.getString(i));
}
PopupMenuCallbackHandler handler = new PopupMenuCallbackHandler(success);
popupMenu.setOnMenuItemClickListener(handler);
popupMenu.setOnDismissListener(handler);
popupMenu.show();
}
示例4: convertJsStackTrace
import com.facebook.react.bridge.ReadableArray; //導入依賴的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;
}
示例5: convertArrayToJson
import com.facebook.react.bridge.ReadableArray; //導入依賴的package包/類
public static JSONArray convertArrayToJson(ReadableArray readableArray) throws JSONException {
JSONArray array = new JSONArray();
for (int i = 0; i < readableArray.size(); i++) {
switch (readableArray.getType(i)) {
case Null:
break;
case Boolean:
array.put(readableArray.getBoolean(i));
break;
case Number:
array.put(readableArray.getDouble(i));
break;
case String:
array.put(readableArray.getString(i));
break;
case Map:
array.put(convertMapToJson(readableArray.getMap(i)));
break;
case Array:
array.put(convertArrayToJson(readableArray.getArray(i)));
break;
}
}
return array;
}
示例6: preload
import com.facebook.react.bridge.ReadableArray; //導入依賴的package包/類
@ReactMethod
public void preload(final ReadableArray sources) {
final Activity activity = getCurrentActivity();
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
for (int i = 0; i < sources.size(); i++) {
final ReadableMap source = sources.getMap(i);
final GlideUrl glideUrl = FastImageViewConverter.glideUrl(source);
final Priority priority = FastImageViewConverter.priority(source);
Glide
.with(activity.getApplicationContext())
.load(glideUrl)
.priority(priority)
.placeholder(TRANSPARENT_DRAWABLE)
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.preload();
}
}
});
}
示例7: handleSetChildren
import com.facebook.react.bridge.ReadableArray; //導入依賴的package包/類
/**
* Handles a setChildren call. This is a simplification of handleManagerChildren that only adds
* children in index order of the childrenTags array
*/
public void handleSetChildren(
ReactShadowNode nodeToManage,
ReadableArray childrenTags
) {
if (!ENABLED) {
mUIViewOperationQueue.enqueueSetChildren(
nodeToManage.getReactTag(),
childrenTags);
return;
}
for (int i = 0; i < childrenTags.size(); i++) {
ReactShadowNode nodeToAdd = mShadowNodeRegistry.getNode(childrenTags.getInt(i));
addNodeToNode(nodeToManage, nodeToAdd, i);
}
}
示例8: receiveCommand
import com.facebook.react.bridge.ReadableArray; //導入依賴的package包/類
@Override public void receiveCommand(TabbedViewPager viewPager, int commandType,
@Nullable ReadableArray args) {
Assertions.assertNotNull(viewPager);
Assertions.assertNotNull(args);
switch (commandType) {
case COMMAND_SET_PAGE: {
viewPager.setCurrentItemFromJs(args.getInt(0), true);
return;
}
case COMMAND_SET_PAGE_WITHOUT_ANIMATION: {
viewPager.setCurrentItemFromJs(args.getInt(0), false);
return;
}
default:
throw new IllegalArgumentException(
String.format("Unsupported command %d received by %s.", commandType,
getClass().getSimpleName()));
}
}
示例9: ShowSequence
import com.facebook.react.bridge.ReadableArray; //導入依賴的package包/類
@ReactMethod
public void ShowSequence(final ReadableArray views, final ReadableMap props, final Promise promise) {
final Activity activity = this.getCurrentActivity();
final List<TapTarget> targetViews = new ArrayList<TapTarget>();
for (int i = 0;i < views.size();i++) {
int view = views.getInt(i);
targetViews.add(this.generateTapTarget(view, props.getMap(String.valueOf(view))));
}
this.getCurrentActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
TapTargetSequence tapTargetSequence = new TapTargetSequence(activity).targets(targetViews);
tapTargetSequence.continueOnCancel(true);
tapTargetSequence.start();
}
});
}
示例10: receiveCommand
import com.facebook.react.bridge.ReadableArray; //導入依賴的package包/類
@Override
public void receiveCommand(
final RNSparkButton view,
int commandType,
@Nullable ReadableArray args) {
Assertions.assertNotNull(view);
Assertions.assertNotNull(args);
switch (commandType) {
case COMMAND_PLAY_ANIMATION: {
view.playAnimation();
return;
}
default:
throw new IllegalArgumentException(String.format(
"Unsupported command %d received by %s.",
commandType,
getClass().getSimpleName()));
}
}
示例11: setChildren
import com.facebook.react.bridge.ReadableArray; //導入依賴的package包/類
/**
* Simplified version of manageChildren that only deals with adding children views
*/
public void setChildren(
int tag,
ReadableArray childrenTags) {
ViewGroup viewToManage = (ViewGroup) mTagsToViews.get(tag);
ViewGroupManager viewManager = (ViewGroupManager) resolveViewManager(tag);
for (int i = 0; i < childrenTags.size(); i++) {
View viewToAdd = mTagsToViews.get(childrenTags.getInt(i));
if (viewToAdd == null) {
throw new IllegalViewOperationException(
"Trying to add unknown view tag: "
+ childrenTags.getInt(i) + "\n detail: " +
constructSetChildrenErrorMessage(
viewToManage,
viewManager,
childrenTags));
}
viewManager.addView(viewToManage, viewToAdd, i);
}
}
示例12: constructSetChildrenErrorMessage
import com.facebook.react.bridge.ReadableArray; //導入依賴的package包/類
/**
* Simplified version of constructManageChildrenErrorMessage that only deals with adding children
* views
*/
private static String constructSetChildrenErrorMessage(
ViewGroup viewToManage,
ViewGroupManager viewManager,
ReadableArray childrenTags) {
ViewAtIndex[] viewsToAdd = new ViewAtIndex[childrenTags.size()];
for (int i = 0; i < childrenTags.size(); i++) {
viewsToAdd[i] = new ViewAtIndex(childrenTags.getInt(i), i);
}
return constructManageChildrenErrorMessage(
viewToManage,
viewManager,
null,
viewsToAdd,
null
);
}
示例13: convertArrayToJson
import com.facebook.react.bridge.ReadableArray; //導入依賴的package包/類
private static JSONArray convertArrayToJson(ReadableArray readableArray) throws JSONException {
JSONArray array = new JSONArray();
for (int i = 0; i < readableArray.size(); i++) {
switch (readableArray.getType(i)) {
case Null:
break;
case Boolean:
array.put(readableArray.getBoolean(i));
break;
case Number:
array.put(readableArray.getDouble(i));
break;
case String:
array.put(readableArray.getString(i));
break;
case Map:
array.put(convertMapToJson(readableArray.getMap(i)));
break;
case Array:
array.put(convertArrayToJson(readableArray.getArray(i)));
break;
}
}
return array;
}
示例14: testGetWrongTypeFromArray
import com.facebook.react.bridge.ReadableArray; //導入依賴的package包/類
public void testGetWrongTypeFromArray() {
mCatalystInstance.getJSModule(TestJSToJavaParametersModule.class)
.returnArrayWithStringDoubleIntMapArrayBooleanNull();
waitForBridgeAndUIIdle();
List<ReadableArray> calls = mRecordingTestModule.getArrayCalls();
assertEquals(1, calls.size());
ReadableArray array = calls.get(0);
assertUnexpectedTypeExceptionThrown(array, 0, "boolean");
assertUnexpectedTypeExceptionThrown(array, 1, "string");
assertUnexpectedTypeExceptionThrown(array, 2, "array");
assertUnexpectedTypeExceptionThrown(array, 3, "double");
assertUnexpectedTypeExceptionThrown(array, 4, "map");
assertUnexpectedTypeExceptionThrown(array, 5, "array");
}
示例15: receiveCommand
import com.facebook.react.bridge.ReadableArray; //導入依賴的package包/類
@Override
public void receiveCommand(ReactViewGroup root, int commandId, @Nullable ReadableArray args) {
switch (commandId) {
case CMD_HOTSPOT_UPDATE: {
if (args == null || args.size() != 2) {
throw new JSApplicationIllegalArgumentException(
"Illegal number of arguments for 'updateHotspot' command");
}
if (Build.VERSION.SDK_INT >= 21) {
float x = PixelUtil.toPixelFromDIP(args.getDouble(0));
float y = PixelUtil.toPixelFromDIP(args.getDouble(1));
root.drawableHotspotChanged(x, y);
}
break;
}
case CMD_SET_PRESSED: {
if (args == null || args.size() != 1) {
throw new JSApplicationIllegalArgumentException(
"Illegal number of arguments for 'setPressed' command");
}
root.setPressed(args.getBoolean(0));
break;
}
}
}