features:
- launcher logo - tab bar tint color - favorites logic udpated
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
@@ -11,7 +12,7 @@ using Xamarin.Forms;
|
||||
|
||||
namespace Pixiview.Utils
|
||||
{
|
||||
public class Stores
|
||||
public static class Stores
|
||||
{
|
||||
public static readonly string PersonalFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
|
||||
public static readonly string CacheFolder = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
|
||||
@@ -43,6 +44,48 @@ namespace Pixiview.Utils
|
||||
}
|
||||
}
|
||||
|
||||
private static IllustFavorite favoriteObject;
|
||||
public static IllustFavorite FavoriteObject
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (sync)
|
||||
{
|
||||
if (favoriteObject == null)
|
||||
{
|
||||
var favorites = LoadFavoritesIllusts();
|
||||
if (favorites != null)
|
||||
{
|
||||
favoriteObject = favorites;
|
||||
}
|
||||
}
|
||||
return favoriteObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static List<IllustItem> Favorites => FavoriteObject.Illusts;
|
||||
|
||||
private static IllustFavorite LoadFavoritesIllusts()
|
||||
{
|
||||
var file = Path.Combine(PersonalFolder, favoriteFile);
|
||||
lock (sync)
|
||||
{
|
||||
return ReadObject<IllustFavorite>(file);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveFavoritesIllusts()
|
||||
{
|
||||
var file = Path.Combine(PersonalFolder, favoriteFile);
|
||||
lock (sync)
|
||||
{
|
||||
var data = FavoriteObject;
|
||||
data.LastFavoriteUtc = DateTime.UtcNow;
|
||||
WriteObject(file, data);
|
||||
}
|
||||
}
|
||||
|
||||
private static T LoadObject<T>(string file, string url, string referer = null, bool force = false)
|
||||
{
|
||||
string content = null;
|
||||
@@ -179,24 +222,6 @@ namespace Pixiview.Utils
|
||||
return result;
|
||||
}
|
||||
|
||||
public static IllustFavorite LoadFavoritesIllusts()
|
||||
{
|
||||
var file = Path.Combine(PersonalFolder, favoriteFile);
|
||||
lock (sync)
|
||||
{
|
||||
return ReadObject<IllustFavorite>(file);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveFavoritesIllusts(IllustFavorite data)
|
||||
{
|
||||
var file = Path.Combine(PersonalFolder, favoriteFile);
|
||||
lock (sync)
|
||||
{
|
||||
WriteObject(file, data);
|
||||
}
|
||||
}
|
||||
|
||||
public static ImageSource LoadIllustImage(string url)
|
||||
{
|
||||
return LoadImage(url, PersonalFolder, imageFolder);
|
||||
|
||||
Reference in New Issue
Block a user