Search in sources :

Example 1 with BitmapImageViewTarget

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());
            }
        }
    });
}
Also used : RoundedBitmapDrawable(android.support.v4.graphics.drawable.RoundedBitmapDrawable) LocalMediaFolder(com.luck.picture.lib.weiui.library.entity.LocalMediaFolder) Bitmap(android.graphics.Bitmap) BitmapImageViewTarget(vip.kuaifan.weiui.extend.integration.glide.request.target.BitmapImageViewTarget) RequestOptions(vip.kuaifan.weiui.extend.integration.glide.request.RequestOptions) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

Bitmap (android.graphics.Bitmap)1 RoundedBitmapDrawable (android.support.v4.graphics.drawable.RoundedBitmapDrawable)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 LocalMediaFolder (com.luck.picture.lib.weiui.library.entity.LocalMediaFolder)1 RequestOptions (vip.kuaifan.weiui.extend.integration.glide.request.RequestOptions)1 BitmapImageViewTarget (vip.kuaifan.weiui.extend.integration.glide.request.target.BitmapImageViewTarget)1