private async Task GetUserPosts(bool needRefresh = false)
        {
            if (_isPostsLoading)
            {
                return;
            }
            _isPostsLoading = true;

            if (needRefresh)
            {
                _presenter.Clear();
                _gridDelegate.ClearPosition();
                _sliderGridDelegate.ClearPosition();
            }

            var error = await _presenter.TryLoadNextPosts();

            if (error == null)
            {
                _isPostsLoading = false;
            }
            else
            {
                ShowAlert(error);
            }

            if (_userDataLoaded)
            {
                loading.StopAnimating();
                collectionView.Hidden = false;
            }
        }
        protected override async Task GetPosts(bool shouldStartAnimating = true, bool clearOld = false)
        {
            if (_isPostsLoading)
            {
                return;
            }
            _isPostsLoading = true;

            if (clearOld)
            {
                _presenter.Clear();
                _gridDelegate.ClearPosition();
                _sliderGridDelegate.ClearPosition();
            }

            var error = await _presenter.TryLoadNextPosts();

            if (error == null)
            {
                _isPostsLoading = false;
            }
            else
            {
                ShowAlert(error);
            }

            if (_userDataLoaded)
            {
                loading.StopAnimating();
                collectionView.Hidden = false;
            }
        }
Ejemplo n.º 3
0
        private async Task GetPosts(bool shouldStartAnimating = true, bool clearOld = false)
        {
            ErrorBase error;

            do
            {
                if (shouldStartAnimating)
                {
                    activityIndicator.StartAnimating();
                    _refreshControl.EndRefreshing();
                }
                else
                {
                    activityIndicator.StopAnimating();
                }

                noFeedLabel.Hidden = true;

                if (clearOld)
                {
                    _sliderGridDelegate.ClearPosition();
                    _gridDelegate.ClearPosition();
                    _presenter.Clear();
                }

                if (CurrentPostCategory == null)
                {
                    error = await _presenter.TryLoadNextTopPosts();
                }
                else
                {
                    _presenter.Tag = CurrentPostCategory;
                    error          = await _presenter.TryGetSearchedPosts();
                }

                if (error is CanceledError)
                {
                    return;
                }

                if (_refreshControl.Refreshing)
                {
                    _refreshControl.EndRefreshing();
                    _isFeedRefreshing = false;
                }
                else
                {
                    activityIndicator.StopAnimating();
                }
            } while (error is RequestError);
            ShowAlert(error);
        }
        protected override async Task GetPosts(bool shouldStartAnimating = true, bool clearOld = false)
        {
            Exception exception;

            do
            {
                if (shouldStartAnimating)
                {
                    activityIndicator.StartAnimating();
                    _refreshControl.EndRefreshing();
                }
                else
                {
                    activityIndicator.StopAnimating();
                }

                noFeedLabel.Hidden = true;

                if (clearOld)
                {
                    _sliderGridDelegate.ClearPosition();
                    _gridDelegate.ClearPosition();
                    _presenter.Clear();
                }

                if (CurrentPostCategory == null)
                {
                    exception = await _presenter.TryLoadNextTopPosts();
                }
                else
                {
                    _presenter.Tag = CurrentPostCategory;
                    exception      = await _presenter.TryGetSearchedPosts();
                }

                if (exception is OperationCanceledException)
                {
                    return;
                }

                if (_refreshControl.Refreshing)
                {
                    _refreshControl.EndRefreshing();
                }
                else
                {
                    activityIndicator.StopAnimating();
                }
            } while (exception is RequestException);
            ShowAlert(exception);
        }