From 5ca2b601848c62607d88fee5afdae6af80f6eea7 Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期三, 20 三月 2024 16:12:26 +0800 Subject: [PATCH] 2024年03月20日16:12:17 --- app/src/main/java/com/hdl/photovoltaic/utils/GlideUtils.java | 29 ++++++++++++++++++----------- 1 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/utils/GlideUtils.java b/app/src/main/java/com/hdl/photovoltaic/utils/GlideUtils.java index c76747d..d9aa883 100644 --- a/app/src/main/java/com/hdl/photovoltaic/utils/GlideUtils.java +++ b/app/src/main/java/com/hdl/photovoltaic/utils/GlideUtils.java @@ -48,7 +48,7 @@ public static void getGeneralImage(Context context, String url, ImageView imageview) { Glide.with(context) .load(url) - .apply(getRequestOptions()) + .apply(getRequestOptions(false)) .into(imageview); } @@ -63,7 +63,7 @@ public static void getGranularRoundedCornersImage(Context context, String url, ImageView imageview, GranularRoundedCorners granularRoundedCorners) { Glide.with(context) .load(url) - .apply(getRequestOptions()) + .apply(getRequestOptions(false)) .transform(granularRoundedCorners)//new GranularRoundedCorners(30f,80f,80f,30f) .into(imageview); } @@ -76,10 +76,10 @@ * @param imageview 鏄剧ず鍥剧墖缁勪欢 * @param roundedCorners 璁剧疆鍥剧墖瑙掑害鍊� */ - public static void getRoundedCornersImage(Context context, String url, ImageView imageview, RoundedCorners roundedCorners) { + public static void getRoundedCornersImage(Context context, String url, ImageView imageview, RoundedCorners roundedCorners, boolean userImage) { Glide.with(context) .load(url) - .apply(getRequestOptions()) + .apply(getRequestOptions(userImage)) .transform(new CenterCrop(), roundedCorners)//Glide鍔犺浇鍥剧墖鍦嗚鏁堟灉涓嶪mageView鐨凷caleType鍐茬獊闂 // .transform(roundedCorners) .into(imageview); @@ -92,21 +92,28 @@ * @param url 鍥剧墖鍦板潃 * @param imageview 鏄剧ず鍥剧墖缁勪欢 */ - public static void getCircleCropImage(Context context, String url, ImageView imageview) { + public static void getCircleCropImage(Context context, String url, ImageView imageview, boolean userImage) { Glide.with(context) .load(url) - .apply(getRequestOptions()) + .apply(getRequestOptions(userImage)) .transform(new CircleCrop()) .into(imageview); } - private static RequestOptions getRequestOptions() { - return new RequestOptions() - .placeholder(R.drawable.default_user) - .error(R.drawable.default_user) - .fallback(R.drawable.default_user); + private static RequestOptions getRequestOptions(boolean userImage) { + if (userImage) { + return new RequestOptions() + .placeholder(R.drawable.default_image) + .error(R.drawable.default_image) + .fallback(R.drawable.default_image); + } else { + return new RequestOptions() + .placeholder(R.drawable.default_user) + .error(R.drawable.default_user) + .fallback(R.drawable.default_user); // .override(113, 130); + } } -- Gitblit v1.8.0