change: favorite merge rule

fix: page progress renderer
This commit is contained in:
Tsanie Lily 2020-05-16 00:02:14 +08:00
parent 8433b44d4f
commit ffb789b8b7
2 changed files with 70 additions and 49 deletions

View File

@ -18,6 +18,11 @@ namespace Pixiview
public static AppTheme CurrentTheme { get; private set; }
public static PlatformCulture CurrentCulture { get; private set; }
public App()
{
Device.SetFlags(new string[0]);
}
private void InitResources()
{
var theme = AppInfo.RequestedTheme;
@ -137,7 +142,10 @@ namespace Pixiview
ResourceHelper.Ok));
}
}
else if (File.Exists(url))
else
{
url = System.Net.WebUtility.UrlDecode(url);
if (File.Exists(url))
{
IllustFavorite favObj;
try
@ -150,6 +158,10 @@ namespace Pixiview
return true;
}
var path = Stores.FavoritesPath;
if (url == path)
{
return false;
}
if (File.Exists(path))
{
MainThread.BeginInvokeOnMainThread(async () =>
@ -164,20 +176,23 @@ namespace Pixiview
if (result == opReplace)
{
// replace favorite file
File.Copy(url, path, true);
File.Delete(path);
File.Move(url, path);
}
else if (result == opCombine)
{
// combine favorite file
var favNow = Stores.GetFavoriteObject();
var list = favObj.Illusts;
var distinct = favNow.Illusts.Where(f => !list.Any(i => i.Id == f.Id)).ToList();
list.AddRange(distinct);
var list = favNow.Illusts;
var distinct = favObj.Illusts.Where(f => !list.Any(i => i.Id == f.Id)).ToList();
list.InsertRange(0, distinct);
favNow.Illusts = list;
Stores.SaveFavoritesIllusts();
}
File.Delete(url);
if (Shell.Current.CurrentState.Location.OriginalString.EndsWith(Routes.Favorites))
{
var sc = (IShellSectionController)Shell.Current.CurrentItem.CurrentItem;
@ -190,7 +205,7 @@ namespace Pixiview
}
else
{
File.Copy(url, path);
File.Move(url, path);
if (Shell.Current.CurrentState.Location.OriginalString.EndsWith(Routes.Favorites))
{
var sc = (IShellSectionController)Shell.Current.CurrentItem.CurrentItem;
@ -202,6 +217,7 @@ namespace Pixiview
}
}
}
}
return true;
}
}

View File

@ -122,7 +122,8 @@ namespace Pixiview.Illust
private IllustUgoiraData ugoiraData;
private Ugoira ugoira;
private volatile int downloaded = 0;
private readonly object sync = new object();
private int downloaded = 0;
private int pageCount;
public ViewIllustPage(IllustItem illust, bool save)
@ -413,11 +414,15 @@ namespace Pixiview.Illust
return;
}
lock (sync)
{
downloaded++;
}
if (downloaded >= pageCount)
{
MainThread.BeginInvokeOnMainThread(async () =>
{
ViewExtensions.CancelAnimations(progress);
await progress.ProgressTo(1, 250, Easing.CubicIn);
await progress.FadeTo(0, easing: Easing.CubicIn);
ProgressVisible = false;