| | |
| | | //查看临时拍摄图片可以删除 |
| | | data?.getIntExtra("position", -1)?.let { |
| | | if (it > -1) { |
| | | if (pathTempList[it].first.exists()) { |
| | | pathTempList[it].first.delete() |
| | | } |
| | | val file = pathTempList[it].first |
| | | pathTempList.removeAt(it) |
| | | if (file.exists()) { |
| | | file.delete() |
| | | } |
| | | refreshImageView() |
| | | } |
| | | } |
| | |
| | | val paths = data?.getStringArrayListExtra(EXTRA_SELECT_IMAGES) |
| | | paths?.forEach { |
| | | val oldFile = File(it) |
| | | if (it.contains("FlightFeather/Temp")) { |
| | | pathTempList.add(Pair(oldFile, true)) |
| | | } else { |
| | | val newFile = File(Environment.getExternalStorageDirectory(), "FlightFeather/Temp/" + UUIDGenerator.generateUUID(4) + ".jpg") |
| | | if (!newFile.parentFile.exists()) { |
| | | newFile.parentFile.mkdirs() |
| | | } |
| | | try { |
| | | FileUtil.copyFile(oldFile, newFile) |
| | | pathTempList.add(Pair(newFile, true)) |
| | | } catch (e: IOException) { |
| | | e.printStackTrace() |
| | | application.toast("复制文件失败") |
| | | } |
| | | } |
| | | } |
| | | refreshImageView() |
| | |
| | | return View.OnClickListener { |
| | | val t = imageViewList.size - pathTempList.size |
| | | val picNum = if (t >= 0) t else 0 |
| | | PhotoUtil.pickPhoto2(this, TAKE_PHOTO, picNum) |
| | | PhotoUtil.pickPhoto(this, TAKE_PHOTO, picNum) |
| | | } |
| | | } |
| | | |