use of com.bumptech.glide.load.model.StreamEncoder in project Shuttle by timusus.
the class ArtworkView method bindView.
@Override
public void bindView(ViewHolder holder) {
super.bindView(holder);
long time = System.currentTimeMillis();
holder.textContainer.setBackground(null);
holder.progressBar.setVisibility(View.VISIBLE);
holder.lineTwo.setText(null);
Glide.with(holder.itemView.getContext()).using(new TypeLoader(type, file), InputStream.class).from(ArtworkProvider.class).as(BitmapAndSize.class).sourceEncoder(new StreamEncoder()).decoder(new BitmapAndSizeDecoder(holder.itemView.getContext())).diskCacheStrategy(DiskCacheStrategy.NONE).load(artworkProvider).listener(new RequestListener<ArtworkProvider, BitmapAndSize>() {
@Override
public boolean onException(Exception e, ArtworkProvider model, Target<BitmapAndSize> target, boolean isFirstResource) {
if (glideListener != null) {
if (holder.itemView.getHandler() != null) {
holder.itemView.getHandler().postDelayed(() -> glideListener.onArtworkLoadFailed(ArtworkView.this), System.currentTimeMillis() + 1000 - time);
}
}
return false;
}
@Override
public boolean onResourceReady(BitmapAndSize resource, ArtworkProvider model, Target<BitmapAndSize> target, boolean isFromMemoryCache, boolean isFirstResource) {
return false;
}
}).into(new ImageViewTarget<BitmapAndSize>(((ViewHolder) holder).imageView) {
@Override
protected void setResource(BitmapAndSize resource) {
holder.textContainer.setBackgroundResource(R.drawable.text_protection_scrim_reversed);
holder.progressBar.setVisibility(View.GONE);
holder.imageView.setImageBitmap(resource.bitmap);
holder.lineTwo.setText(String.format("%sx%spx", resource.size.width, resource.size.height));
}
});
holder.lineOne.setText(ArtworkModel.getTypeString(type));
if (type == ArtworkProvider.Type.FOLDER && file != null) {
holder.lineOne.setText(file.getName());
}
if (isCustom && file != null && file.getPath().contains("custom_artwork")) {
holder.lineOne.setText(holder.itemView.getContext().getString(R.string.artwork_type_custom));
}
holder.checkView.setVisibility(isSelected() ? View.VISIBLE : View.GONE);
}
Aggregations