| | |
| | | |
| | | //当前选择的拍照类型 |
| | | private var currentType = MediaFileType.RoutineRecord |
| | | private var currentTypeName = currentType.des |
| | | |
| | | lateinit var viewModel: MenuCameraViewModel |
| | | |
| | | private val viewList = mutableListOf<View>() |
| | | |
| | | private val listMap = mutableMapOf<MediaFileType, RecyclerView>() |
| | | |
| | | var subTask: Subtask? = null |
| | | var inspection: Inspection? = null |
| | |
| | | val oldFile = File(it) |
| | | val cal = Calendar.getInstance().apply { time = subTask?.executionstarttime } |
| | | scene?.run { |
| | | val path = "FlightFeather/Photo/" + districtname + "/"+ cal.get(Calendar.YEAR) + "年" + (cal.get(Calendar.MONTH) + 1) + "月/"+ (cal.get(Calendar.MONTH) + 1) + "月" + cal.get(Calendar.DAY_OF_MONTH) + "日/"+ name + "/任意拍照/" |
| | | val path = "FlightFeather/Photo/" + districtname + "/" + cal.get(Calendar.YEAR) + "年" + (cal.get(Calendar.MONTH) + 1) + "月/" + |
| | | (cal.get(Calendar.MONTH) + 1) + "月" + cal.get(Calendar.DAY_OF_MONTH) + "日/" + name + "/任意拍照/" + currentTypeName + "/" |
| | | |
| | | val fileName = UUIDGenerator.generateUUID(4) + ".jpg" |
| | | val newFile = File(Environment.getExternalStorageDirectory(), path + fileName) |
| | | if (!newFile.parentFile.exists()) { |
| | |
| | | addOnItemTouchListener(RecyclerItemClickListener(this@MenuCameraActivity, this, object : RecyclerItemClickListener.OnItemClickListener { |
| | | override fun onItemClick(view: View?, position: Int) { |
| | | currentType = type |
| | | currentTypeName = title.text.toString() |
| | | //拍照 |
| | | if (dataList[position].guid == null) { |
| | | PhotoUtil.pickPhoto2(this@MenuCameraActivity, TAKE_PHOTO, 9) |
| | |
| | | } |
| | | |
| | | })) |
| | | |
| | | if (!listMap.containsKey(type)) { |
| | | listMap[type] = this |
| | | } |
| | | } |
| | | |
| | | viewList.add(view) |
| | |
| | | } |
| | | |
| | | private fun addPhoto(mediaFile: Mediafile) { |
| | | getDataSet(currentType).run { |
| | | first.value?.add(mediaFile) |
| | | second.adapter?.run { |
| | | notifyDataSetChanged() |
| | | if (listMap.containsKey(currentType)) { |
| | | viewModel.fileList.value?.forEach { |
| | | if (it.type == currentType) { |
| | | it.dataList.add(mediaFile)//第一个数据为拍照按钮 |
| | | listMap[currentType]?.adapter?.notifyDataSetChanged() |
| | | } |
| | | } |
| | | } |
| | | // getDataSet(currentType).run { |
| | | // first.value?.add(mediaFile) |
| | | // second.adapter?.run { |
| | | // notifyDataSetChanged() |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | private fun deletePhoto(pos: Int) { |
| | | getDataSet(currentType).run { |
| | | first.value?.removeAt(pos + 1)//第一个数据为拍照按钮 |
| | | second.adapter?.run { |
| | | notifyDataSetChanged() |
| | | if (listMap.containsKey(currentType)) { |
| | | viewModel.fileList.value?.forEach { |
| | | if (it.type == currentType) { |
| | | it.dataList.removeAt(pos + 1)//第一个数据为拍照按钮 |
| | | listMap[currentType]?.adapter?.notifyDataSetChanged() |
| | | } |
| | | } |
| | | } |
| | | // getDataSet(currentType).run { |
| | | // first.value?.removeAt(pos + 1)//第一个数据为拍照按钮 |
| | | // second.adapter?.run { |
| | | // notifyDataSetChanged() |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | private fun getDataSet(type: MediaFileType) = when (type) { |