示例#1
0
        async Task RefreshContributions()
        {
            if (Connectivity.NetworkAccess == NetworkAccess.Internet)
            {
                Contributions.Clear();

                var contributionsList = await _mvpApiService.GetContributionsAsync(0, _pageSize, true).ConfigureAwait(false);

                if (contributionsList != null)
                {
                    _contributions.AddRange(contributionsList.Contributions);
                    Contributions = _contributions.ToGroupedContributions();
                }
            }
        }
示例#2
0
        private async Task LoadLatestContributionsAsync()
        {
            try
            {
                var contrib = await mvpApiService.GetContributionsAsync(1, 20);

                ContributionsContentControl.DataContext = contrib;
                ContributionsContentControl.Visibility  = Visibility.Visible;
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }
        }
示例#3
0
        async Task RefreshContributions()
        {
            Contributions.Clear();
            contributions.Clear();

            var contributionsList = await MvpApiService.GetContributionsAsync(0, pageSize).ConfigureAwait(false);

            if (contributionsList == null)
            {
                return;
            }

            Contributions = contributionsList.Contributions;
        }
示例#4
0
        /// <summary>
        /// Loads more contributions when scrolled to the bottom.
        /// </summary>
        async Task LoadMore()
        {
            if (IsLoadingMore)
            {
                return;
            }

            if (!await VerifyInternetConnection())
            {
                return;
            }

            try
            {
                IsLoadingMore = true;

                var contributionsList = await MvpApiService.GetContributionsAsync(Contributions.Count, pageSize).ConfigureAwait(false);

                if (contributionsList == null)
                {
                    await DialogService.AlertAsync(Translations.error_couldntloadmorecontributions, Translations.error_title, Translations.ok).ConfigureAwait(false);

                    return;
                }

                foreach (var item in contributionsList.Contributions.OrderByDescending(x => x.StartDate))
                {
                    Contributions.Add(item);
                }

                AnalyticsService.Track("More Contributions Loaded");

                // If we've reached the end, change the threshold.
                if (!contributionsList.Contributions.Any())
                {
                    ItemThreshold = -1;
                    return;
                }
            }
            catch (Exception ex)
            {
                AnalyticsService.Report(ex);
                await DialogService.AlertAsync(Translations.error_couldntloadmorecontributions, Translations.error_title, Translations.ok).ConfigureAwait(false);
            }
            finally
            {
                IsLoadingMore = false;
            }
        }
示例#5
0
        /// <summary>
        /// Refreshes the list of contributions.
        /// </summary>
        async Task RefreshContributions(bool refresh = false)
        {
            ItemThreshold = 2;

            if (Connectivity.NetworkAccess != NetworkAccess.Internet)
            {
                State          = LayoutState.Custom;
                CustomStateKey = StateKeys.Offline;
                return;
            }

            try
            {
                State = LayoutState.Loading;

                var contributionsList = await MvpApiService.GetContributionsAsync(0, pageSize).ConfigureAwait(false);

                if (contributionsList == null)
                {
                    State = LayoutState.Error;
                    return;
                }

                Contributions = new ObservableCollection <Contribution>(contributionsList.Contributions.OrderByDescending(x => x.StartDate).ToList());
            }
            catch (Exception ex)
            {
                AnalyticsService.Report(ex);
                State = LayoutState.Error;
            }
            finally
            {
                IsRefreshing = false;

                if (State != LayoutState.Error)
                {
                    State = Contributions.Count > 0 ? LayoutState.None : LayoutState.Empty;
                }
            }
        }