コード例 #1
0
ファイル: InfoPage.xaml.cs プロジェクト: cybort/PikaComic-UWP
        private async void LoadComment()
        {
            try
            {
                pr_Load.Visibility = Visibility.Visible;
                Cloading           = true;
                if (CpageN == 1)
                {
                    ls_comment.Items.Clear();
                }
                string uri = "";

                uri = "https://picaapi.picacomic.com/comics/" + _id + "/comments?page=" + CpageN;

                string results = await WebClientClass.GetResults(new Uri(uri));

                CommentsModel info = JsonConvert.DeserializeObject <CommentsModel>(results);

                if (info.code == 200)
                {
                    if (info.data.comments.docs.Count != 0)
                    {
                        info.data.comments.docs.ForEach(x => ls_comment.Items.Add(x));
                        CpageN++;
                    }
                    else
                    {
                        messShow.Show("沒有更多了", 2000);
                        btn_LoadMore.Visibility = Visibility.Collapsed;
                    }
                }
                else
                {
                    messShow.Show(info.message, 2000);
                }
            }
            catch (Exception ex)
            {
                if (ex.HResult == -2147012867)
                {
                    messShow.Show("檢查你的網絡連接!", 3000);
                }
                else
                {
                    messShow.Show("讀取信息失敗了,挂個VPN試試?", 3000);
                }
            }
            finally
            {
                Cloading           = false;
                pr_Load.Visibility = Visibility.Collapsed;
            }
        }
コード例 #2
0
ファイル: InfoPage.xaml.cs プロジェクト: cybort/PikaComic-UWP
        private async void Collect(bool iscollect)
        {
            try
            {
                pr_Load.Visibility = Visibility.Visible;

                string uri = "";

                uri = "https://picaapi.picacomic.com/comics/" + _id + "/favourite";

                string results = await WebClientClass.PostResults(new Uri(uri), "");

                CommentsModel info = JsonConvert.DeserializeObject <CommentsModel>(results);

                if (info.code == 200)
                {
                    if (iscollect)
                    {
                        btn_UnCollect.Visibility = Visibility.Visible;
                        btn_Collect.Visibility   = Visibility.Collapsed;
                    }
                    else
                    {
                        btn_UnCollect.Visibility = Visibility.Collapsed;
                        btn_Collect.Visibility   = Visibility.Visible;
                    }
                    messShow.Show("操作成功辣!", 3000);
                }
                else
                {
                    messShow.Show(info.message, 2000);
                }
            }
            catch (Exception ex)
            {
                if (ex.HResult == -2147012867)
                {
                    messShow.Show("檢查你的網絡連接!", 3000);
                }
                else
                {
                    messShow.Show("操作失敗了,挂個VPN試試?", 3000);
                }
            }
            finally
            {
                pr_Load.Visibility = Visibility.Collapsed;
            }
        }