Exemplo n.º 1
0
        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() + " ##");
        }