|
@@ -23,21 +23,14 @@
|
|
|
|
|
|
package com.sybotan.android.demo.activities
|
|
|
|
|
|
+import android.content.Intent
|
|
|
import android.os.Bundle
|
|
|
import android.util.Log
|
|
|
+import android.view.Gravity
|
|
|
+import android.view.View
|
|
|
+import android.widget.TextView
|
|
|
import android.widget.Toast
|
|
|
import cn.sagacloud.android.cadengine.FloorScene
|
|
|
-import cn.sagacloud.cadengine.HttpDownloadMap
|
|
|
-import com.sybotan.android.demo.R
|
|
|
-import com.sybotan.android.graphy.events.SGraphyViewMoveEvent
|
|
|
-import kotlinx.android.synthetic.main.activity_graphy.*
|
|
|
-import org.greenrobot.eventbus.EventBus
|
|
|
-import org.greenrobot.eventbus.Subscribe
|
|
|
-import org.jetbrains.anko.doAsync
|
|
|
-import org.jetbrains.anko.uiThread
|
|
|
-
|
|
|
-import android.content.Intent
|
|
|
-import android.view.View
|
|
|
import cn.sagacloud.android.cadengine.items.PointItem
|
|
|
import cn.sagacloud.android.cadengine.items.QrcodeItem
|
|
|
import cn.sagacloud.android.cadengine.items.SpaceNameItem
|
|
@@ -45,21 +38,36 @@ import cn.sagacloud.android.cadengine.items.TunableSpaceItem
|
|
|
import cn.sagacloud.android.cadengine.types.Point
|
|
|
import cn.sagacloud.android.cadengine.types.Space
|
|
|
import cn.sagacloud.android.cadengine.types.TunableSpace
|
|
|
+import cn.sagacloud.cadengine.HttpDownloadMap
|
|
|
import com.google.gson.Gson
|
|
|
+import com.sybotan.android.demo.R
|
|
|
import com.sybotan.android.demo.activities.poc.DeviceActivity
|
|
|
import com.sybotan.android.demo.bean.result.*
|
|
|
import com.sybotan.android.demo.retrofit.BaseViewModelInterface
|
|
|
+import com.sybotan.android.demo.tools.DensityUtils
|
|
|
import com.sybotan.android.demo.viewmodel.GraphyVM
|
|
|
+import com.sybotan.android.graphy.events.SGraphyViewMoveEvent
|
|
|
import com.zbar.lib.CaptureActivity
|
|
|
+import kotlinx.android.synthetic.main.activity_graphy.*
|
|
|
+import org.greenrobot.eventbus.EventBus
|
|
|
+import org.greenrobot.eventbus.Subscribe
|
|
|
+import org.jetbrains.anko.doAsync
|
|
|
+import org.jetbrains.anko.textColor
|
|
|
+import org.jetbrains.anko.uiThread
|
|
|
|
|
|
|
|
|
class GraphyActivity : BaseActivity() {
|
|
|
companion object {
|
|
|
private val TAG = GraphyActivity::class.java.name
|
|
|
- private val REQUEST_CODE_SCAN = 0x0000 // 扫描二维码
|
|
|
- private val REQUEST_CODE_EQUIP = 0x0001 // 添加设备
|
|
|
+
|
|
|
+ /** 扫描二维码 */
|
|
|
+ private val REQUEST_CODE_SCAN = 0x0000
|
|
|
+
|
|
|
+ /** 添加设备成功 */
|
|
|
+ private val REQUEST_CODE_EQUIP = 0x0001
|
|
|
}
|
|
|
|
|
|
+ /** viewModel */
|
|
|
lateinit var graphyVM: GraphyVM
|
|
|
|
|
|
/** 建筑Id */
|
|
@@ -86,12 +94,6 @@ class GraphyActivity : BaseActivity() {
|
|
|
val scene = FloorScene()
|
|
|
val gson = Gson()
|
|
|
|
|
|
-// val path = "base/cbde057b91e711eb9901557a780001bf.jsonz"
|
|
|
-// val path = "base/ebd53bb00d3511eb9a1db95f725712e8.jsonz"
|
|
|
-// val path = "base/a4e671ec8b8111eb9a520dc30d098a92.jsonz"
|
|
|
-// val path = "base/0764ad79555d11ebab557bd2e22cfb56.jsonz"
|
|
|
-// val path = "base/05d5b9e6c8c411eb8437353008b31107.jsonz"
|
|
|
-
|
|
|
@Subscribe
|
|
|
fun test(msg: SGraphyViewMoveEvent) {
|
|
|
Log.d(TAG, "msg=$msg")
|
|
@@ -174,6 +176,7 @@ class GraphyActivity : BaseActivity() {
|
|
|
drawLl.visibility = View.VISIBLE
|
|
|
graphyVM.getSpaceEq(scene.choseSpace)
|
|
|
}
|
|
|
+ equipLocation.setText("($x,$y)")
|
|
|
|
|
|
}
|
|
|
//未选中空间
|
|
@@ -234,10 +237,10 @@ class GraphyActivity : BaseActivity() {
|
|
|
* 页面全部监听事件
|
|
|
*/
|
|
|
private fun initListener() {
|
|
|
- //nfc点击监听
|
|
|
+ /** nfc点击监听 */
|
|
|
nfc.setOnClickListener { Toast.makeText(this, "正在开发中,敬请期待", Toast.LENGTH_SHORT).show() }
|
|
|
|
|
|
- //checkBox
|
|
|
+ /** checkBox */
|
|
|
modelCheckBox.setOnCheckedChangeListener { buttonView, isChecked ->
|
|
|
if (isChecked) {
|
|
|
modelSubmit.isEnabled = true
|
|
@@ -248,25 +251,25 @@ class GraphyActivity : BaseActivity() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //设置空间的任务状态完成
|
|
|
+ /** 设置空间的任务状态完成 */
|
|
|
modelSubmit.setOnClickListener {
|
|
|
graphyVM.setJob(scene.choseSpace, codeEdit.text.toString())
|
|
|
}
|
|
|
|
|
|
- //打点按钮
|
|
|
+ /** 打点按钮 */
|
|
|
addDot.setOnClickListener {
|
|
|
scene.type = "dot"
|
|
|
addDot.alpha = 0.3f
|
|
|
}
|
|
|
|
|
|
- //绑定二维码按钮
|
|
|
+ /** 绑定二维码按钮 */
|
|
|
qrcode.setOnClickListener {
|
|
|
scene.type = "qrcode"
|
|
|
qrcodeLl.visibility = View.VISIBLE
|
|
|
spaceStructure.visibility = View.GONE
|
|
|
}
|
|
|
|
|
|
- //取消绑定二维码
|
|
|
+ /** 取消绑定二维码 */
|
|
|
qrcodeCancel.setOnClickListener {
|
|
|
qrcodeLl.visibility = View.GONE
|
|
|
spaceStructure.visibility = View.VISIBLE
|
|
@@ -274,13 +277,13 @@ class GraphyActivity : BaseActivity() {
|
|
|
scene.item?.let { it1 -> scene.removeItem(it1) }
|
|
|
}
|
|
|
|
|
|
- //下一步
|
|
|
+ /** 下一步 */
|
|
|
qrcodeNext.setOnClickListener {
|
|
|
val intent = Intent(this@GraphyActivity, CaptureActivity::class.java)
|
|
|
startActivityForResult(intent, REQUEST_CODE_SCAN)
|
|
|
}
|
|
|
|
|
|
- //添加设备
|
|
|
+ /** 添加设备 */
|
|
|
drawEquip.setOnClickListener {
|
|
|
scene.type = "equip"
|
|
|
drawLl.visibility = View.GONE
|
|
@@ -288,11 +291,14 @@ class GraphyActivity : BaseActivity() {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /** 取消添加设备 */
|
|
|
equipCancel.setOnClickListener {
|
|
|
drawLl.visibility = View.VISIBLE
|
|
|
equipLl.visibility = View.GONE
|
|
|
+ scene.type = "normal"
|
|
|
}
|
|
|
|
|
|
+ /** 添加设备下一步 */
|
|
|
equipNext.setOnClickListener {
|
|
|
val intent = Intent(this, DeviceActivity::class.java)
|
|
|
val bundle = Bundle()
|
|
@@ -438,6 +444,28 @@ class GraphyActivity : BaseActivity() {
|
|
|
|
|
|
/** 查询空间下的设备(所在关系) */
|
|
|
GraphyVM.SPACE_EQ -> {
|
|
|
+ val list = params as List<SpaceEqModel>
|
|
|
+ for (item in scene.equipList) {
|
|
|
+ scene.removeItem(item)
|
|
|
+ }
|
|
|
+ scene.equipList.clear()
|
|
|
+ equipWwv.removeAllViews()
|
|
|
+ for (model in list) {
|
|
|
+ val textview = TextView(this)
|
|
|
+ textview.setText(model.type + "(${model.children.size + 1})")
|
|
|
+ textview.setSingleLine()
|
|
|
+ textview.gravity = Gravity.CENTER
|
|
|
+ textview.textSize = 12f
|
|
|
+ textview.height = DensityUtils.dp2px(this, 30f)
|
|
|
+ textview.textColor = resources.getColor(R.color.grey_900)
|
|
|
+ equipWwv.addView(textview)
|
|
|
+
|
|
|
+ if (!model.children.isEmpty() && !model.isCheck) {
|
|
|
+ for (child in model.children) {
|
|
|
+ //TODO
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -464,10 +492,24 @@ class GraphyActivity : BaseActivity() {
|
|
|
}
|
|
|
scene.qrcodeItemList.clear()
|
|
|
|
|
|
+ for (item in scene.equipList) {
|
|
|
+ scene.removeItem(item)
|
|
|
+ }
|
|
|
+ scene.equipList.clear()
|
|
|
+
|
|
|
spaceStructure.visibility = View.GONE
|
|
|
+ drawLl.visibility = View.GONE
|
|
|
+ equipLl.visibility = View.GONE
|
|
|
+
|
|
|
scene.type = "normal"
|
|
|
modelCheckBox.isChecked = false
|
|
|
codeEdit.setText("")
|
|
|
+ equipLocation.setText("")
|
|
|
+ roof.isChecked = false
|
|
|
+ floor.isChecked = false
|
|
|
+ wall.isChecked = false
|
|
|
+ air.isChecked = false
|
|
|
+ scene.point = Point()
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -483,7 +525,8 @@ class GraphyActivity : BaseActivity() {
|
|
|
"\ny轴:${point.data.mY}" +
|
|
|
"\n点击下方“问题已解决”按钮后可关闭该问题点。"
|
|
|
)
|
|
|
- //问题已解决按钮
|
|
|
+
|
|
|
+ /** 问题已解决按钮 */
|
|
|
quesSubmit.setOnClickListener {
|
|
|
graphyVM.closeProblem(point, scene.choseSpace)
|
|
|
spaceStructure.visibility = View.VISIBLE
|
|
@@ -505,7 +548,8 @@ class GraphyActivity : BaseActivity() {
|
|
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
|
|
super.onActivityResult(requestCode, resultCode, data)
|
|
|
when (requestCode) {
|
|
|
- REQUEST_CODE_SCAN -> // 扫描二维码回传
|
|
|
+ /** 扫描二维码回传 */
|
|
|
+ REQUEST_CODE_SCAN ->
|
|
|
if (resultCode == RESULT_OK) {
|
|
|
if (data != null) {
|
|
|
//获取扫描结果
|
|
@@ -520,6 +564,19 @@ class GraphyActivity : BaseActivity() {
|
|
|
)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /** 添加设备成功 */
|
|
|
+ REQUEST_CODE_EQUIP -> {
|
|
|
+ if (resultCode == RESULT_OK) {
|
|
|
+ equipLocation.setText("")
|
|
|
+ roof.isChecked = false
|
|
|
+ floor.isChecked = false
|
|
|
+ wall.isChecked = false
|
|
|
+ air.isChecked = false
|
|
|
+ scene.point = Point()
|
|
|
+ graphyVM.getSpaceEq(scene.choseSpace)
|
|
|
+ }
|
|
|
+ }
|
|
|
else -> {
|
|
|
}
|
|
|
}
|