Пример #1
0
        private void sync_StatusChanged(object sender, SyncStatus e)
        {
            if (e.Error)
            {
                this.labelSyncStatus.Text      = "Sync Error. Internet Issues?";
                this.labelSyncStatus.IsVisible = true;
                this.labelSyncStatus.TextColor = Config.ColorRed;
                Device.StartTimer(TimeSpan.FromSeconds(2), () =>
                {
                    this.labelSyncStatus.IsVisible = false;
                    return(false);
                });
                return;
            }

            this.labelSyncStatus.TextColor = Config.ColorTextOnBackground;

            if (e.Completed)
            {
                this.labelSyncStatus.Text      = "Sync completed";
                this.labelSyncStatus.IsVisible = true;
                Device.StartTimer(TimeSpan.FromSeconds(2), () =>
                {
                    this.labelSyncStatus.IsVisible = false;
                    return(false);
                });
                return;
            }

            string text = "Sync in progress";

            if (e.TotalCount > 0)
            {
                text += " " + e.Current.ToString() + " / " + e.TotalCount.ToString();
            }
            else
            {
                text += "...";
            }
            this.labelSyncStatus.Text      = text;
            this.labelSyncStatus.IsVisible = true;
        }
Пример #2
0
        async void doOnSyncCompleted(SyncStatus syncStatus)
        {
            if (rootPage == null)
            {
                return;
            }
            if (NavPage.CurrentPage != rootPage)
            {
                return;
            }

            int myAthleteID = App.Repository.GetMyAthleteID();

            if (this.rootPage.State == MainSnookerPage.StateEnum.Person && this.rootPage.AthleteID == myAthleteID)
            {
                bool forceReload = true;
                await this.GoToMyProfile(ProfilePersonStateEnum.Unknown, forceReload);
            }

            // update the title of the root page
            if (App.Sync.LastSyncResults != null && App.Sync.LastSyncResults.Result == SyncResultEnum.Ok)
            {
                rootPage.Title = "sync ok";
            }
            else
            {
                rootPage.Title = "sync error. Internet issues?";
            }

            // reset the title of the root page back
            System.Timers.Timer timer = new System.Timers.Timer();
            timer.Interval = 2000;
            timer.Elapsed += (s1, e1) => {
                Device.BeginInvokeOnMainThread(() => {
                    timer.Stop();
                    rootPage.UpdateTheTitle();
                });
            };
            timer.Start();
        }