Exemplo n.º 1
0
        public IDisposable Loading(Activity activity, LoadingConfig config)
        {
            if (_progress != null && _progress.IsShowing)
            {
                _progress.Dismiss();
            }

            _progress = KProgressHUD.Create(activity, KProgressHUD.Style.SpinIndeterminate).SetLabel(config.Text);

            _progress.SetCancellable(config.Cancellable);

            if (config.Cancellable)
            {
                _progress.SetCancelAction(() =>
                {
                    _progress.Dismiss();

                    config.CancelAction?.Invoke();
                });
            }

            if (config.MarkType == MarkType.Black)
            {
                _progress.SetDimAmount(0.5f);
            }

            _progress.Show();

            if (config.Duration != null)
            {
                DelayDismiss((int)config.Duration.Value.TotalMilliseconds);
            }

            return(new DisposableAction(() => _progress.Dismiss()));
        }
Exemplo n.º 2
0
        public IProgressDialog Progress(Activity activity, ProgressConfig config)
        {
            if (_progress != null && _progress.IsShowing)
            {
                _progress.Dismiss();
            }

            _progress = KProgressHUD.Create(activity, KProgressHUD.Style.PieDeterminate).SetLabel(config.Text);

            _progress.SetMaxProgress(100);

            _progress.SetCancellable(config.Cancellable);

            if (config.Cancellable)
            {
                _progress.SetCancelAction(() =>
                {
                    _progress.Dismiss();

                    config.CancelAction?.Invoke();
                });
            }

            if (config.MarkType == MarkType.Black)
            {
                _progress.SetDimAmount(0.5f);
            }

            _progress.Show();

            return(new LoadingDialog(_progress));
        }
Exemplo n.º 3
0
        private void AutoClose()
        {
            if (hud == null)
            {
                return;
            }

            Handler handler = new Handler();

            handler.PostDelayed(new Runnable(() =>
            {
                hud.Dismiss();
            }), 2000);
        }
Exemplo n.º 4
0
 public void Hide()
 {
     _progress.Dismiss();
 }