/// <summary> /// Retrieves the next element from source. /// </summary> /// <param name="current">Current element</param> /// <returns>The next element from items, if it exists. Otherwise, returns null</returns> public async Task <EntitiesBase.YouTubeVideo> Next(EntitiesBase.YouTubeVideo current) { var data = _storageService.Load <ObservableCollection <EntitiesBase.YouTubeVideo> >("Videos_s5"); if (current == null || !data.Any()) { return(null); } var index = data.IndexOf(current); if (index == -1) { return(null); } if (index != data.Count - 1) { return(data[index + 1]); } var nextPageData = await GetData((int)Math.Ceiling(data.Count / (double)MaxResults)); if (!nextPageData.Any()) { return(null); } return(nextPageData.First()); }
/// <summary> /// Checks if data source has a element before the passed as parameter /// </summary> /// <param name="current">Current element</param> /// <returns>True, if there is a previous element, false if there is not</returns> public bool HasPrevious(EntitiesBase.YouTubeVideo current) { var data = _storageService.Load <ObservableCollection <EntitiesBase.YouTubeVideo> >("Videos_s5"); if (current == null || !data.Any()) { return(false); } return(data.IndexOf(current) > 0); }
/// <summary> /// Checks if data source has a element after the passed as parameter /// </summary> /// <param name="current">Current element</param> /// <returns>True, if there is a next element, false if there is not</returns> public async Task <bool> HasNext(EntitiesBase.YouTubeVideo current) { var data = await GetData(); if (current == null || !data.Any()) { return(false); } return(data.IndexOf(current) < data.Count - 1); }
/// <summary> /// Checks if data source has a element before the passed as parameter /// </summary> /// <param name="current">Current element</param> /// <returns>True, if there is a previous element, false if there is not</returns> public bool HasPrevious(EntitiesBase.YouTubeVideo current) { var data = new List <EntitiesBase.YouTubeVideo>(); if (current == null || !data.Any()) { return(false); } return(data.IndexOf(current) > 0); }
/// <summary> /// Retrieves the next element from source. /// </summary> /// <param name="current">Current element</param> /// <returns>The next element from items, if it exists. Otherwise, returns null</returns> public async Task <EntitiesBase.YouTubeVideo> Next(EntitiesBase.YouTubeVideo current) { var data = await GetData(); if (current == null) { return(data.FirstOrDefault()); } if (data.Any() && data.Last().Equals(current)) { return(null); } return(data[data.IndexOf(current) + 1]); }
/// <summary> /// Retrieves the previous element from source. /// </summary> /// <param name="current">Current element</param> /// <returns>The previous element from items, if it exists. Otherwise, returns null</returns> public EntitiesBase.YouTubeVideo Previous(EntitiesBase.YouTubeVideo current) { var data = new List <EntitiesBase.YouTubeVideo>(); if (current == null) { return(data.FirstOrDefault()); } if (data.Any() && data.First().Equals(current)) { return(null); } return(data[data.IndexOf(current) - 1]); }
/// <summary> /// Retrieves the previous element from source. /// </summary> /// <param name="current">Current element</param> /// <returns>The previous element from items, if it exists. Otherwise, returns null</returns> public EntitiesBase.YouTubeVideo Previous(EntitiesBase.YouTubeVideo current) { var data = _storageService.Load <ObservableCollection <EntitiesBase.YouTubeVideo> >("Videos_s5"); if (current == null || !data.Any()) { return(null); } var index = data.IndexOf(current); if (index == -1 || index == 0) { return(null); } return(data[index - 1]); }
/// <summary> /// Checks if data source has a element after the passed as parameter /// </summary> /// <param name="current">Current element</param> /// <returns>True, if there is a next element, false if there is not</returns> public async Task <bool> HasNext(EntitiesBase.YouTubeVideo current) { var data = _storageService.Load <ObservableCollection <EntitiesBase.YouTubeVideo> >("Videos_s5"); if (current == null || !data.Any()) { return(false); } if (data.IndexOf(current) < data.Count - 1) { return(true); } var nextPageData = await GetData((int)Math.Ceiling(data.Count / (double)MaxResults)); return(nextPageData.Any()); }