本文整理汇总了Java中com.facebook.react.bridge.JavaOnlyMap类的典型用法代码示例。如果您正苦于以下问题:Java JavaOnlyMap类的具体用法?Java JavaOnlyMap怎么用?Java JavaOnlyMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JavaOnlyMap类属于com.facebook.react.bridge包,在下文中一共展示了JavaOnlyMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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");
}
示例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);
}
示例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));
}
示例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);
}
示例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));
}
示例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"));
}
示例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));
}
示例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));
}