Exemplo n.º 1
0
        void showProgress(Context context, int progress, string status = null, MaskType maskType = MaskType.Black, TimeSpan?timeout = null, Action clickCallback = null, Action cancelCallback = null, Action <Dialog> prepareDialogCallback = null, Action <Dialog> dialogShownCallback = null)
        {
            if (!timeout.HasValue || timeout == null)
            {
                timeout = TimeSpan.Zero;
            }

            if (CurrentDialog != null && progressWheel == null)
            {
                DismissCurrent(context);
            }

            lock (dialogLock)
            {
                if (CurrentDialog == null)
                {
                    SetupDialog(context, maskType, cancelCallback, (a, d, m) => {
                        var inflater = LayoutInflater.FromContext(context);
                        var view     = inflater.Inflate(Resource.Layout.loadingprogress, null);

                        if (clickCallback != null)
                        {
                            view.Click += (sender, e) => clickCallback();
                        }

                        progressWheel = view.FindViewById <ProgressWheel>(Resource.Id.loadingProgressWheel);
                        statusText    = view.FindViewById <TextView>(Resource.Id.textViewStatus);

                        if (maskType != MaskType.Black)
                        {
                            view.SetBackgroundResource(Resource.Drawable.roundedbgdark);
                        }

                        progressWheel.SetProgress(0);

                        if (statusText != null)
                        {
                            statusText.Text       = status ?? "";
                            statusText.Visibility = string.IsNullOrEmpty(status) ? ViewStates.Gone : ViewStates.Visible;
                        }

                        return(view);
                    }, prepareDialogCallback, dialogShownCallback);

                    RunTimeout(context, timeout);
                }
                else
                {
                    Application.SynchronizationContext.Send(state => {
                        progressWheel?.SetProgress(progress);
                        statusText.Text = status ?? "";
                    }, null);
                }
            }
        }
Exemplo n.º 2
0
		void showProgress(Context context, int progress, string status = null, MaskType maskType = MaskType.Black, TimeSpan? timeout = null, Action clickCallback = null, Action cancelCallback = null)
		{
			if (!timeout.HasValue || timeout == null)
				timeout = TimeSpan.Zero;

			if (CurrentDialog != null && progressWheel == null)
				DismissCurrent (context);

			lock (dialogLock)
			{
				if (CurrentDialog == null)
				{
					SetupDialog (context, maskType, cancelCallback, (a, d, m) => {
						var inflater = LayoutInflater.FromContext(context);
						var view = inflater.Inflate(Resource.Layout.loadingprogress, null);

						if (clickCallback != null)
							view.Click += (sender, e) => clickCallback();

						progressWheel = view.FindViewById<ProgressWheel>(Resource.Id.loadingProgressWheel);
						statusText = view.FindViewById<TextView>(Resource.Id.textViewStatus);

						if (maskType != MaskType.Black)
							view.SetBackgroundResource(Resource.Drawable.roundedbgdark);

						progressWheel.SetProgress(0);

						if (statusText != null)
						{
							statusText.Text = status ?? "";
							statusText.Visibility = string.IsNullOrEmpty(status) ? ViewStates.Gone : ViewStates.Visible;
						}

						return view;
					});

					if (timeout.Value > TimeSpan.Zero)
					{
						Task.Factory.StartNew(() => {
							if (!waitDismiss.WaitOne (timeout.Value))
								DismissCurrent (context);

						}).ContinueWith(ct => {
							var ex = ct.Exception;

							if (ex != null)
								Android.Util.Log.Error("AndHUD", ex.ToString());
						}, TaskContinuationOptions.OnlyOnFaulted);
					}
				}
				else
				{
					Application.SynchronizationContext.Send(state => {
						progressWheel.SetProgress (progress);
						statusText.Text = status ?? "";
					}, null);
				}
			}
		}
Exemplo n.º 3
0
        void showProgress(Context context, int progress, string status = null, MaskType maskType = MaskType.Black, TimeSpan?timeout = null, Action clickCallback = null, Action cancelCallback = null)
        {
            if (!timeout.HasValue || timeout == null)
            {
                timeout = TimeSpan.Zero;
            }

            if (CurrentDialog != null && progressWheel == null)
            {
                DismissCurrent(context);
            }

            lock (dialogLock)
            {
                if (CurrentDialog == null)
                {
                    SetupDialog(context, maskType, cancelCallback, (a, d, m) => {
                        var inflater = LayoutInflater.FromContext(context);
                        var view     = inflater.Inflate(Resource.Layout.loadingprogress, null);

                        if (clickCallback != null)
                        {
                            view.Click += (sender, e) => clickCallback();
                        }

                        progressWheel = view.FindViewById <ProgressWheel>(Resource.Id.loadingProgressWheel);
                        statusText    = view.FindViewById <TextView>(Resource.Id.textViewStatus);

                        if (maskType != MaskType.Black)
                        {
                            view.SetBackgroundResource(Resource.Drawable.roundedbgdark);
                        }

                        progressWheel.SetProgress(0);

                        if (statusText != null)
                        {
                            statusText.Text       = status ?? "";
                            statusText.Visibility = string.IsNullOrEmpty(status) ? ViewStates.Gone : ViewStates.Visible;
                        }

                        return(view);
                    });

                    if (timeout.Value > TimeSpan.Zero)
                    {
                        Task.Factory.StartNew(() => {
                            if (!waitDismiss.WaitOne(timeout.Value))
                            {
                                DismissCurrent(context);
                            }
                        }).ContinueWith(ct => {
                            var ex = ct.Exception;

                            if (ex != null)
                            {
                                Android.Util.Log.Error("AndHUD", ex.ToString());
                            }
                        }, TaskContinuationOptions.OnlyOnFaulted);
                    }
                }
                else
                {
                    Application.SynchronizationContext.Send(state => {
                        progressWheel.SetProgress(progress);
                        statusText.Text = status ?? "";
                    }, null);
                }
            }
        }
Exemplo n.º 4
0
        void showProgress(Activity activity, int progress, string status = null, MaskType maskType = MaskType.Black, TimeSpan?timeout = null, Action clickCallback = null)
        {
            if (timeout == null)
            {
                timeout = TimeSpan.Zero;
            }

            if (CurrentDialog != null && progressWheel == null)
            {
                DismissCurrent(activity);
            }

            lock (dialogLock)
            {
                if (CurrentDialog == null)
                {
                    SetupDialog(activity, maskType, (a, d, m) => {
                        var view = activity.LayoutInflater.Inflate(Resource.Layout.LoadingProgress, null);

                        if (clickCallback != null)
                        {
                            view.Click += (sender, e) => clickCallback();
                        }

                        progressWheel = view.FindViewById <ProgressWheel>(Resource.Id.LoadingProgressWheel);
                        statusText    = view.FindViewById <TextView>(Resource.Id.textViewStatus);

                        if (maskType != MaskType.Black)
                        {
                            view.SetBackgroundResource(Resource.Drawable.RoundedBgDark);
                        }

                        progressWheel.SetProgress(0);

                        if (statusText != null)
                        {
                            statusText.Text       = status ?? "";
                            statusText.Visibility = string.IsNullOrEmpty(status) ? ViewStates.Gone : ViewStates.Visible;
                        }

                        return(view);
                    });

                    if (timeout > TimeSpan.Zero)
                    {
                        Task.Factory.StartNew(() => {
                            if (!waitDismiss.WaitOne(timeout.Value))
                            {
                                DismissCurrent(activity);
                            }
                        });
                    }
                }
                else
                {
                    activity.RunOnUiThread(() => {
                        progressWheel.SetProgress(progress);
                        statusText.Text = status ?? "";
                    });
                }
            }
        }