Пример #1
0
 private void LoadHotSearch()
 {
     App.ShowLoading();
     HttpHelper.httpGet(CommonData.HotSearch, (ar) =>
     {
         string result = HttpHelper.SyncResultTostring(ar);
         if (result != null)
         {
             MoreChannelResult channelDetails = null;
             try
             {
                 channelDetails = JsonConvert.DeserializeObject <MoreChannelResult>(result);
             }
             catch (Exception ex)
             {
                 System.Diagnostics.Debug.WriteLine("LoadChannelCompleted   json 解析错误" + ex.Message);
                 App.HideLoading();
             }
             if (channelDetails != null && channelDetails.err_code == HttpHelper.rightCode)
             {
                 this.Dispatcher.BeginInvoke(() =>
                 {
                     HotSearch.ItemsSource = channelDetails.data;
                     App.HideLoading();
                 });
             }
         }
         else
         {
             App.HideLoading();
         }
     });
 }
Пример #2
0
        private void LoadChannelCompleted(IAsyncResult ar)
        {
            string result = HttpHelper.SyncResultTostring(ar);

            if (result != null)
            {
                MoreChannelResult channelDetails = null;
                try
                {
                    channelDetails = JsonConvert.DeserializeObject <MoreChannelResult>(result);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("LoadChannelCompleted   json 解析错误" + ex.Message);
                    App.HideLoading();
                }
                if (channelDetails != null && channelDetails.err_code == HttpHelper.rightCode)
                {
                    this.Dispatcher.BeginInvoke(() =>
                    {
                        App.HideLoading();
                        loadGrid.Visibility = Visibility.Collapsed;
                        //if (pageCount > 0)
                        //{
                        //    stackPanel.Children.Remove(addTipGrid);
                        //}
                        AddChannelView(channelDetails.data, 200, 2);
                        pageCount++;
                    });
                }
            }
            else
            {
                //App.ShowToast("获取数据失败,请检查网络或重试");
                App.HideLoading();
                this.Dispatcher.BeginInvoke(() =>
                {
                    loadGrid.Visibility = Visibility.Visible;
                });
            }
        }
Пример #3
0
 private void BeginSearch(string name)
 {
     System.Diagnostics.Debug.WriteLine("获取搜索结果 url:" + CommonData.SearchUrl + "&name=" + name);
     HttpHelper.httpGet(CommonData.SearchUrl + "&name=" + name, (ar) =>
     {
         string result = HttpHelper.SyncResultTostring(ar);
         if (result != null)
         {
             MoreChannelResult channelDetails = null;
             try
             {
                 channelDetails = JsonConvert.DeserializeObject <MoreChannelResult>(result);
             }
             catch (Exception ex)
             {
                 System.Diagnostics.Debug.WriteLine("LoadChannelCompleted   json 解析错误" + ex.Message);
                 App.HideLoading();
             }
             if (channelDetails != null && channelDetails.err_code == HttpHelper.rightCode)
             {
                 this.Dispatcher.BeginInvoke(() =>
                 {
                     if (channelDetails.data.Count > 0)
                     {
                         SerachInfo.ItemsSource = channelDetails.data;
                     }
                     else
                     {
                         App.ShowToast("没有搜索结果");
                     }
                 });
             }
         }
         else
         {
             App.HideLoading();
         }
     });
 }
Пример #4
0
        private void LoadChannelCompleted(IAsyncResult ar)
        {
            string result = HttpHelper.SyncResultTostring(ar);

            if (result != null)
            {
                MoreChannelResult channelDetails = null;
                try
                {
                    channelDetails = JsonConvert.DeserializeObject <MoreChannelResult>(result);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("LoadChannelCompleted   json 解析错误" + ex.Message);
                    App.HideLoading();
                }
                if (channelDetails != null && channelDetails.err_code == HttpHelper.rightCode)
                {
                    this.Dispatcher.BeginInvoke(() =>
                    {
                        App.HideLoading();
                        //loadGrid.Visibility = Visibility.Collapsed;
                        ////if (pageCount > 0)
                        ////{
                        ////    stackPanel.Children.Remove(addTipGrid);
                        ////}
                        //AddChannelView(channelDetails.data, 200, 2);
                        List <VideoViewModel> TemplateListData = new List <VideoViewModel>();

                        for (int i = 0; i < channelDetails.data.Count; i = i + 2)
                        {
                            if (channelDetails.data.Count > i + 1)
                            {
                                MoreChannel template1    = channelDetails.data[i];
                                MoreChannel template2    = channelDetails.data[i + 1];
                                VideoViewModel videoData = new VideoViewModel
                                {
                                    //stupid func
                                    name     = template1.name,
                                    tag      = template1.tag,
                                    desc     = template1.desc,
                                    picUrl   = template1.image,
                                    videoId  = template1.videoId,
                                    name1    = template2.name,
                                    tag1     = template2.tag,
                                    desc1    = template2.desc,
                                    videoId1 = template2.videoId,
                                    picUrl1  = template2.image,
                                };
                                TemplateListData.Add(videoData);
                            }
                            else
                            {
                                MoreChannel template1    = channelDetails.data[i];
                                VideoViewModel videoData = new VideoViewModel
                                {
                                    name    = template1.name,
                                    tag     = template1.tag,
                                    desc    = template1.desc,
                                    videoId = template1.videoId,
                                };
                                TemplateListData.Add(videoData);
                            }
                        }
                        moreChannelInfo.ItemsSource = TemplateListData;
                        pageCount++;
                    });
                }
            }
            else
            {
                //App.ShowToast("获取数据失败,请检查网络或重试");
                App.HideLoading();
                this.Dispatcher.BeginInvoke(() =>
                {
                    reLoadGrid.Visibility = Visibility.Visible;
                });
            }
        }