| | |
| | | import com.facebook.imagepipeline.postprocessors.IterativeBoxBlurPostProcessor; |
| | | import com.facebook.imagepipeline.request.ImageRequest; |
| | | import com.facebook.imagepipeline.request.ImageRequestBuilder; |
| | | import com.igo.user.IGoApplication; |
| | | import com.igo.user.R; |
| | | import com.igo.user.views.textbanner.utils.DisplayUtils; |
| | | |
| | | /** |
| | |
| | | * 加载图片 |
| | | */ |
| | | @SuppressLint("CheckResult") |
| | | public static void load(ImageView imageView, String url) { |
| | | Glide.with(imageView) |
| | | .load(url) |
| | | .into(imageView); |
| | | } |
| | | |
| | | /*** |
| | | * 加载图片 |
| | | */ |
| | | @SuppressLint("CheckResult") |
| | | public static void load(ImageView imageView, String url, int placeholder, int error, int radius) { |
| | | Glide.with(imageView) |
| | | .load(url) |
| | | .apply(getRequestOption(radius)) |
| | | .apply(getRequestOption(placeholder, error, DisplayUtils.dip2px(imageView.getContext(), radius))) |
| | | .placeholder(placeholder) |
| | | .error(error) |
| | | .into(imageView); |
| | | } |
| | | private static RequestOptions getRequestOption(int radius) { |
| | | RequestOptions chatcricleFoursUserHead; |
| | | DiskCacheStrategy diskCacheStrategy = DiskCacheStrategy.RESOURCE; |
| | | |
| | | private static RequestOptions getRequestOption(int placeholder, int error, int radius) { |
| | | RequestOptions requestOptions = new RequestOptions() |
| | | .error(error) |
| | | .placeholder(placeholder) |
| | | .diskCacheStrategy(DiskCacheStrategy.RESOURCE); |
| | | if (radius == 0) { |
| | | chatcricleFoursUserHead = new RequestOptions() |
| | | .error(R.color.gray) |
| | | .placeholder(R.color.gray) |
| | | .diskCacheStrategy(diskCacheStrategy) |
| | | .centerCrop(); |
| | | requestOptions = requestOptions.centerCrop(); |
| | | } else { |
| | | chatcricleFoursUserHead = new RequestOptions() |
| | | .error(R.color.gray) |
| | | .placeholder(R.color.gray) |
| | | .diskCacheStrategy(diskCacheStrategy) |
| | | .apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(DisplayUtils.dip2px(IGoApplication.Companion.getAppContext(), radius)))); |
| | | requestOptions = requestOptions.apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(radius))); |
| | | } |
| | | return chatcricleFoursUserHead; |
| | | return requestOptions; |
| | | } |
| | | } |