private void AppendContent(string storageName) { //DateTime trackLoadingTime = DateTime.Now; var channelItem = MiscHelpers.GetChannelItemFromIsolatedStorage(storageName + ".xml"); //ToDo: Add case if file not exsit, then fetch manually //... //ToDO: Check null if (channelItem == null) return; if ("search".Equals(_categoryName)) { HeaderBox.Text = channelItem.FeedTitle; defaultPhoto = "http://s2.googleusercontent.com/s2/favicons?domain=" + channelItem.FeedLink; //HeaderIcon.Source = new BitmapImage(new Uri(icon, UriKind.RelativeOrAbsolute)); } else if ("favourite".Equals(_categoryName) || "savelater".Equals(_categoryName) || "historicalview".Equals(_categoryName)) { defaultPhoto = "http://s2.googleusercontent.com/s2/favicons?domain=" + channelItem.FeedLink; //HeaderIcon.Source = new BitmapImage(new Uri(icon, UriKind.RelativeOrAbsolute)); } //Change add icon to remove icon if true if (storageName.Contains("fbd-channel-")) { var homeTileList = MiscHelpers.GetItemFromIsolatedStorage<List<PinTile>>("fbd-pintiles.xml"); var decodedStorageName = HttpUtility.UrlDecode(storageName); var existingHomeTile = GeneralHelper.GetHomeTile(decodedStorageName, homeTileList); if (existingHomeTile != null) { var button = (ApplicationBarIconButton)ApplicationBar.Buttons[1]; button.IconUri = new Uri("/Images/General/AppBar/btn_unsubscibe_w.png", UriKind.RelativeOrAbsolute); _isSubscribed = true; } } if (HomePagePinTiles.IsFull() && _isSubscribed == false) { var button = (ApplicationBarIconButton)ApplicationBar.Buttons[1]; button.IsEnabled = false; } _numOfNewNewsItem = channelItem.NumOfNewNewsItems; //var defaultPhoto = _cf[_categoryName]["photo_default"]; var newsList = channelItem.NewsItems; if (newsList != null && newsList.Count > 0) { //_firstItem = newsList[0]; var favouriteChannelItem = MiscHelpers.GetChannelItemFromIsolatedStorage("fbd-favorites.xml"); var readLaterChannelItem = MiscHelpers.GetChannelItemFromIsolatedStorage("fbd-readlater.xml"); var newsItems = new ObservableCollection<DataModel.UIContextItem>(); if ("historicalview".Equals(_categoryName)) { newsList.Reverse(); } foreach (var newsItem in newsList) { //Set 1st-item for bookmark/pin if item contains image if (_firstItem == null && newsItem.NewsImages != null && newsItem.NewsImages.Count > 0 && newsItem.NewsImages[0] != null) { _firstItem = newsItem; } var uItem = MiscHelpers.CreateUINewsItem(newsItem); uItem.ImageFavourite = _m.IsNewsItemInList(favouriteChannelItem, uItem.Tag.ToString()) ? _m.imageFavouriteOn : _m.imageFavouriteOff; uItem.ImageReadLater = _m.IsNewsItemInList(readLaterChannelItem, uItem.Tag.ToString()) ? _m.imageReadLaterOn : _m.imageReadLaterOff; //uItem.BackgroundColor = (uItem.IsNew) // ? new SolidColorBrush(Colors.Yellow) // : new SolidColorBrush(Colors.Transparent); if (newsItem.NewsImages != null && newsItem.NewsImages.Count > 0 && newsItem.NewsImages[0] != null) { Analytics.GetInstance().TrackHasImage("newslist-hasImageYes", "y"); var imageB = new BitmapImage(new Uri(newsItem.NewsImages[0], UriKind.Absolute)) { CreateOptions = BitmapCreateOptions.BackgroundCreation }; imageB.ImageOpened += delegate { uItem.NewsImageSource = imageB; }; } else { Analytics.GetInstance().TrackHasImage("newslist-hasImageNo", "n"); } var image = new BitmapImage(new Uri(defaultPhoto, UriKind.RelativeOrAbsolute)); uItem.NewsImageSource = image; newsItems.Add(uItem); } if (_firstItem == null) { _firstItem = newsList[0]; } NewsListBox.ItemsSource = newsItems; if (_adsTimer != null) { _adsTimer.Stop(); } } else { //ToDo: Handle empty list } //Analytics.GetInstance().TrackLoadingTime("NewsList-AppendContent", trackLoadingTime); }
private void AppendCategoryContent(string storageName) { //DateTime trackLoadingTime = DateTime.Now; var categoryItem = MiscHelpers.GetCatergoryItemFromIsolatedStorage(storageName + ".xml"); //ToDo: Add case if file not exsit, then fetch manually if (categoryItem == null) return; //var defaultPhoto = _cf[_categoryName]["photo_default"]; var channelList = categoryItem.ChannelItems; if (channelList != null && channelList.Count > 0) { //_firstItem = channelList[0].NewsItems[0]; if ("search".Equals(_categoryName)) { HeaderBox.Text = channelList[0].FeedTitle; defaultPhoto = "http://s2.googleusercontent.com/s2/favicons?domain=" + channelList[0].FeedLink; //HeaderIcon.Source = new BitmapImage(new Uri(icon, UriKind.RelativeOrAbsolute)); } else if ("favourite".Equals(_categoryName) || "savelater".Equals(_categoryName) || "historicalview".Equals(_categoryName)) { defaultPhoto = "http://s2.googleusercontent.com/s2/favicons?domain=" + channelList[0].FeedLink; //HeaderIcon.Source = new BitmapImage(new Uri(icon, UriKind.RelativeOrAbsolute)); } var favouriteChannelItem = MiscHelpers.GetChannelItemFromIsolatedStorage("fbd-favorites.xml"); var readLaterChannelItem = MiscHelpers.GetChannelItemFromIsolatedStorage("fbd-readlater.xml"); //var newsItems = new ObservableCollection<DataModel.UIContextItem>(); DataModel.ContextItem tempFirstItem = null; foreach (var item in channelList) { if (item.NewsItems != null && item.NewsItems.Count > 0) { if (giantCategoryitem != null) { giantCategoryitem.ChannelItems.Add(item); } Dispatcher.BeginInvoke(() => { DataModel.NewsItem newsItem = item.NewsItems[0]; //Set 1st-item for bookmark/pin if item contains image if (_firstItem == null && newsItem.NewsImages != null && newsItem.NewsImages.Count > 0 && newsItem.NewsImages[0] != null) { _firstItem = newsItem; } tempFirstItem = newsItem; var uItem = MiscHelpers.CreateUINewsItem(newsItem); uItem.ImageFavourite = _m.IsNewsItemInList(favouriteChannelItem, uItem.Tag.ToString()) ? _m.imageFavouriteOn : _m.imageFavouriteOff; uItem.ImageReadLater = _m.IsNewsItemInList(readLaterChannelItem, uItem.Tag.ToString()) ? _m.imageReadLaterOn : _m.imageReadLaterOff; if (item.NewsImages != null && item.NewsImages.Count > 0 && item.NewsImages[0] != null) { Analytics.GetInstance().TrackHasImage("newslist-hasImageYes", "y"); var imageB = new BitmapImage(new Uri(item.NewsImages[0], UriKind.Absolute)) { CreateOptions = BitmapCreateOptions.BackgroundCreation }; imageB.ImageOpened += delegate { uItem.NewsImageSource = imageB; }; } else { Analytics.GetInstance().TrackHasImage("newslist-hasImageNo", "n"); } var image = new BitmapImage(new Uri(defaultPhoto, UriKind.RelativeOrAbsolute)); uItem.NewsImageSource = image; _ctgyNewsItems.Add(uItem); }); } } if (_firstItem == null) { _firstItem = tempFirstItem; } //NewsListBox.ItemsSource = _ctgyNewsItems; } else { //ToDo: Handle empty list } if (giantCategoryitem != null) { MiscHelpers.SaveDataToIsolatedStorage("fbd-giant.xml", giantCategoryitem, typeof (DataModel.CategoryItem), FileMode.Create); } //Analytics.GetInstance().TrackLoadingTime("NewsList-AppendCategoryContent", trackLoadingTime); }