本文整理汇总了Java中com.facebook.react.bridge.JavaOnlyMap类的典型用法代码示例。如果您正苦于以下问题:Java JavaOnlyMap类的具体用法?Java JavaOnlyMap怎么用?Java JavaOnlyMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JavaOnlyMap类属于com.facebook.react.bridge包,在下文中一共展示了JavaOnlyMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: collectViewUpdates
import com.facebook.react.bridge.JavaOnlyMap; //导入依赖的package包/类
public void collectViewUpdates(JavaOnlyMap propsMap) {
List<JavaOnlyMap> transforms = new ArrayList<>(mTransformConfigs.size());
for (TransformConfig transformConfig : mTransformConfigs) {
double value;
if (transformConfig instanceof AnimatedTransformConfig) {
int nodeTag = ((AnimatedTransformConfig) transformConfig).mNodeTag;
AnimatedNode node = mNativeAnimatedNodesManager.getNodeById(nodeTag);
if (node == null) {
throw new IllegalArgumentException("Mapped style node does not exists");
} else if (node instanceof ValueAnimatedNode) {
value = ((ValueAnimatedNode) node).getValue();
} else {
throw new IllegalArgumentException("Unsupported type of node used as a transform child " +
"node " + node.getClass());
}
} else {
value = ((StaticTransformConfig) transformConfig).mValue;
}
transforms.add(JavaOnlyMap.of(transformConfig.mProperty, value));
}
propsMap.putArray("transform", JavaOnlyArray.from(transforms));
}
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:26,代码来源:TransformAnimatedNode.java
示例2: testSelection
import com.facebook.react.bridge.JavaOnlyMap; //导入依赖的package包/类
@Test
public void testSelection() {
ReactEditText view = mManager.createViewInstance(mThemedContext);
view.setText("Need some text to select something...");
mManager.updateProperties(view, buildStyles());
assertThat(view.getSelectionStart()).isEqualTo(0);
assertThat(view.getSelectionEnd()).isEqualTo(0);
JavaOnlyMap selection = JavaOnlyMap.of("start", 5, "end", 10);
mManager.updateProperties(view, buildStyles("selection", selection));
assertThat(view.getSelectionStart()).isEqualTo(5);
assertThat(view.getSelectionEnd()).isEqualTo(10);
mManager.updateProperties(view, buildStyles("selection", null));
assertThat(view.getSelectionStart()).isEqualTo(5);
assertThat(view.getSelectionEnd()).isEqualTo(10);
}
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:19,代码来源:ReactTextInputPropertyTest.java
示例3: testFontFamilyBoldItalicStyleApplied
import com.facebook.react.bridge.JavaOnlyMap; //导入依赖的package包/类
@Test
public void testFontFamilyBoldItalicStyleApplied() {
UIManagerModule uiManager = getUIManagerModule();
ReactRootView rootView = createText(
uiManager,
JavaOnlyMap.of(
ViewProps.FONT_FAMILY, "sans-serif",
ViewProps.FONT_WEIGHT, "500",
ViewProps.FONT_STYLE, "italic"),
JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));
CustomStyleSpan customStyleSpan =
getSingleSpan((TextView) rootView.getChildAt(0), CustomStyleSpan.class);
assertThat(customStyleSpan.getFontFamily()).isEqualTo("sans-serif");
assertThat(customStyleSpan.getStyle() & Typeface.ITALIC).isNotZero();
assertThat(customStyleSpan.getWeight() & Typeface.BOLD).isNotZero();
}
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:19,代码来源:ReactTextTest.java
示例4: testTextDecorationLineLineThroughApplied
import com.facebook.react.bridge.JavaOnlyMap; //导入依赖的package包/类
@Test
public void testTextDecorationLineLineThroughApplied() {
UIManagerModule uiManager = getUIManagerModule();
ReactRootView rootView = createText(
uiManager,
JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "line-through"),
JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));
TextView textView = (TextView) rootView.getChildAt(0);
Spanned text = (Spanned) textView.getText();
UnderlineSpan[] underlineSpans =
text.getSpans(0, text.length(), UnderlineSpan.class);
StrikethroughSpan strikeThroughSpan =
getSingleSpan(textView, StrikethroughSpan.class);
assertThat(underlineSpans).hasSize(0);
assertThat(strikeThroughSpan instanceof StrikethroughSpan).isTrue();
}
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:19,代码来源:ReactTextTest.java
示例5: testTextDecorationLineUnderlineLineThroughApplied
import com.facebook.react.bridge.JavaOnlyMap; //导入依赖的package包/类
@Test
public void testTextDecorationLineUnderlineLineThroughApplied() {
UIManagerModule uiManager = getUIManagerModule();
ReactRootView rootView = createText(
uiManager,
JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline line-through"),
JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));
UnderlineSpan underlineSpan =
getSingleSpan((TextView) rootView.getChildAt(0), UnderlineSpan.class);
StrikethroughSpan strikeThroughSpan =
getSingleSpan((TextView) rootView.getChildAt(0), StrikethroughSpan.class);
assertThat(underlineSpan instanceof UnderlineSpan).isTrue();
assertThat(strikeThroughSpan instanceof StrikethroughSpan).isTrue();
}
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:17,代码来源:ReactTextTest.java
示例6: testNativeAnimatedEventDoNotUpdate
import com.facebook.react.bridge.JavaOnlyMap; //导入依赖的package包/类
@Test
public void testNativeAnimatedEventDoNotUpdate() {
int viewTag = 1000;
createSimpleAnimatedViewWithOpacity(viewTag, 0d);
mNativeAnimatedNodesManager.addAnimatedEventToView(viewTag, "otherEvent", JavaOnlyMap.of(
"animatedValueTag", 1,
"nativeEventPath", JavaOnlyArray.of("contentOffset", "y")));
mNativeAnimatedNodesManager.addAnimatedEventToView(999, "topScroll", JavaOnlyMap.of(
"animatedValueTag", 1,
"nativeEventPath", JavaOnlyArray.of("contentOffset", "y")));
mNativeAnimatedNodesManager.onEventDispatch(createScrollEvent(viewTag, 10));
ArgumentCaptor<ReactStylesDiffMap> stylesCaptor =
ArgumentCaptor.forClass(ReactStylesDiffMap.class);
reset(mUIImplementationMock);
mNativeAnimatedNodesManager.runUpdates(nextFrameTime());
verify(mUIImplementationMock).synchronouslyUpdateViewOnUIThread(eq(viewTag), stylesCaptor.capture());
assertThat(stylesCaptor.getValue().getDouble("opacity", Double.NaN)).isEqualTo(0);
}
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:25,代码来源:NativeAnimatedNodeTraversalTest.java
示例7: testReplaceExistingNonRootView
import com.facebook.react.bridge.JavaOnlyMap; //导入依赖的package包/类
/**
* Makes sure replaceExistingNonRootView by replacing a view with a new view that has a background
* color set.
*/
@Test
public void testReplaceExistingNonRootView() {
UIManagerModule uiManager = getUIManagerModule();
TestMoveDeleteHierarchy hierarchy = createMoveDeleteHierarchy(uiManager);
int newViewTag = 1234;
uiManager.createView(
newViewTag,
ReactViewManager.REACT_CLASS,
hierarchy.rootView,
JavaOnlyMap.of("backgroundColor", Color.RED));
uiManager.replaceExistingNonRootView(hierarchy.view2, newViewTag);
uiManager.onBatchComplete();
executePendingFrameCallbacks();
assertThat(hierarchy.nativeRootView.getChildCount()).isEqualTo(4);
assertThat(hierarchy.nativeRootView.getChildAt(2)).isInstanceOf(ReactViewGroup.class);
ReactViewGroup view = (ReactViewGroup) hierarchy.nativeRootView.getChildAt(2);
assertThat(view.getBackgroundColor()).isEqualTo(Color.RED);
}
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:27,代码来源:UIManagerModuleTest.java
示例8: testUpdateSimpleHierarchy
import com.facebook.react.bridge.JavaOnlyMap; //导入依赖的package包/类
@Test
public void testUpdateSimpleHierarchy() {
UIManagerModule uiManager = getUIManagerModule();
ViewGroup rootView = createSimpleTextHierarchy(uiManager, "Some text");
TextView textView = (TextView) rootView.getChildAt(0);
int rawTextTag = 3;
uiManager.updateView(
rawTextTag,
ReactRawTextManager.REACT_CLASS,
JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "New text"));
uiManager.onBatchComplete();
executePendingFrameCallbacks();
assertThat(textView.getText().toString()).isEqualTo("New text");
}
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:19,代码来源:UIManagerModuleTest.java
示例9: testNativeAnimatedEventDoUpdate
import com.facebook.react.bridge.JavaOnlyMap; //导入依赖的package包/类
@Test
public void testNativeAnimatedEventDoUpdate() {
int viewTag = 1000;
createSimpleAnimatedViewWithOpacity(viewTag, 0d);
mNativeAnimatedNodesManager.addAnimatedEventToView(viewTag, "topScroll", JavaOnlyMap.of(
"animatedValueTag", 1,
"nativeEventPath", JavaOnlyArray.of("contentOffset", "y")));
mNativeAnimatedNodesManager.onEventDispatch(createScrollEvent(viewTag, 10));
ArgumentCaptor<ReactStylesDiffMap> stylesCaptor =
ArgumentCaptor.forClass(ReactStylesDiffMap.class);
reset(mUIImplementationMock);
mNativeAnimatedNodesManager.runUpdates(nextFrameTime());
verify(mUIImplementationMock).synchronouslyUpdateViewOnUIThread(eq(viewTag), stylesCaptor.capture());
assertThat(stylesCaptor.getValue().getDouble("opacity", Double.NaN)).isEqualTo(10);
}
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:21,代码来源:NativeAnimatedNodeTraversalTest.java
示例10: updateView
import com.facebook.react.bridge.JavaOnlyMap; //导入依赖的package包/类
public final void updateView(UIImplementation uiImplementation) {
if (mConnectedViewTag == -1) {
throw new IllegalStateException("Node has not been attached to a view");
}
JavaOnlyMap propsMap = new JavaOnlyMap();
for (Map.Entry<String, Integer> entry : mPropMapping.entrySet()) {
@Nullable AnimatedNode node = mNativeAnimatedNodesManager.getNodeById(entry.getValue());
if (node == null) {
throw new IllegalArgumentException("Mapped property node does not exists");
} else if (node instanceof StyleAnimatedNode) {
((StyleAnimatedNode) node).collectViewUpdates(propsMap);
} else if (node instanceof ValueAnimatedNode) {
propsMap.putDouble(entry.getKey(), ((ValueAnimatedNode) node).getValue());
} else {
throw new IllegalArgumentException("Unsupported type of node used in property node " +
node.getClass());
}
}
// TODO: Reuse propsMap and stylesDiffMap objects - note that in subsequent animation steps
// for a given node most of the time we will be creating the same set of props (just with
// different values). We can take advantage on that and optimize the way we allocate property
// maps (we also know that updating view props doesn't retain a reference to the styles object).
uiImplementation.synchronouslyUpdateViewOnUIThread(
mConnectedViewTag,
new ReactStylesDiffMap(propsMap));
}
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:27,代码来源:PropsAnimatedNode.java
示例11: testTextDecorationLineUnderlineApplied
import com.facebook.react.bridge.JavaOnlyMap; //导入依赖的package包/类
@Test
public void testTextDecorationLineUnderlineApplied() {
UIManagerModule uiManager = getUIManagerModule();
ReactRootView rootView = createText(
uiManager,
JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline"),
JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));
TextView textView = (TextView) rootView.getChildAt(0);
Spanned text = (Spanned) textView.getText();
UnderlineSpan underlineSpan = getSingleSpan(textView, UnderlineSpan.class);
StrikethroughSpan[] strikeThroughSpans =
text.getSpans(0, text.length(), StrikethroughSpan.class);
assertThat(underlineSpan instanceof UnderlineSpan).isTrue();
assertThat(strikeThroughSpans).hasSize(0);
}
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:18,代码来源:ReactTextTest.java
示例12: shouldDeleteDbEntry
import com.facebook.react.bridge.JavaOnlyMap; //导入依赖的package包/类
@Test
public void shouldDeleteDbEntry() throws Exception {
String tableName = "testTable";
ReadableMap readableMap = JavaOnlyMap.of("id", 1);
AwaitablePromise<Integer> awaitablePromise = new AwaitablePromise<>();
when(sqLiteDatabase.delete(tableName, "id = ?", new String[] {"1"})).thenReturn(1);
DeleteCommand deleteCommand = new DeleteCommand(reactContext, rnRecordSQLiteHelper);
deleteCommand.delete(tableName, readableMap, awaitablePromise.promise());
Integer deleteCount = awaitablePromise.awaitResolve();
assertThat(deleteCount, is(1));
}
开发者ID:reneweb,项目名称:rnrecord,代码行数:13,代码来源:DeleteCommandTest.java
示例13: shouldFindDbEntry
import com.facebook.react.bridge.JavaOnlyMap; //导入依赖的package包/类
@Test
public void shouldFindDbEntry() throws Exception {
String tableName = "testTable";
ReadableMap readableMap = JavaOnlyMap.of("id", 1D);
AwaitablePromise<JavaOnlyArray> awaitablePromise = new AwaitablePromise<>();
Cursor cursor = mockCursor();
when(sqLiteDatabase.rawQuery("SELECT * from " + tableName + " WHERE id = ? ;", new String[] { "1.0" })).thenReturn(cursor);
FindCommand findCommand = new FindCommand(reactContext, rnRecordSQLiteHelper);
findCommand.find(tableName, readableMap, awaitablePromise.promise());
JavaOnlyArray result = awaitablePromise.awaitResolve();
assertThat(result.size(), is(1));
assertThat(result.getMap(0).getString("name"), is("rob"));
}
开发者ID:reneweb,项目名称:rnrecord,代码行数:15,代码来源:FindCommandTest.java
示例14: shouldUpdateDbEntry
import com.facebook.react.bridge.JavaOnlyMap; //导入依赖的package包/类
@Test
public void shouldUpdateDbEntry() throws Exception {
String tableName = "testTable";
ContentValues contentValues = new ContentValues();
contentValues.put("name", "rob");
contentValues.put("id", 1D);
ReadableMap readableMap = JavaOnlyMap.of("id", 1D, "name", "rob");
AwaitablePromise<Integer> awaitablePromise = new AwaitablePromise<>();
when(sqLiteDatabase.update(tableName, contentValues, "id = ?", new String[] {"1.0"})).thenReturn(1);
UpdateCommand updateCommand = new UpdateCommand(reactContext, rnRecordSQLiteHelper);
updateCommand.update(tableName, readableMap, awaitablePromise.promise());
Integer updateCount = awaitablePromise.awaitResolve();
assertThat(updateCount, is(1));
}
开发者ID:reneweb,项目名称:rnrecord,代码行数:16,代码来源:UpdateCommandTest.java
示例15: shouldSaveDbEntry
import com.facebook.react.bridge.JavaOnlyMap; //导入依赖的package包/类
@Test
public void shouldSaveDbEntry() throws Exception {
String tableName = "testTable";
ContentValues contentValues = new ContentValues();
contentValues.put("name", "rob");
AwaitablePromise<Double> awaitablePromise = new AwaitablePromise<>();
when(sqLiteDatabase.insert(tableName, null, contentValues)).thenReturn(1L);
SaveCommand saveCommand = new SaveCommand(reactContext, rnRecordSQLiteHelper);
saveCommand.save(tableName, JavaOnlyMap.of("name", "rob"), awaitablePromise.promise());
Double insertCount = awaitablePromise.awaitResolve();
assertThat(insertCount, is(1D));
}
开发者ID:reneweb,项目名称:rnrecord,代码行数:14,代码来源:SaveCommandTest.java
示例16: createSimpleAnimatedViewWithOpacity
import com.facebook.react.bridge.JavaOnlyMap; //导入依赖的package包/类
/**
* Generates a simple animated nodes graph and attaches the props node to a given {@param viewTag}
* Parameter {@param opacity} is used as a initial value for the "opacity" attribute.
*
* Nodes are connected as follows (nodes IDs in parens):
* ValueNode(1) -> StyleNode(2) -> PropNode(3)
*/
private void createSimpleAnimatedViewWithOpacity(int viewTag, double opacity) {
mNativeAnimatedNodesManager.createAnimatedNode(
1,
JavaOnlyMap.of("type", "value", "value", opacity, "offset", 0d));
mNativeAnimatedNodesManager.createAnimatedNode(
2,
JavaOnlyMap.of("type", "style", "style", JavaOnlyMap.of("opacity", 1)));
mNativeAnimatedNodesManager.createAnimatedNode(
3,
JavaOnlyMap.of("type", "props", "props", JavaOnlyMap.of("style", 2)));
mNativeAnimatedNodesManager.connectAnimatedNodes(1, 2);
mNativeAnimatedNodesManager.connectAnimatedNodes(2, 3);
mNativeAnimatedNodesManager.connectAnimatedNodeToView(3, viewTag);
}
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:22,代码来源:NativeAnimatedNodeTraversalTest.java
示例17: testCallbackPositive
import com.facebook.react.bridge.JavaOnlyMap; //导入依赖的package包/类
@Test
public void testCallbackPositive() {
final JavaOnlyMap options = new JavaOnlyMap();
options.putString("buttonPositive", "OK");
final SimpleCallback actionCallback = new SimpleCallback();
mDialogModule.showAlert(options, null, actionCallback);
final AlertDialog dialog = (AlertDialog) getFragment().getDialog();
dialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick();
assertEquals(1, actionCallback.getCalls());
assertEquals(DialogModule.ACTION_BUTTON_CLICKED, actionCallback.getArgs()[0]);
assertEquals(DialogInterface.BUTTON_POSITIVE, actionCallback.getArgs()[1]);
}
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:16,代码来源:DialogModuleTest.java
示例18: testPropsApplied
import com.facebook.react.bridge.JavaOnlyMap; //导入依赖的package包/类
@Test
public void testPropsApplied() {
UIManagerModule uiManager = getUIManagerModule();
ReactRootView rootView = new ReactRootView(RuntimeEnvironment.application);
rootView.setLayoutParams(new ReactRootView.LayoutParams(100, 100));
int rootTag = uiManager.addMeasuredRootView(rootView);
int textInputTag = rootTag + 1;
final String hintStr = "placeholder text";
uiManager.createView(
textInputTag,
ReactTextInputManager.REACT_CLASS,
rootTag,
JavaOnlyMap.of(
ViewProps.FONT_SIZE, 13.37, ViewProps.HEIGHT, 20.0, "placeholder", hintStr));
uiManager.manageChildren(
rootTag,
null,
null,
JavaOnlyArray.of(textInputTag),
JavaOnlyArray.of(0),
null);
uiManager.onBatchComplete();
executePendingChoreographerCallbacks();
EditText editText = (EditText) rootView.getChildAt(0);
assertThat(editText.getHint()).isEqualTo(hintStr);
assertThat(editText.getTextSize()).isEqualTo((float) Math.ceil(13.37));
assertThat(editText.getHeight()).isEqualTo(20);
}
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:34,代码来源:TextInputTest.java
示例19: testCallbackNeutral
import com.facebook.react.bridge.JavaOnlyMap; //导入依赖的package包/类
@Test
public void testCallbackNeutral() {
final JavaOnlyMap options = new JavaOnlyMap();
options.putString("buttonNeutral", "Later");
final SimpleCallback actionCallback = new SimpleCallback();
mDialogModule.showAlert(options, null, actionCallback);
final AlertDialog dialog = (AlertDialog) getFragment().getDialog();
dialog.getButton(DialogInterface.BUTTON_NEUTRAL).performClick();
assertEquals(1, actionCallback.getCalls());
assertEquals(DialogModule.ACTION_BUTTON_CLICKED, actionCallback.getArgs()[0]);
assertEquals(DialogInterface.BUTTON_NEUTRAL, actionCallback.getArgs()[1]);
}
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:16,代码来源:DialogModuleTest.java
示例20: testBoldFontApplied
import com.facebook.react.bridge.JavaOnlyMap; //导入依赖的package包/类
@Test
public void testBoldFontApplied() {
UIManagerModule uiManager = getUIManagerModule();
ReactRootView rootView = createText(
uiManager,
JavaOnlyMap.of(ViewProps.FONT_WEIGHT, "bold"),
JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));
CustomStyleSpan customStyleSpan =
getSingleSpan((TextView) rootView.getChildAt(0), CustomStyleSpan.class);
assertThat(customStyleSpan.getWeight() & Typeface.BOLD).isNotZero();
assertThat(customStyleSpan.getStyle() & Typeface.ITALIC).isZero();
}
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:15,代码来源:ReactTextTest.java
注:本文中的com.facebook.react.bridge.JavaOnlyMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论