void client_2_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { try { string data = e.Result; // if (this.responseResult.Equals("") || this.responseResult == null) // { this.responseResult = data; // } //bool result = tvodUltility.writeDataToFile(this.responseResult, this.folder, this.childCategoryFile); parseJSONDramaList(this.responseResult); if (this.numberVideo > 0) { for (int i = 0; i < numberVideoPerPage; i++) { dramaObj = new DramaClass(); dramaObj = listDrama[i]; //string source_image = imgCache.getImage(parentCategoryObj.category_image); string source_image = ""; if (fixCacheImage == true) { //source_image = imgCache.getImage_2(childCategoryObj.category_id); } else //Day la hoan thien nhat tuy nhien can thoi gian de fix data ( cache Image) { source_image = imgCache.getImage(dramaObj.drama_image_path); if (source_image == null || source_image == string.Empty || source_image == "") { source_image = "http"; } } ds.Add(new DramaClass() { drama_image_path = source_image, drama_english_title = dramaObj.drama_english_title, drama_vietnamese_title = dramaObj.drama_vietnamese_title, drama_quantity = dramaObj.drama_quantity, drama_id = dramaObj.drama_id }); } this.lstDrama.ItemsSource = ds; disableProgressBar(); } else { ds.Add(new DramaClass() { drama_image_path = "http", drama_english_title = "Không có dữ liệu", drama_vietnamese_title = "", drama_quantity = "", drama_id = "" }); this.lstDrama.ItemsSource = ds; disableProgressBar(); } } catch (WebException ex) { Debug.WriteLine(ex.Message); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
private void parseJSONDramaList(String jsonDramaList) { try { var dramaListJSONObj = JsonConvert.DeserializeObject <RootDramaClass>(jsonDramaList); if (dramaListJSONObj.success == true || dramaListJSONObj.type == "drama") { this.total_video = Int32.Parse(dramaListJSONObj.total_quantity); listDrama = new List <DramaClass>(); foreach (var obj in dramaListJSONObj.items) { dramaObj = new DramaClass(); dramaObj.drama_id = obj.drama_id; dramaObj.drama_english_title = obj.drama_english_title; dramaObj.drama_image_path = obj.drama_image_path; dramaObj.drama_quantity = "Số tập trong bộ : " + obj.drama_quantity; dramaObj.drama_vietnamese_title = obj.drama_vietnamese_title; listDrama.Add(dramaObj); } this.numberVideoPerPage = Int16.Parse(dramaListJSONObj.quantity); this.numberVideo = Int16.Parse(dramaListJSONObj.total_quantity); } else { dramaObj = new DramaClass(); dramaObj.drama_english_title = "Không có dữ liệu !"; this.numberVideoPerPage = 0; this.numberVideo = 0; } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
private void lstDrama_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { DramaClass dramaObjTemp = (sender as ListBox).SelectedItem as DramaClass; NavigationService.Navigate(new Uri("/List_Video_Follow_Drama.xaml?drama_id=" + dramaObjTemp.drama_id + "&drama_english_title=" + dramaObjTemp.drama_english_title + "&drama_vietnamese_title=" + dramaObjTemp.drama_vietnamese_title + "&drama_image_path=" + dramaObjTemp.drama_image_path + "&drama_quantity=" + dramaObjTemp.drama_quantity, UriKind.Relative)); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }