コード例 #1
0
ファイル: MainViewModel.cs プロジェクト: yakuz-a/Airstem
        private async Task LoadWhatsNewData()
        {
            if (!App.Locator.Network.IsActive)
            {
                WhatsNewMessage = Core.StringMessage.NoInternetConnection;
                return;
            }

            IsLoading = true;

            if (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily != "Windows.Mobile")
            {
                countToLoad = 10;
            }

            try
            {
                await LoadDataForAlbumAndTracks(countToLoad);

                var _lastArtist = await _scroble.GetTopArtistsAsync(limit : 5);

                if (_lastArtist != null && _lastArtist.Artists != null && _lastArtist.Artists.Count > 0)
                {
                    TopArtists = _lastArtist.Artists;
                }

                if (_lastArtist != null)
                {
                    _lastArtist = null;
                }

                loadedCount++;
            }
            catch (Exception)
            {
                WhatsNewMessage = Core.StringMessage.SomethinWentWrong;
            }

            if (loadedCount == 4 && TopArtists != null)
            {
                WhatsNewMessage = Core.StringMessage.NoMessge;
            }
            else
            {
                WhatsNewMessage = Core.StringMessage.EmptyMessage;
            }

            IsLoading = false;
        }
コード例 #2
0
ファイル: MainViewModel.cs プロジェクト: yongjan/Audiotica
        public async Task LoadChartDataAsync()
        {
            IsSliderLoading   = true;
            IsFeaturedLoading = true;
            IsNewLoading      = true;

            var rnd = new Random(DateTime.Now.Millisecond);

            try
            {
                var page = rnd.Next(1, 25);
                SpotlightItems = (await _service.GetTopArtistsAsync(page, 10)).Content.ToList();
            }
            catch (Exception e)
            {
                ShowNetworkError(e);
            }
            finally
            {
                IsSliderLoading = false;
            }

            try
            {
                var page = rnd.Next(1, 25);
                TopTracks = (await _service.GetTopTracksAsync(page, 10)).Content.ToList();
            }
            catch (Exception e)
            {
                ShowNetworkError(e);
            }
            finally
            {
                IsFeaturedLoading = false;
            }
            try
            {
                // NewAlbums = (await _service.GetNewAlbums()).Items;
            }
            catch (Exception e)
            {
                ShowNetworkError(e);
            }
            finally
            {
                IsNewLoading = false;
            }
        }
コード例 #3
0
        private async void LoadSpotlight()
        {
            AudioticaSpotlight spotlight = null;

            try
            {
                spotlight = await _audioticaService.GetSpotlightAsync();
            }
            catch
            {
                // ignored
            }

            PageResponse <LastArtist> topArtist = null;

            try
            {
                topArtist = await _service.GetTopArtistsAsync(limit : 10);
            }
            catch
            {
                // ignored
            }

            LargeFeatures  = new ObservableCollection <SpotlightFeature>();
            MediumFeatures = new ObservableCollection <SpotlightFeature>();

            if (spotlight != null)
            {
                if (spotlight.LargeFeatures != null)
                {
                    foreach (
                        var spotlightFeature in spotlight.LargeFeatures.Where(p => ShouldShow(p.ShowTo, p.ShowToNot)))
                    {
                        LargeFeatures.Add(spotlightFeature);
                    }
                }

                if (spotlight.MediumFeatures != null)
                {
                    foreach (
                        var spotlightFeature in
                        spotlight.MediumFeatures.Where(p => p.InsertAtTop && ShouldShow(p.ShowTo, p.ShowToNot)))
                    {
                        MediumFeatures.Add(spotlightFeature);
                    }
                }
            }

            if (topArtist != null && topArtist.Content != null)
            {
                foreach (var lastArtist in topArtist.Content)
                {
                    MediumFeatures.Add(
                        new SpotlightFeature
                    {
                        Title    = lastArtist.Name,
                        Text     = string.Format("{0:#,###} plays", lastArtist.PlayCount),
                        ImageUri = lastArtist.MainImage.Largest.AbsoluteUri,
                        Action   = "artist:" + lastArtist.Name
                    });
                }
            }

            if (spotlight != null && spotlight.MediumFeatures != null)
            {
                foreach (
                    var spotlightFeature in
                    spotlight.MediumFeatures.Where(p => !p.InsertAtTop && ShouldShow(p.ShowTo, p.ShowToNot)))
                {
                    MediumFeatures.Add(spotlightFeature);
                }
            }
            if (spotlight != null || topArtist != null)
            {
                MessengerInstance.Send(true, "spotlight");
            }
        }