| | |
| | | import android.widget.ImageView; |
| | | import android.widget.TextView; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.recyclerview.widget.RecyclerView; |
| | | |
| | | import com.bumptech.glide.Glide; |
| | | import com.bumptech.glide.load.engine.DiskCacheStrategy; |
| | | import com.dayu.pipirrapp.R; |
| | | import com.dayu.pipirrapp.listener.OnItemLongClickListener; |
| | | import com.luck.picture.lib.adapter.holder.PreviewGalleryAdapter; |
| | | import com.luck.picture.lib.config.PictureMimeType; |
| | | import com.luck.picture.lib.config.SelectMimeType; |
| | | import com.luck.picture.lib.entity.LocalMedia; |
| | |
| | | */ |
| | | public void delete(int position) { |
| | | try { |
| | | |
| | | if (position != RecyclerView.NO_POSITION && list.size() > position) { |
| | | list.remove(position); |
| | | notifyItemRemoved(position); |
| | |
| | | /** |
| | | * 创建ViewHolder |
| | | */ |
| | | @NonNull |
| | | @Override |
| | | public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { |
| | | View view = mInflater.inflate(R.layout.item_add_filter_image, viewGroup, false); |
| | |
| | | * 设置值 |
| | | */ |
| | | @Override |
| | | public void onBindViewHolder(final ViewHolder viewHolder, final int position) { |
| | | public void onBindViewHolder(@NonNull final ViewHolder viewHolder, final int position) { |
| | | //少于MaxSize张,显示继续添加的图标 |
| | | if (getItemViewType(position) == TYPE_CAMERA) { |
| | | viewHolder.mImg.setImageResource(R.mipmap.ic_add_image); |
| | |
| | | viewHolder.mIvDel.setOnClickListener(view -> { |
| | | int index = viewHolder.getAbsoluteAdapterPosition(); |
| | | if (index != RecyclerView.NO_POSITION && list.size() > index) { |
| | | mItemClickListener.onDeleteClick(index); |
| | | list.remove(index); |
| | | notifyItemRemoved(index); |
| | | notifyItemRangeChanged(index, list.size()); |
| | |
| | | * Open PictureSelector |
| | | */ |
| | | void openPicture(); |
| | | |
| | | /** |
| | | * 删除了某一个 |
| | | * |
| | | * @param position |
| | | */ |
| | | void onDeleteClick(int position); |
| | | } |
| | | |
| | | private OnItemLongClickListener mItemLongClickListener; |