|
|
|
@ -18,7 +18,6 @@ object ExportUtils {
|
|
|
|
|
context: Context,
|
|
|
|
|
usbPath: String,
|
|
|
|
|
datas: MutableList<Gas>,
|
|
|
|
|
commonDialog: CommonDialog?
|
|
|
|
|
): String? {
|
|
|
|
|
val allData = mutableListOf<List<SimpleCellValue>>()
|
|
|
|
|
datas.forEach {
|
|
|
|
@ -31,7 +30,6 @@ object ExportUtils {
|
|
|
|
|
}
|
|
|
|
|
LogUtils.w("testExportExcel ori data size = ${datas.size}, cell data size = ${allData.size}")
|
|
|
|
|
val excelPath = ExcelUtils.writeStringListToExcel(allData, usbPath, context)
|
|
|
|
|
commonDialog?.dismiss()
|
|
|
|
|
return excelPath
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -40,7 +38,6 @@ object ExportUtils {
|
|
|
|
|
context: Context,
|
|
|
|
|
usbPath: String,
|
|
|
|
|
datas: MutableList<Warning>,
|
|
|
|
|
loadingDialog: CommonDialog?
|
|
|
|
|
): String? {
|
|
|
|
|
val allData = mutableListOf<List<SimpleCellValue>>()
|
|
|
|
|
datas.forEach {
|
|
|
|
@ -53,15 +50,12 @@ object ExportUtils {
|
|
|
|
|
}
|
|
|
|
|
LogUtils.w("testExportWarnExcel ori data size = ${datas.size}, cell data size = ${allData.size}")
|
|
|
|
|
val excelPath = ExcelUtils.writeStringListToExcel(allData, usbPath, context, true)
|
|
|
|
|
loadingDialog?.dismiss()
|
|
|
|
|
return excelPath
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun testCopyVideo(
|
|
|
|
|
context: Context,
|
|
|
|
|
usbPath: String,
|
|
|
|
|
datas: MutableList<Video>,
|
|
|
|
|
loadingDialog: CommonDialog?
|
|
|
|
|
) {
|
|
|
|
|
val usbVideoPath = usbPath + File.separator + "Video"
|
|
|
|
|
val dFile = File(usbVideoPath);
|
|
|
|
@ -69,11 +63,20 @@ object ExportUtils {
|
|
|
|
|
dFile.mkdir()
|
|
|
|
|
}
|
|
|
|
|
datas.forEach {
|
|
|
|
|
FileUtils.copy(
|
|
|
|
|
File(it.path).inputStream(),
|
|
|
|
|
File(usbVideoPath + "/${it.name}").outputStream()
|
|
|
|
|
)
|
|
|
|
|
copyFile(it.path, usbVideoPath + "/${it.name}")
|
|
|
|
|
}
|
|
|
|
|
loadingDialog?.dismiss()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun copyFile(srcPath: String, dstPath: String) {
|
|
|
|
|
File(srcPath).runCatching {
|
|
|
|
|
takeIf { it.exists() }?.inputStream()?.use { inputStream ->
|
|
|
|
|
File(dstPath).outputStream().use { outputStream ->
|
|
|
|
|
inputStream.copyTo(outputStream)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}.onFailure { // print or throw }
|
|
|
|
|
LogUtils.w("copyFile error, $srcPath")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|