コード例 #1
0
        /// <summary>
        /// Starts the action.
        /// </summary>
        /// <param name="action">Action.</param>
        /// <param name="cancellationToken">Cancellation token.</param>
        private async Task StartAction(Rest.CrexAction action, CancellationToken cancellationToken)
        {
            //
            // Check if we were able to load the data.
            //
            if (action == null)
            {
                HideLoading();
                ShowDataErrorDialog(null);

                return;
            }

            //
            // Check if we can display this action.
            //
            if (action.RequiredCrexVersion.HasValue && action.RequiredCrexVersion.Value > Crex.Application.Current.CrexVersion)
            {
                HideLoading();
                ShowUpdateRequiredDialog();

                return;
            }

            cancellationToken.ThrowIfCancellationRequested();
            ShowLoading();

            //
            // Load the new view controller from the template.
            //
            var newViewController = GetViewControllerForTemplate(action.Template);

            try
            {
                newViewController.Data = action.Data.ToJson();
                await newViewController.LoadContentAsync();
            }
            catch
            {
                HideLoading();
                ShowDataErrorDialog(null);

                return;
            }

            cancellationToken.ThrowIfCancellationRequested();
            LoadingCancellationTokenSource = null;

            if (ViewControllers.Length == 0)
            {
                ViewControllers = new[] { newViewController };
            }
            else
            {
                PushViewController(newViewController, true);
            }

            HideLoading();
        }
コード例 #2
0
ファイル: Application.cs プロジェクト: BlueBoxMoon/crex
        /// <summary>
        /// Starts the specified action.
        /// </summary>
        /// <param name="sender">The UIViewController that is starting this action.</param>
        /// <param name="action">The action to be started.</param>
        public override async Task StartAction(object sender, Rest.CrexAction action)
        {
            NavigationController navigationController = sender is NavigationController
                ? ( NavigationController )sender
                : ( NavigationController )(( UIViewController )sender).NavigationController;

            await navigationController.StartAction(action);
        }
コード例 #3
0
ファイル: CrexActivity.cs プロジェクト: BlueBoxMoon/crex
        /// <summary>
        /// Starts the view template.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="action">The action that should be loaded.</param>
        public async Task StartAction(Rest.CrexAction action)
        {
            LoadingCancellationTokenSource = new CancellationTokenSource();

            try
            {
                await StartAction(action, LoadingCancellationTokenSource.Token);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
コード例 #4
0
ファイル: CrexActivity.cs プロジェクト: BlueBoxMoon/crex
        /// <summary>
        /// Starts the view template.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="action">The action that should be loaded.</param>
        private async Task StartAction(Rest.CrexAction action, CancellationToken cancellationToken)
        {
            //
            // Check if we were able to load the data.
            //
            if (action == null)
            {
                HideLoading();
                LoadingCancellationTokenSource = null;
                ShowDataErrorDialog(null, () =>
                {
                    if (Fragments.Count == 0)
                    {
                        Finish();
                    }
                });

                return;
            }

            //
            // Check if we can display this action.
            //
            if (action.RequiredCrexVersion.HasValue && action.RequiredCrexVersion.Value > Crex.Application.Current.CrexVersion)
            {
                HideLoading();
                ShowUpdateRequiredDialog();

                return;
            }

            cancellationToken.ThrowIfCancellationRequested();

            ShowLoading();

            var fragment = GetFragmentForTemplate(action.Template);

            fragment.Data = action.Data.ToJson();

            try
            {
                await fragment.LoadContentAsync();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                HideLoading();
                LoadingCancellationTokenSource = null;
                ShowDataErrorDialog(null, () =>
                {
                    if (Fragments.Count == 0)
                    {
                        Finish();
                    }
                });

                return;
            }

            cancellationToken.ThrowIfCancellationRequested();

            LoadingCancellationTokenSource = null;
            PushFragment(fragment);
            HideLoading();
        }
コード例 #5
0
 /// <summary>
 /// Starts the view template.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="action">The action that should be loaded.</param>
 public override async Task StartAction(object sender, Rest.CrexAction action)
 {
     await CrexActivity.MainActivity.StartAction(action);
 }