improve progress bar
This commit is contained in:
parent
fcd48d408c
commit
8ce5942662
@ -116,13 +116,15 @@ namespace Pixiview.Illust
|
|||||||
|
|
||||||
public IllustItem IllustItem { get; private set; }
|
public IllustItem IllustItem { get; private set; }
|
||||||
|
|
||||||
private readonly object sync = new object();
|
|
||||||
private readonly bool saveFavorites;
|
private readonly bool saveFavorites;
|
||||||
private readonly ImageSource fontIconLove;
|
private readonly ImageSource fontIconLove;
|
||||||
private readonly ImageSource fontIconNotLove;
|
private readonly ImageSource fontIconNotLove;
|
||||||
private IllustUgoiraData ugoiraData;
|
private IllustUgoiraData ugoiraData;
|
||||||
private Ugoira ugoira;
|
private Ugoira ugoira;
|
||||||
|
|
||||||
|
private volatile int downloaded = 0;
|
||||||
|
private int pageCount;
|
||||||
|
|
||||||
public ViewIllustPage(IllustItem illust, bool save)
|
public ViewIllustPage(IllustItem illust, bool save)
|
||||||
{
|
{
|
||||||
IllustItem = illust;
|
IllustItem = illust;
|
||||||
@ -137,7 +139,11 @@ namespace Pixiview.Illust
|
|||||||
? fontIconLove
|
? fontIconLove
|
||||||
: fontIconNotLove;
|
: fontIconNotLove;
|
||||||
|
|
||||||
ProgressVisible = IsPageVisible = illust != null && illust.PageCount > 1;
|
if (illust != null)
|
||||||
|
{
|
||||||
|
pageCount = illust.PageCount;
|
||||||
|
ProgressVisible = IsPageVisible = pageCount > 1;
|
||||||
|
}
|
||||||
Resources.Add("carouselView", GetCarouseTemplate());
|
Resources.Add("carouselView", GetCarouseTemplate());
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -335,11 +341,12 @@ namespace Pixiview.Illust
|
|||||||
illust.CopyToItem(illustItem);
|
illust.CopyToItem(illustItem);
|
||||||
MainThread.BeginInvokeOnMainThread(() =>
|
MainThread.BeginInvokeOnMainThread(() =>
|
||||||
{
|
{
|
||||||
var pageCount = illustItem.PageCount;
|
var count = illustItem.PageCount;
|
||||||
|
pageCount = count;
|
||||||
Title = illustItem.Title;
|
Title = illustItem.Title;
|
||||||
IsPageVisible = pageCount > 1;
|
IsPageVisible = count > 1;
|
||||||
IsAnimateSliderVisible = illustItem.IsAnimeVisible;
|
IsAnimateSliderVisible = illustItem.IsAnimeVisible;
|
||||||
ProgressVisible = pageCount > 1;
|
ProgressVisible = count > 1;
|
||||||
});
|
});
|
||||||
if (preload.user.TryGetValue(illust.userId, out var user))
|
if (preload.user.TryGetValue(illust.userId, out var user))
|
||||||
{
|
{
|
||||||
@ -401,34 +408,32 @@ namespace Pixiview.Illust
|
|||||||
|
|
||||||
private void RefreshProgress()
|
private void RefreshProgress()
|
||||||
{
|
{
|
||||||
var illusts = Illusts;
|
if (pageCount <= 1)
|
||||||
var length = illusts.Length;
|
|
||||||
if (length <= 1)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lock (sync)
|
|
||||||
|
downloaded++;
|
||||||
|
if (downloaded >= pageCount)
|
||||||
{
|
{
|
||||||
var loading = illusts.Count(i => i.Loading);
|
MainThread.BeginInvokeOnMainThread(async () =>
|
||||||
if (loading <= 0)
|
|
||||||
{
|
{
|
||||||
MainThread.BeginInvokeOnMainThread(async () =>
|
await progress.ProgressTo(1, 250, Easing.CubicIn);
|
||||||
{
|
await progress.FadeTo(0, easing: Easing.CubicIn);
|
||||||
await progress.ProgressTo(1, 250, Easing.CubicIn);
|
ProgressVisible = false;
|
||||||
await progress.FadeTo(0, easing: Easing.CubicIn);
|
});
|
||||||
ProgressVisible = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var val = (length - loading) / (float)length;
|
|
||||||
MainThread.BeginInvokeOnMainThread(() =>
|
|
||||||
{
|
|
||||||
ViewExtensions.CancelAnimations(progress);
|
|
||||||
progress.ProgressTo(val, 250, Easing.CubicIn);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var val = downloaded / (float)pageCount;
|
||||||
|
App.DebugPrint($"download progress: {val}");
|
||||||
|
MainThread.BeginInvokeOnMainThread(() =>
|
||||||
|
{
|
||||||
|
ViewExtensions.CancelAnimations(progress);
|
||||||
|
progress.ProgressTo(val, 250, Easing.CubicIn);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TapPrevious_Tapped(object sender, EventArgs e)
|
private void TapPrevious_Tapped(object sender, EventArgs e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user