private void parseJSONChildCategory(String jsonChildCategory) { try { var childCatJSONObj = JsonConvert.DeserializeObject <RootChildCategoryClass>(jsonChildCategory); if (childCatJSONObj.success == true) { foreach (var obj in childCatJSONObj.items) { childCategoryObj = new ChildCategoryClass(); childCategoryObj.category_id = obj.category_id; childCategoryObj.category_name = obj.category_name; childCategoryObj.category_image = obj.category_image; childCategoryObj.number_video_category = "Số lượng :" + obj.number_video_category; listChildCategory.Add(childCategoryObj); } this.numberChildCategories = Int16.Parse(childCatJSONObj.quantity); } else { childCategoryObj = new ChildCategoryClass(); childCategoryObj.category_name = "Không có dữ liệu !"; listChildCategory.Add(childCategoryObj); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
//Phuc vu cho viec Cache Data APIs // private void BindingDataParentCategory_FixData(string subFolder, string subFileName) { try { IsolatedStorageFile File = IsolatedStorageFile.GetUserStoreForApplication(); string sFile = subFolder + "\\" + subFileName; bool fileExist = File.FileExists(sFile); string rawData = ""; if (fileExist == true) { StreamReader reader = new StreamReader(new IsolatedStorageFileStream(sFile, FileMode.Open, File)); rawData = reader.ReadToEnd(); reader.Close(); } parseJSONChildCategory(rawData); ds = new ObservableCollection <ChildCategoryClass>(); ds.Clear(); for (int i = 0; i < numberChildCategories; i++) { childCategoryObj = new ChildCategoryClass(); childCategoryObj = listChildCategory[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 { source_image = imgCache.getImage(childCategoryObj.category_image); } ds.Add(new ChildCategoryClass() { category_image = source_image, category_name = childCategoryObj.category_name, number_video_category = childCategoryObj.number_video_category, category_id = childCategoryObj.category_id }); } this.lstChildCategory.ItemsSource = ds; } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
private void lstChildCategory_SelectionChanged_1(object sender, SelectionChangedEventArgs e) { try { ChildCategoryClass childCategory = (sender as ListBox).SelectedItem as ChildCategoryClass; if (childCategory.category_id == SystemParameter.ID_HD_LIVE_CHILD_CATEGORY || childCategory.category_id == SystemParameter.ID_SD_LIVE_CHILD_CATEGORY || childCategory.category_id == SystemParameter.ID_MOBILE_LIVE_CHILD_CATEGORY) { NavigationService.Navigate(new Uri("/ListChannel_Follow_Child_Category.xaml?child_category_id=" + childCategory.category_id + "&child_category_name=" + childCategory.category_name, UriKind.Relative)); } else if (childCategory.category_id == SystemParameter.ID_DRAMA_CATEGORY) { NavigationService.Navigate(new Uri("/List_Drama_Activity.xaml?child_category_id=" + childCategory.category_id + "&child_category_name=" + childCategory.category_name, UriKind.Relative)); } else { NavigationService.Navigate(new Uri("/List_Video_Follow_Child_Category.xaml?child_category_id=" + childCategory.category_id + "&child_category_name=" + childCategory.category_name, UriKind.Relative)); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
void client_1_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { string data = e.Result; if (this.responseResult.Equals("") || this.responseResult == null) { this.responseResult = data; } /* Ghi du lieu vao File lan dau tien */ if (this.parent_category_id.Equals("13")) { this.childCategoryFile = "music_child_category.json"; } else if (this.parent_category_id.Equals("14")) { this.childCategoryFile = "phim_child_category.json"; } else if (this.parent_category_id.Equals("15")) { this.childCategoryFile = "clip_child_category.json"; } else if (this.parent_category_id.Equals("16")) { this.childCategoryFile = "live_child_category.json"; } else if (this.parent_category_id.Equals("552")) { this.childCategoryFile = "radio_child_category.json"; } else if (this.parent_category_id.Equals("685")) { this.childCategoryFile = "news_child_category.json"; } else { this.childCategoryFile = "child_category.json"; } bool result = tvodUltility.writeDataToFile(this.responseResult, this.folder, this.childCategoryFile); parseJSONChildCategory(this.responseResult); ds.Clear(); for (int i = 0; i < numberChildCategories; i++) { childCategoryObj = new ChildCategoryClass(); childCategoryObj = listChildCategory[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(childCategoryObj.category_image); } ds.Add(new ChildCategoryClass() { category_image = source_image, category_name = childCategoryObj.category_name, number_video_category = childCategoryObj.number_video_category, category_id = childCategoryObj.category_id }); } this.lstChildCategory.ItemsSource = ds; }