protected override async Task <IAsyncEnumerable <VideoInfoControlViewModel> > GetPagedItemsImpl(int start, int count) { var rawPage = ((start) / 30); var page = rawPage + 1; var res = _ResList.ElementAtOrDefault(rawPage); if (res == null) { try { res = await ContentFinder.GetUserVideos(UserId, (uint)page); } catch { return(AsyncEnumerable.Empty <VideoInfoControlViewModel>()); } _ResList.Add(res); } var head = start - rawPage * 30; var items = res.Items.Skip(head).Take(count); return(items.Select(x => { var vm = new VideoInfoControlViewModel(x.VideoId, isNgEnabled: false); vm.SetupDisplay(x); return vm; }) .ToAsyncEnumerable()); }
protected override async Task <IEnumerable <NicoVideo> > PreloadNicoVideo(int start, int count) { var rawPage = ((start) / 30); var page = rawPage + 1; var res = _ResList.ElementAtOrDefault(rawPage); if (res == null) { try { res = await ContentFinder.GetUserVideos(UserId, (uint)page); } catch { return(Enumerable.Empty <NicoVideo>()); } _ResList.Add(res); } var head = start - rawPage * 30; var items = res.Items.Skip(head).Take(count); List <NicoVideo> videos = new List <NicoVideo>(); foreach (var item in items) { var nicoVideo = await HohoemaApp.MediaManager.GetNicoVideoAsync(item.VideoId, withInitialize : false); nicoVideo.PreSetTitle(item.Title); nicoVideo.PreSetThumbnailUrl(item.ThumbnailUrl.AbsoluteUri); nicoVideo.PreSetVideoLength(item.Length); videos.Add(nicoVideo); } return(videos); }