private void AttachMeasuredRootViewToInstance( ReactRootView rootView, IReactInstance reactInstance) { DispatcherHelpers.AssertOnDispatcher(); // Reset view content as it's going to be populated by the // application content from JavaScript rootView.TouchHandler?.Dispose(); rootView.Children.Clear(); rootView.Tag = null; var uiManagerModule = reactInstance.GetNativeModule <UIManagerModule>(); var rootTag = uiManagerModule.AddMeasuredRootView(rootView); rootView.TouchHandler = new TouchHandler(rootView); var jsAppModuleName = rootView.JavaScriptModuleName; var appParameters = new Dictionary <string, object> { { "rootTag", rootTag }, { "initalProps", null /* TODO: add launch options to root view */ } }; reactInstance.GetJavaScriptModule <AppRegistry>().runApplication(jsAppModuleName, appParameters); }
private void DetachViewFromInstance(ReactRootView rootView, IReactInstance reactInstance) { DispatcherHelpers.AssertOnDispatcher(); var uiManagerModule = reactInstance.GetNativeModule <UIManagerModule>(); uiManagerModule.DetachRootView(rootView); reactInstance.GetJavaScriptModule <AppRegistry>().unmountApplicationComponentAtRootTag(rootView.GetTag()); }
private async Task DetachViewFromInstanceAsync( ReactRootView rootView, IReactInstance reactInstance) { DispatcherHelpers.AssertOnDispatcher(); // Detaches ReactRootView from instance manager root view list and size change monitoring. // This has to complete before unmounting the application. // Returns a task to await the completion of the `removeRootView` UIManager call (an effect of // unmounting the application) and the release of all dispatcher affined UI objects. var rootViewRemovedTask = await reactInstance.GetNativeModule <UIManagerModule>() .DetachRootViewAsync(rootView); reactInstance.GetJavaScriptModule <AppRegistry>().unmountApplicationComponentAtRootTag(rootView.GetTag()); await rootViewRemovedTask; }
private void AttachMeasuredRootViewToInstance( ReactRootView rootView, IReactInstance reactInstance) { DispatcherHelpers.AssertOnDispatcher(); var rootTag = reactInstance.GetNativeModule <UIManagerModule>() .AddMeasuredRootView(rootView); var jsAppModuleName = rootView.JavaScriptModuleName; var appParameters = new Dictionary <string, object> { { "rootTag", rootTag }, { "initialProps", rootView.InitialProps } }; reactInstance.GetJavaScriptModule <AppRegistry>().runApplication(jsAppModuleName, appParameters); }
private async Task AttachMeasuredRootViewToInstanceAsync( ReactRootView rootView, IReactInstance reactInstance) { RnLog.Info(ReactConstants.RNW, $"ReactInstanceManager: AttachMeasuredRootViewToInstanceAsync ({rootView.JavaScriptModuleName}) - entry"); DispatcherHelpers.AssertOnDispatcher(); var rootTag = await reactInstance.GetNativeModule <UIManagerModule>() .AddMeasuredRootViewAsync(rootView); RnLog.Info(ReactConstants.RNW, $"ReactInstanceManager: AttachMeasuredRootViewToInstanceAsync ({rootView.JavaScriptModuleName}) - added to UIManager (tag: {rootTag}), starting React app"); var jsAppModuleName = rootView.JavaScriptModuleName; var appParameters = new Dictionary <string, object> { { "rootTag", rootTag }, { "initialProps", rootView.InitialProps } }; reactInstance.GetJavaScriptModule <AppRegistry>().runApplication(jsAppModuleName, appParameters); RnLog.Info(ReactConstants.RNW, $"ReactInstanceManager: AttachMeasuredRootViewToInstanceAsync ({rootView.JavaScriptModuleName}) - done"); }
/// <summary> /// Gets the instance of the <see cref="INativeModule"/> associated /// with the <see cref="IReactInstance"/>. /// </summary> /// <typeparam name="T">Type of native module.</typeparam> /// <returns>The native module instance.</returns> public T GetNativeModule <T>() where T : INativeModule { AssertReactInstance(); return(_reactInstance.GetNativeModule <T>()); }
private void AttachMeasuredRootViewToInstance( ReactRootView rootView, IReactInstance reactInstance) { Log.Info(ReactConstants.Tag, "[ReactInstanceManager] ## Enter AttachMeasuredRootViewToInstance ##"); DispatcherHelpers.AssertOnDispatcher(); // Reset view content as it's going to be populated by the // application content from JavaScript //rootView.TouchHandler?.Dispose(); //rootView.RemoveAllView(); rootView.SetTag(0); var uiManagerModule = reactInstance.GetNativeModule <UIManagerModule>(); var rootTag = uiManagerModule.AddMeasuredRootView(rootView); //rootView.TouchHandler = new TouchHandler(rootView); // TODO: commented temporarily var jsAppModuleName = rootView.JavaScriptModuleName; var appParameters = new Dictionary <string, object> { { "rootTag", rootTag }, { "initalProps", null /* TODO: add launch options to root view */ } }; /* Entry of RN.js world */ Log.Info(ReactConstants.Tag, "[ReactInstanceManager] Entry of RN.js world:[" + jsAppModuleName.ToString() + "]"); reactInstance.GetJavaScriptModule <AppRegistry>().runApplication(jsAppModuleName, appParameters); // [UT-STUB] // TEST STUB BGN //Log.Info("MPM", "## MediaPlayerModule Test begin ##"); //MediaPlayerModule mpModule = _currentReactContext.ReactInstance.GetNativeModule<MediaPlayerModule>(); //mpModule.play(); // exceptional testing // to pick which one ? //mpModule.init("http://109.123.100.75:8086/assets/MusicPlayer/resources/music.mp3?platform=tizen&hash=5a9a91184e611dae3fed162b8787ce5f"); //mpModule.init("https://pc.tedcdn.com/talk/stream/2017S/None/SineadBurke_2017S-950k.mp4"); // mpModule.init("/opt/usr/apps/MusicPlayer.Tizen/shared/res/assets/MusicPlayer/resources/adele.mp3"); //mpModule.seekTo(20*1000); /* * string[] uri= {"/opt/baisuzhen.mp3", "/opt/aaa.mp3"}; * * for (int i = 0; i < 100; i++) * { * mpModule.init(uri[i%2]); // wrong type with right source * mpModule.play(); * Thread.Sleep(1000*5); * } */ //mpModule.init("/opt/baisuzhen.mp3"); // wrong type with right source //mpModule.setVolume(0.1f); //mpModule.setSubtitle("/opt/[zmk.tw]The.Circle.2017.srt"); //mpModule.play(); //Thread.Sleep(1000*5); // mpModule.stop(); //Thread.Sleep(1000*3); //mpModule.play(); //Thread.Sleep(1000*15); //mpModule.deInit(); //mpModule.pause(); //mpModule.seekTo(20*1000); //mpModule.seekTo(700*1000); //mpModule.setVolume(0.4f); //mpModule.play(); //Thread.Sleep(1000*36); //mpModule.pause(); //mpModule.deInit(); //mpModule.play(); //Log.Info(ReactConstants.Tag, "## MediaPlayerModule 55555555555 ##"); //Thread.Sleep(1000*650); //Log.Info("MediaPlayerModule", $"## MediaPlayerModule 5555555555"); //mpModule.stop(); //Log.Info(ReactConstants.Tag, "## MediaPlayerModule 66666666666 ##"); // TEST STUB END /* * // Create 'Button' thread * Thread th_On = new Thread(new ParameterizedThreadStart(UT_CreateView)); * th_On.IsBackground = true; * th_On.Start(this); * * // terminate 'Button' thread * Thread th_Off = new Thread(new ParameterizedThreadStart(UT_DropView)); * th_Off.IsBackground = true; * th_Off.Start(this); * * // No detach mode = =!! * //th_On.Join(); * //th_Off.Join(); * */ //UT_UIManagerModuleTest(this); // [UT-STUB] Log.Info(ReactConstants.Tag, "[ReactInstanceManager] ## Exit AttachMeasuredRootViewToInstance ThreadID=" + Thread.CurrentThread.ManagedThreadId.ToString() + " ##"); }
private void AttachMeasuredRootViewToInstance( ReactRootView rootView, IReactInstance reactInstance) { DispatcherHelpers.AssertOnDispatcher(); // Reset view content as it's going to be populated by the // application content from JavaScript rootView.TouchHandler?.Dispose(); rootView.Children.Clear(); rootView.Tag = null; var uiManagerModule = reactInstance.GetNativeModule<UIManagerModule>(); var rootTag = uiManagerModule.AddMeasuredRootView(rootView); rootView.TouchHandler = new TouchHandler(rootView); var jsAppModuleName = rootView.JavaScriptModuleName; var appParameters = new Dictionary<string, object> { { "rootTag", rootTag }, { "initalProps", null /* TODO: add launch options to root view */ } }; reactInstance.GetJavaScriptModule<AppRegistry>().runApplication(jsAppModuleName, appParameters); }