change: favorite merge rule
fix: page progress renderer
This commit is contained in:
parent
8433b44d4f
commit
ffb789b8b7
110
Pixiview/App.cs
110
Pixiview/App.cs
@ -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,47 +142,70 @@ namespace Pixiview
|
||||
ResourceHelper.Ok));
|
||||
}
|
||||
}
|
||||
else if (File.Exists(url))
|
||||
else
|
||||
{
|
||||
IllustFavorite favObj;
|
||||
try
|
||||
url = System.Net.WebUtility.UrlDecode(url);
|
||||
if (File.Exists(url))
|
||||
{
|
||||
favObj = Stores.LoadFavoritesIllusts(url);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DebugError("open.file", $"failed to parse file, name: {url}, error: {ex.Message}");
|
||||
return true;
|
||||
}
|
||||
var path = Stores.FavoritesPath;
|
||||
if (File.Exists(path))
|
||||
{
|
||||
MainThread.BeginInvokeOnMainThread(async () =>
|
||||
IllustFavorite favObj;
|
||||
try
|
||||
{
|
||||
var opReplace = ResourceHelper.FavoritesReplace;
|
||||
var opCombine = ResourceHelper.FavoritesCombine;
|
||||
var result = await current.DisplayActionSheet(
|
||||
ResourceHelper.FavoritesOperation,
|
||||
ResourceHelper.Cancel,
|
||||
opCombine,
|
||||
opReplace);
|
||||
if (result == opReplace)
|
||||
favObj = Stores.LoadFavoritesIllusts(url);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DebugError("open.file", $"failed to parse file, name: {url}, error: {ex.Message}");
|
||||
return true;
|
||||
}
|
||||
var path = Stores.FavoritesPath;
|
||||
if (url == path)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (File.Exists(path))
|
||||
{
|
||||
MainThread.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
// replace favorite file
|
||||
File.Copy(url, path, true);
|
||||
}
|
||||
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 opReplace = ResourceHelper.FavoritesReplace;
|
||||
var opCombine = ResourceHelper.FavoritesCombine;
|
||||
var result = await current.DisplayActionSheet(
|
||||
ResourceHelper.FavoritesOperation,
|
||||
ResourceHelper.Cancel,
|
||||
opCombine,
|
||||
opReplace);
|
||||
if (result == opReplace)
|
||||
{
|
||||
// replace favorite file
|
||||
File.Delete(path);
|
||||
File.Move(url, path);
|
||||
}
|
||||
else if (result == opCombine)
|
||||
{
|
||||
// combine favorite file
|
||||
var favNow = Stores.GetFavoriteObject();
|
||||
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();
|
||||
}
|
||||
favNow.Illusts = list;
|
||||
Stores.SaveFavoritesIllusts();
|
||||
}
|
||||
|
||||
File.Delete(url);
|
||||
|
||||
if (Shell.Current.CurrentState.Location.OriginalString.EndsWith(Routes.Favorites))
|
||||
{
|
||||
var sc = (IShellSectionController)Shell.Current.CurrentItem.CurrentItem;
|
||||
if (sc.PresentedPage is FavoritesPage fav)
|
||||
{
|
||||
fav.Reload(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
File.Move(url, path);
|
||||
if (Shell.Current.CurrentState.Location.OriginalString.EndsWith(Routes.Favorites))
|
||||
{
|
||||
var sc = (IShellSectionController)Shell.Current.CurrentItem.CurrentItem;
|
||||
@ -186,18 +214,6 @@ namespace Pixiview
|
||||
fav.Reload(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
File.Copy(url, path);
|
||||
if (Shell.Current.CurrentState.Location.OriginalString.EndsWith(Routes.Favorites))
|
||||
{
|
||||
var sc = (IShellSectionController)Shell.Current.CurrentItem.CurrentItem;
|
||||
if (sc.PresentedPage is FavoritesPage fav)
|
||||
{
|
||||
fav.Reload(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
downloaded++;
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user