feature: parallels downloading image, refresh btn
This commit is contained in:
parent
3a80c0826b
commit
507b4c59f2
@ -7,6 +7,10 @@
|
||||
x:Class="Pixiview.Illust.RelatedIllustsPage"
|
||||
Title="{r:Text RelatedIllusts}"
|
||||
BackgroundColor="{DynamicResource WindowColor}">
|
||||
<ContentPage.ToolbarItems>
|
||||
<ToolbarItem Order="Primary" Clicked="Refresh_Clicked"
|
||||
IconImageSource="{DynamicResource FontIconRefresh}"/>
|
||||
</ContentPage.ToolbarItems>
|
||||
<Grid>
|
||||
<ScrollView x:Name="scrollView" Scrolled="ScrollView_Scrolled"
|
||||
HorizontalOptions="Fill" HorizontalScrollBarVisibility="Never">
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Pixiview.UI;
|
||||
using Pixiview.Utils;
|
||||
@ -88,5 +89,17 @@ namespace Pixiview.Illust
|
||||
var y = e.ScrollY;
|
||||
OnScrolled(y);
|
||||
}
|
||||
|
||||
private void Refresh_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
if (IsLoading)
|
||||
{
|
||||
return;
|
||||
}
|
||||
startIndex = -1;
|
||||
nextIndex = 0;
|
||||
illustIds = null;
|
||||
StartLoad(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,20 +41,6 @@ namespace Pixiview.Illust
|
||||
var items = page.Illusts;
|
||||
var length = items.Length;
|
||||
page.PagePositionText = $"{index + 1}/{length}";
|
||||
|
||||
var item = items[index];
|
||||
if (!item.Loading && item.Image == null)
|
||||
{
|
||||
Task.Run(() => page.DoLoadImage(index));
|
||||
}
|
||||
if (index < length - 1)
|
||||
{
|
||||
item = items[index + 1];
|
||||
if (!item.Loading && item.Image == null)
|
||||
{
|
||||
Task.Run(() => page.DoLoadImage(index + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnCurrentAnimeFramePropertyChanged(BindableObject obj, object old, object @new)
|
||||
@ -117,6 +103,7 @@ namespace Pixiview.Illust
|
||||
public IllustItem IllustItem { get; private set; }
|
||||
public bool IsPageVisible { get; private set; }
|
||||
|
||||
private readonly ParallelOptions parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = Configs.MaxThreads };
|
||||
private readonly bool saveFavorites;
|
||||
private readonly ImageSource fontIconLove;
|
||||
private readonly ImageSource fontIconNotLove;
|
||||
@ -363,17 +350,18 @@ namespace Pixiview.Illust
|
||||
}
|
||||
}
|
||||
|
||||
DoLoadImage(0, true);
|
||||
var image = items[0].Image;
|
||||
if (image != null)
|
||||
{
|
||||
illustItem.Image = image;
|
||||
}
|
||||
var isAnime = illustItem.IllustType == IllustType.Anime;
|
||||
IsAnimateSliderVisible = isAnime;
|
||||
|
||||
Task.Run(() => DoLoadImage(0, true));
|
||||
if (items.Length > 1)
|
||||
{
|
||||
DoLoadImage(1);
|
||||
Parallel.For(1, items.Length, parallelOptions, i =>
|
||||
{
|
||||
DoLoadImage(i);
|
||||
});
|
||||
}
|
||||
else if (illustItem.IllustType == IllustType.Anime)
|
||||
else if (isAnime)
|
||||
{
|
||||
// anime
|
||||
ugoiraData = Stores.LoadIllustUgoiraData(illustItem.Id);
|
||||
@ -381,7 +369,6 @@ namespace Pixiview.Illust
|
||||
{
|
||||
var length = ugoiraData.body.frames.Length;
|
||||
MaximumFrame = length > 0 ? length : 1;
|
||||
IsAnimateSliderVisible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -409,6 +396,10 @@ namespace Pixiview.Illust
|
||||
if (image != null)
|
||||
{
|
||||
item.Image = image;
|
||||
if(index == 0)
|
||||
{
|
||||
IllustItem.Image = image;
|
||||
}
|
||||
}
|
||||
item.Loading = false;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ namespace Pixiview.UI
|
||||
public const string IconSparkles = "\uf890";
|
||||
public const string IconOrder = "\uf88f";
|
||||
public const string IconLayer = "\uf302";
|
||||
public const string IconRefresh = "\uf2f1";
|
||||
public const string IconRefresh = "\uf2f9";
|
||||
public const string IconLove = "\uf004";
|
||||
public const string IconOption = "\uf013";
|
||||
public const string IconFavorite = "\uf02e";
|
||||
|
@ -132,7 +132,6 @@ namespace Pixiview.Utils
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
var file = Path.Combine(directory, Path.GetFileName(url));
|
||||
App.DebugPrint($"download, url: {url}");
|
||||
var response = Download(url, headers =>
|
||||
{
|
||||
headers.Referrer = new Uri(Configs.Referer);
|
||||
|
Loading…
x
Reference in New Issue
Block a user