Esempio n. 1
0
        private async Task <int> BindingContent(bool requireUpdate = false, string updateStatus = "đang cập nhật...")
        {
            try
            {
                int updated = 0;

                this.SetProgressIndicator(true, updateStatus);
                if (_pageNumber == 0)
                {
                    _pageNumber = 1;
                }

                var feedId = _currentPublisher.FeedIds[_currentIndex];

                if (requireUpdate && !NetworkInterface.GetIsNetworkAvailable())
                {
                    Messenger.ShowToast("không có mạng...");
                    requireUpdate = false;
                }

                updated = await _viewModel.RefreshLatestData(feedId, _currentPublisher.Id, requireUpdate);

                _feedManager.SetLastId <Guid>(feedId.ToString());

                if (_viewModel.AllItemViewModels.Count == 0)
                {
                    //this.SetProgressIndicator(false);
                    //Messenger.ShowToast("chưa có tin nào...", completedAction: () => this.BackToPreviousPage());
                    return(updated);
                }

                if (updated > 0)
                {
                    _viewModel.PagedItemViewModels.Clear();
                    _pageNumber = 1;
                }

                _viewModel.LoadPage(_pageNumber, AppConfig.ShowUnreadItemOnly);

                UpdateItemReadCount();
                UpdateViewTitle();
                this.llsItemList.ItemsSource = _viewModel.PagedItemViewModels;

                CreateAppBar();

                if (updated > 0)
                {
                    llsItemList.ScrollToTop();
                }
                else
                {
                    llsItemList.ScrollTo <string>(_lastItemId);
                }

                this.SetProgressIndicator(false);

                return(updated);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }