|
@@ -15,7 +15,9 @@ import androidx.constraintlayout.widget.ConstraintLayout
|
|
|
import androidx.core.app.ActivityCompat
|
|
|
import androidx.lifecycle.lifecycleScope
|
|
|
import com.framework.mvvm.model.vo.AdmRequest
|
|
|
+import com.framework.mvvm.model.vo.Building
|
|
|
import com.framework.mvvm.mv.AdmViewModel
|
|
|
+import com.google.gson.Gson
|
|
|
import com.sybotan.android.demo.R
|
|
|
import com.sybotan.android.demo.activities.poc.SceneActivity
|
|
|
import com.sybotan.android.demo.activities.poc.SpaceActivity
|
|
@@ -32,6 +34,9 @@ import org.kodein.di.DIAware
|
|
|
import org.kodein.di.android.closestDI
|
|
|
import org.kodein.di.android.x.viewmodel.viewModel
|
|
|
import org.kodein.di.instance
|
|
|
+import java.io.File
|
|
|
+import java.io.FileWriter
|
|
|
+import java.text.SimpleDateFormat
|
|
|
|
|
|
class PocActivity : BaseActivity(), DIAware {
|
|
|
|
|
@@ -122,28 +127,53 @@ class PocActivity : BaseActivity(), DIAware {
|
|
|
lifecycleScope.launch(Dispatchers.IO) {
|
|
|
LocalDataOperation.getInstance().offlineSendRequest.uploadImageNew(this@PocActivity)
|
|
|
}
|
|
|
- mVm.uploadBuilding(request) {
|
|
|
- // ToastUtils.showMyToast("建筑数据上传成功")
|
|
|
- val builder = AlertDialog.Builder(this)
|
|
|
- val dialog = builder.setMessage("建筑数据上传成功")
|
|
|
- .setPositiveButton("确定") { dialog, id ->
|
|
|
- dialog.dismiss()
|
|
|
- }.create()
|
|
|
- dialog.show()
|
|
|
+ mVm.uploadBuilding(
|
|
|
+ request, block = {
|
|
|
+ // ToastUtils.showMyToast("建筑数据上传成功")
|
|
|
+ val builder = AlertDialog.Builder(this)
|
|
|
+ val dialog = builder.setMessage("建筑数据上传成功")
|
|
|
+ .setPositiveButton("确定") { dialog, id ->
|
|
|
+ dialog.dismiss()
|
|
|
+ }.create()
|
|
|
+ dialog.show()
|
|
|
+
|
|
|
+ lifecycleScope.launch {
|
|
|
+ val unUploadNum = mVm.getNoDoneTaskByProjectId(projectId)
|
|
|
+ unUploadTv.text = "$unUploadNum"
|
|
|
+ if (unUploadNum > 0) {
|
|
|
+ unUploadLabelTv.setTextColor(Color.RED)
|
|
|
+ unUploadTv.setTextColor(Color.RED)
|
|
|
+ } else {
|
|
|
+ unUploadLabelTv.setTextColor(resources.getColor(R.color.black_1F2429))
|
|
|
+ unUploadTv.setTextColor(resources.getColor(R.color.black_1F2429))
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- lifecycleScope.launch {
|
|
|
- val unUploadNum = mVm.getNoDoneTaskByProjectId(projectId)
|
|
|
- unUploadTv.text = "$unUploadNum"
|
|
|
- if (unUploadNum > 0) {
|
|
|
- unUploadLabelTv.setTextColor(Color.RED)
|
|
|
- unUploadTv.setTextColor(Color.RED)
|
|
|
- } else {
|
|
|
- unUploadLabelTv.setTextColor(resources.getColor(R.color.black_1F2429))
|
|
|
- unUploadTv.setTextColor(resources.getColor(R.color.black_1F2429))
|
|
|
+ },
|
|
|
+ log = { msg: String, building: Building? ->
|
|
|
+ val dir = getExternalFilesDir("log")
|
|
|
+ if (dir == null || !dir.exists()) {
|
|
|
+ dir?.mkdir()
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
+ val writer = FileWriter(
|
|
|
+ File(
|
|
|
+ dir,
|
|
|
+ "${
|
|
|
+ SimpleDateFormat("YYYY年MM月dd日 HH:mm:ss").format(
|
|
|
+ System.currentTimeMillis()
|
|
|
+ )
|
|
|
+ }-${request.projectId}.${building?.buildingId ?: ""}.log"
|
|
|
+ )
|
|
|
+ )
|
|
|
+ writer.use {
|
|
|
+ it.append(msg)
|
|
|
+ it.append("\n")
|
|
|
+ val json = Gson().toJson(building)
|
|
|
+ it.append(json)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
dictBtn.setOnClickListener {
|