Java 类com.facebook.react.uimanager.UIManagerModule 实例源码

项目:react-native-andorid-shadow    文件:RNReactNativeAndoridShadowModule.java   
@ReactMethod
    public void applyShadowForView(final Integer tag, final ReadableMap param) {
        Log.d(TAG,"AndroidShadowManager applyShadowForView! tag: " + tag);
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            return;
        }
        UIManagerModule uiManager = reactContext.getNativeModule(UIManagerModule.class);
        uiManager.addUIBlock(new UIBlock() {

            @Override
            public void execute(NativeViewHierarchyManager nvhm) {
                ReactViewGroup targetView = (ReactViewGroup) nvhm.resolveView(tag);
                Log.d(TAG,"AndroidShadowManager view w = " + targetView.getWidth() + " h = " + targetView.getHeight());
//                targetView.setBackgroundColor(Color.CYAN);
                targetView.getViewTreeObserver().addOnGlobalLayoutListener(new OutlineAdjuster(targetView,param));

            }
        });
    }
项目:react-native-recyclerview-list    文件:RecyclerViewBackedScrollView.java   
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    if (super.onInterceptTouchEvent(ev)) {
        NativeGestureUtil.notifyNativeGestureStarted(this, ev);
        mDragging = true;
        getReactContext().getNativeModule(UIManagerModule.class).getEventDispatcher()
                .dispatchEvent(ScrollEvent.obtain(
                        getId(),
                        ScrollEventType.BEGIN_DRAG,
                        0, /* offsetX = 0, horizontal scrolling only */
                        computeVerticalScrollOffset(),
                        0, // xVelocity
                        0, // yVelocity
                        getWidth(),
                        computeVerticalScrollRange(),
                        getWidth(),
                        getHeight()));
        return true;
    }

    return false;
}
项目:react-native-recyclerview-list    文件:RecyclerViewBackedScrollView.java   
@Override
public boolean onTouchEvent(MotionEvent ev) {
    int action = ev.getAction() & MotionEvent.ACTION_MASK;
    if (action == MotionEvent.ACTION_UP && mDragging) {
        mDragging = false;
        mVelocityHelper.calculateVelocity(ev);
        getReactContext().getNativeModule(UIManagerModule.class).getEventDispatcher()
                .dispatchEvent(ScrollEvent.obtain(
                        getId(),
                        ScrollEventType.END_DRAG,
                        0, /* offsetX = 0, horizontal scrolling only */
                        computeVerticalScrollOffset(),
                        mVelocityHelper.getXVelocity(),
                        mVelocityHelper.getYVelocity(),
                        getWidth(),
                        computeVerticalScrollRange(),
                        getWidth(),
                        getHeight()));
    }
    return super.onTouchEvent(ev);
}
项目:RNLearn_Project1    文件:ReactTextTest.java   
@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();
}
项目:RNLearn_Project1    文件:ReactTextTest.java   
@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();
}
项目:RNLearn_Project1    文件:ReactModalHostView.java   
@Override
protected void onSizeChanged(final int w, final int h, int oldw, int oldh) {
  super.onSizeChanged(w, h, oldw, oldh);
  if (getChildCount() > 0) {
    final int viewTag = getChildAt(0).getId();
    ReactContext reactContext = (ReactContext) getContext();
    reactContext.runOnNativeModulesQueueThread(
      new GuardedRunnable(reactContext) {
        @Override
        public void runGuarded() {
          ((ReactContext) getContext()).getNativeModule(UIManagerModule.class)
            .updateNodeSize(viewTag, w, h);
        }
      });
  }
}
项目:RNLearn_Project1    文件:ReactTextTest.java   
@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();
}
项目:RNLearn_Project1    文件:ReactToolbarManager.java   
@Override
protected void addEventEmitters(final ThemedReactContext reactContext, final ReactToolbar view) {
  final EventDispatcher mEventDispatcher = reactContext.getNativeModule(UIManagerModule.class)
      .getEventDispatcher();
  view.setNavigationOnClickListener(
      new View.OnClickListener() {
        @Override
        public void onClick(View v) {
          mEventDispatcher.dispatchEvent(
              new ToolbarClickEvent(view.getId(), -1));
        }
      });

  view.setOnMenuItemClickListener(
      new ReactToolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
          mEventDispatcher.dispatchEvent(
              new ToolbarClickEvent(
                  view.getId(),
                  menuItem.getOrder()));
          return true;
        }
      });
}
项目:RNLearn_Project1    文件:ReactScrollViewHelper.java   
private static void emitScrollEvent(ViewGroup scrollView, ScrollEventType scrollEventType) {
  View contentView = scrollView.getChildAt(0);

  if (contentView == null) {
    return;
  }

  ReactContext reactContext = (ReactContext) scrollView.getContext();
  reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
      ScrollEvent.obtain(
          scrollView.getId(),
          scrollEventType,
          scrollView.getScrollX(),
          scrollView.getScrollY(),
          contentView.getWidth(),
          contentView.getHeight(),
          scrollView.getWidth(),
          scrollView.getHeight()));
}
项目:RNLearn_Project1    文件:ReactTestHelper.java   
/**
 * @return a CatalystInstance mock that has a default working ReactQueueConfiguration.
 */
public static CatalystInstance createMockCatalystInstance() {
  ReactQueueConfigurationSpec spec = ReactQueueConfigurationSpec.builder()
      .setJSQueueThreadSpec(MessageQueueThreadSpec.mainThreadSpec())
      .setNativeModulesQueueThreadSpec(MessageQueueThreadSpec.mainThreadSpec())
      .build();
  ReactQueueConfiguration ReactQueueConfiguration = ReactQueueConfigurationImpl.create(
      spec,
      new QueueThreadExceptionHandler() {
        @Override
        public void handleException(Exception e) {
          throw new RuntimeException(e);
        }
      });

  CatalystInstance reactInstance = mock(CatalystInstance.class);
  when(reactInstance.getReactQueueConfiguration()).thenReturn(ReactQueueConfiguration);
  when(reactInstance.getNativeModule(UIManagerModule.class))
      .thenReturn(mock(UIManagerModule.class));

  return reactInstance;
}
项目:RNLearn_Project1    文件:ReactTextTest.java   
@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);
}
项目:RNLearn_Project1    文件:ReactTextTest.java   
@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();
}
项目:RNLearn_Project1    文件:ReactTextTest.java   
@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();
}
项目:RNLearn_Project1    文件:ReactTestHelper.java   
/**
 * @return a CatalystInstance mock that has a default working ReactQueueConfiguration.
 */
public static CatalystInstance createMockCatalystInstance() {
  ReactQueueConfigurationSpec spec = ReactQueueConfigurationSpec.builder()
      .setJSQueueThreadSpec(MessageQueueThreadSpec.mainThreadSpec())
      .setNativeModulesQueueThreadSpec(MessageQueueThreadSpec.mainThreadSpec())
      .build();
  ReactQueueConfiguration ReactQueueConfiguration = ReactQueueConfigurationImpl.create(
      spec,
      new QueueThreadExceptionHandler() {
        @Override
        public void handleException(Exception e) {
          throw new RuntimeException(e);
        }
      });

  CatalystInstance reactInstance = mock(CatalystInstance.class);
  when(reactInstance.getReactQueueConfiguration()).thenReturn(ReactQueueConfiguration);
  when(reactInstance.getNativeModule(UIManagerModule.class))
      .thenReturn(mock(UIManagerModule.class));

  return reactInstance;
}
项目:RNLearn_Project1    文件:ReactModalHostView.java   
@Override
protected void onSizeChanged(final int w, final int h, int oldw, int oldh) {
  super.onSizeChanged(w, h, oldw, oldh);
  if (getChildCount() > 0) {
    final int viewTag = getChildAt(0).getId();
    ReactContext reactContext = (ReactContext) getContext();
    reactContext.runOnNativeModulesQueueThread(
      new GuardedRunnable(reactContext) {
        @Override
        public void runGuarded() {
          ((ReactContext) getContext()).getNativeModule(UIManagerModule.class)
            .updateNodeSize(viewTag, w, h);
        }
      });
  }
}
项目:RNLearn_Project1    文件:ReactToolbarManager.java   
@Override
protected void addEventEmitters(final ThemedReactContext reactContext, final ReactToolbar view) {
  final EventDispatcher mEventDispatcher = reactContext.getNativeModule(UIManagerModule.class)
      .getEventDispatcher();
  view.setNavigationOnClickListener(
      new View.OnClickListener() {
        @Override
        public void onClick(View v) {
          mEventDispatcher.dispatchEvent(
              new ToolbarClickEvent(view.getId(), -1));
        }
      });

  view.setOnMenuItemClickListener(
      new ReactToolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
          mEventDispatcher.dispatchEvent(
              new ToolbarClickEvent(
                  view.getId(),
                  menuItem.getOrder()));
          return true;
        }
      });
}
项目:RNLearn_Project1    文件:ReactScrollViewHelper.java   
private static void emitScrollEvent(ViewGroup scrollView, ScrollEventType scrollEventType) {
  View contentView = scrollView.getChildAt(0);

  if (contentView == null) {
    return;
  }

  ReactContext reactContext = (ReactContext) scrollView.getContext();
  reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
      ScrollEvent.obtain(
          scrollView.getId(),
          scrollEventType,
          scrollView.getScrollX(),
          scrollView.getScrollY(),
          contentView.getWidth(),
          contentView.getHeight(),
          scrollView.getWidth(),
          scrollView.getHeight()));
}
项目:RNLearn_Project1    文件:CoreModulesPackage.java   
private UIManagerModule createUIManager(ReactApplicationContext reactContext) {
  ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_START);
  Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "createUIManagerModule");
  try {
    List<ViewManager> viewManagersList = mReactInstanceManager.createAllViewManagers(
      reactContext);
    return new UIManagerModule(
      reactContext,
      viewManagersList,
      mUIImplementationProvider,
      mLazyViewManagersEnabled);
  } finally {
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
    ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_END);
  }
}
项目:react-native-twitterkit    文件:ReactTweetViewManager.java   
@Override
public void onSizeChanged(TweetView view, final int width, final int height) {
  Log.d(TAG, "TweetView changed size: " + width + ", " + height);
  ReactContext ctx = (ReactContext) view.getContext();
  final UIManagerModule uiManager = ctx.getNativeModule(UIManagerModule.class);
  final int reactTag = view.getReactTag();

  ctx.runOnNativeModulesQueueThread(new Runnable() {
    @Override
    public void run() {
      uiManager.updateNodeSize(reactTag, width, height);
    }
  });
}
项目:react-native-recyclerview-list    文件:RecyclerViewBackedScrollView.java   
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
    super.onScrollChanged(l, t, oldl, oldt);

    if (mOnScrollDispatchHelper.onScrollChanged(l, t)) {
        getReactContext().getNativeModule(UIManagerModule.class).getEventDispatcher()
                .dispatchEvent(ScrollEvent.obtain(
                        getId(),
                        ScrollEventType.SCROLL,
                        0, /* offsetX = 0, horizontal scrolling only */
                        computeVerticalScrollOffset(),
                        mOnScrollDispatchHelper.getXFlingVelocity(),
                        mOnScrollDispatchHelper.getYFlingVelocity(),
                        getWidth(),
                        computeVerticalScrollRange(),
                        getWidth(),
                        getHeight()));
    }

    final int firstIndex = ((LinearLayoutManager) getLayoutManager()).findFirstVisibleItemPosition();
    final int lastIndex = ((LinearLayoutManager) getLayoutManager()).findLastVisibleItemPosition();

    if (firstIndex != mFirstVisibleIndex || lastIndex != mLastVisibleIndex) {
        getReactContext().getNativeModule(UIManagerModule.class).getEventDispatcher()
                .dispatchEvent(new VisibleItemsChangeEvent(
                        getId(),
                        SystemClock.nanoTime(),
                        firstIndex,
                        lastIndex));

        mFirstVisibleIndex = firstIndex;
        mLastVisibleIndex = lastIndex;
    }
}
项目:RNLearn_Project1    文件:ReactTextTest.java   
@Test
public void testFontFamilyStyleApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.FONT_FAMILY, "sans-serif"),
      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).isZero();
  assertThat(customStyleSpan.getWeight() & Typeface.BOLD).isZero();
}
项目:react-native-pull-up-down-refresh    文件:RCTLazyLoadViewManager.java   
@Override
protected void addEventEmitters(
        final ThemedReactContext reactContext,
        final RCTLazyLoadView view) {
    view.setOnEvChangeListener(
            new OnEvChangeListener() {
                @Override
                public void onWindowVisibilityChange( boolean hiddenState) {
                    reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher()
                            .dispatchEvent(new WindowVisibilityChangeEvent(view.getId(), SystemClock.nanoTime(), hiddenState));
                }

            });
}
项目:react-native-datepicker-component-android    文件:RNDatePickerComponentViewManager.java   
@Override
public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
    ReactContext reactContext = (ReactContext) view.getContext();
    @SuppressLint("DefaultLocale") String date = String.format("%d-%d-%d", year, monthOfYear+1, dayOfMonth);
    reactContext.getNativeModule(UIManagerModule.class)
            .getEventDispatcher()
            .dispatchEvent(new RNDatePickerComponentEvent(view.getId(), date));
}
项目:react-native-webgl-view-shot    文件:RNWebGLTextureViewLoader.java   
@Override
public void loadWithConfig(ReadableMap config, RNWebGLTextureCompletionBlock callback) {
    int tag = config.getInt("view");
    try {
        UIManagerModule uiManager = this.reactContext.getNativeModule(UIManagerModule.class);
        uiManager.addUIBlock(new RNWebGLTextureViewUIBlock(config, tag, callback));
    }
    catch (Exception e) {
        callback.call(e, null);
    }
}
项目:react-native-tabbed-view-pager-android    文件:ReactViewPager.java   
public ReactViewPager(ReactContext reactContext) {
  super(reactContext);
  mEventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
  mIsCurrentItemFromJs = false;
  setOnPageChangeListener(new PageChangeListener());
  setAdapter(new Adapter());
}
项目:RNLearn_Project1    文件:ReactTextInputManager.java   
public ReactTextInputTextWatcher(
    final ReactContext reactContext,
    final ReactEditText editText) {
  mEventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
  mEditText = editText;
  mPreviousText = null;
}
项目:RNLearn_Project1    文件:ReactTextTest.java   
@Test
public void testItalicFontApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.FONT_STYLE, "italic"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  CustomStyleSpan customStyleSpan =
      getSingleSpan((TextView) rootView.getChildAt(0), CustomStyleSpan.class);
  assertThat(customStyleSpan.getStyle() & Typeface.ITALIC).isNotZero();
  assertThat(customStyleSpan.getWeight() & Typeface.BOLD).isZero();
}
项目:RNLearn_Project1    文件:ReactTextTest.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Test
public void testMaxLinesApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.NUMBER_OF_LINES, 2),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  TextView textView = (TextView) rootView.getChildAt(0);
  assertThat(textView.getText().toString()).isEqualTo("test text");
  assertThat(textView.getMaxLines()).isEqualTo(2);
  assertThat(textView.getEllipsize()).isEqualTo(TextUtils.TruncateAt.END);
}
项目:RNLearn_Project1    文件:ReactSwitchManager.java   
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  ReactContext reactContext = (ReactContext) buttonView.getContext();
  reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
      new ReactSwitchEvent(
          buttonView.getId(),
          isChecked));
}
项目:RNLearn_Project1    文件:ReactDrawerLayoutManager.java   
@Override
protected void addEventEmitters(ThemedReactContext reactContext, ReactDrawerLayout view) {
  view.setDrawerListener(
      new DrawerEventEmitter(
          view,
          reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher()));
}
项目:RNLearn_Project1    文件:ReactSliderManager.java   
@Override
public void onProgressChanged(SeekBar seekbar, int progress, boolean fromUser) {
  ReactContext reactContext = (ReactContext) seekbar.getContext();
  reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
      new ReactSliderEvent(
          seekbar.getId(),
          ((ReactSlider) seekbar).toRealProgress(progress),
          fromUser));
}
项目:RNLearn_Project1    文件:TextInputTest.java   
public UIManagerModule getUIManagerModule() {
  ReactApplicationContext reactContext = ReactTestHelper.createCatalystContextForTest();
  List<ViewManager> viewManagers = Arrays.asList(
      new ViewManager[] {
          new ReactTextInputManager(),
      });
  UIManagerModule uiManagerModule = new UIManagerModule(
      reactContext,
      viewManagers,
      new UIImplementationProvider(),
      false);
  uiManagerModule.onHostResume();
  return uiManagerModule;
}
项目:RNLearn_Project1    文件:SwipeRefreshLayoutManager.java   
@Override
protected void addEventEmitters(
    final ThemedReactContext reactContext,
    final ReactSwipeRefreshLayout view) {
  view.setOnRefreshListener(
      new OnRefreshListener() {
        @Override
        public void onRefresh() {
          reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher()
              .dispatchEvent(new RefreshEvent(view.getId()));
        }
      });
}
项目:RNLearn_Project1    文件:ReactPickerManager.java   
@Override
protected void addEventEmitters(
    final ThemedReactContext reactContext,
    final ReactPicker picker) {
  picker.setOnSelectListener(
          new PickerEventEmitter(
                  picker,
                  reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher()));
}
项目:RNLearn_Project1    文件:ReactViewPager.java   
public ReactViewPager(ReactContext reactContext) {
  super(reactContext);
  mEventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
  mIsCurrentItemFromJs = false;
  setOnPageChangeListener(new PageChangeListener());
  setAdapter(new Adapter());
}
项目:RNLearn_Project1    文件:ReactImageView.java   
public void setShouldNotifyLoadEvents(boolean shouldNotify) {
  if (!shouldNotify) {
    mControllerListener = null;
  } else {
    final EventDispatcher mEventDispatcher = ((ReactContext) getContext()).
        getNativeModule(UIManagerModule.class).getEventDispatcher();

    mControllerListener = new BaseControllerListener<ImageInfo>() {
      @Override
      public void onSubmit(String id, Object callerContext) {
        mEventDispatcher.dispatchEvent(
            new ImageLoadEvent(getId(), ImageLoadEvent.ON_LOAD_START));
      }

      @Override
      public void onFinalImageSet(
          String id,
          @Nullable final ImageInfo imageInfo,
          @Nullable Animatable animatable) {
        if (imageInfo != null) {
          mEventDispatcher.dispatchEvent(
            new ImageLoadEvent(getId(), ImageLoadEvent.ON_LOAD,
              mImageSource.getSource(), imageInfo.getWidth(), imageInfo.getHeight()));
          mEventDispatcher.dispatchEvent(
            new ImageLoadEvent(getId(), ImageLoadEvent.ON_LOAD_END));
        }
      }

      @Override
      public void onFailure(String id, Throwable throwable) {
        mEventDispatcher.dispatchEvent(
          new ImageLoadEvent(getId(), ImageLoadEvent.ON_ERROR));
        mEventDispatcher.dispatchEvent(
          new ImageLoadEvent(getId(), ImageLoadEvent.ON_LOAD_END));
      }
    };
  }

  mIsDirty = true;
}
项目:RNLearn_Project1    文件:ReactRootView.java   
@Override
public void onChildStartedNativeGesture(MotionEvent androidEvent) {
  if (mReactInstanceManager == null || !mIsAttachedToInstance ||
    mReactInstanceManager.getCurrentReactContext() == null) {
    FLog.w(
      ReactConstants.TAG,
      "Unable to dispatch touch to JS as the catalyst instance has not been attached");
    return;
  }
  ReactContext reactContext = mReactInstanceManager.getCurrentReactContext();
  EventDispatcher eventDispatcher = reactContext.getNativeModule(UIManagerModule.class)
    .getEventDispatcher();
  mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, eventDispatcher);
}
项目:RNLearn_Project1    文件:ReactTextTest.java   
@Test
public void testFontFamilyBoldStyleApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.FONT_FAMILY, "sans-serif", ViewProps.FONT_WEIGHT, "bold"),
      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).isZero();
  assertThat(customStyleSpan.getWeight() & Typeface.BOLD).isNotZero();
}
项目:RNLearn_Project1    文件:ReactTextTest.java   
@Test
public void testFontFamilyItalicStyleApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.FONT_FAMILY, "sans-serif", 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).isZero();
}
项目:RNLearn_Project1    文件:ReactTextTest.java   
@Test
public void testBackgroundColorStyleApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.BACKGROUND_COLOR, Color.BLUE),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  Drawable backgroundDrawable = ((TextView) rootView.getChildAt(0)).getBackground();
  assertThat(((ReactViewBackgroundDrawable) backgroundDrawable).getColor()).isEqualTo(Color.BLUE);
}