| | |
| | | |
| | | import android.content.Context; |
| | | import android.net.Uri; |
| | | import android.text.TextUtils; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | |
| | | private final ArrayList<LocalMedia> list = new ArrayList<>(); |
| | | Map<String, UplodFileState> fileStates; |
| | | private int selectMax = 9; |
| | | private Context mContext; |
| | | private final Context mContext; |
| | | |
| | | |
| | | public AddPictureAdapter(Context context, List<LocalMedia> result, Map<String, UplodFileState> fileStates) { |
| | |
| | | } |
| | | |
| | | // 更新进度 |
| | | UplodFileState uplodFileState = fileStates.get(media.getCompressPath()); |
| | | uplodFileState.setAdapterPosition(position); |
| | | MyLog.d("progressRequestBodyHolder>>>" + "State:" + uplodFileState.getState() + ">>>position:" + position + ">>>Progress: " + uplodFileState.getProgress()); |
| | | |
| | | if (uplodFileState.getState() == UplodFileState.STATE_UPDING) { |
| | | 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) { |
| | | viewHolder.maskLayerBg.setVisibility(View.GONE); |
| | | viewHolder.circleProgressView.setVisibility(View.GONE); |
| | | UplodFileState uplodFileState; |
| | | if (TextUtils.isEmpty(media.getCompressPath())) { |
| | | uplodFileState = fileStates.get(media.getRealPath()); |
| | | } else { |
| | | viewHolder.maskLayerBg.setVisibility(View.VISIBLE); |
| | | uplodFileState = fileStates.get(media.getCompressPath()); |
| | | } |
| | | |
| | | |
| | | if (uplodFileState != null) { |
| | | uplodFileState.setAdapterPosition(position); |
| | | MyLog.d("progressRequestBodyHolder>>>" + "State:" + uplodFileState.getState() + ">>>position:" + position + ">>>Progress: " + uplodFileState.getProgress()); |
| | | |
| | | if (uplodFileState.getState() == UplodFileState.STATE_UPDING) { |
| | | 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) { |
| | | viewHolder.maskLayerBg.setVisibility(View.GONE); |
| | | viewHolder.circleProgressView.setVisibility(View.GONE); |
| | | } else { |
| | | viewHolder.maskLayerBg.setVisibility(View.VISIBLE); |
| | | viewHolder.postError.setVisibility(View.VISIBLE); |
| | | viewHolder.circleProgressView.setVisibility(View.GONE); |
| | | } |
| | | } |
| | | |
| | | |
| | | //itemView 的点击事件 |
| | | if (mItemClickListener != null) { |
| | |
| | | |
| | | // 更新进度参数 |
| | | if (fileStates.containsKey(uplodFileState.getFilePath())) { |
| | | if (uplodFileState.getState()==0){ |
| | | if (uplodFileState.getState() == 0) { |
| | | // 获取已有的 UplodFileState 对象并更新进度 |
| | | UplodFileState existingState = fileStates.get(uplodFileState.getFilePath()); |
| | | existingState.setProgress(uplodFileState.getProgress()); // 更新进度 |
| | |
| | | // 通知适配器刷新指定位置的项 |
| | | notifyItemChanged(position); |
| | | } |
| | | }else if (uplodFileState.getState()==2){ |
| | | } else if (uplodFileState.getState() == 2) { |
| | | |
| | | } |
| | | |
| | |
| | | mIvDel = view.findViewById(R.id.iv_del); |
| | | tvDuration = view.findViewById(R.id.tv_duration); |
| | | circleProgressView = view.findViewById(R.id.cpv); |
| | | maskLayerBg=view.findViewById(R.id.mask_layer_bg); |
| | | postError=view.findViewById(R.id.postError); |
| | | maskLayerBg = view.findViewById(R.id.mask_layer_bg); |
| | | postError = view.findViewById(R.id.postError); |
| | | } |
| | | } |
| | | |