@Override public void loadThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, Uri uri) { Glide.with(context) .load(uri) .asBitmap() // some .jpeg files are actually gif .placeholder(placeholder) .override(resize, resize) .centerCrop() .into(imageView); }
@Override public void loadGifThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, Uri uri) { Glide.with(context) .load(uri) .asBitmap() .placeholder(placeholder) .override(resize, resize) .centerCrop() .into(imageView); }
@Override public void displayImage(Activity activity, final ImageView imageView, String path, @DrawableRes int loadingResId, @DrawableRes int failResId, int width, int height, final MQDisplayImageListener listener) { final String finalPath = getPath(path); Glide.with(activity).load(finalPath).asBitmap().placeholder(loadingResId).error(failResId).override(width, height).listener(new RequestListener<String, Bitmap>() { @Override public boolean onException(Exception e, String model, Target<Bitmap> target, boolean isFirstResource) { return false; } @Override public boolean onResourceReady(Bitmap resource, String model, Target<Bitmap> target, boolean isFromMemoryCache, boolean isFirstResource) { if (listener != null) { listener.onSuccess(imageView, finalPath); } return false; } }).into(imageView); }
@Override public void onBindView(View view) { final ImageView iv_header_bg = (ImageView) view.findViewById(R.id.iv_header_bg); final ImageView iv_cover = (ImageView) view.findViewById(R.id.iv_cover); TextView tv_title = (TextView) view.findViewById(R.id.tv_title); TextView tv_update_date = (TextView) view.findViewById(R.id.tv_update_date); TextView tv_comment = (TextView) view.findViewById(R.id.tv_comment); tv_title.setText(onlineMusicList.getBillboard().getName()); tv_update_date.setText(getString(R.string.recent_update, onlineMusicList.getBillboard().getUpdate_date())); tv_comment.setText(onlineMusicList.getBillboard().getComment()); Glide.with(OnlineMusicActivity.this) .load(onlineMusicList.getBillboard().getPic_s640()) .asBitmap() .placeholder(R.drawable.default_cover) .error(R.drawable.default_cover) .override(200, 200) .into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { iv_cover.setImageBitmap(resource); iv_header_bg.setImageBitmap(ImageUtils.blur(resource)); } }); } });
private void loadPhoto(final PhotoResult photoResult, final ImageView iv) { Glide.with(mContext).load(photoResult.getPhotoPath()).asBitmap() .centerCrop().dontAnimate().thumbnail(0.5F).override(photoSize, photoSize) .diskCacheStrategy(DiskCacheStrategy.RESULT).placeholder(R.drawable.photo_loading) .into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { iv.setImageBitmap(resource); PhotoUtil.bitmap2File(mContext, resource, photoResult, null); } }); }