com.facebook.react.uimanager.ThemedReactContext Java Examples

The following examples show how to use com.facebook.react.uimanager.ThemedReactContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RNX5WebViewManager.java    From react-native-x5 with MIT License 6 votes vote down vote up
@Override
protected WebView createViewInstance(ThemedReactContext reactContext) {
    X5WeView webView = new X5WeView(reactContext);

    webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissionsCallback callback) {
            callback.invoke(origin, true, false);
        }
    });
    reactContext.addLifecycleEventListener(webView);
    mWebViewConfig.configWebView(webView);
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setDisplayZoomControls(false);

    // Fixes broken full-screen modals/galleries due to body height being 0.
    webView.setLayoutParams(
            new LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.MATCH_PARENT));

    if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        WebView.setWebContentsDebuggingEnabled(true);
    }

    return webView;
}
 
Example #2
Source File: PiliPlayerViewManager.java    From react-native-pili with MIT License 6 votes vote down vote up
@Override
protected PLVideoView createViewInstance(ThemedReactContext reactContext) {
    this.reactContext = reactContext;
    mEventEmitter = reactContext.getJSModule(RCTEventEmitter.class);
    mVideoView = new PLVideoView(reactContext);
    // Set some listeners
    mVideoView.setOnPreparedListener(mOnPreparedListener);
    mVideoView.setOnInfoListener(mOnInfoListener);
    mVideoView.setOnVideoSizeChangedListener(mOnVideoSizeChangedListener);
    mVideoView.setOnBufferingUpdateListener(mOnBufferingUpdateListener);
    mVideoView.setOnCompletionListener(mOnCompletionListener);
    mVideoView.setOnSeekCompleteListener(mOnSeekCompleteListener);
    mVideoView.setOnErrorListener(mOnErrorListener);

    reactContext.addLifecycleEventListener(this);
    return mVideoView;
}
 
Example #3
Source File: PPTGoogleMapManager.java    From react-native-maps with MIT License 6 votes vote down vote up
/**
 * Implementation of the react create view instance method - returns the map view to react.
 *
 * @param context
 * @return MapView
 */
@Override
protected MapView createViewInstance(ThemedReactContext context) {
    mapView = new MapView(context);

    mapView.onCreate(null);
    mapView.onResume();

    if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
        locationManager = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
    }

    reactContext = context;

    return mapView;
}
 
Example #4
Source File: RNJWPlayerView.java    From react-native-jw-media-player with MIT License 6 votes vote down vote up
public RNJWPlayerView(ThemedReactContext reactContext, ReactApplicationContext appContext) {
    super(getNonBuggyContext(reactContext, appContext));
    mAppContext = appContext;

    mThemedReactContext = reactContext;

    mActivity = getActivity();
    if (mActivity != null) {
        mWindow = mActivity.getWindow();
    }

    mRootView = mActivity.findViewById(android.R.id.content);

    Context simpleContext = getNonBuggyContext(getReactContext(), getAppContext());

    audioManager = (AudioManager) simpleContext.getSystemService(Context.AUDIO_SERVICE);
}
 
Example #5
Source File: ReactTextInputManager.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
public ReactEditText createViewInstance(ThemedReactContext context) {
  ReactEditText editText = new ReactEditText(context);
  int inputType = editText.getInputType();
  editText.setInputType(inputType & (~InputType.TYPE_TEXT_FLAG_MULTI_LINE));
  editText.setReturnKeyType("done");
  editText.setTextSize(
      TypedValue.COMPLEX_UNIT_PX,
      (int) Math.ceil(PixelUtil.toPixelFromSP(ViewDefaults.FONT_SIZE_SP)));
  return editText;
}
 
Example #6
Source File: ReactPickerManager.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
protected void addEventEmitters(
    final ThemedReactContext reactContext,
    final ReactPicker picker) {
  picker.setOnSelectListener(
          new PickerEventEmitter(
                  picker,
                  reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher()));
}
 
Example #7
Source File: ARTSurfaceViewShadowNode.java    From art with MIT License 5 votes vote down vote up
@Override
public void setThemedContext(ThemedReactContext themedContext) {
  super.setThemedContext(themedContext);
  if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N) {
    themedContext.addLifecycleEventListener(this);
  }
}
 
Example #8
Source File: FabricUIManager.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
@DoNotStrip
public <T extends SizeMonitoringFrameLayout & MeasureSpecProvider> int addRootView(
    final T rootView) {

  SystraceMessage.beginSection(
    Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
    "FabricUIManager.addRootView")
    .flush();
  try {
    final int rootTag = ReactRootViewTagGenerator.getNextRootViewTag();
    ThemedReactContext themedRootContext =
        new ThemedReactContext(mReactApplicationContext, rootView.getContext());

    ReactShadowNode rootShadowNode = createRootShadowNode(rootTag, themedRootContext);

    int widthMeasureSpec = rootView.getWidthMeasureSpec();
    int heightMeasureSpec = rootView.getHeightMeasureSpec();
    updateRootView(rootShadowNode, widthMeasureSpec, heightMeasureSpec);

    rootView.setOnSizeChangedListener(
      new SizeMonitoringFrameLayout.OnSizeChangedListener() {
        @Override
        public void onSizeChanged(final int width, final int height, int oldW, int oldH) {
          updateRootSize(rootTag, width, height);
        }
      });

    mRootShadowNodeRegistry.registerNode(rootShadowNode);
    mUIViewOperationQueue.addRootView(rootTag, rootView, themedRootContext);
    return rootTag;
  } finally{
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
  }
}
 
Example #9
Source File: RNYandexMapKitManager.java    From react-native-yandexmapkit with MIT License 5 votes vote down vote up
@Override
protected RNYandexMapKitView createViewInstance(ThemedReactContext reactContext) {
    RNYandexMapKitModule nativeModule = reactContext.getNativeModule(RNYandexMapKitModule.class);
    String apiKey = nativeModule.getApiKey();
    RNYandexMapKitView view = new RNYandexMapKitView(reactContext, apiKey);
    return view;
}
 
Example #10
Source File: RNJitsiMeetViewManager.java    From react-native-jitsi-meet with Apache License 2.0 5 votes vote down vote up
@Override
public RNJitsiMeetView createViewInstance(ThemedReactContext context) {
    if (mJitsiMeetViewReference.getJitsiMeetView() == null) {
        RNJitsiMeetView view = new RNJitsiMeetView(context.getCurrentActivity());
        view.setListener(this);
        mJitsiMeetViewReference.setJitsiMeetView(view);
    }
    return mJitsiMeetViewReference.getJitsiMeetView();
}
 
Example #11
Source File: ReactAztecManager.java    From react-native-aztec with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void addEventEmitters(final ThemedReactContext reactContext, final ReactAztecText aztecText) {
    aztecText.addTextChangedListener(new AztecTextWatcher(reactContext, aztecText));
    aztecText.setOnFocusChangeListener(
            new View.OnFocusChangeListener() {
                public void onFocusChange(View v, boolean hasFocus) {
                    EventDispatcher eventDispatcher = reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
                    final ReactAztecText editText = (ReactAztecText)v;
                    if (hasFocus) {
                        eventDispatcher.dispatchEvent(
                                new ReactAztecFocusEvent(
                                        editText.getId()));
                    } else {
                        eventDispatcher.dispatchEvent(
                                new ReactAztecBlurEvent(
                                        editText.getId()));

                        eventDispatcher.dispatchEvent(
                                new ReactAztecEndEditingEvent(
                                        editText.getId(),
                                        editText.toHtml(false)));
                    }
                }
            });

    // Don't think we need to add setOnEditorActionListener here (intercept Enter for example), but
    // in case check ReactTextInputManager
}
 
Example #12
Source File: ReactAztecText.java    From react-native-aztec with GNU General Public License v2.0 5 votes vote down vote up
public ReactAztecText(ThemedReactContext reactContext) {
    super(reactContext);
    this.setAztecKeyListener(new ReactAztecText.OnAztecKeyListener() {
        @Override
        public boolean onEnterKey() {
            if (shouldHandleOnEnter) {
                return onEnter();
            }
            return false;
        }
        @Override
        public boolean onBackspaceKey() {
            if (shouldHandleOnBackspace) {
                return onBackspace();
            }
            return false;
        }
    });
    mInputMethodManager = (InputMethodManager)
            Assertions.assertNotNull(getContext().getSystemService(Context.INPUT_METHOD_SERVICE));
    this.setOnSelectionChangedListener(new OnSelectionChangedListener() {
        @Override
        public void onSelectionChanged(int selStart, int selEnd) {
            ReactAztecText.this.updateToolbarButtons(selStart, selEnd);
            ReactAztecText.this.propagateSelectionChanges(selStart, selEnd);
        }
    });
    this.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
}
 
Example #13
Source File: AMapViewManager.java    From react-native-amap with MIT License 5 votes vote down vote up
@Override
protected MapView createViewInstance(ThemedReactContext reactContent) {
    AMapOptions options = new AMapOptions();
    options.zoomControlsEnabled(false);
    //options.zoomGesturesEnabled(false);
    //options.rotateGesturesEnabled(false);
    mapView = new MapView(reactContent, options);
    mapView.onCreate(null);
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);
    map = mapView.getMap();
    eventDispatcher = reactContent.getNativeModule(UIManagerModule.class).getEventDispatcher();
    return mapView;
}
 
Example #14
Source File: CustomTwilioVideoView.java    From react-native-twilio-video-webrtc with MIT License 5 votes vote down vote up
public CustomTwilioVideoView(ThemedReactContext context) {
    super(context);
    this.themedReactContext = context;
    this.eventEmitter = themedReactContext.getJSModule(RCTEventEmitter.class);

    // add lifecycle for onResume and on onPause
    themedReactContext.addLifecycleEventListener(this);

    /*
     * Enable changing the volume using the up/down keys during a conversation
     */
    if (themedReactContext.getCurrentActivity() != null) {
        themedReactContext.getCurrentActivity().setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
    }
    /*
     * Needed for setting/abandoning audio focus during call
     */
    audioManager = (AudioManager) themedReactContext.getSystemService(Context.AUDIO_SERVICE);
    myNoisyAudioStreamReceiver = new BecomingNoisyReceiver();
    intentFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);

    // Create the local data track
   // localDataTrack = LocalDataTrack.create(this);
   localDataTrack = LocalDataTrack.create(getContext());

   // Start the thread where data messages are received
    dataTrackMessageThread.start();
    dataTrackMessageThreadHandler = new Handler(dataTrackMessageThread.getLooper());

}
 
Example #15
Source File: CollapsingParallaxManager.java    From react-native-collapsing-toolbar with MIT License 5 votes vote down vote up
@Override
public FrameLayout createViewInstance(ThemedReactContext context) {
    FrameLayout view = new FrameLayout(context);
    CollapsingToolbarLayout.LayoutParams params = new CollapsingToolbarLayout.LayoutParams(
        CollapsingToolbarLayout.LayoutParams.MATCH_PARENT,
        CollapsingToolbarLayout.LayoutParams.WRAP_CONTENT
    );
    params.setCollapseMode(CollapsingToolbarLayout.LayoutParams.COLLAPSE_MODE_PARALLAX);
    view.setLayoutParams(params);
    return view;
}
 
Example #16
Source File: BottomSheetHeaderManager.java    From react-native-bottom-sheet-behavior with MIT License 5 votes vote down vote up
@Override
protected BottomSheetHeaderView createViewInstance(ThemedReactContext reactContext) {
    BottomSheetHeaderView view = new BottomSheetHeaderView(reactContext);
    view.setOnClickListener(new BottomSheetHeaderListener());
    view.setClickable(true);
    view.setEnabled(true);
    return view;
}
 
Example #17
Source File: MergedAppBarLayoutManager.java    From react-native-bottom-sheet-behavior with MIT License 5 votes vote down vote up
@Override
public AppBarLayout createViewInstance(ThemedReactContext context) {
    AppBarLayout view = new AppBarLayout(context);

    int width = CoordinatorLayout.LayoutParams.MATCH_PARENT;
    int height = CoordinatorLayout.LayoutParams.WRAP_CONTENT;
    CoordinatorLayout.LayoutParams params = new CoordinatorLayout.LayoutParams(width, height);
    params.setBehavior(new MergedAppBarLayoutBehavior(context, null));
    view.setLayoutParams(params);
    // Set tag to match on ScrollAwareFABBehavior.
    view.setTag("modal-appbar");
    mergedBehavior = MergedAppBarLayoutBehavior.from(view);
    return view;
}
 
Example #18
Source File: ScrollingAppBarLayoutManager.java    From react-native-bottom-sheet-behavior with MIT License 5 votes vote down vote up
@Override
public AppBarLayout createViewInstance(ThemedReactContext context) {
    AppBarLayout view = new AppBarLayout(context);
    int width = CoordinatorLayout.LayoutParams.MATCH_PARENT;
    int height = CoordinatorLayout.LayoutParams.WRAP_CONTENT;
    CoordinatorLayout.LayoutParams params = new CoordinatorLayout.LayoutParams(width, height);
    params.setBehavior(new ScrollingAppBarLayoutBehavior(context, null));

    view.setLayoutParams(params);
    scrollingBehavior = ScrollingAppBarLayoutBehavior.from(view);
    return view;
}
 
Example #19
Source File: RNRtmpView.java    From react-native-rtmpview with MIT License 5 votes vote down vote up
private void init(Context context) {
    //Inflate xml resource, pass "this" as the parent, we use <merge> tag in xml to avoid
    //redundant parent, otherwise a LinearLayout will be added to this LinearLayout ending up
    //with two view groups
    inflate(getContext(), R.layout.react_rtmp_view,this);

    mExoPlayerView = findViewById(R.id.player_view);
    ((ThemedReactContext)context).addLifecycleEventListener(this);
}
 
Example #20
Source File: ReactDrawerLayoutManager.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
protected void addEventEmitters(ThemedReactContext reactContext, ReactDrawerLayout view) {
  view.setDrawerListener(
      new DrawerEventEmitter(
          view,
          reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher()));
}
 
Example #21
Source File: ReactSliderPropertyTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Before
public void setup() {
  ReactApplicationContext mContext = new ReactApplicationContext(RuntimeEnvironment.application);
  CatalystInstance mCatalystInstanceMock = ReactTestHelper.createMockCatalystInstance();
  mContext.initializeWithInstance(mCatalystInstanceMock);
  mThemedContext = new ThemedReactContext(mContext, mContext);
  mManager = new ReactSliderManager();
}
 
Example #22
Source File: VLCPlayerView.java    From react-native-vlc-player with MIT License 5 votes vote down vote up
public VLCPlayerView(ThemedReactContext context) {
    super(context);
    mThemedReactContext = context;
    mEventEmitter = mThemedReactContext.getJSModule(RCTEventEmitter.class);
    mThemedReactContext.addLifecycleEventListener(this);
    init();
}
 
Example #23
Source File: MapViewManager.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
@Override
protected TextureMapView createViewInstance(ThemedReactContext themedReactContext) {
    TextureMapView mapView =  new TextureMapView(themedReactContext);
    BaiduMap map = mapView.getMap();
    mapListener = new MapListener(mapView, themedReactContext);
    map.setOnMapStatusChangeListener(mapListener);
    map.setOnMapLoadedCallback(mapListener);
    map.setOnMapClickListener(mapListener);
    map.setOnMapDoubleClickListener(mapListener);
    map.setOnMarkerClickListener(mapListener);
    return mapView;
}
 
Example #24
Source File: BrightcovePlayerPosterView.java    From react-native-brightcove-player with MIT License 5 votes vote down vote up
public BrightcovePlayerPosterView(ThemedReactContext context, ReactApplicationContext applicationContext) {
    super(context);
    this.context = context;
    this.applicationContext = applicationContext;
    this.applicationContext.addLifecycleEventListener(this);
    this.imageView = new ImageView(context);
    this.imageView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    this.imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    this.addView(imageView);
    this.requestLayout();
}
 
Example #25
Source File: ARTSurfaceViewManager.java    From react-native-GPay with MIT License 4 votes vote down vote up
@Override
protected ARTSurfaceView createViewInstance(ThemedReactContext reactContext) {
  return new ARTSurfaceView(reactContext);
}
 
Example #26
Source File: ReactDrawerLayoutManager_1d0b39_s.java    From coming with MIT License 4 votes vote down vote up
@Override
protected ReactDrawerLayout createViewInstance(ThemedReactContext context) {
  return new ReactDrawerLayout(context);
}
 
Example #27
Source File: ReactProgressBarViewManager.java    From react-native-GPay with MIT License 4 votes vote down vote up
@Override
protected ProgressBarContainerView createViewInstance(ThemedReactContext context) {
  return new ProgressBarContainerView(context);
}
 
Example #28
Source File: DropdownManager.java    From ReactNativeDropdownAndroid with MIT License 4 votes vote down vote up
@Override
protected Dropdown createViewInstance(ThemedReactContext context) {
    return new Dropdown(context);
}
 
Example #29
Source File: ARTRenderableViewManager.java    From react-native-GPay with MIT License 4 votes vote down vote up
@Override
protected View createViewInstance(ThemedReactContext reactContext) {
  throw new IllegalStateException("ARTShape does not map into a native view");
}
 
Example #30
Source File: BannerView.java    From react-native-fbads with MIT License 4 votes vote down vote up
public BannerView(ThemedReactContext context) {
  super(context);
  mContext = context;
  mContext.addLifecycleEventListener(this);
  mEventEmitter = mContext.getJSModule(RCTEventEmitter.class);
}