Skip to content

Commit 086c5d0

Browse files
committed
update to Flow
1 parent e37217c commit 086c5d0

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

Flow.Launcher.Infrastructure/Image/ImageCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Threading.Tasks;
66
using System.Windows.Media;
77

8-
namespace Wox.Infrastructure.Image
8+
namespace Flow.Launcher.Infrastructure.Image
99
{
1010
[Serializable]
1111
public class ImageCache

Flow.Launcher.Infrastructure/Image/ImageLoader.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
using Flow.Launcher.Infrastructure.Logger;
1010
using Flow.Launcher.Infrastructure.Storage;
1111

12-
namespace Wox.Infrastructure.Image
12+
namespace Flow.Launcher.Infrastructure.Image
1313
{
1414
public static class ImageLoader
1515
{
16-
private static readonly ImageCache _imageCache = new ImageCache();
16+
private static readonly ImageCache ImageCache = new ImageCache();
1717
private static readonly ConcurrentDictionary<string, string> _guidToKey = new ConcurrentDictionary<string, string>();
18-
private static readonly bool _enableHashImage = true;
19-
18+
private static readonly ConcurrentDictionary<string, string> GuidToKey = new ConcurrentDictionary<string, string>();
2019
private static BinaryStorage<Dictionary<string, int>> _storage;
2120
private static IImageHashGenerator _hashGenerator;
21+
private static bool EnableImageHash = true;
2222

2323
private static readonly string[] ImageExtensions =
2424
{
@@ -36,25 +36,25 @@ public static void Initialize()
3636
_storage = new BinaryStorage<Dictionary<string, int>>("Image");
3737
_hashGenerator = new ImageHashGenerator();
3838

39-
_imageCache.Usage = LoadStorageToConcurrentDictionary();
39+
ImageCache.Usage = LoadStorageToConcurrentDictionary();
4040

4141
foreach (var icon in new[] { Constant.DefaultIcon, Constant.ErrorIcon })
4242
{
4343
ImageSource img = new BitmapImage(new Uri(icon));
4444
img.Freeze();
45-
_imageCache[icon] = img;
45+
ImageCache[icon] = img;
4646
}
4747

4848
Task.Run(() =>
4949
{
5050
Stopwatch.Normal("|ImageLoader.Initialize|Preload images cost", () =>
5151
{
52-
_imageCache.Usage.AsParallel().ForAll(x =>
52+
ImageCache.Usage.AsParallel().ForAll(x =>
5353
{
5454
Load(x.Key);
5555
});
5656
});
57-
Log.Info($"|ImageLoader.Initialize|Number of preload images is <{_imageCache.Usage.Count}>, Images Number: {_imageCache.CacheSize()}, Unique Items {_imageCache.UniqueImagesInCache()}");
57+
Log.Info($"|ImageLoader.Initialize|Number of preload images is <{ImageCache.Usage.Count}>, Images Number: {ImageCache.CacheSize()}, Unique Items {ImageCache.UniqueImagesInCache()}");
5858
});
5959
}
6060

@@ -106,11 +106,11 @@ private static ImageResult LoadInternal(string path, bool loadFullImage = false)
106106
{
107107
if (string.IsNullOrEmpty(path))
108108
{
109-
return new ImageResult(_imageCache[Constant.ErrorIcon], ImageType.Error);
109+
return new ImageResult(ImageCache[Constant.ErrorIcon], ImageType.Error);
110110
}
111-
if (_imageCache.ContainsKey(path))
111+
if (ImageCache.ContainsKey(path))
112112
{
113-
return new ImageResult(_imageCache[path], ImageType.Cache);
113+
return new ImageResult(ImageCache[path], ImageType.Cache);
114114
}
115115

116116
if (path.StartsWith("data:", StringComparison.OrdinalIgnoreCase))
@@ -139,8 +139,8 @@ private static ImageResult LoadInternal(string path, bool loadFullImage = false)
139139
Log.Exception($"|ImageLoader.Load|Failed to get thumbnail for {path} on first try", e);
140140
Log.Exception($"|ImageLoader.Load|Failed to get thumbnail for {path} on second try", e2);
141141

142-
ImageSource image = _imageCache[Constant.ErrorIcon];
143-
_imageCache[path] = image;
142+
ImageSource image = ImageCache[Constant.ErrorIcon];
143+
ImageCache[path] = image;
144144
imageResult = new ImageResult(image, ImageType.Error);
145145
}
146146
}
@@ -191,7 +191,7 @@ private static ImageResult GetThumbnailResult(ref string path, bool loadFullImag
191191
}
192192
else
193193
{
194-
image = _imageCache[Constant.ErrorIcon];
194+
image = ImageCache[Constant.ErrorIcon];
195195
path = Constant.ErrorIcon;
196196
}
197197

0 commit comments

Comments
 (0)