Ejemplo n.º 1
0
        private async void LoadPostData(Subject subject)
        {
            try
            {
                AppHelper.ShowProgressMessage("正在加载数据......");
                subject.CurrentGrid.Visibility = Visibility.Collapsed;
                LoginAppBarButton.IsEnabled    = false;
                HttpHelper helper  = new HttpHelper(App.HttpClient);
                string     content = await helper.GetHttpString(new Uri(NeihanApi.GetCurrentUrl(subject.Menu.Name, subject.Page)));

                List <Post> posts = ParseDataUtils.ParsePost(content);
                if (posts.Count > 0)
                {
                    ParseDataUtils.CopyListToObservableCollection(posts, subject.Posts);
                }
                else
                {
                    ShowTipMessage("未获取到数据,请稍后重试!");
                }
                AppHelper.ShowStatusBar();
                LoginAppBarButton.IsEnabled    = true;
                subject.CurrentGrid.Visibility = Visibility.Visible;
                ShowTipMessage(string.Format("已成功加载{0}条数据,图片加载可能有些慢,请小伙伴耐心等待!", subject.Posts.Count));
            }
            catch (Exception e)
            {
                ShowTipMessage("数据加载失败,请稍后重试!");
            }
        }
Ejemplo n.º 2
0
        private Subject GetCurrentSubject()
        {
            switch (DataPivot.SelectedIndex)
            {
            case 0:
            {
                _indexSubject.Menu        = NeihanApi.GetMenus()[0];
                _indexSubject.Posts       = IndexPosts;
                _indexSubject.CurrentGrid = IndexFooterGrid;
                _indexSubject.ListView    = IndexPostListView;
                return(_indexSubject);
            }

            case 1:
            {
                _hotSubject.Menu        = NeihanApi.GetMenus()[1];
                _hotSubject.Posts       = HotPosts;
                _hotSubject.CurrentGrid = HotFooterGrid;
                _hotSubject.ListView    = HotPostListView;
                return(_hotSubject);
            }

            case 2:
            {
                _cmtHotSubject.Menu        = NeihanApi.GetMenus()[2];
                _cmtHotSubject.Posts       = CmtHotPosts;
                _cmtHotSubject.CurrentGrid = CmtHotFooterGrid;
                _cmtHotSubject.ListView    = CmtHotPostListView;
                return(_cmtHotSubject);
            }

            case 3:
            {
                _newSubject.Menu        = NeihanApi.GetMenus()[3];
                _newSubject.Posts       = NewPosts;
                _newSubject.CurrentGrid = NewFooterGrid;
                _newSubject.ListView    = NewPostListView;
                return(_newSubject);
            }

            default:
            {
                _indexSubject.Menu        = NeihanApi.GetMenus()[0];
                _indexSubject.Posts       = IndexPosts;
                _indexSubject.CurrentGrid = IndexFooterGrid;
                return(_indexSubject);
            }
            }
        }