public static async Task <FavViewModel> CreateAsync(BiliFav fav) { var model = new FavViewModel() { Title = fav.Title, Id = fav.Id }; var list = new ObservableCollection <FavVideoViewModel>(); foreach (var video in fav.VideoList) { list.Add(await FavVideoViewModel.CreateAsync(video.Title, video.Bv, video.Picture)); } list.Add(new FavVideoViewModel() { Bv = "加载更多", Title = "加载更多", CoverImg = new BitmapImage(new Uri("ms-appx:///Assets/LoadMore.png")) }); model.VideoList = list; return(model); }
public async Task GetMoreVideoAsync(XamlRoot xamlRoot) { var count = this.VideoList.Count - 1; if ((count < 20) || (count % 20 != 0)) { var dialog = new ErrorDialog("已经没有更多了", xamlRoot) { PrimaryButtonText = "" }; await dialog.ShowAsync(); return; } var fav = await BiliFavHelper.GetBiliFavAsync(this.Id, (count / 20) + 1, UserPage.SESSDATA); if (fav == null) { var dialog = new ErrorDialog("已经没有更多了", xamlRoot) { PrimaryButtonText = "" }; await dialog.ShowAsync(); return; } var list = new List <FavVideoViewModel>(); foreach (var video in fav.VideoList) { list.Add(await FavVideoViewModel.CreateAsync(video.Title, video.Bv, video.Picture)); } this.VideoList.Remove(this.VideoList.TakeLast(1).Single()); list.ForEach(v => this.VideoList.Add(v)); this.VideoList.Add(new FavVideoViewModel() { Bv = "加载更多", Title = "加载更多", CoverImg = new BitmapImage(new Uri("ms-appx:///Assets/LoadMore.png")) }); }
public static async Task <FavVideoViewModel> CreateAsync(string title, string bv, string coverUrl) { var model = new FavVideoViewModel(); model.Title = title; model.Bv = bv; try { var imgSource = new BitmapImage(new Uri(coverUrl)); model.CoverImg = imgSource; } catch (System.Exception ex)//封面下载不了的异常 { model.CoverImg = new BitmapImage(new Uri("ms-appx:///Assets/LockScreenLogo.scale-200.png")); } return(model); }