diff --git a/Aria2Fast/Service/Model/MikanModel.cs b/Aria2Fast/Service/Model/MikanModel.cs index fcf9697..84e7a50 100644 --- a/Aria2Fast/Service/Model/MikanModel.cs +++ b/Aria2Fast/Service/Model/MikanModel.cs @@ -117,6 +117,9 @@ public class MikanAnimeRss : BaseNotificationModel private List _items { get; set; } + private bool _isUpdateToday; + private int _episode = 0; + private string _updateTime; public List Items { @@ -131,10 +134,15 @@ public List Items { _episode = e; } + + _isUpdateToday = TimeHelper.IsUpdateToday(item.Updated, +8); ; + _updateTime = TimeHelper.FormatTimeAgo(item.Updated, +8); } } } + + public string ShowEpisode { get @@ -147,13 +155,9 @@ public string ShowEpisode } return text; - // text += $" 总{Items.Count}"; } } - - private int _episode = 0; - //TODO 当前集数 public int Episode { @@ -169,15 +173,7 @@ public string UpdateTime { get { - var item = Items.FirstOrDefault(); - if (item != null) - { - - string result = TimeHelper.FormatTimeAgo(item.Updated, +8); - - return result; - } - return string.Empty; + return _updateTime; } } @@ -185,12 +181,7 @@ public bool IsUpdateToday { get { - var item = Items.FirstOrDefault(); - if (item != null) - { - return TimeHelper.IsUpdateToday(item.Updated, +8); ; - } - return false; + return _isUpdateToday; } } diff --git a/Aria2Fast/Utils/ImageCacheUtils.cs b/Aria2Fast/Utils/ImageCacheUtils.cs index fe7aea5..3bc1f83 100644 --- a/Aria2Fast/Utils/ImageCacheUtils.cs +++ b/Aria2Fast/Utils/ImageCacheUtils.cs @@ -35,11 +35,8 @@ await Task.Run(() => { bitmap.UriSource = new Uri(file); bitmap.EndInit(); - // 这一步很重要,它标记了图片的缓存行为,当图片加载完毕后,它会被保留在内存中 bitmap.Freeze(); - //var img = new BitmapImage(new Uri(file)); - //img.CacheOption = BitmapCacheOption.OnLoad; cache.Set(cacheKey, bitmap, new CacheItemPolicy()); Debug.WriteLine($"[缓存]{cacheKey}"); @@ -57,13 +54,14 @@ await Task.Run(() => { /// public static BitmapImage GetImageWithLocalCache(Uri uri) { - //MemoryCache cache = MemoryCache.Default; + MemoryCache cache = MemoryCache.Default; var fileName = Path.GetFileName(uri.LocalPath); - //if (cache.Contains(fileName)) - //{ - // var bmp = (BitmapImage)cache.Get(fileName); - // return bmp; - //} + if (cache.Contains(fileName)) + { + var bmp = (BitmapImage)cache.Get(fileName); + //bmp.Freeze(); + return bmp; + } var dirPath = Path.Combine(Directory.GetCurrentDirectory(), "ImageCached"); if (!Directory.Exists(dirPath)) @@ -94,7 +92,7 @@ public static BitmapImage GetImageWithLocalCache(Uri uri) } img.CacheOption = BitmapCacheOption.OnLoad; img.EndInit(); - + img.Freeze(); return img; } diff --git a/Aria2Fast/View/AnimeListView.xaml b/Aria2Fast/View/AnimeListView.xaml index 204ba64..206a54d 100644 --- a/Aria2Fast/View/AnimeListView.xaml +++ b/Aria2Fast/View/AnimeListView.xaml @@ -54,9 +54,15 @@ Margin="0,45,0,0" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" - ItemsSource="{Binding Master.AnimeDays}" /> - - - + ItemsSource="{Binding Master.AnimeDays, IsAsync=True}"> + + + + + + + + + diff --git a/Aria2Fast/View/MikanAnimeDayControl.xaml b/Aria2Fast/View/MikanAnimeDayControl.xaml index f2cf6f8..6b41cfc 100644 --- a/Aria2Fast/View/MikanAnimeDayControl.xaml +++ b/Aria2Fast/View/MikanAnimeDayControl.xaml @@ -59,7 +59,7 @@ Height="200" Opacity="0" RenderOptions.BitmapScalingMode="HighQuality" - Source="{Binding ImageCache}" + Source="{Binding ImageCache, IsAsync=True}" Stretch="UniformToFill">