Java Code Examples for com.facebook.react.uimanager.ThemedReactContext#addLifecycleEventListener()
The following examples show how to use
com.facebook.react.uimanager.ThemedReactContext#addLifecycleEventListener() .
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: PiliPlayerViewManager.java From pili-react-native with MIT License | 6 votes |
@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 2
Source File: RNX5WebViewManager.java From react-native-x5 with MIT License | 6 votes |
@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 3
Source File: PiliPlayerViewManager.java From react-native-pili with MIT License | 6 votes |
@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 4
Source File: ARTSurfaceViewShadowNode.java From art with MIT License | 5 votes |
@Override public void setThemedContext(ThemedReactContext themedContext) { super.setThemedContext(themedContext); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N) { themedContext.addLifecycleEventListener(this); } }
Example 5
Source File: CrosswalkWebViewGroupManager.java From react-native-crosswalk-webview-plus with MIT License | 5 votes |
@Override public CrosswalkWebView createViewInstance (ThemedReactContext context) { CrosswalkWebView crosswalkWebView; Activity _activity = reactContext.getCurrentActivity(); crosswalkWebView = (CrosswalkWebView) LayoutInflater.from(_activity).inflate(R.layout.xwalk_webview, null); crosswalkWebView.bindContext(context); XWalkSettings settings =crosswalkWebView.getSettings(); settings.setDomStorageEnabled(true);// open local storage settings.setAllowFileAccess(false); settings.setAllowContentAccess(false); settings.setDatabaseEnabled(true); settings.setCacheMode(XWalkSettings.LOAD_CACHE_ELSE_NETWORK); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { settings.setAllowFileAccessFromFileURLs(false); setAllowUniversalAccessFromFileURLs(crosswalkWebView, false); } // Fixes broken full-screen modals/galleries due to body height being 0. crosswalkWebView.setLayoutParams( new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // open cookies XWalkCookieManager mCookieManager = new XWalkCookieManager(); mCookieManager.setAcceptCookie(true); mCookieManager.setAcceptFileSchemeCookies(true); context.addLifecycleEventListener(crosswalkWebView); reactContext.addActivityEventListener(new XWalkActivityEventListener(crosswalkWebView)); return crosswalkWebView; }
Example 6
Source File: RNCameraViewManager.java From react-native-camera-android with MIT License | 5 votes |
@Override public RNCameraView createViewInstance(ThemedReactContext context) { context.addLifecycleEventListener(this); mCameraView = new RNCameraView(context); mCameraView.setMaskColor(DEFAULT_VIEWFINDER_BACKGROUND_COLOR); mCameraView.setBorderColor(DEFAULT_VIEWFINDER_BORDER_COLOR); mCameraView.setBorderStrokeWidth(DEFAULT_VIEWFINDER_BORDER_WIDTH); mCameraView.setBorderLineLength(DEFAULT_VIEWFINDER_BORDER_LENGTH); mCameraView.setDrawLaser(DEFAULT_VIEWFINDER_DRAW_LASER); mCameraView.setLaserColor(DEFAULT_VIEWFINDER_LASER_COLOR); mCameraView.setCameraType(DEFAULT_CAMERA_TYPE); mCameraView.setTorchMode(DEFAULT_TORCH_MODE); mCameraViewVisible = true; return mCameraView; }
Example 7
Source File: MagnetWebViewManager.java From magnet-client with Mozilla Public License 2.0 | 5 votes |
@Override protected WebView createViewInstance(ThemedReactContext reactContext) { MagnetWebView magnetWebView = new MagnetWebView(mContext); reactContext.addLifecycleEventListener(magnetWebView); if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { WebView.setWebContentsDebuggingEnabled(true); } return magnetWebView; }
Example 8
Source File: CrosswalkWebViewGroupManager.java From react-native-webview-crosswalk with MIT License | 5 votes |
@Override public CrosswalkWebView createViewInstance (ThemedReactContext context) { Activity _activity = reactContext.getCurrentActivity(); CrosswalkWebView crosswalkWebView = new CrosswalkWebView(context, _activity); context.addLifecycleEventListener(crosswalkWebView); reactContext.addActivityEventListener(new XWalkActivityEventListener(crosswalkWebView)); return crosswalkWebView; }
Example 9
Source File: ReactVideoView.java From react-native-video with MIT License | 5 votes |
public ReactVideoView(ThemedReactContext themedReactContext) { super(themedReactContext); mThemedReactContext = themedReactContext; mEventEmitter = themedReactContext.getJSModule(RCTEventEmitter.class); themedReactContext.addLifecycleEventListener(this); initializeMediaPlayerIfNeeded(); setSurfaceTextureListener(this); mProgressUpdateRunnable = new Runnable() { @Override public void run() { if (mMediaPlayerValid && !isCompleted && !mPaused && !mBackgroundPaused) { WritableMap event = Arguments.createMap(); event.putDouble(EVENT_PROP_CURRENT_TIME, mMediaPlayer.getCurrentPosition() / 1000.0); event.putDouble(EVENT_PROP_PLAYABLE_DURATION, mVideoBufferedDuration / 1000.0); //TODO:mBufferUpdateRunnable event.putDouble(EVENT_PROP_SEEKABLE_DURATION, mVideoDuration / 1000.0); mEventEmitter.receiveEvent(getId(), Events.EVENT_PROGRESS.toString(), event); // Check for update after an interval mProgressUpdateHandler.postDelayed(mProgressUpdateRunnable, Math.round(mProgressUpdateInterval)); } } }; }
Example 10
Source File: ReactWebViewManager.java From react-native-GPay with MIT License | 4 votes |
@Override @TargetApi(Build.VERSION_CODES.LOLLIPOP) protected WebView createViewInstance(ThemedReactContext reactContext) { ReactWebView webView = createReactWebViewInstance(reactContext); webView.setWebChromeClient(new WebChromeClient() { @Override public boolean onConsoleMessage(ConsoleMessage message) { if (ReactBuildConfig.DEBUG) { return super.onConsoleMessage(message); } // Ignore console logs in non debug builds. return true; } @Override public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) { callback.invoke(origin, true, false); } }); reactContext.addLifecycleEventListener(webView); mWebViewConfig.configWebView(webView); WebSettings settings = webView.getSettings(); settings.setBuiltInZoomControls(true); settings.setDisplayZoomControls(false); settings.setDomStorageEnabled(true); settings.setAllowFileAccess(false); settings.setAllowContentAccess(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { settings.setAllowFileAccessFromFileURLs(false); setAllowUniversalAccessFromFileURLs(webView, false); } setMixedContentMode(webView, "never"); // Fixes broken full-screen modals/galleries due to body height being 0. webView.setLayoutParams( new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); setGeolocationEnabled(webView, false); if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { WebView.setWebContentsDebuggingEnabled(true); } return webView; }