private async Task CreateCategoryItem(ImageMetaData imageMetaData) { Func<Task<IBitmap>> lazyImageFactory = () => downloadManager.DownloadImage(imageMetaData.imageThumbnail); var category = new CategoryItem(imageMetaData.imageUrl, imageMetaData.Category, lazyImageFactory); CategoryItems.Add(category); await category.LoadImage(); }
private async Task GetTop4WallPaperItems() { var rssForFeed = await _rssReader.GetFeed(_themes.Top4.FeedUrl); var imageMetaData = _rssReader.GetImageMetaData(rssForFeed); var taskList = new List<Task>(); foreach (var imd in imageMetaData) { SetupLiveTile(imd.GetResizedImageUrl()); Func<Task<IBitmap>> lazyImageFactory = () => _downloadManager.DownloadImage(imd.imageThumbnail); var categoryItem = new CategoryItem(imd.imageUrl ,imd.Category, lazyImageFactory); Top4Items.Add(categoryItem); taskList.Add(categoryItem.LoadImage()); } await Task.WhenAll(taskList); }
private async Task GetCategory(Theme theme) { Func<Task<IBitmap>> lazyImageFactory = async () => { var feed = await _rssReader.GetFeed(theme.FeedUrl); var firstImageFromFeed = _rssReader.GetFirstImageMetaData(feed); firstImageFromFeed.Category = theme.Name; return await _downloadManager.DownloadImage(firstImageFromFeed.imageThumbnail); }; var categoryItem = new CategoryItem(theme.FeedUrl, theme.Name, lazyImageFactory); CategoryItems.Add(categoryItem); await categoryItem.LoadImage(); }
private async Task GetTop4WallPaperItems() { rss rssForFeed = null; try { rssForFeed = await _rssReader.GetFeed(_themes.Top4.FeedUrl); var imageMetaData = _rssReader.GetImageMetaData(rssForFeed); var taskList = new List<Task>(); foreach (var imd in imageMetaData.Skip(0).Take(2)) { Func<Task<IBitmap>> lazyImageFactory = () => _downloadManager.DownloadImage(imd.imageThumbnail); var categoryItem = new CategoryItem(imd.imageUrl, imd.Category, lazyImageFactory); Top2Items.Add(categoryItem); taskList.Add(categoryItem.LoadImage()); } foreach (var imd in imageMetaData.Skip(2).Take(2)) { Func<Task<IBitmap>> lazyImageFactory = () => _downloadManager.DownloadImage(imd.imageThumbnail); var categoryItem = new CategoryItem(imd.imageUrl, imd.Category, lazyImageFactory); Bottom2Items.Add(categoryItem); taskList.Add(categoryItem.LoadImage()); } await Task.WhenAll(taskList); } catch (Exception ) { } }