wei
2020-12-11 488efb508eb0648773fe7b68e810e04bcd7ca075
HDL_ON/Common/ImageUtlis.cs
@@ -1,11 +1,6 @@
using System;
using Shared;
using HDL_ON;
using HDL_ON.UI.CSS;
using HDL_ON.DAL.Server;
using HDL_ON.UI;
using System.Threading;
using HDL_ON.Entity;
namespace HDL_ON
{
@@ -106,19 +101,19 @@
                    {
                        imageView.ImageBytes = null;
                        imageView.ImagePath = imageKey;
                        Utlis.WriteLine("imageKey 加载本地图片成功");
                        //Utlis.WriteLine("imageKey 加载本地图片成功");
                    }
                }
                else
                {
                    //2.自定义图片,检测是否本地缓存过,没有则云端下载然后缓存
                    if (!ignoreCache && FileUtils.Exists(imageKey))
                    if (!ignoreCache && Common.FileUtlis.Files.Exists(imageKey))
                    {
                        //2.1 本地有缓存并且不忽略缓存,直接本地读取
                        if (imageView != null)
                        {
                            imageView.ImageBytes = FileUtils.ReadFile(imageKey);
                            Utlis.WriteLine("imageKey 加载自定义缓存图片成功");
                            imageView.ImageBytes = Common.FileUtlis.Files.ReadFile(imageKey);
                            //Utlis.WriteLine("imageKey 加载自定义缓存图片成功");
                        }
                    }
                    else
@@ -129,21 +124,21 @@
                            byte[] imageBytes = GetImageDownloadUrl(imageKey);
                            if (imageBytes != null)
                            {
                                FileUtils.WriteFileByBytes(imageKey, imageBytes);
                                Common.FileUtlis.Files.WriteFileByBytes(imageKey, imageBytes);
                                //2.3 下载成功,显示并缓存本地
                                Application.RunOnMainThread(() =>
                                {
                                    if (imageView != null)
                                    {
                                        imageView.ImageBytes = imageBytes;
                                        Utlis.WriteLine("imageKey 加载云端下载图片成功");
                                        //Utlis.WriteLine("imageKey 加载云端下载图片成功");
                                    }
                                });
                            }
                            else
                            {
                                //2.4 下载是否,是否使用默认图片
                                Utlis.WriteLine("imageKey 加载云端图片失败");
                                //Utlis.WriteLine("imageKey 加载云端图片失败");
                            }
                        });
                    }
@@ -177,19 +172,19 @@
                    {
                        //imageView.ImageBytes = null;
                        frameLayout.BackgroundImagePath = imageKey;
                        Utlis.WriteLine("imageKey 加载本地图片成功");
                        //Utlis.WriteLine("imageKey 加载本地图片成功");
                    }
                }
                else
                {
                    //2.自定义图片,检测是否本地缓存过,没有则云端下载然后缓存
                    if (!ignoreCache && FileUtils.Exists(imageKey))
                    if (!ignoreCache && Common.FileUtlis.Files.Exists(imageKey))
                    {
                        //2.1 本地有缓存并且不忽略缓存,直接本地读取
                        if (frameLayout != null)
                        {
                            frameLayout.BackgroundImagePath = imageKey;
                            Utlis.WriteLine("imageKey 加载自定义缓存图片成功");
                            //Utlis.WriteLine("imageKey 加载自定义缓存图片成功");
                        }
                    }
                    else
@@ -200,21 +195,21 @@
                            byte[] imageBytes = GetImageDownloadUrl(imageKey);
                            if (imageBytes != null)
                            {
                                FileUtils.WriteFileByBytes(imageKey, imageBytes);
                                Common.FileUtlis.Files.WriteFileByBytes(imageKey, imageBytes);
                                //2.3 下载成功,显示并缓存本地
                                Application.RunOnMainThread(() =>
                                {
                                    if (frameLayout != null)
                                    {
                                        frameLayout.BackgroundImagePath = imageKey;
                                        Utlis.WriteLine("imageKey 加载云端下载图片成功");
                                        //Utlis.WriteLine("imageKey 加载云端下载图片成功");
                                    }
                                });
                            }
                            else
                            {
                                //2.4 下载是否,是否使用默认图片
                                Utlis.WriteLine("imageKey 加载云端图片失败");
                                //Utlis.WriteLine("imageKey 加载云端图片失败");
                            }
                        });
                    }
@@ -264,10 +259,10 @@
            {
                var imageKey = GetHeadImageKey(userId);
                byte[] imageBytes;
                if (!ignoreCache && FileUtils.Exists(imageKey))
                if (!ignoreCache && Common.FileUtlis.Files.Exists(imageKey))
                {
                    //本地有缓存
                    imageBytes = FileUtils.ReadFile(imageKey);
                    imageBytes = Common.FileUtlis.Files.ReadFile(imageKey);
                }
                else
                {
@@ -276,7 +271,7 @@
                    if(imageBytes != null)
                    {
                        //保存到本地
                        FileUtils.WriteFileByBytes(imageKey, imageBytes);
                        Common.FileUtlis.Files.WriteFileByBytes(imageKey, imageBytes);
                    }
                   
                }