本文整理匯總了Java中com.facebook.react.bridge.ReadableArray.getInt方法的典型用法代碼示例。如果您正苦於以下問題:Java ReadableArray.getInt方法的具體用法?Java ReadableArray.getInt怎麽用?Java ReadableArray.getInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.facebook.react.bridge.ReadableArray
的用法示例。
在下文中一共展示了ReadableArray.getInt方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: receiveCommand
import com.facebook.react.bridge.ReadableArray; //導入方法依賴的package包/類
@Override
public void receiveCommand(SketchViewContainer root, int commandId, @Nullable ReadableArray args) {
Assertions.assertNotNull(root);
switch (commandId) {
case COMMAND_CLEAR_SKETCH:
root.sketchView.clear();
return;
case COMMAND_CHANGE_TOOL:
Assertions.assertNotNull(args);
int toolId = args.getInt(0);
root.sketchView.setToolType(toolId);
return;
case COMMAND_SAVE_SKETCH:
try {
SketchFile sketchFile = root.saveToLocalCache();
onSaveSketch(root, sketchFile);
return;
} catch (IOException e) {
e.printStackTrace();
}
default:
throw new IllegalArgumentException(String.format(Locale.ENGLISH, "Unsupported command %d.", commandId));
}
}
示例2: 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();
}
});
}
示例3: 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
);
}
示例4: 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);
}
}
示例5: 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);
}
}
示例6: readableArrayToIntArray
import com.facebook.react.bridge.ReadableArray; //導入方法依賴的package包/類
public static int[] readableArrayToIntArray(ReadableArray readableArray) {
int[] arr = new int[readableArray.size()];
for (int i = 0; i < readableArray.size(); i++) {
arr[i] = readableArray.getInt(i);
}
return arr;
}
示例7: transmit
import com.facebook.react.bridge.ReadableArray; //導入方法依賴的package包/類
@ReactMethod
public void transmit(Integer carrierFrequency, ReadableArray burstsPattern, Promise promise) {
int[] pattern = new int[burstsPattern.size()];
for (int i = 0; i < burstsPattern.size(); i++) {
pattern[i] = burstsPattern.getInt(i);
}
try {
manager.transmit(carrierFrequency, pattern);
promise.resolve(true);
} catch (Exception e) {
promise.reject(e);
}
}
示例8: vibrateByPattern
import com.facebook.react.bridge.ReadableArray; //導入方法依賴的package包/類
@ReactMethod
public void vibrateByPattern(ReadableArray pattern, int repeat) {
long[] patternLong = new long[pattern.size()];
for (int i = 0; i < pattern.size(); i++) {
patternLong[i] = pattern.getInt(i);
}
Vibrator v = (Vibrator) getReactApplicationContext().getSystemService(Context.VIBRATOR_SERVICE);
if (v != null) {
v.vibrate(patternLong, repeat);
}
}
示例9: setColors
import com.facebook.react.bridge.ReadableArray; //導入方法依賴的package包/類
@ReactProp(name = "colors", customType = "ColorArray")
public void setColors(ReactSwipeRefreshLayout view, @Nullable ReadableArray colors) {
if (colors != null) {
int[] colorValues = new int[colors.size()];
for (int i = 0; i < colors.size(); i++) {
colorValues[i] = colors.getInt(i);
}
view.setColorSchemeColors(colorValues);
} else {
view.setColorSchemeColors();
}
}
示例10: AdditionAnimatedNode
import com.facebook.react.bridge.ReadableArray; //導入方法依賴的package包/類
public AdditionAnimatedNode(
ReadableMap config,
NativeAnimatedNodesManager nativeAnimatedNodesManager) {
mNativeAnimatedNodesManager = nativeAnimatedNodesManager;
ReadableArray inputNodes = config.getArray("input");
mInputNodes = new int[inputNodes.size()];
for (int i = 0; i < mInputNodes.length; i++) {
mInputNodes[i] = inputNodes.getInt(i);
}
}
示例11: DivisionAnimatedNode
import com.facebook.react.bridge.ReadableArray; //導入方法依賴的package包/類
public DivisionAnimatedNode(
ReadableMap config,
NativeAnimatedNodesManager nativeAnimatedNodesManager) {
mNativeAnimatedNodesManager = nativeAnimatedNodesManager;
ReadableArray inputNodes = config.getArray("input");
mInputNodes = new int[inputNodes.size()];
for (int i = 0; i < mInputNodes.length; i++) {
mInputNodes[i] = inputNodes.getInt(i);
}
}
示例12: MultiplicationAnimatedNode
import com.facebook.react.bridge.ReadableArray; //導入方法依賴的package包/類
public MultiplicationAnimatedNode(
ReadableMap config,
NativeAnimatedNodesManager nativeAnimatedNodesManager) {
mNativeAnimatedNodesManager = nativeAnimatedNodesManager;
ReadableArray inputNodes = config.getArray("input");
mInputNodes = new int[inputNodes.size()];
for (int i = 0; i < mInputNodes.length; i++) {
mInputNodes[i] = inputNodes.getInt(i);
}
}
示例13: printColumnsText
import com.facebook.react.bridge.ReadableArray; //導入方法依賴的package包/類
/**
* 打印表格的一行,可以指定列寬、對齊方式
*
* @param colsTextArr 各列文本字符串數組
* @param colsWidthArr 各列寬度數組(以英文字符計算, 每個中文字符占兩個英文字符, 每個寬度大於0)
* @param colsAlign 各列對齊方式(0居左, 1居中, 2居右)
* 備注: 三個參數的數組長度應該一致, 如果colsText[i]的寬度大於colsWidth[i], 則文本換行
*/
@ReactMethod
public void printColumnsText(ReadableArray colsTextArr, ReadableArray colsWidthArr, ReadableArray colsAlign, final Promise p) {
final IWoyouService ss = woyouService;
final String[] clst = new String[colsTextArr.size()];
for (int i = 0; i < colsTextArr.size(); i++) {
clst[i] = colsTextArr.getString(i);
}
final int[] clsw = new int[colsWidthArr.size()];
for (int i = 0; i < colsWidthArr.size(); i++) {
clsw[i] = colsWidthArr.getInt(i);
}
final int[] clsa = new int[colsAlign.size()];
for (int i = 0; i < colsAlign.size(); i++) {
clsa[i] = colsAlign.getInt(i);
}
ThreadPoolManager.getInstance().executeTask(new Runnable() {
@Override
public void run() {
try {
ss.printColumnsText(clst, clsw, clsa, new ICallback.Stub() {
@Override
public void onRunResult(boolean isSuccess) {
if (isSuccess) {
p.resolve(null);
} else {
p.reject("0", isSuccess + "");
}
}
@Override
public void onReturnString(String result) {
p.resolve(result);
}
@Override
public void onRaiseException(int code, String msg) {
p.reject("" + code, msg);
}
});
} catch (Exception e) {
e.printStackTrace();
Log.i(TAG, "ERROR: " + e.getMessage());
p.reject("" + 0, e.getMessage());
}
}
});
}
示例14: setup
import com.facebook.react.bridge.ReadableArray; //導入方法依賴的package包/類
/**
* Initialize MoveProxy with given moveFrom and moveTo arrays.
*/
public void setup(ReadableArray moveFrom, ReadableArray moveTo) {
mMoveTo = moveTo;
if (moveFrom == null) {
setSize(0);
return;
}
int size = moveFrom.size();
int requiredSpace = size + size;
if (mMapping.length < requiredSpace) {
mMapping = new int[requiredSpace];
mChildren = new FlatShadowNode[size];
}
setSize(size);
// Array contains data in the following way:
// [ k0, v0, k1, v1, k2, v2, ... ]
//
// where vi = moveFrom.getInt(ki)
// We don't technically *need* to store vi, but they are accessed so often that it makes sense
// to cache it instead of calling ReadableArray.getInt() all the time.
// Sorting algorithm will reorder ki/vi pairs in such a way that vi < v(i+1)
// Code below is an insertion sort, adapted from DualPivotQuicksort.doSort()
// At each step i, we got the following data:
// [k0, v0, k1, v2, .. k(i-1), v(i-1), unused...]
// where v0 < v1 < v2 ... < v(i-1)
//
// This holds true for step i = 0 (array of size one is sorted)
// Again, k0 = 0, v0 = moveFrom.getInt(k0)
setKeyValue(0, 0, moveFrom.getInt(0));
// At each of the next steps, we grab a new key and walk back until we find first key that is
// less than current, shifting key/value pairs if they are larger than current key.
for (int i = 1; i < size; i++) {
// this is our next key
int current = moveFrom.getInt(i);
// this loop will find correct position for it
int j;
// At this point, array is like this: [ k0, v0, k1, v1, k2, v2, ..., k(i-1), v(i-1), ... ]
for (j = i - 1; j >= 0; j--) {
if (moveFromToValue(j) < current) {
break;
}
// value at index j is < current value, shift that value and its key
setKeyValue(j + 1, moveFromToIndex(j), moveFromToValue(j));
}
setKeyValue(j + 1, i, current);
}
}
示例15: addChildren
import com.facebook.react.bridge.ReadableArray; //導入方法依賴的package包/類
/**
* Adds all children from addChildTags and moveFrom/moveTo.
*/
private void addChildren(
ReactShadowNode parentNode,
@Nullable ReadableArray addChildTags,
@Nullable ReadableArray addAtIndices) {
int prevIndex = -1;
int moveToIndex;
int moveToChildIndex;
if (mMoveProxy.size() == 0) {
moveToIndex = Integer.MAX_VALUE;
moveToChildIndex = Integer.MAX_VALUE;
} else {
moveToIndex = 0;
moveToChildIndex = mMoveProxy.getMoveTo(0);
}
int numNodesToAdd;
int addToIndex;
int addToChildIndex;
if (addAtIndices == null) {
numNodesToAdd = 0;
addToIndex = Integer.MAX_VALUE;
addToChildIndex = Integer.MAX_VALUE;
} else {
numNodesToAdd = addAtIndices.size();
addToIndex = 0;
addToChildIndex = addAtIndices.getInt(0);
}
// both mMoveProxy and addChildTags are already sorted, but combined order is not sorted. Use
// a merge step from mergesort to walk over both arrays and extract elements in sorted order.
while (true) {
if (addToChildIndex < moveToChildIndex) {
ReactShadowNode addToChild = resolveShadowNode(addChildTags.getInt(addToIndex));
addChildAt(parentNode, addToChild, addToChildIndex, prevIndex);
prevIndex = addToChildIndex;
++addToIndex;
if (addToIndex == numNodesToAdd) {
addToChildIndex = Integer.MAX_VALUE;
} else {
addToChildIndex = addAtIndices.getInt(addToIndex);
}
} else if (moveToChildIndex < addToChildIndex) {
ReactShadowNode moveToChild = mMoveProxy.getChildMoveTo(moveToIndex);
addChildAt(parentNode, moveToChild, moveToChildIndex, prevIndex);
prevIndex = moveToChildIndex;
++moveToIndex;
if (moveToIndex == mMoveProxy.size()) {
moveToChildIndex = Integer.MAX_VALUE;
} else {
moveToChildIndex = mMoveProxy.getMoveTo(moveToIndex);
}
} else {
// moveToChildIndex == addToChildIndex can only be if both are equal to Integer.MAX_VALUE
// which means that we exhausted both arrays, and all children are added.
break;
}
}
}