Exemplo n.º 1
0
        /// <summary>
        /// Called after the creation of a <see cref="IReactInstance"/>, in
        /// order to initialize native modules that require the React or
        /// JavaScript modules.
        /// </summary>
        public override void Initialize()
        {
            var ctx          = Context;
            var uiImpl       = ctx.GetNativeModule <UIManagerModule>().UIImplementation;
            var nodesManager = new NativeAnimatedNodesManager(uiImpl);

            _animatedFrameCallback = (sender, args) =>
            {
                try
                {
                    var renderingArgs = args as RenderingEventArgs;
                    if (renderingArgs == null)
                    {
                        return;
                    }

                    var operations = default(List <Action <NativeAnimatedNodesManager> >);
                    lock (_operationsGate)
                    {
                        operations       = _readyOperations;
                        _readyOperations = null;
                    }

                    if (operations != null)
                    {
                        foreach (var operation in operations)
                        {
                            operation(nodesManager);
                        }
                    }

                    if (nodesManager.HasActiveAnimations)
                    {
                        nodesManager.RunUpdates(renderingArgs.RenderingTime);
                    }
                }
                catch (Exception ex)
                {
                    Context.HandleException(ex);
                }
            };

            ctx.AddLifecycleEventListener(this);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called after the creation of a <see cref="IReactInstance"/>, in
        /// order to initialize native modules that require the React or
        /// JavaScript modules.
        /// </summary>
        public override void Initialize()
        {
            var ctx          = Context;
            var uiManager    = ctx.GetNativeModule <UIManagerModule>();
            var nodesManager = new NativeAnimatedNodesManager(uiManager);

            _animatedFrameCallback = (sender, args) =>
            {
                try
                {
                    var operations = default(List <Action <NativeAnimatedNodesManager> >);
                    lock (_operationsGate)
                    {
                        operations       = _readyOperations;
                        _readyOperations = null;
                    }

                    if (operations != null)
                    {
                        foreach (var operation in operations)
                        {
                            operation(nodesManager);
                        }
                    }

                    if (nodesManager.HasActiveAnimations)
                    {
                        nodesManager.RunUpdates(args.RenderingTime);
                    }
                    else
                    {
                        ReactChoreographer.Instance.DeactivateCallback(nameof(NativeAnimatedModule));
                    }
                }
                catch (Exception ex)
                {
                    Context.HandleException(ex);
                }
            };

            ctx.AddLifecycleEventListener(this);
        }
Exemplo n.º 3
0
        private bool OnEcoreRender()
        {
            //Log.Error(ReactConstants.Tag, ">>>>>>>>>>>>> OnEcoreRender-1 <<<<<<<<<<<<<<<<<<<");
            try
            {
                var operations = default(List <Action <NativeAnimatedNodesManager> >);
                lock (_operationsGate)
                {
                    operations       = _readyOperations;
                    _readyOperations = null;
                }

                if (operations != null)
                {
                    Log.Info(ReactConstants.Tag, ">>>>>>>>>>>>> OnEcoreRender-2 <<<<<<<<<<<<<<<<<<<");
                    foreach (var operation in operations)
                    {
                        operation(_nativeAnimnodeMgr);
                    }
                }

                if (_nativeAnimnodeMgr.HasActiveAnimations)
                {
                    Log.Info(ReactConstants.Tag, "### HasActiveAnimations sw.ElapsedMilliseconds = " + sw.ElapsedMilliseconds);

                    //TimeSpan timeSpan = new TimeSpan(60);
                    //
                    _nativeAnimnodeMgr.RunUpdates(sw.Elapsed);
                }
            }
            catch (Exception ex)
            {
                Context.HandleException(ex);
            }

            return(true);
        }