67 lines
1.7 KiB
C#
67 lines
1.7 KiB
C#
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using Gallery.Resources.UI;
|
|
using Gallery.Util;
|
|
using Gallery.Util.Interface;
|
|
using Gallery.Util.Model;
|
|
using Xamarin.Forms;
|
|
|
|
namespace Gallery.Views
|
|
{
|
|
public partial class GalleryPage : GalleryCollectionPage
|
|
{
|
|
private int currentPage;
|
|
|
|
public GalleryPage(IGallerySource source) : base(source)
|
|
{
|
|
Resources.Add("cardView", GetCardViewTemplate());
|
|
InitializeComponent();
|
|
|
|
currentPage = 1;
|
|
}
|
|
|
|
protected override ActivityIndicator LoadingIndicator => activityLoading;
|
|
|
|
protected override void OnAppearing()
|
|
{
|
|
if (currentPage != 1 && Gallery == null)
|
|
{
|
|
currentPage = 1;
|
|
}
|
|
base.OnAppearing();
|
|
}
|
|
|
|
protected override async Task<GalleryItem[]> DoloadGalleryData(bool force)
|
|
{
|
|
var result = await Source.GetRecentItemsAsync(currentPage);
|
|
return result;
|
|
}
|
|
|
|
protected override IEnumerable<GalleryItem> DoGetGalleryList(GalleryItem[] data, out int tag)
|
|
{
|
|
tag = currentPage;
|
|
return data;
|
|
}
|
|
|
|
private void FlowLayout_MaxHeightChanged(object sender, HeightEventArgs e)
|
|
{
|
|
SetOffset(e.ContentHeight - scrollView.Bounds.Height - SCROLL_OFFSET);
|
|
}
|
|
|
|
protected override bool CheckRefresh()
|
|
{
|
|
currentPage++;
|
|
#if DEBUG
|
|
Log.Print($"loading page: {currentPage}");
|
|
#endif
|
|
return true;
|
|
}
|
|
|
|
private void ScrollView_Scrolled(object sender, ScrolledEventArgs e)
|
|
{
|
|
var y = e.ScrollY;
|
|
OnScrolled(y);
|
|
}
|
|
}
|
|
}
|