use of vip.kuaifan.weiui.extend.integration.glide.request.target.BitmapImageViewTarget in project weiui by kuaifan.
the class PictureAlbumDirectoryAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
final LocalMediaFolder folder = folders.get(position);
String name = folder.getName();
int imageNum = folder.getImageNum();
String imagePath = folder.getFirstImagePath();
boolean isChecked = folder.isChecked();
int checkedNum = folder.getCheckedNum();
holder.tv_sign.setVisibility(checkedNum > 0 ? View.VISIBLE : View.INVISIBLE);
holder.itemView.setSelected(isChecked);
if (mimeType == PictureMimeType.ofAudio()) {
holder.first_image.setImageResource(R.drawable.audio_placeholder);
} else {
RequestOptions options = new RequestOptions().placeholder(R.drawable.ic_placeholder).centerCrop().sizeMultiplier(0.5f).diskCacheStrategy(DiskCacheStrategy.ALL).override(160, 160);
Glide.with(holder.itemView.getContext()).asBitmap().load(imagePath).apply(options).into(new BitmapImageViewTarget(holder.first_image) {
@Override
protected void setResource(Bitmap resource) {
RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(mContext.getResources(), resource);
circularBitmapDrawable.setCornerRadius(8);
holder.first_image.setImageDrawable(circularBitmapDrawable);
}
});
}
holder.image_num.setText("(" + imageNum + ")");
holder.tv_folder_name.setText(name);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (onItemClickListener != null) {
for (LocalMediaFolder mediaFolder : folders) {
mediaFolder.setChecked(false);
}
folder.setChecked(true);
notifyDataSetChanged();
onItemClickListener.onItemClick(folder.getName(), folder.getImages());
}
}
});
}
Aggregations