Beispiel #1
0
        public async void OnRefresh()
        {
            _swipeRefreshLayout.Post(() => {
                _swipeRefreshLayout.Refreshing = true;
            });
            pageIndex = 1;
            if (position == 3)
            {
                var result = await KbArticlesService.ListKbArticle(AccessTokenUtil.GetToken(this.Activity), pageIndex);

                if (result.Success)
                {
                    //var tempList = result.Data;
                    kbArticlesList = result.Data;
                    adapterKbArticles.SetNewData(kbArticlesList);
                    if (kbArticlesList != null && kbArticlesList.Count != 0)
                    {
                        await SQLiteUtil.UpdateKbArticlesList(result.Data);
                    }
                    _swipeRefreshLayout.Refreshing = false;
                }
                else
                {
                    AlertUtil.ToastShort(Activity, result.Message);
                    _swipeRefreshLayout.Refreshing = false;
                }
            }
            else
            {
                var result = await NewsService.ListNews(AccessTokenUtil.GetToken(this.Activity), pageIndex, position);

                if (result.Success)
                {
                    newsList = result.Data;
                    if (position == 1)
                    {
                        newsList.ForEach(f => f.IsHot = true);
                    }
                    if (position == 2)
                    {
                        newsList.ForEach(f => f.IsRecommend = true);
                    }
                    adapter.SetNewData(newsList);
                    if (newsList != null && newsList.Count != 0)
                    {
                        await SQLiteUtil.UpdateNewsList(newsList);
                    }
                    _swipeRefreshLayout.Refreshing = false;
                }
                else
                {
                    AlertUtil.ToastShort(Activity, result.Message);
                    _swipeRefreshLayout.Refreshing = false;
                }
            }
        }
Beispiel #2
0
        private async void LoadMoreKbarticles()
        {
            pageIndex++;
            var result = await KbArticlesService.ListKbArticle(AccessTokenUtil.GetToken(this.Activity), pageIndex);

            if (result.Success)
            {
                var tempList = result.Data;
                kbArticlesList.AddRange(tempList);
                adapterKbArticles.SetNewData(kbArticlesList);
                await SQLiteUtil.UpdateKbArticlesList(tempList);
            }
            else
            {
                AlertUtil.ToastShort(Activity, result.Message);
            }
        }
        private async Task <List <KbArticles> > listKbArticlesServer()
        {
            var result = await KbArticlesService.ListKbArticle(AccessTokenUtil.GetToken(this.Activity), pageIndex);

            if (result.Success)
            {
                _swipeRefreshLayout.Refreshing = false;
                try
                {
                    await SQLiteUtil.UpdateKbArticlesList(result.Data);

                    return(result.Data);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.Write(ex.ToString());
                    return(null);
                }
            }
            return(null);
        }