fix: scroll back to top issue on Android
optimize: collection invalidated logic
This commit is contained in:
parent
e751185207
commit
64223b99af
@ -80,7 +80,7 @@ namespace Pixiview.Illust
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await scrollView.ScrollToAsync(0, -topOffset, true);
|
await ScrollToTopAsync(scrollView);
|
||||||
flag = false;
|
flag = false;
|
||||||
lastUpdated = default;
|
lastUpdated = default;
|
||||||
StartLoad(true);
|
StartLoad(true);
|
||||||
|
@ -185,6 +185,16 @@ namespace Pixiview.Illust
|
|||||||
return collection;
|
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)
|
protected virtual void StartLoad(bool force = false, bool isBottom = false)
|
||||||
{
|
{
|
||||||
if (force || lastUpdated != LastUpdated)
|
if (force || lastUpdated != LastUpdated)
|
||||||
@ -200,6 +210,7 @@ namespace Pixiview.Illust
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
InvalidateCollection();
|
||||||
IsLoading = true;
|
IsLoading = true;
|
||||||
}
|
}
|
||||||
#if __IOS__
|
#if __IOS__
|
||||||
@ -222,6 +233,7 @@ namespace Pixiview.Illust
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
InvalidateCollection();
|
||||||
IsLoading = true;
|
IsLoading = true;
|
||||||
}
|
}
|
||||||
indicator.Animate("margin", top =>
|
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)
|
protected DataTemplate GetCardViewTemplate(bool hideUser = false)
|
||||||
{
|
{
|
||||||
return new DataTemplate(() =>
|
return new DataTemplate(() =>
|
||||||
|
@ -59,7 +59,7 @@ namespace Pixiview.Illust
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await scrollView.ScrollToAsync(0, -topOffset, true);
|
await ScrollToTopAsync(scrollView);
|
||||||
StartLoad(true);
|
StartLoad(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,9 +355,8 @@ namespace Pixiview.Illust
|
|||||||
|
|
||||||
private async void PrepareLoad()
|
private async void PrepareLoad()
|
||||||
{
|
{
|
||||||
await scrollView.ScrollToAsync(0, -topOffset, true);
|
await ScrollToTopAsync(scrollView);
|
||||||
// release
|
// release
|
||||||
ReleaseCollection();
|
|
||||||
previousEnabled = false;
|
previousEnabled = false;
|
||||||
dateEnabled = false;
|
dateEnabled = false;
|
||||||
nextEnabled = false;
|
nextEnabled = false;
|
||||||
@ -367,12 +366,7 @@ namespace Pixiview.Illust
|
|||||||
|
|
||||||
private void ReleaseCollection()
|
private void ReleaseCollection()
|
||||||
{
|
{
|
||||||
var collection = IllustCollection;
|
InvalidateCollection();
|
||||||
if (collection != null)
|
|
||||||
{
|
|
||||||
collection.Running = false;
|
|
||||||
IllustCollection = null;
|
|
||||||
}
|
|
||||||
currentPage = 1;
|
currentPage = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ namespace Pixiview.Illust
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await scrollView.ScrollToAsync(0, -topOffset, true);
|
await ScrollToTopAsync(scrollView);
|
||||||
StartLoad(true);
|
StartLoad(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,14 +97,7 @@ namespace Pixiview.Illust
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await scrollView.ScrollToAsync(0, -topOffset, true);
|
await ScrollToTopAsync(scrollView);
|
||||||
// release
|
|
||||||
var collection = IllustCollection;
|
|
||||||
if (collection != null)
|
|
||||||
{
|
|
||||||
collection.Running = false;
|
|
||||||
IllustCollection = null;
|
|
||||||
}
|
|
||||||
startIndex = -1;
|
startIndex = -1;
|
||||||
nextIndex = 0;
|
nextIndex = 0;
|
||||||
illustIds = null;
|
illustIds = null;
|
||||||
|
@ -107,7 +107,7 @@ namespace Pixiview.Illust
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await scrollView.ScrollToAsync(0, -topOffset, true);
|
await ScrollToTopAsync(scrollView);
|
||||||
// release
|
// release
|
||||||
var collection = IllustCollection;
|
var collection = IllustCollection;
|
||||||
if (collection != null)
|
if (collection != null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user