downloading placeholder

This commit is contained in:
2020-05-10 20:41:20 +08:00
parent c271063390
commit 8b891cc692
6 changed files with 17 additions and 13 deletions

View File

@@ -49,7 +49,7 @@ namespace Pixiview.Illust
public void Reload(bool force = false)
{
loaded = false;
lastUpdated = default;
StartLoad(force);
}

View File

@@ -50,12 +50,12 @@ namespace Pixiview.Illust
#endregion
protected static bool NeedUpdate { get; private set; } = true;
protected static DateTime LastUpdated { get; private set; } = DateTime.Now;
public IllustCollection IllustCollection { get; set; }
protected virtual bool IsFavoriteVisible => true;
protected bool loaded;
protected DateTime lastUpdated;
private T illustData;
private readonly ParallelOptions parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = Configs.MaxThreads };
@@ -77,7 +77,7 @@ namespace Pixiview.Illust
public override void OnUnload()
{
Illusts = IllustCollection.Empty;
loaded = false;
lastUpdated = default;
}
protected override void OnAppearing()
@@ -85,10 +85,8 @@ namespace Pixiview.Illust
base.OnAppearing();
Connectivity.ConnectivityChanged += Connectivity_ConnectivityChanged;
if (NeedUpdate || !loaded)
if (lastUpdated != LastUpdated)
{
NeedUpdate = false;
loaded = false;
StartLoad();
}
else if (IsFavoriteVisible)
@@ -111,7 +109,7 @@ namespace Pixiview.Illust
{
if (e.NetworkAccess == NetworkAccess.Internet)
{
if (!loaded)
if (lastUpdated != LastUpdated)
{
StartLoad(true);
}
@@ -149,9 +147,9 @@ namespace Pixiview.Illust
protected void StartLoad(bool force = false)
{
if (force || !loaded)
if (force || lastUpdated != LastUpdated)
{
loaded = true;
lastUpdated = LastUpdated;
IsLoading = true;
Task.Run(() => DoLoadIllusts(force));
}
@@ -166,7 +164,7 @@ namespace Pixiview.Illust
// image
var image = new RoundImage
{
BackgroundColor = Color.LightGray,
BackgroundColor = StyleDefinition.ColorDownloadBackground,
CornerRadius = 10,
CornerMasks = CornerMask.Top,
HorizontalOptions = LayoutOptions.Fill,
@@ -351,7 +349,7 @@ namespace Pixiview.Illust
}
if (force && IsFavoriteVisible)
{
NeedUpdate = true;
LastUpdated = DateTime.Now;
}
var data = DoGetIllustList(illustData, commandIllustImageTapped).Where(i => i != null);
@@ -362,6 +360,10 @@ namespace Pixiview.Illust
var favorites = Stores.Favorites;
foreach (var item in collection)
{
if (item.Image == null)
{
item.Image = StyleDefinition.DownloadBackground;
}
item.IsFavorite = favorites.Any(i => i.Id == item.Id);
}
}

View File

@@ -17,6 +17,8 @@ namespace Pixiview.UI
public static readonly Color ColorLightShadow = Color.FromRgba(0, 0, 0, 0x20);
public static readonly Color ColorDeepShadow = Color.FromRgba(0, 0, 0, 0x50);
public static readonly Color ColorRedBackground = Color.FromRgb(0xfd, 0x43, 0x63);
public static readonly Color ColorDownloadBackground = Color.FromRgb(0xd7, 0xd9, 0xe0);
public static readonly ImageSource DownloadBackground = ImageSource.FromFile("download.png");
public static readonly double FontSizeMicro = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
public static readonly double FontSizeSmall = Device.GetNamedSize(NamedSize.Small, typeof(Label));