| | |
| | | RecyclerView mRecyclerView; |
| | | AddPictureAdapter mAdapter; |
| | | int maxSelectNum = 10;//最大照片 |
| | | int maxSelectVideoNum = 0;//最大视频 |
| | | int maxSelectVideoNum = 3;//最大视频 |
| | | |
| | | int videoMaxSecond = 60; |
| | | private final List<LocalMedia> mData = new ArrayList<>(); |
| | | private ActivityResultLauncher<Intent> launcherResult; |
| | | private ImageEngine imageEngine; |
| | |
| | | |
| | | if (!TextUtils.isEmpty(binding.contentET.getText().toString())) { |
| | | if (isAllPost) { |
| | | if (uplodFileStates.size() > 0) { |
| | | if (!uplodFileStates.isEmpty()) { |
| | | postData(); |
| | | } else { |
| | | ToastUtil.showToast(AddIssueActivity.this, "请上传图片"); |
| | |
| | | private void mOpenPicture() { |
| | | // 进入相册 |
| | | PictureSelectionModel selectionModel = PictureSelector.create(this) |
| | | .openGallery(SelectMimeType.ofImage()) |
| | | .openGallery(SelectMimeType.ofAll()) |
| | | .setMaxSelectNum(maxSelectNum) |
| | | .setMaxVideoSelectNum(maxSelectVideoNum) |
| | | .setImageEngine(imageEngine) |
| | | //设置图片压缩 |
| | | .setCompressEngine(new ImageFileCompressEngine()) |
| | | //设置视频图片一起在相册选择 |
| | | .isWithSelectVideoImage(true) |
| | | //设置最大视频时长 |
| | | .setRecordVideoMaxSecond(videoMaxSecond) |
| | | // 过滤视频最大时长 |
| | | .setFilterVideoMaxSecond(videoMaxSecond) |
| | | // 拍照是否纠正旋转图片 |
| | | .isCameraRotateImage(true) |
| | | .setSelectedData(mAdapter.getData()); |
| | | |
| | | selectionModel.forResult(launcherResult); |
| | |
| | | Log.i(TAG, "文件时长: " + media.getDuration()); |
| | | String compressPath = media.getCompressPath(); |
| | | //判断是否有这个路径,没有的话上传该图片并添加uplodFileStates中 |
| | | if (TextUtils.isEmpty(compressPath)) { |
| | | compressPath = media.getRealPath(); |
| | | } |
| | | if (!existingPaths.contains(compressPath)) { |
| | | UplodFileState uplodFileState = new UplodFileState(); |
| | | uplodFileState.setFilePath(compressPath); |
| | |
| | | |
| | | //上传图片 |
| | | private void uplodeImg(UplodFileState uplodFileState) { |
| | | ApiManager.getInstance().uploadFile(this, uplodFileState, new UploadFileListener() { |
| | | @Override |
| | | public void onBack(UplodFileState state) { |
| | | uplodFileStates.replace(state.getFilePath(), state); |
| | | mAdapter.updateProgress(uplodFileState); |
| | | } |
| | | ApiManager.getInstance().uploadFile(this, uplodFileState, state -> { |
| | | |
| | | uplodFileStates.replace(state.getFilePath(), state); |
| | | mAdapter.updateProgress(uplodFileState); |
| | | }, mAdapter); |
| | | } |
| | | |