Ejemplo n.º 1
0
        public static IDisposable SubscribeStatus(this IObservable <bool> @this, string message)
        {
            var hud     = new Hud();
            var isShown = false;

            var d = @this.Subscribe(x => {
                if (x && !isShown)
                {
                    hud.Show(message);
                }
                else if (!x && isShown)
                {
                    hud.Hide();
                }
                isShown = x;
            }, err => {
                BTProgressHUD.ShowErrorWithStatus(err.Message);
                isShown = false;
            }, () => {
                if (isShown)
                {
                    BTProgressHUD.Dismiss();
                }
            });

            var d2 = Disposable.Create(() =>
            {
                if (isShown)
                {
                    BTProgressHUD.Dismiss();
                }
            });

            return(new CompositeDisposable(d, d2));
        }
Ejemplo n.º 2
0
        public async static Task DoWorkAsync(this UIViewController controller, string workTitle, Func<Task> work)
        {
            var hud = new Hud();
			hud.Show(workTitle);

            //Make sure the Toolbar is disabled too
            if (controller.ToolbarItems != null)
            {
                foreach (var t in controller.ToolbarItems)
                    t.Enabled = false;
            }

            try
            {
                NetworkActivity.PushNetworkActive();
                await work();
            }
            finally
            {
                NetworkActivity.PopNetworkActive();
                hud.Hide();

                //Enable all the toolbar items
                if (controller.ToolbarItems != null)
                {
                    foreach (var t in controller.ToolbarItems)
                        t.Enabled = true;
                }
            }
        }
        public async static Task DoWorkAsync(this UIViewController controller, string workTitle, Func <Task> work)
        {
            var hud = new Hud();

            hud.Show(workTitle);

            //Make sure the Toolbar is disabled too
            if (controller.ToolbarItems != null)
            {
                foreach (var t in controller.ToolbarItems)
                {
                    t.Enabled = false;
                }
            }

            try
            {
                NetworkActivity.PushNetworkActive();
                await work();
            }
            finally
            {
                NetworkActivity.PopNetworkActive();
                hud.Hide();

                //Enable all the toolbar items
                if (controller.ToolbarItems != null)
                {
                    foreach (var t in controller.ToolbarItems)
                    {
                        t.Enabled = true;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public static IDisposable SubscribeStatus(this IObservable<bool> @this, string message)
        {
            var hud = new Hud();
            var isShown = false;

            var d = @this.Subscribe(x => {
                if (x && !isShown)
                    hud.Show(message);
                else if (!x && isShown)
                    hud.Hide();
                isShown = x;
            }, err => {
                BTProgressHUD.ShowErrorWithStatus(err.Message);
                isShown = false;
            }, () => {
                if (isShown)
                    BTProgressHUD.Dismiss();
            });

            var d2 = Disposable.Create(() =>
            {
                if (isShown)
                    BTProgressHUD.Dismiss();
            });

            return new CompositeDisposable(d, d2);
        }