コード例 #1
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));
        }
コード例 #2
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()));
        }
コード例 #3
0
 public LoadingDialog(KProgressHUD progress)
 {
     _progress = progress;
 }
コード例 #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);



            FindViewById <Button>(Resource.Id.indeterminate).Click += (sender, e) =>
            {
                hud = KProgressHUD
                      .Create(this, KProgressHUD.Style.SpinIndeterminate)
                      .Show();

                AutoClose();
            };

            FindViewById <Button>(Resource.Id.label_indeterminate).Click += (sender, e) =>
            {
                hud = KProgressHUD
                      .Create(this, KProgressHUD.Style.SpinIndeterminate)
                      .SetLabel("please wait ...")
                      .SetCancelAction(() =>
                {
                    Toast.MakeText(this, "You cancelled manually!", ToastLength.Short).Show();
                })
                      .Show();

                AutoClose();
            };


            FindViewById <Button>(Resource.Id.detail_indeterminate).Click += (sender, e) =>
            {
                hud = KProgressHUD
                      .Create(this, KProgressHUD.Style.SpinIndeterminate)
                      .SetLabel("please wait ...")
                      .SetDetailsLabel("Downloading data")
                      .Show();

                AutoClose();
            };


            FindViewById <Button>(Resource.Id.grace_indeterminate).Click += (sender, e) =>
            {
                hud = KProgressHUD
                      .Create(this, KProgressHUD.Style.SpinIndeterminate)
                      .SetGraceTime(1000)
                      .SetLabel("please wait ...")
                      .Show();

                AutoClose();
            };


            FindViewById <Button>(Resource.Id.determinate).Click += (sender, e) =>
            {
                hud = KProgressHUD
                      .Create(this, KProgressHUD.Style.PieDeterminate)
                      .SetLabel("please wait ...")
                      .Show();

                SimulateProgressUpdate();
            };


            FindViewById <Button>(Resource.Id.annular_determinate).Click += (sender, e) =>
            {
                hud = KProgressHUD
                      .Create(this, KProgressHUD.Style.AnnularDeterminate)
                      .SetLabel("please wait ...")
                      .Show();

                SimulateProgressUpdate();
            };


            FindViewById <Button>(Resource.Id.bar_determinate).Click += (sender, e) =>
            {
                hud = KProgressHUD
                      .Create(this, KProgressHUD.Style.BarDeterminate)
                      .SetLabel("please wait ...")
                      .Show();

                SimulateProgressUpdate();
            };

            FindViewById <Button>(Resource.Id.custom_view).Click += (sender, e) =>
            {
                ImageView imageView = new ImageView(this);
                imageView.SetBackgroundResource(Resource.Drawable.spin_animation);

                AnimationDrawable drawable = (AnimationDrawable)imageView.Background;
                drawable.Start();

                hud = KProgressHUD
                      .Create(this)
                      .SetCustomView(imageView)
                      .SetLabel("custom view ...")
                      .Show();

                AutoClose();
            };


            FindViewById <Button>(Resource.Id.dim_background).Click += (sender, e) =>
            {
                hud = KProgressHUD
                      .Create(this, KProgressHUD.Style.SpinIndeterminate)
                      .SetDimAmount(0.5f)
                      .Show();

                AutoClose();
            };


            FindViewById <Button>(Resource.Id.custom_color_animate).Click += (sender, e) =>
            {
                hud = KProgressHUD
                      .Create(this, KProgressHUD.Style.SpinIndeterminate)
                      .SetBackgroundColor(Color.Red)
                      .SetAnimationSpeed(2)
                      .Show();

                AutoClose();
            };
        }