| | |
| | | import android.graphics.RectF; |
| | | import android.widget.ImageView; |
| | | |
| | | import androidx.annotation.Nullable; |
| | | import androidx.core.graphics.drawable.RoundedBitmapDrawable; |
| | | import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory; |
| | | |
| | | import com.bumptech.glide.Glide; |
| | | import com.bumptech.glide.load.DataSource; |
| | | import com.bumptech.glide.load.engine.DiskCacheStrategy; |
| | | import com.bumptech.glide.load.engine.GlideException; |
| | | import com.bumptech.glide.load.resource.bitmap.CenterCrop; |
| | | import com.bumptech.glide.load.resource.bitmap.CircleCrop; |
| | | import com.bumptech.glide.load.resource.bitmap.GranularRoundedCorners; |
| | | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; |
| | | import com.bumptech.glide.load.resource.gif.GifDrawable; |
| | | import com.bumptech.glide.request.RequestListener; |
| | | import com.bumptech.glide.request.RequestOptions; |
| | | import com.bumptech.glide.request.target.Target; |
| | | import com.hdl.photovoltaic.R; |
| | | import com.hdl.photovoltaic.other.HdlThreadLogic; |
| | | |
| | |
| | | |
| | | private static RequestOptions getRequestOptions() { |
| | | return new RequestOptions() |
| | | .placeholder(R.mipmap.ic_launcher) |
| | | .error(R.mipmap.ic_launcher) |
| | | .fallback(R.mipmap.ic_launcher); |
| | | .placeholder(R.drawable.default_user) |
| | | .error(R.drawable.default_user) |
| | | .fallback(R.drawable.default_user); |
| | | // .override(113, 130); |
| | | |
| | | } |
| | |
| | | if (conn.getResponseCode() == 200) { |
| | | InputStream inStream = conn.getInputStream(); |
| | | Bitmap bitmap = BitmapFactory.decodeStream(inStream); |
| | | imageView.setImageBitmap(getRoundedCornerBitmap(bitmap,pixels)); |
| | | imageView.setImageBitmap(getRoundedCornerBitmap(bitmap, pixels)); |
| | | } |
| | | } catch (Exception e) { |
| | | } |
| | |
| | | canvas.drawBitmap(bitmap, rect, rect, paint); |
| | | return output; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 界面线数据显示样式 |
| | | * |
| | | * @param context 上下文 |
| | | * @param imageview 显示图片组件 |
| | | */ |
| | | public static void getDrawableGifAnimation(Context context, ImageView imageview) { |
| | | if (context == null) { |
| | | return; |
| | | } |
| | | if (imageview == null) { |
| | | return; |
| | | } |
| | | Glide.with(context) |
| | | .asGif() |
| | | .load(R.drawable.null_data_icon)//(res或者gif的url链接) |
| | | .diskCacheStrategy(DiskCacheStrategy.ALL) |
| | | .listener(new RequestListener<GifDrawable>() { |
| | | @Override |
| | | public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<GifDrawable> target, boolean isFirstResource) { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean onResourceReady(GifDrawable resource, Object model, Target<GifDrawable> target, DataSource dataSource, boolean isFirstResource) { |
| | | // resource.setLoopCount(1);控制播放次数 |
| | | return false; |
| | | } |
| | | }) |
| | | .into(imageview); |
| | | } |
| | | |
| | | |
| | | } |