diff --git a/Pixiview/Illust/FavoritesPage.xaml.cs b/Pixiview/Illust/FavoritesPage.xaml.cs index a77bd32..09b830d 100644 --- a/Pixiview/Illust/FavoritesPage.xaml.cs +++ b/Pixiview/Illust/FavoritesPage.xaml.cs @@ -80,7 +80,7 @@ namespace Pixiview.Illust { return; } - await scrollView.ScrollToAsync(0, -topOffset, true); + await ScrollToTopAsync(scrollView); flag = false; lastUpdated = default; StartLoad(true); diff --git a/Pixiview/Illust/IllustCollectionPage.cs b/Pixiview/Illust/IllustCollectionPage.cs index 87a3114..0e233a9 100644 --- a/Pixiview/Illust/IllustCollectionPage.cs +++ b/Pixiview/Illust/IllustCollectionPage.cs @@ -185,6 +185,16 @@ namespace Pixiview.Illust return collection; } + protected void InvalidateCollection() + { + var collection = IllustCollection; + if (collection != null) + { + collection.Running = false; + IllustCollection = null; + } + } + protected virtual void StartLoad(bool force = false, bool isBottom = false) { if (force || lastUpdated != LastUpdated) @@ -200,6 +210,7 @@ namespace Pixiview.Illust } else { + InvalidateCollection(); IsLoading = true; } #if __IOS__ @@ -222,6 +233,7 @@ namespace Pixiview.Illust } else { + InvalidateCollection(); IsLoading = true; } indicator.Animate("margin", top => @@ -282,6 +294,14 @@ namespace Pixiview.Illust } } + protected async Task ScrollToTopAsync(ScrollView scrollView) + { + if (scrollView.ScrollY > -topOffset) + { + await scrollView.ScrollToAsync(0, -topOffset, true); + } + } + protected DataTemplate GetCardViewTemplate(bool hideUser = false) { return new DataTemplate(() => diff --git a/Pixiview/Illust/MainPage.xaml.cs b/Pixiview/Illust/MainPage.xaml.cs index 6bbe48b..bf1d31f 100644 --- a/Pixiview/Illust/MainPage.xaml.cs +++ b/Pixiview/Illust/MainPage.xaml.cs @@ -59,7 +59,7 @@ namespace Pixiview.Illust { return; } - await scrollView.ScrollToAsync(0, -topOffset, true); + await ScrollToTopAsync(scrollView); StartLoad(true); } diff --git a/Pixiview/Illust/RankingPage.xaml.cs b/Pixiview/Illust/RankingPage.xaml.cs index 626783d..ecb94f7 100644 --- a/Pixiview/Illust/RankingPage.xaml.cs +++ b/Pixiview/Illust/RankingPage.xaml.cs @@ -355,9 +355,8 @@ namespace Pixiview.Illust private async void PrepareLoad() { - await scrollView.ScrollToAsync(0, -topOffset, true); + await ScrollToTopAsync(scrollView); // release - ReleaseCollection(); previousEnabled = false; dateEnabled = false; nextEnabled = false; @@ -367,12 +366,7 @@ namespace Pixiview.Illust private void ReleaseCollection() { - var collection = IllustCollection; - if (collection != null) - { - collection.Running = false; - IllustCollection = null; - } + InvalidateCollection(); currentPage = 1; } } diff --git a/Pixiview/Illust/RecommendsPage.xaml.cs b/Pixiview/Illust/RecommendsPage.xaml.cs index 5194f2c..6a37423 100644 --- a/Pixiview/Illust/RecommendsPage.xaml.cs +++ b/Pixiview/Illust/RecommendsPage.xaml.cs @@ -343,7 +343,7 @@ namespace Pixiview.Illust { return; } - await scrollView.ScrollToAsync(0, -topOffset, true); + await ScrollToTopAsync(scrollView); StartLoad(true); } } diff --git a/Pixiview/Illust/RelatedIllustsPage.xaml.cs b/Pixiview/Illust/RelatedIllustsPage.xaml.cs index b7f835f..0faf4a2 100644 --- a/Pixiview/Illust/RelatedIllustsPage.xaml.cs +++ b/Pixiview/Illust/RelatedIllustsPage.xaml.cs @@ -97,14 +97,7 @@ namespace Pixiview.Illust { return; } - await scrollView.ScrollToAsync(0, -topOffset, true); - // release - var collection = IllustCollection; - if (collection != null) - { - collection.Running = false; - IllustCollection = null; - } + await ScrollToTopAsync(scrollView); startIndex = -1; nextIndex = 0; illustIds = null; diff --git a/Pixiview/Illust/UserIllustPage.xaml.cs b/Pixiview/Illust/UserIllustPage.xaml.cs index 1abfdb0..486830c 100644 --- a/Pixiview/Illust/UserIllustPage.xaml.cs +++ b/Pixiview/Illust/UserIllustPage.xaml.cs @@ -107,7 +107,7 @@ namespace Pixiview.Illust { return; } - await scrollView.ScrollToAsync(0, -topOffset, true); + await ScrollToTopAsync(scrollView); // release var collection = IllustCollection; if (collection != null)