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

View File

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