private void GetTags(int page = 1) { Task.Factory.StartNew(() => { using (LoadingIndicatorService.EnterLoadingBlock()) { using (var session = new EightTracksSession(EightTracksModule.ApiKey)) { session.SetHttpClientMaxResponseContentBufferSize(OneMegaByte); var response = session.Query <Tags>().Execute( page: page); if (response != null) { if (!response.NextPage.IsNull) { _nextTagPage = response.NextPage.Number; } else { _nextTagPage = null; } if (!response.PreviousPage.IsNull) { _previousTagPage = response.PreviousPage.Number; } else { _previousTagPage = null; } return(response.Tags); } } } return(null); }) .ContinueWith(t => { _tags.Clear(); foreach (var tag in t.Result) { _tags.Add(tag); } RefreshCommands(); }, _ui); }
private void GetMixes(int page = 1, string filter = null) { Task.Factory.StartNew(() => { using (LoadingIndicatorService.EnterLoadingBlock()) { using (var session = new EightTracksSession(EightTracksModule.ApiKey)) { session.SetHttpClientMaxResponseContentBufferSize(OneMegaByte); var response = session.Query <Mixes>().GetMix( sorting: global::EightTracks.Mixes.Sort.Popular, filter: filter, page: page, resultsPerPage: 25); if (response != null) { _currentMixPage = response.Page; _numberOfMixPages = response.TotalPages; return(response.Mixes); } } } return(null); }) .ContinueWith(t => { RefreshCommands(); if (t.Exception != null) { ToastService.Show(t.Exception.Message); Logger.Log(t.Exception.ToString(), Category.Exception, Priority.Medium); return; } if (t.Result != null) { _mixes.Clear(); foreach (var mix in t.Result) { _mixes.Add(mix); } } }, _ui); }
private void SearchForMixes(string text, string type) { _tagFilterList.Clear(); if (type == "Tag") { _tagFilterList.Add(text); } var ui = TaskScheduler.FromCurrentSynchronizationContext(); Task.Factory.StartNew(() => { using (LoadingIndicatorService.EnterLoadingBlock()) { using (var session = new EightTracksSession(EightTracksModule.ApiKey)) { session.SetHttpClientMaxResponseContentBufferSize(OneMegaByte); if (type == "Tag") { var response = session.Query<Mixes>().GetMix(tag: text); _currentPage = response.Page; _numberOfPages = response.TotalPages; return response.Mixes; } else { var response = session.Query<Mixes>().GetMix(filter: text); _currentPage = response.Page; _numberOfPages = response.TotalPages; return response.Mixes; } } } }) .ContinueWith(t => { GoToNextPageCommand.NotifyCanExecuteChanged(); GoToPreviousPageCommand.NotifyCanExecuteChanged(); _tags.Clear(); foreach (var mix in t.Result) { foreach (var tag in mix.TagListCacheAsArray) { var value = tag.Trim(); if (!_tags.Contains(value) && !_tagFilterList.Contains(value)) { _tags.Add(value); } } } _mixes.Clear(); foreach (var mix in t.Result) { _mixes.Add(mix); } }, ui); }
private void SearchForRecentMixes() { var ui = TaskScheduler.FromCurrentSynchronizationContext(); Task.Factory.StartNew(() => { using (LoadingIndicatorService.EnterLoadingBlock()) { using (var session = new EightTracksSession(EightTracksModule.ApiKey)) { session.SetHttpClientMaxResponseContentBufferSize(OneMegaByte); var response = session.Query<Mixes>().GetMix( sorting: global::EightTracks.Mixes.Sort.Random, resultsPerPage: 25); _currentPage = response.Page; _numberOfPages = response.TotalPages; return response.Mixes; } } }) .ContinueWith(t => { GoToNextPageCommand.NotifyCanExecuteChanged(); GoToPreviousPageCommand.NotifyCanExecuteChanged(); if (t.Exception != null) { Logger.Log("Error while fetching mixes: " + t.Exception, Category.Exception, Priority.Medium); ToastService.Show("An error occurred while getting mixes"); } else { _tags.Clear(); if (t.Result == null) { return; } foreach (var mix in t.Result) { foreach (var tag in mix.TagListCacheAsArray) { var value = tag.Trim(); if (!_tags.Contains(value) && !_tagFilterList.Contains(value)) { _tags.Add(value); } } } if (!t.Result.Any()) { ToastService.Show("No results found"); return; } _mixes.Clear(); foreach (var mix in t.Result) { _mixes.Add(mix); } } }, ui); }
private void SearchForMixes(string text, string type) { _tagFilterList.Clear(); if (type == "Tag") { _tagFilterList.Add(text); } var ui = TaskScheduler.FromCurrentSynchronizationContext(); Task.Factory.StartNew(() => { using (LoadingIndicatorService.EnterLoadingBlock()) { using (var session = new EightTracksSession(EightTracksModule.ApiKey)) { session.SetHttpClientMaxResponseContentBufferSize(OneMegaByte); if (type == "Tag") { var response = session.Query <Mixes>().GetMix(tag: text); _currentPage = response.Page; _numberOfPages = response.TotalPages; return(response.Mixes); } else { var response = session.Query <Mixes>().GetMix(filter: text); _currentPage = response.Page; _numberOfPages = response.TotalPages; return(response.Mixes); } } } }) .ContinueWith(t => { GoToNextPageCommand.NotifyCanExecuteChanged(); GoToPreviousPageCommand.NotifyCanExecuteChanged(); _tags.Clear(); foreach (var mix in t.Result) { foreach (var tag in mix.TagListCacheAsArray) { var value = tag.Trim(); if (!_tags.Contains(value) && !_tagFilterList.Contains(value)) { _tags.Add(value); } } } _mixes.Clear(); foreach (var mix in t.Result) { _mixes.Add(mix); } }, ui); }
private void SearchForRecentMixes() { var ui = TaskScheduler.FromCurrentSynchronizationContext(); Task.Factory.StartNew(() => { using (LoadingIndicatorService.EnterLoadingBlock()) { using (var session = new EightTracksSession(EightTracksModule.ApiKey)) { session.SetHttpClientMaxResponseContentBufferSize(OneMegaByte); var response = session.Query <Mixes>().GetMix( sorting: global::EightTracks.Mixes.Sort.Random, resultsPerPage: 25); _currentPage = response.Page; _numberOfPages = response.TotalPages; return(response.Mixes); } } }) .ContinueWith(t => { GoToNextPageCommand.NotifyCanExecuteChanged(); GoToPreviousPageCommand.NotifyCanExecuteChanged(); if (t.Exception != null) { Logger.Log("Error while fetching mixes: " + t.Exception, Category.Exception, Priority.Medium); ToastService.Show("An error occurred while getting mixes"); } else { _tags.Clear(); if (t.Result == null) { return; } foreach (var mix in t.Result) { foreach (var tag in mix.TagListCacheAsArray) { var value = tag.Trim(); if (!_tags.Contains(value) && !_tagFilterList.Contains(value)) { _tags.Add(value); } } } if (!t.Result.Any()) { ToastService.Show("No results found"); return; } _mixes.Clear(); foreach (var mix in t.Result) { _mixes.Add(mix); } } }, ui); }
protected virtual void SearchForMixes(Mixes.Sort sortType, int page = 1) { Task.Factory.StartNew(() => { using (LoadingIndicatorService.EnterLoadingBlock()) { using (var session = new EightTracksSession(EightTracksModule.ApiKey)) { session.SetHttpClientMaxResponseContentBufferSize(OneMegaByte); var response = session.Query <Mixes>().GetMix( sorting: sortType, filter: String.Join("+", TagFilterList), page: page, resultsPerPage: 25); if (response != null) { _currentPage = response.Page; _numberOfPages = response.TotalPages; return(response.Mixes); } } } return(null); }) .ContinueWith(t => { GoToNextPageCommand.NotifyCanExecuteChanged(); GoToPreviousPageCommand.NotifyCanExecuteChanged(); if (t.Exception != null) { ToastService.Show(t.Exception.Message); Logger.Log(t.Exception.ToString(), Category.Exception, Priority.Medium); return; } if (t.Result != null) { _tags.Clear(); foreach (var mix in t.Result) { foreach (var tag in mix.TagListCacheAsArray) { var value = tag.Trim(); if (!_tags.Contains(value) && !_tagFilterList.Contains(value)) { _tags.Add(value); } } } if (!t.Result.Any() && SortType != global::EightTracks.Mixes.Sort.Random) { ToastService.Show("No results found"); return; } _mixes.Clear(); foreach (var mix in t.Result) { _mixes.Add(mix); } } else { // TODO : Notify user } }, _ui); }