com.facebook.react.uimanager.NativeViewHierarchyManager Java Examples
The following examples show how to use
com.facebook.react.uimanager.NativeViewHierarchyManager.
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: RNJWPlayerModule.java From react-native-jw-media-player with MIT License | 7 votes |
@ReactMethod public void play(final int reactTag) { try { UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class); uiManager.addUIBlock(new UIBlock() { public void execute (NativeViewHierarchyManager nvhm) { RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag); if (playerView != null && playerView.mPlayer != null) { playerView.mPlayer.play(); } } }); } catch (IllegalViewOperationException e) { throw e; } }
Example #2
Source File: RNJWPlayerModule.java From react-native-jw-media-player with MIT License | 6 votes |
@ReactMethod public void toggleSpeed(final int reactTag) { try { UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class); uiManager.addUIBlock(new UIBlock() { public void execute (NativeViewHierarchyManager nvhm) { RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag); if (playerView != null && playerView.mPlayer != null) { float rate = playerView.mPlayer.getPlaybackRate(); if (rate < 2) { playerView.mPlayer.setPlaybackRate(rate += 0.5); } else { playerView.mPlayer.setPlaybackRate((float) 0.5); } } } }); } catch (IllegalViewOperationException e) { throw e; } }
Example #3
Source File: YouTubeModule.java From react-native-youtube with MIT License | 6 votes |
@ReactMethod public void getDuration(final int reactTag, final Promise promise) { try { UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class); uiManager.addUIBlock(new UIBlock() { public void execute (NativeViewHierarchyManager nvhm) { YouTubeView youTubeView = (YouTubeView) nvhm.resolveView(reactTag); YouTubeManager youTubeManager = (YouTubeManager) nvhm.resolveViewManager(reactTag); int duration = youTubeManager.getDuration(youTubeView); promise.resolve(duration); } }); } catch (IllegalViewOperationException e) { promise.reject(E_MODULE_ERROR, e); } }
Example #4
Source File: YouTubeModule.java From react-native-youtube with MIT License | 6 votes |
@ReactMethod public void getCurrentTime(final int reactTag, final Promise promise) { try { UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class); uiManager.addUIBlock(new UIBlock() { public void execute (NativeViewHierarchyManager nvhm) { YouTubeView youTubeView = (YouTubeView) nvhm.resolveView(reactTag); YouTubeManager youTubeManager = (YouTubeManager) nvhm.resolveViewManager(reactTag); int currentTime = youTubeManager.getCurrentTime(youTubeView); promise.resolve(currentTime); } }); } catch (IllegalViewOperationException e) { promise.reject(E_MODULE_ERROR, e); } }
Example #5
Source File: YouTubeModule.java From react-native-youtube with MIT License | 6 votes |
@ReactMethod public void getVideosIndex(final int reactTag, final Promise promise) { try { UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class); uiManager.addUIBlock(new UIBlock() { public void execute (NativeViewHierarchyManager nvhm) { YouTubeView youTubeView = (YouTubeView) nvhm.resolveView(reactTag); YouTubeManager youTubeManager = (YouTubeManager) nvhm.resolveViewManager(reactTag); int index = youTubeManager.getVideosIndex(youTubeView); promise.resolve(index); } }); } catch (IllegalViewOperationException e) { promise.reject(E_MODULE_ERROR, e); } }
Example #6
Source File: RNInstabugReactnativeModule.java From Instabug-React-Native with MIT License | 6 votes |
@ReactMethod public void hideView(final ReadableArray ids) { MainThreadHandler.runOnMainThread(new Runnable() { @Override public void run() { UIManagerModule uiManagerModule = getReactApplicationContext().getNativeModule(UIManagerModule.class); uiManagerModule.prependUIBlock(new UIBlock() { @Override public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) { final View[] arrayOfViews = new View[ids.size()]; for (int i = 0; i < ids.size(); i++) { int viewId = (int) ids.getDouble(i); try { arrayOfViews[i] = nativeViewHierarchyManager.resolveView(viewId); } catch(Exception e) { e.printStackTrace(); } } Instabug.setViewsAsPrivate(arrayOfViews); } }); } }); }
Example #7
Source File: RNShadowTextGradient.java From react-native-text-gradient with MIT License | 6 votes |
private @Nullable View resolveView(int tag) { UiThreadUtil.assertOnUiThread(); ReactApplicationContext context = mContext.get(); if (context != null) { UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class); NativeViewHierarchyManager manager = ReflectUtils.getFieldValue( ReflectUtils.getFieldValue( uiManager.getUIImplementation(), "mOperationsQueue", null ), "mNativeViewHierarchyManager", null ); if (manager != null) { return manager.resolveView(tag); } } return null; }
Example #8
Source File: FabricUIManager.java From react-native-GPay with MIT License | 6 votes |
public FabricUIManager( ReactApplicationContext reactContext, ViewManagerRegistry viewManagerRegistry, JavaScriptContextHolder jsContext, EventDispatcher eventDispatcher) { DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(reactContext); mReactApplicationContext = reactContext; mViewManagerRegistry = viewManagerRegistry; mNativeViewHierarchyManager = new NativeViewHierarchyManager(viewManagerRegistry); mUIViewOperationQueue = new UIViewOperationQueue( reactContext, mNativeViewHierarchyManager, 0); mFabricReconciler = new FabricReconciler(mUIViewOperationQueue); mFabricEventEmitter = new FabricEventEmitter(mReactApplicationContext, this); mEventDispatcher = eventDispatcher; mJSContext = jsContext; }
Example #9
Source File: RNJWPlayerModule.java From react-native-jw-media-player with MIT License | 6 votes |
@ReactMethod public void setFullscreen(final int reactTag, final boolean fullscreen) { try { UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class); uiManager.addUIBlock(new UIBlock() { public void execute (NativeViewHierarchyManager nvhm) { RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag); if (playerView != null && playerView.mPlayer != null) { playerView.mPlayer.setFullscreen(fullscreen, fullscreen); } } }); } catch (IllegalViewOperationException e) { throw e; } }
Example #10
Source File: RNJWPlayerModule.java From react-native-jw-media-player with MIT License | 6 votes |
@ReactMethod public void state(final int reactTag, final Promise promise) { try { UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class); uiManager.addUIBlock(new UIBlock() { public void execute (NativeViewHierarchyManager nvhm) { RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag); if (playerView != null && playerView.mPlayer != null) { PlayerState playerState = playerView.mPlayer.getState(); promise.resolve(stateToInt(playerState)); } else { promise.reject("RNJW Error", "Player is null"); } } }); } catch (IllegalViewOperationException e) { promise.reject("RNJW Error", e); } }
Example #11
Source File: RNJWPlayerModule.java From react-native-jw-media-player with MIT License | 6 votes |
@ReactMethod public void position(final int reactTag, final Promise promise) { try { UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class); uiManager.addUIBlock(new UIBlock() { public void execute (NativeViewHierarchyManager nvhm) { RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag); if (playerView != null && playerView.mPlayer != null) { promise.resolve((Double.valueOf(playerView.mPlayer.getPosition()).intValue())); } else { promise.reject("RNJW Error", "Player is null"); } } }); } catch (IllegalViewOperationException e) { promise.reject("RNJW Error", e); } }
Example #12
Source File: RNJWPlayerModule.java From react-native-jw-media-player with MIT License | 6 votes |
@ReactMethod public void setControls(final int reactTag, final boolean show) { try { UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class); uiManager.addUIBlock(new UIBlock() { public void execute (NativeViewHierarchyManager nvhm) { RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag); if (playerView != null && playerView.mPlayer != null) { playerView.mPlayer.setControls(show); playerView.mPlayer.getConfig().setControls(show); } } }); } catch (IllegalViewOperationException e) { throw e; } }
Example #13
Source File: RNJWPlayerModule.java From react-native-jw-media-player with MIT License | 6 votes |
@ReactMethod public void setPlaylistIndex(final int reactTag, final int index) { try { UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class); uiManager.addUIBlock(new UIBlock() { public void execute (NativeViewHierarchyManager nvhm) { RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag); if (playerView != null && playerView.mPlayer != null) { playerView.mPlayer.setCurrentAudioTrack(index); } } }); } catch (IllegalViewOperationException e) { throw e; } }
Example #14
Source File: RNJWPlayerModule.java From react-native-jw-media-player with MIT License | 6 votes |
@ReactMethod public void seekTo(final int reactTag, final double time) { try { UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class); uiManager.addUIBlock(new UIBlock() { public void execute (NativeViewHierarchyManager nvhm) { RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag); if (playerView != null && playerView.mPlayer != null) { playerView.mPlayer.seek(time); } } }); } catch (IllegalViewOperationException e) { throw e; } }
Example #15
Source File: RNJWPlayerModule.java From react-native-jw-media-player with MIT License | 6 votes |
@ReactMethod public void stop(final int reactTag) { try { UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class); uiManager.addUIBlock(new UIBlock() { public void execute (NativeViewHierarchyManager nvhm) { RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag); if (playerView != null && playerView.mPlayer != null) { playerView.mPlayer.stop(); playerView.userPaused = true; } } }); } catch (IllegalViewOperationException e) { throw e; } }
Example #16
Source File: RNJWPlayerModule.java From react-native-jw-media-player with MIT License | 6 votes |
@ReactMethod public void pause(final int reactTag) { try { UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class); uiManager.addUIBlock(new UIBlock() { public void execute (NativeViewHierarchyManager nvhm) { RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag); if (playerView != null && playerView.mPlayer != null) { playerView.mPlayer.pause(); playerView.userPaused = true; } } }); } catch (IllegalViewOperationException e) { throw e; } }
Example #17
Source File: RNJWPlayerModule.java From react-native-jw-media-player with MIT License | 6 votes |
@ReactMethod public void setSpeed(final int reactTag, final float speed) { try { UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class); uiManager.addUIBlock(new UIBlock() { public void execute (NativeViewHierarchyManager nvhm) { RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag); if (playerView != null && playerView.mPlayer != null) { playerView.mPlayer.setPlaybackRate(speed); } } }); } catch (IllegalViewOperationException e) { throw e; } }
Example #18
Source File: RNViewUtils.java From react-native-sensors-analytics with Apache License 2.0 | 5 votes |
public static View getViewByTag(ReactContext reactContext, int viewTag) { NativeViewHierarchyManager manager = getNativeViewHierarchyManager(reactContext); if (manager == null) { return null; } return manager.resolveView(viewTag); }
Example #19
Source File: RNJWPlayerModule.java From react-native-jw-media-player with MIT License | 4 votes |
@ReactMethod public void loadPlaylistItem(final int reactTag, final ReadableMap playlistItem) { try { UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class); uiManager.addUIBlock(new UIBlock() { public void execute (NativeViewHierarchyManager nvhm) { RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag); if (playlistItem != null && playerView != null && playerView.mPlayer != null) { if (playlistItem.hasKey("file")) { String newFile = playlistItem.getString("file"); PlaylistItem newPlayListItem = new PlaylistItem(); newPlayListItem.setFile(newFile); if (playlistItem.hasKey("playerStyle")) { setCustomStyle(playerView.mPlayer, playlistItem.getString("playerStyle")); } if (playlistItem.hasKey("title")) { newPlayListItem.setTitle(playlistItem.getString("title")); } if (playlistItem.hasKey("desc")) { newPlayListItem.setDescription(playlistItem.getString("desc")); } if (playlistItem.hasKey("image")) { newPlayListItem.setImage(playlistItem.getString("image")); } if (playlistItem.hasKey("mediaId")) { newPlayListItem.setMediaId(playlistItem.getString("mediaId")); } boolean autostart = true; boolean controls = true; if (playlistItem.hasKey("autostart")) { autostart = playlistItem.getBoolean("autostart"); } if (playlistItem.hasKey("controls")) { controls = playlistItem.getBoolean("controls"); } playerView.mPlayer.getConfig().setAutostart(autostart); playerView.mPlayer.getConfig().setControls(controls); playerView.mPlayer.setControls(controls); playerView.mPlayer.load(newPlayListItem); if (autostart) { playerView.mPlayer.play(); } } } } }); } catch (IllegalViewOperationException e) { throw e; } }
Example #20
Source File: RNJWPlayerModule.java From react-native-jw-media-player with MIT License | 4 votes |
@ReactMethod public void loadPlaylist(final int reactTag, final ReadableArray playlist) { try { UIManagerModule uiManager = mReactContext.getNativeModule(UIManagerModule.class); uiManager.addUIBlock(new UIBlock() { public void execute(NativeViewHierarchyManager nvhm) { RNJWPlayerView playerView = (RNJWPlayerView) nvhm.resolveView(reactTag); if (playlist != null && playlist.size() > 0 && playerView != null && playerView.mPlayer != null) { List<PlaylistItem> mPlayList = new ArrayList<>(); ReadableMap playlistItem; String file = ""; String image = ""; String title = ""; String desc = ""; String mediaId = ""; Boolean autostart = true; Boolean controls = true; int j = 0; while (playlist.size() > j) { playlistItem = playlist.getMap(j); if (playlistItem != null) { if (playlistItem.hasKey("file")) { file = playlistItem.getString("file"); } if (playlistItem.hasKey("title")) { title = playlistItem.getString("title"); } if (playlistItem.hasKey("desc")) { desc = playlistItem.getString("desc"); } if (playlistItem.hasKey("image")) { image = playlistItem.getString("image"); } if (playlistItem.hasKey("mediaId")) { mediaId = playlistItem.getString("mediaId"); } if (playlistItem.hasKey("autostart")) { autostart = playlistItem.getBoolean("autostart"); } if (playlistItem.hasKey("controls")) { controls = playlistItem.getBoolean("controls"); } PlaylistItem newPlayListItem = new PlaylistItem.Builder() .file(file) .title(title) .description(desc) .image(image) .mediaId(mediaId) .build(); mPlayList.add(newPlayListItem); } j++; } if (playlist.getMap(0).hasKey("playerStyle")) { setCustomStyle(playerView.mPlayer, playlist.getMap(0).getString("playerStyle")); } playerView.mPlayer.getConfig().setAutostart(autostart); playerView.mPlayer.getConfig().setControls(controls); playerView.mPlayer.setControls(controls); playerView.mPlayer.load(mPlayList); if (autostart) { playerView.mPlayer.play(); } } } }); } catch (IllegalViewOperationException e) { throw e; } }
Example #21
Source File: FabricReconcilerTest.java From react-native-GPay with MIT License | 4 votes |
private MockUIViewOperationQueue(ReactApplicationContext context) { super(context, mock(NativeViewHierarchyManager.class), 0); mOperations = new ArrayList<>(); }