Ejemplo n.º 1
0
        public async void LoadComment()
        {
            try
            {
                GetEmojis();
                _Loading           = true;
                pr_load.Visibility = Visibility.Visible;
                wc = new WebClientClass();
                string url = "http://api.bilibili.com/x/reply?type=1&sort=0&oid=" + _aid + "&pn=" + pageNum + "&ps=20&platform=wp&appkey=" + ApiHelper._appKey + "&access_key=" + ApiHelper.access_key + "&rnd" + new Random().Next(1, 9999);
                url += "&sign=" + ApiHelper.GetSign(url);
                string results = await wc.GetResults(new Uri(url));

                NewCommentModel model = JsonConvert.DeserializeObject <NewCommentModel>(results);
                if (pageNum == 1)
                {
                    ListView_Comment_Hot.ItemsSource = model.data.hots;
                    ListView_Comment_New.Items.Clear();
                }
                if (model.data.replies.Count != 0)
                {
                    model.data.replies.ForEach(x => ListView_Comment_New.Items.Add(x));
                    pageNum++;
                }
                else
                {
                    messShow.Show("加载完了...", 3000);
                }
            }
            catch (Exception ex)
            {
                if (ex.HResult == -2147012867)
                {
                    messShow.Show("检查你的网络连接!", 3000);
                }
                else
                {
                    messShow.Show("读取评论失败!\r\n" + ex.Message, 3000);
                }
            }
            finally
            {
                pr_load.Visibility = Visibility.Collapsed;
                _Loading           = false;
            }
        }
Ejemplo n.º 2
0
        public async void LoadHotComment(string aid)
        {
            try
            {
                pr_load.Visibility = Visibility.Visible;

                wc = new WebClientClass();
                string url = "http://api.bilibili.com/x/reply?type=1&sort=1&oid=" + aid + "&pn=1&ps=20&platform=wp&appkey=" + ApiHelper._appKey + "&access_key=" + ApiHelper.access_key + "&rnd" + new Random().Next(1, 9999);;
                url += "&sign=" + ApiHelper.GetSign(url);
                string results = await wc.GetResults(new Uri(url));

                NewCommentModel model = JsonConvert.DeserializeObject <NewCommentModel>(results);
                if (model.data.replies.Count != 0)
                {
                    model.data.replies.ForEach(x => ls_Hot.Items.Add(x));
                }
                else
                {
                    messShow.Show("加载完了...", 3000);
                }
            }
            catch (Exception ex)
            {
                if (ex.HResult == -2147012867)
                {
                    messShow.Show("检查你的网络连接!", 3000);
                }
                else
                {
                    messShow.Show("读取热门评论失败!\r\n" + ex.Message, 3000);
                }
            }
            finally
            {
                pr_load.Visibility = Visibility.Collapsed;
            }
        }