Exemplo n.º 1
0
        private async Task InitializeCoverAsync()
        {
            CoverVisible = false;
            Cover        = null;
            if (!HasCover)
            {
                coverNotificationOption = CoverNotificationOption.NO_COVER;
                UpdateCoverNotification();
                IsCoverNotificationVisible = true;
            }
            else
            {
                byte[] coverByteArray = MainModel.CoverCache.TryGetCoverFromCache(Md5Hash);
                if (coverByteArray != null)
                {
                    ShowCover(coverByteArray);
                }
                else if (coverMirrorName == null)
                {
                    coverNotificationOption = CoverNotificationOption.NO_COVER_MIRROR;
                    UpdateCoverNotification();
                    IsCoverNotificationVisible = true;
                }
                else
                {
                    if (IsInOfflineMode)
                    {
                        coverNotificationOption = CoverNotificationOption.NO_COVER_DUE_TO_OFFLINE_MODE;
                        UpdateCoverNotification();
                        IsCoverNotificationVisible = true;
                    }
                    else
                    {
                        string coverUrl = GenerateCoverUrl(MainModel.Mirrors[coverMirrorName]);
                        coverNotificationOption = CoverNotificationOption.COVER_IS_LOADING;
                        UpdateCoverNotification();
                        IsCoverNotificationVisible = true;
                        try
                        {
                            coverByteArray = await MainModel.CoverCache.GetCoverAsync(Md5Hash, coverUrl);

                            ShowCover(coverByteArray);
                        }
                        catch (Exception exception)
                        {
                            Logger.Exception(exception);
                            coverNotificationOption = CoverNotificationOption.COVER_LOADING_ERROR;
                            UpdateCoverNotification();
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private async Task InitializeCoverAsync()
        {
            CoverVisible = false;
            Cover        = null;
            if (!HasCover)
            {
                coverNotificationOption = CoverNotificationOption.NO_COVER;
                UpdateCoverNotification();
                IsCoverNotificationVisible = true;
            }
            else
            {
                if (coverMirrorName == null)
                {
                    coverNotificationOption = CoverNotificationOption.NO_COVER_MIRROR;
                    UpdateCoverNotification();
                    IsCoverNotificationVisible = true;
                }
                else
                {
                    if (IsInOfflineMode)
                    {
                        coverNotificationOption = CoverNotificationOption.NO_COVER_DUE_TO_OFFLINE_MODE;
                        UpdateCoverNotification();
                        IsCoverNotificationVisible = true;
                    }
                    else
                    {
                        string coverUrl = GenerateCoverUrl(MainModel.Mirrors[coverMirrorName]);
                        coverNotificationOption = CoverNotificationOption.COVER_IS_LOADING;
                        UpdateCoverNotification();
                        IsCoverNotificationVisible = true;
                        try
                        {
                            Cover = await LoadCoverAsync(coverUrl);

                            CoverVisible            = true;
                            coverNotificationOption = CoverNotificationOption.NO_NOTIFICATION;
                            UpdateCoverNotification();
                            IsCoverNotificationVisible = false;
                        }
                        catch (Exception exception)
                        {
                            Logger.Exception(exception);
                            coverNotificationOption = CoverNotificationOption.COVER_LOADING_ERROR;
                            UpdateCoverNotification();
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
 private void ShowCover(byte[] coverByteArray)
 {
     try
     {
         Cover                   = ConvertCoverByteArrayToBitmapImage(coverByteArray);
         CoverVisible            = true;
         coverNotificationOption = CoverNotificationOption.NO_NOTIFICATION;
         UpdateCoverNotification();
         IsCoverNotificationVisible = false;
     }
     catch (Exception exception)
     {
         Logger.Exception(exception);
         coverNotificationOption = CoverNotificationOption.COVER_LOADING_ERROR;
         UpdateCoverNotification();
     }
 }