com.bumptech.glide.BitmapTypeRequest Java Examples
The following examples show how to use
com.bumptech.glide.BitmapTypeRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GlideImageGetter.java From RichText with MIT License | 4 votes |
@Override public Drawable getDrawable(ImageHolder holder, final RichTextConfig config, TextView textView) { final ImageTarget target; final GenericRequestBuilder load; DrawableTypeRequest dtr; DrawableWrapper drawableWrapper = new DrawableWrapper(); byte[] src = Base64.decode(holder.getSource()); if (src != null) { dtr = Glide.with(textView.getContext()).load(src); } else { dtr = Glide.with(textView.getContext()).load(holder.getSource()); } Rect rect = null; if (config.cacheType >= CacheType.LAYOUT) { rect = loadCache(holder.getSource()); if (rect != null) { drawableWrapper.setBounds(rect); } } else { drawableWrapper.setBounds(0, 0, holder.getWidth(), holder.getHeight()); } if (holder.isGif()) { target = new ImageTargetGif(textView, drawableWrapper, holder, config, this, rect); load = dtr.asGif(); } else { target = new ImageTargetBitmap(textView, drawableWrapper, holder, config, this, rect); load = dtr.asBitmap().atMost(); } checkTag(textView); targets.add(target); if (!config.resetSize && holder.isInvalidateSize()) { load.override(holder.getWidth(), holder.getHeight()); } if (holder.getScaleType() == ImageHolder.ScaleType.CENTER_CROP) { if (holder.isGif()) { //noinspection ConstantConditions ((GifTypeRequest) load).centerCrop(); } else { //noinspection ConstantConditions ((BitmapTypeRequest) load).centerCrop(); } } else if (holder.getScaleType() == ImageHolder.ScaleType.FIT_CENTER) { if (holder.isGif()) { //noinspection ConstantConditions ((GifTypeRequest) load).fitCenter(); } else { //noinspection ConstantConditions ((BitmapTypeRequest) load).fitCenter(); } } textView.post(new Runnable() { @Override public void run() { load.placeholder(config.placeHolder).error(config.errorImage).into(target); } }); drawableWrapper.setCallback(textView); return drawableWrapper; }