| | |
| | | }); |
| | | viewHolder.mIvDel.setVisibility(View.INVISIBLE); |
| | | viewHolder.circleProgressView.setVisibility(View.GONE); |
| | | viewHolder.maskLayerBg.setVisibility(View.GONE); |
| | | } else { |
| | | //删除图片 |
| | | viewHolder.mIvDel.setVisibility(View.VISIBLE); |
| | |
| | | } |
| | | |
| | | // 更新进度 |
| | | UplodFileState uplodFileState; |
| | | if (TextUtils.isEmpty(media.getCompressPath())) { |
| | | uplodFileState = fileStates.get(media.getRealPath()); |
| | | } else { |
| | | uplodFileState = fileStates.get(media.getCompressPath()); |
| | | } |
| | | |
| | | |
| | | UplodFileState uplodFileState = TextUtils.isEmpty(media.getCompressPath()) |
| | | ? fileStates.get(media.getRealPath()) |
| | | : fileStates.get(media.getCompressPath()); |
| | | if (uplodFileState != null) { |
| | | MyLog.d("progressRequestBodyHolder>>>" + "path:" + uplodFileState.getFilePath() + ">>>position:" + position); |
| | | uplodFileState.setAdapterPosition(position); |
| | | MyLog.d("progressRequestBodyHolder>>>" + "State:" + uplodFileState.getState() + ">>>position:" + position + ">>>Progress: " + uplodFileState.getProgress()); |
| | | |
| | | if (uplodFileState.getState() == UplodFileState.STATE_UPDING) { |
| | | MyLog.d("progressRequestBodyHolder>>>" + "正在上传"); |
| | | viewHolder.postError.setVisibility(View.GONE); |
| | | if (uplodFileState.getProgress() < 100) { |
| | | viewHolder.maskLayerBg.setVisibility(View.VISIBLE); |
| | | viewHolder.circleProgressView.setVisibility(View.VISIBLE); |
| | | viewHolder.circleProgressView.setProgress(uplodFileState.getProgress()); |
| | | |
| | | } else { |
| | | viewHolder.circleProgressView.setVisibility(View.GONE); |
| | | viewHolder.maskLayerBg.setVisibility(View.GONE); |
| | | } |
| | | } else if (fileStates.get(media.getCompressPath()).getState() == UplodFileState.STATE_DONE) { |
| | | } else if (uplodFileState.getState() == UplodFileState.STATE_DONE) { |
| | | MyLog.d("progressRequestBodyHolder>>>" + "完成"); |
| | | viewHolder.maskLayerBg.setVisibility(View.GONE); |
| | | viewHolder.circleProgressView.setVisibility(View.GONE); |
| | | } else { |
| | | MyLog.d("progressRequestBodyHolder>>>" + "错误"); |
| | | viewHolder.maskLayerBg.setVisibility(View.VISIBLE); |
| | | viewHolder.postError.setVisibility(View.VISIBLE); |
| | | viewHolder.circleProgressView.setVisibility(View.GONE); |
| | |
| | | int adapterPosition = viewHolder.getAbsoluteAdapterPosition(); |
| | | mItemClickListener.onItemClick(v, adapterPosition); |
| | | }); |
| | | viewHolder.postError.setOnClickListener(v -> { |
| | | mItemClickListener.onReUpload(uplodFileState); |
| | | }); |
| | | } |
| | | |
| | | if (mItemLongClickListener != null) { |
| | | viewHolder.itemView.setOnLongClickListener(v -> { |
| | | int adapterPosition = viewHolder.getAbsoluteAdapterPosition(); |
| | | int adapterPosition = viewHolder.getBindingAdapterPosition(); |
| | | mItemLongClickListener.onItemLongClick(viewHolder, adapterPosition, v); |
| | | return true; |
| | | }); |
| | |
| | | |
| | | // 更新进度参数 |
| | | if (fileStates.containsKey(uplodFileState.getFilePath())) { |
| | | // 获取已有的 UplodFileState 对象并更新进度 |
| | | UplodFileState existingState = fileStates.get(uplodFileState.getFilePath()); |
| | | int position = existingState.getAdapterPosition(); |
| | | existingState.setState(uplodFileState.getState()); |
| | | if (uplodFileState.getState() == 0) { |
| | | // 获取已有的 UplodFileState 对象并更新进度 |
| | | UplodFileState existingState = fileStates.get(uplodFileState.getFilePath()); |
| | | existingState.setState(uplodFileState.getState()); |
| | | existingState.setProgress(uplodFileState.getProgress()); // 更新进度 |
| | | // 获取进度更新项的位置 |
| | | int position = existingState.getAdapterPosition(); |
| | | if (position != RecyclerView.NO_POSITION) { |
| | | // 通知适配器刷新指定位置的项 |
| | | notifyItemChanged(position); |
| | | } |
| | | } else if (uplodFileState.getState() == 2) { |
| | | |
| | | } |
| | | |
| | | if (position != RecyclerView.NO_POSITION) { |
| | | notifyItemChanged(position); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | * @param position |
| | | */ |
| | | void onDeleteClick(int position); |
| | | |
| | | /** |
| | | * 上传失败后重新上传 |
| | | */ |
| | | void onReUpload(UplodFileState uplodFileState); |
| | | } |
| | | |
| | | private OnItemLongClickListener mItemLongClickListener; |