riku
2022-02-18 d59d55575d913646b7a90fca651904ab889c6723
app/src/main/java/cn/flightfeather/thirdappmodule/module/base/BaseTakePicActivity.kt
@@ -56,10 +56,11 @@
                //查看临时拍摄图片可以删除
                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()
                    }
                }
@@ -68,16 +69,17 @@
                val paths = data?.getStringArrayListExtra(EXTRA_SELECT_IMAGES)
                paths?.forEach {
                    val oldFile = File(it)
                    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("复制文件失败")
                    if (it.contains("FlightFeather/Temp")) {
                        pathTempList.add(Pair(oldFile, true))
                    } else {
                        val newFile = File(Environment.getExternalStorageDirectory(), "FlightFeather/Temp/" + UUIDGenerator.generateUUID(4) + ".jpg")
                        try {
                            FileUtil.copyFile(oldFile, newFile)
                            pathTempList.add(Pair(newFile, true))
                        } catch (e: IOException) {
                            e.printStackTrace()
                            application.toast("复制文件失败")
                        }
                    }
                }
                refreshImageView()
@@ -132,7 +134,7 @@
        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)
        }
    }