| | |
| | | package com.igo.user.utils; |
| | | |
| | | import android.annotation.SuppressLint; |
| | | import android.app.Activity; |
| | | import android.graphics.Bitmap; |
| | | import android.net.Uri; |
| | | import android.provider.MediaStore; |
| | | import android.text.TextUtils; |
| | | import android.util.Log; |
| | | import android.widget.ImageView; |
| | | |
| | | import com.bumptech.glide.Glide; |
| | | import com.bumptech.glide.load.engine.DiskCacheStrategy; |
| | | import com.bumptech.glide.load.resource.bitmap.CenterCrop; |
| | | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; |
| | | import com.bumptech.glide.request.RequestOptions; |
| | | import com.facebook.common.util.UriUtil; |
| | | import com.facebook.drawee.backends.pipeline.Fresco; |
| | | import com.facebook.drawee.backends.pipeline.PipelineDraweeController; |
| | |
| | | import com.facebook.imagepipeline.postprocessors.IterativeBoxBlurPostProcessor; |
| | | import com.facebook.imagepipeline.request.ImageRequest; |
| | | import com.facebook.imagepipeline.request.ImageRequestBuilder; |
| | | import com.igo.user.views.textbanner.utils.DisplayUtils; |
| | | |
| | | /** |
| | | * Created by Administrator on 2018/1/23. |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | /*** |
| | | * 加载图片 |
| | | */ |
| | | @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(placeholder, error, DisplayUtils.dip2px(imageView.getContext(), radius))) |
| | | .placeholder(placeholder) |
| | | .error(error) |
| | | .into(imageView); |
| | | } |
| | | |
| | | private static RequestOptions getRequestOption(int placeholder, int error, int radius) { |
| | | RequestOptions requestOptions = new RequestOptions() |
| | | .error(error) |
| | | .placeholder(placeholder) |
| | | .diskCacheStrategy(DiskCacheStrategy.RESOURCE); |
| | | if (radius == 0) { |
| | | requestOptions = requestOptions.centerCrop(); |
| | | } else { |
| | | requestOptions = requestOptions.apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(radius))); |
| | | } |
| | | return requestOptions; |
| | | } |
| | | } |