optimize: flow measure and layout
This commit is contained in:
@@ -7,6 +7,7 @@ using Pixiview.Resources;
|
||||
using Pixiview.UI;
|
||||
using Pixiview.UI.Theme;
|
||||
using Pixiview.Utils;
|
||||
using Xamarin.Essentials;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Pixiview.Illust
|
||||
@@ -613,12 +614,13 @@ namespace Pixiview.Illust
|
||||
if (now == null)
|
||||
{
|
||||
now = collection;
|
||||
IllustCollection = now;
|
||||
}
|
||||
else
|
||||
{
|
||||
now = new IllustCollection(now.Concat(collection));
|
||||
//now = new IllustCollection(now.Concat(collection));
|
||||
now.AddRange(collection);
|
||||
}
|
||||
IllustCollection = now;
|
||||
return now;
|
||||
}
|
||||
|
||||
@@ -652,7 +654,7 @@ namespace Pixiview.Illust
|
||||
Down
|
||||
}
|
||||
|
||||
public class IllustCollection : List<IllustItem>
|
||||
public class IllustCollection : List<IllustItem>, IIllustCollectionChanged
|
||||
{
|
||||
private static IllustCollection empty;
|
||||
|
||||
@@ -668,6 +670,8 @@ namespace Pixiview.Illust
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler<CollectionChangedEventArgs> CollectionChanged;
|
||||
|
||||
public IllustCollection() : base()
|
||||
{
|
||||
running = true;
|
||||
@@ -677,8 +681,28 @@ namespace Pixiview.Illust
|
||||
running = true;
|
||||
}
|
||||
|
||||
public void AddRange(List<IllustItem> items)
|
||||
{
|
||||
var e = new CollectionChangedEventArgs
|
||||
{
|
||||
NewStartingIndex = Count,
|
||||
NewItems = items
|
||||
};
|
||||
base.AddRange(items);
|
||||
if (MainThread.IsMainThread)
|
||||
{
|
||||
CollectionChanged?.Invoke(this, e);
|
||||
}
|
||||
else
|
||||
{
|
||||
MainThread.BeginInvokeOnMainThread(() =>
|
||||
CollectionChanged?.Invoke(this, e));
|
||||
}
|
||||
}
|
||||
|
||||
private readonly object sync = new object();
|
||||
private volatile bool running;
|
||||
|
||||
public bool Running
|
||||
{
|
||||
get => running;
|
||||
|
@@ -307,10 +307,7 @@ namespace Pixiview.Illust
|
||||
|
||||
private void FlowLayout_MaxHeightChanged(object sender, HeightEventArgs e)
|
||||
{
|
||||
if (e.ContentHeight > 0)
|
||||
{
|
||||
SetOffset(e.ContentHeight - scrollView.Bounds.Height - SCROLL_OFFSET);
|
||||
}
|
||||
SetOffset(e.ContentHeight - scrollView.Bounds.Height - SCROLL_OFFSET);
|
||||
}
|
||||
|
||||
protected override bool CheckRefresh()
|
||||
|
@@ -72,10 +72,7 @@ namespace Pixiview.Illust
|
||||
|
||||
private void FlowLayout_MaxHeightChanged(object sender, HeightEventArgs e)
|
||||
{
|
||||
if (e.ContentHeight > 0)
|
||||
{
|
||||
SetOffset(e.ContentHeight - scrollView.Bounds.Height - SCROLL_OFFSET);
|
||||
}
|
||||
SetOffset(e.ContentHeight - scrollView.Bounds.Height - SCROLL_OFFSET);
|
||||
}
|
||||
|
||||
protected override bool CheckRefresh()
|
||||
|
@@ -82,10 +82,7 @@ namespace Pixiview.Illust
|
||||
|
||||
private void FlowLayout_MaxHeightChanged(object sender, HeightEventArgs e)
|
||||
{
|
||||
if (e.ContentHeight > 0)
|
||||
{
|
||||
SetOffset(e.ContentHeight - scrollView.Bounds.Height - SCROLL_OFFSET);
|
||||
}
|
||||
SetOffset(e.ContentHeight - scrollView.Bounds.Height - SCROLL_OFFSET);
|
||||
}
|
||||
|
||||
protected override bool CheckRefresh()
|
||||
|
Reference in New Issue
Block a user