예제 #1
0
        //custom async method
        public Task PerformTaskAsync2(IProgress <CustomProgress> progress)
        {
            Task t  = new Task(IntenseMethodThatTakesCPUTime);
            Task t2 = Task.Run(() =>
            {
                CustomProgress prog = new CustomProgress();
                prog.update         = "Processing wait 0 of 10";
                prog.value          = 0;
                progress.Report(prog);
                for (int i = 0; i < 10; i++)
                {
                    //https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task?view=netframework-4.7.2
                    System.Threading.Thread.Sleep(500);
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        ContentPresenter cp = new ContentPresenter();
                    });
                    //doing the below will cause it to crash (can only be done on UI thread onyl)
                    //ContentPresenter cp = new ContentPresenter();
                    prog.update = string.Format("Processing wait {0} of 10", i + 1);
                    prog.value  = i + 1;
                    progress.Report(prog);
                }
                //this is also not allowed
                //BackgroundTaskReport.Text = "Complete";
            });

            return(t2);
        }
예제 #2
0
        //custom async method
        public Task PerformTaskAsync(IProgress <CustomProgress> progress)
        {
            Task t  = new Task(IntenseMethodThatTakesCPUTime);
            Task t2 = Task.Run(() =>
            {
                CustomProgress prog  = new CustomProgress();
                prog.update          = "Processing wait 0 of 10";
                prog.value           = 0;
                CustomProgress prog2 = new CustomProgress()
                {
                    value = 8
                };
                progress.Report(prog);
                for (int i = 0; i < 10; i++)
                {
                    //https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task?view=netframework-4.7.2
                    System.Threading.Thread.Sleep(500);
                    prog.update = string.Format("Processing wait {0} of 10", i + 1);
                    prog.value  = i + 1;
                    if (i == 4)
                    {
                        progress.Report(prog2);
                    }
                    else
                    {
                        progress.Report(prog);
                    }
                }
            });

            return(t2);
        }
예제 #3
0
        public ProgressView()
        {
            downloadProgess = new CustomProgress()
            {
                ProgressTintColor = UIColor.DarkGray,
                BackgroundColor   = UIColor.White,
            };
            downloadProgess.SizeToFit();
            var style = this.GetStyle();

            sliderProgress = new CustomProgress()
            {
                ProgressTintColor = style.AccentColorHorizontal,
            };
            slider = new OBSlider();
            slider.AccessibilityIdentifier = "Progress";
            slider.BackgroundColor         = UIColor.Clear;
            slider.MinimumTrackTintColor   = style.AccentColorHorizontal;
            slider.MaximumTrackTintColor   = UIColor.Clear;
            slider.SizeToFit();
            slider.ValueChanged    += (object sender, EventArgs e) => { sliderProgress.Progress = slider.Value; };
            slider.EditingDidBegin += (object sender, EventArgs e) => { EditingStarted?.Invoke(); };
            slider.EditingDidEnd   += (sender, args) => {
                EditingEnded?.Invoke();
                PlaybackManager.Shared.Seek(slider.Value);
            };
            slider.SetThumbImage(Images.GetPlaybackSliderThumb(), UIControlState.Normal);
            this.Frame = slider.Frame;
            this.AddSubview(downloadProgess);
            this.AddSubview(sliderProgress);
            this.AddSubview(slider);
        }
예제 #4
0
        public override Widget build(BuildContext context)
        {
            Widget progressWidget = new Container();

            if (this._progress < 1.0f)
            {
                progressWidget = new CustomProgress(this._progress,
                                                    CColors.White
                                                    );
            }

            if (!Application.isEditor)
            {
                var ratio = Window.instance.devicePixelRatio;
                var top   = (int)(44 * ratio);
                if (Application.platform != RuntimePlatform.Android)
                {
                    top = (int)((MediaQuery.of(context).padding.top + 44) * ratio);
                }

                var bottom = (int)(MediaQuery.of(context).padding.bottom *ratio);
                this._webViewObject.SetMargins(0, top, 0, bottom);
            }

            return(new Container(
                       color: CColors.White,
                       child: new CustomSafeArea(
                           bottom: false,
                           child: new Container(
                               color: CColors.Background,
                               child: new Column(
                                   children: new List <Widget> {
                new Container(
                    child: new Stack(
                        children: new List <Widget> {
                    this._buildNavigationBar(),
                    new Align(
                        alignment: Alignment.bottomCenter,
                        child: progressWidget
                        )
                }
                        )
                    ),
                new Expanded(
                    child: new Center(
                        child: new Text(
                            this._onClose ? "正在关闭..." : "正在加载...",
                            style: CTextStyle.PXLarge
                            )
                        )
                    )
            }
                                   )
                               )
                           )
                       ));
        }
예제 #5
0
        protected async Task <bool> UserLogOut()
        {
            ILoginService _ILoginService = new LoginService();

            if (AppUtils.IsNetwork())
            {
                _objProgress = new CustomProgress(Activity);
                var Authkey = StorageUtils <String> .GetPreferencesValue(DroidConstant.CurrentUser);

                var response = await _ILoginService.LogoutUser(ServiceType.UserService, Authkey);

                _objProgress.DismissDialog();
                if (response != null)
                {
                    if (response.IsSuccess)
                    {
                        StorageUtils <String> .SavePreferences(DroidConstant.CurrentUser, "");

                        LoginManager.Instance.LogOut();
                        new GoogleApiClient.Builder(Activity)
                        .AddApi(PlusClass.API)
                        .AddScope(new Scope(Scopes.Profile))
                        .Build().Disconnect();
                        Activity.StartActivity(typeof(LoginActivity));
                        Activity.Finish();

                        return(true);
                    }
                    else
                    {
                        AppUtils.ShowToast(Activity, response.Message);

                        return(true);
                    }
                }
                else
                {
                    AppUtils.ShowToast(Activity, response.Message);
                    return(true);
                }
            }
            else
            {
                AppUtils.ShowToast(Activity, Resources.GetString(Resource.String.network_error));
                _objProgress.DismissDialog();
                return(true);
            }
        }
/// <summary>
/// Fetch Event
/// </summary>
/// <returns>List</returns>
        async Task <List <EventList> > GetEventList()
        {
            if (AppUtils.IsNetwork())
            {
                var request = new EventRequest
                {
                    PageNo = 1
                };
                _objProgress = new CustomProgress(Activity);
                var Authkey = StorageUtils <String> .GetPreferencesValue(DroidConstant.CurrentUser);

                var response = await _IEventListService.GetEnrolledEventsList(request, ServiceType.EventService, Authkey);

                _objProgress.DismissDialog();
                if (response != null)
                {
                    if (response.IsSuccess && response.Result != null)
                    {
                        result = response.Result;
                        if (result.Count == 0 && request.PageNo == 1)
                        {
                            //AppUtils.ShowToast(Activity, response.Message);
                        }
                        else
                        {
                            eventAdapter.UpdateList(result);
                        }
                    }
                    else
                    {
                        //AppUtils.ShowToast(Activity, response.Message);
                    }
                }
                else
                {
                    //AppUtils.ShowToast(Activity, Resources.GetString(Resource.String.network_error));
                }
            }
            else
            {
                AppUtils.ShowToast(Activity, Resources.GetString(Resource.String.network_error));
                _objProgress.DismissDialog();
            }
            return(result);
        }
예제 #7
0
        public Task <bool> PerformTaskWithCancelAsync(IProgress <CustomProgress> progress, CancellationToken ct)
        {
            Task <bool> t2 = Task.Run(() =>
            {
                //progress
                CustomProgress prog = new CustomProgress
                {
                    update = "Processing wait 0 of 10",
                    value  = 0
                };
                progress.Report(prog);

                //run task that takes up lots of stuffs
                for (int i = 0; i < 10; i++)
                {
                    //https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task?view=netframework-4.7.2
                    for (int j = 0; j < 10; j++)
                    {
                        Thread.Sleep(50);
                    }
                    ct.ThrowIfCancellationRequested();
                    prog.update = string.Format("Processing wait {0} of 10", i + 1);
                    prog.value  = i + 1;
                    progress.Report(prog);
                }
            }).ContinueWith(task =>
            {
                if (task.Status == TaskStatus.Faulted)
                {
                    return(false);
                }
                return(true);
            });

            return(t2);
        }
예제 #8
0
 private void Progress_ProgressChangedCancel(object sender, CustomProgress e)
 {
     TaskCancelTestingBlock.Text     = e.update;
     TaskCancelTestingProgress.Value = e.value;
 }
예제 #9
0
 private void Progress_ProgressChanged2(object sender, CustomProgress e)
 {
     HybridTaskReport.Text    = e.update;
     HybridTaskProgress.Value = e.value;
 }
예제 #10
0
 private void Progress_ProgressChanged(object sender, CustomProgress e)
 {
     BackgroundTaskReport.Text    = e.update;
     BackgroundTaskProgress.Value = e.value;
 }
예제 #11
0
        public override Widget build(BuildContext context)
        {
            Widget progressWidget;

            if (this._progress < 1.0f)
            {
                progressWidget = new CustomProgress(this._progress,
                                                    CColors.White
                                                    );
            }
            else
            {
                progressWidget = new Container();
            }

            if (!Application.isEditor)
            {
                var ratio = Window.instance.devicePixelRatio;
                var navigationBarHeight = this.widget.fullScreen ? 0 : 44;
                var top = (int)(navigationBarHeight * ratio);
                if (Application.platform != RuntimePlatform.Android)
                {
                    top = (int)((MediaQuery.of(context).padding.top + navigationBarHeight) * ratio);
                }

                var left  = this.widget.landscape ? (int)(80 * ratio) : 0;
                var right = left;

                var bottom = (int)(MediaQuery.of(context).padding.bottom *ratio);
                this._webViewObject.SetMargins(left, top, right, bottom);

                if (this.widget.landscape && this._progress == 1)
                {
                    Screen.orientation = ScreenOrientation.LandscapeLeft;
                    Screen.fullScreen  = true;
                }
            }

            return(new Container(
                       color: CColors.White,
                       child: new CustomSafeArea(
                           top: !this.widget.fullScreen,
                           bottom: false,
                           child: new Container(
                               color: CColors.Background,
                               child: new Column(
                                   children: new List <Widget> {
                new Container(
                    child: new Stack(
                        children: new List <Widget> {
                    this._buildNavigationBar(),
                    new Align(
                        alignment: Alignment.bottomCenter,
                        child: progressWidget
                        )
                }
                        )
                    ),
                new Expanded(
                    child: new Container(
                        color: this.widget.landscape ? CColors.Black : null,
                        child: new Center(
                            child: new Text(
                                this._onClose ? "正在关闭..." : "",
                                style: CTextStyle.PXLarge
                                )
                            )
                        )
                    )
            }
                                   )
                               )
                           )
                       ));
        }