From ca6c6cb62a939fa074dfaf863feb60601f0e29f9 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Sat, 26 Nov 2022 10:16:04 -0600 Subject: [PATCH] Use loading.png for loading time image placeholder --- Flow.Launcher.Infrastructure/Constant.cs | 1 + Flow.Launcher.Infrastructure/Image/ImageLoader.cs | 5 +++-- Flow.Launcher/Images/loading.png | Bin 0 -> 164 bytes Flow.Launcher/ViewModel/PluginViewModel.cs | 4 ++-- Flow.Launcher/ViewModel/ResultViewModel.cs | 4 ++-- 5 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 Flow.Launcher/Images/loading.png diff --git a/Flow.Launcher.Infrastructure/Constant.cs b/Flow.Launcher.Infrastructure/Constant.cs index b0eebd2df..56f421e30 100644 --- a/Flow.Launcher.Infrastructure/Constant.cs +++ b/Flow.Launcher.Infrastructure/Constant.cs @@ -29,6 +29,7 @@ namespace Flow.Launcher.Infrastructure public static readonly string DefaultIcon = Path.Combine(ImagesDirectory, "app.png"); public static readonly string ErrorIcon = Path.Combine(ImagesDirectory, "app_error.png"); public static readonly string MissingImgIcon = Path.Combine(ImagesDirectory, "app_missing_img.png"); + public static readonly string LoadingImgIcon = Path.Combine(ImagesDirectory, "loading.png"); public static string PythonPath; diff --git a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs index 130221379..416c66d24 100644 --- a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs +++ b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs @@ -21,7 +21,8 @@ namespace Flow.Launcher.Infrastructure.Image private static readonly ConcurrentDictionary GuidToKey = new(); private static IImageHashGenerator _hashGenerator; private static readonly bool EnableImageHash = true; - public static ImageSource DefaultImage { get; } = new BitmapImage(new Uri(Constant.MissingImgIcon)); + public static ImageSource MissingImage { get; } = new BitmapImage(new Uri(Constant.MissingImgIcon)); + public static ImageSource LoadingImage { get; } = new BitmapImage(new Uri(Constant.LoadingImgIcon)); public const int SmallIconSize = 32; @@ -111,7 +112,7 @@ namespace Flow.Launcher.Infrastructure.Image { if (string.IsNullOrEmpty(path)) { - return new ImageResult(DefaultImage, ImageType.Error); + return new ImageResult(MissingImage, ImageType.Error); } if (ImageCache.ContainsKey(path, loadFullImage)) diff --git a/Flow.Launcher/Images/loading.png b/Flow.Launcher/Images/loading.png new file mode 100644 index 0000000000000000000000000000000000000000..2e2263a4daace5e6b301afeec8a9adb669ed97b8 GIT binary patch literal 164 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTC$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWw1GZk{fVAr-gYoM+@@aNuAu_?xn9_nmDO0^8VLs|2_2weoWy e1Rl&6O<*{)gvqG9A?z^FL PluginPair.Metadata.ActionKeywords.Count == 1 ? Visibility.Visible : Visibility.Collapsed; public string InitilizaTime => PluginPair.Metadata.InitTime + "ms"; diff --git a/Flow.Launcher/ViewModel/ResultViewModel.cs b/Flow.Launcher/ViewModel/ResultViewModel.cs index 2d61f6cab..53a7ffbb2 100644 --- a/Flow.Launcher/ViewModel/ResultViewModel.cs +++ b/Flow.Launcher/ViewModel/ResultViewModel.cs @@ -126,7 +126,7 @@ namespace Flow.Launcher.ViewModel private volatile bool ImageLoaded; - private ImageSource image = ImageLoader.DefaultImage; + private ImageSource image = ImageLoader.LoadingImage; public ImageSource Image { @@ -168,7 +168,7 @@ namespace Flow.Launcher.ViewModel if (ImageLoader.CacheContainImage(imagePath)) { // will get here either when icoPath has value\icon delegate is null\when had exception in delegate - image = await ImageLoader.LoadAsync(imagePath, loadFullImage); + image = await ImageLoader.LoadAsync(imagePath, loadFullImage).ConfigureAwait(false); return; }