|
@@ -10,6 +10,7 @@ import android.util.Log
|
|
|
import android.view.Gravity
|
|
|
import android.view.MotionEvent
|
|
|
import android.view.View
|
|
|
+import android.view.WindowManager
|
|
|
import android.widget.*
|
|
|
import androidx.appcompat.widget.SwitchCompat
|
|
|
import androidx.core.widget.NestedScrollView
|
|
@@ -66,7 +67,8 @@ class EquipDetailActivity : BaseActivity(), View.OnTouchListener {
|
|
|
private val REQUEST_CODE_PIC = 0X102
|
|
|
private val REQUEST_EQUIP_CODE = 0X103
|
|
|
|
|
|
- private lateinit var info: Infos
|
|
|
+ private var info: Infos? = null
|
|
|
+ private var currentPosition: Int? = 0
|
|
|
private lateinit var recycler: RecyclerView
|
|
|
private lateinit var viewRecycler: RecyclerView
|
|
|
private lateinit var mtextContent: EditText
|
|
@@ -80,6 +82,7 @@ class EquipDetailActivity : BaseActivity(), View.OnTouchListener {
|
|
|
private lateinit var equipClass: ListItemView
|
|
|
private lateinit var root: NestedScrollView
|
|
|
private lateinit var btnSubmit: TextView
|
|
|
+ private lateinit var pasteDetail: TextView
|
|
|
private lateinit var stateName: TextView
|
|
|
private lateinit var expandLvPipe: SuperExpandableListView
|
|
|
private lateinit var expandLvRelation: SuperExpandableListView
|
|
@@ -121,6 +124,7 @@ class EquipDetailActivity : BaseActivity(), View.OnTouchListener {
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
super.onCreate(savedInstanceState)
|
|
|
+ window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
|
|
|
setContentView(R.layout.activity_equip_detail)
|
|
|
initView()
|
|
|
initData()
|
|
@@ -142,6 +146,7 @@ class EquipDetailActivity : BaseActivity(), View.OnTouchListener {
|
|
|
scale = bundle.getFloat("scale", 0f)
|
|
|
centerPoint = bundle.getParcelable("centerPoint")!!
|
|
|
uuid = IdGenerator.getId(projectId, IdGenerator.EQUIPMENT)
|
|
|
+ pasteDetail = findViewById(R.id.pasteDetail)
|
|
|
recycler = findViewById(R.id.recycler)
|
|
|
height = findViewById(R.id.height)
|
|
|
locationWhere = findViewById(R.id.locationWhere)
|
|
@@ -171,7 +176,10 @@ class EquipDetailActivity : BaseActivity(), View.OnTouchListener {
|
|
|
beans.add(photo)
|
|
|
pictureAdapter = PictureAdapter(this, beans, "", false, 0, 85)
|
|
|
viewRecycler.adapter = pictureAdapter
|
|
|
- pictureAdapter.setOnPicAdd { addPic() }
|
|
|
+ pictureAdapter.setOnPicAdd {
|
|
|
+ this.info = null
|
|
|
+ addPic()
|
|
|
+ }
|
|
|
height.setTvRight(position?.z?.offset)
|
|
|
locationWhere.setTvRight(position?.z?.region)
|
|
|
location.setTvRight("(x=${position?.x},y=${position?.y})")
|
|
@@ -180,6 +188,23 @@ class EquipDetailActivity : BaseActivity(), View.OnTouchListener {
|
|
|
equipClass.isEnabled = false
|
|
|
location.isEnabled = false
|
|
|
}
|
|
|
+ if (TextUtils.isEmpty(deviceId)) {
|
|
|
+ pasteDetail.alpha = 1.0f
|
|
|
+ pasteDetail.isEnabled = true
|
|
|
+ }
|
|
|
+ pasteDetail.setOnClickListener {
|
|
|
+ staticInfoAdapter.hashMap = Constant.infoMap
|
|
|
+ staticInfoAdapter.valueList.clear()
|
|
|
+ staticInfoAdapter.notifyDataSetChanged()
|
|
|
+ if (staticInfoAdapter.hashMap != null && staticInfoAdapter.hashMap.get("compType") != null) {
|
|
|
+ val compCode = staticInfoAdapter.hashMap.get("compType")
|
|
|
+ compType.setTvRight(compCode.toString())
|
|
|
+
|
|
|
+ }
|
|
|
+ if (!TextUtils.isEmpty(Constant.equipCode)) {
|
|
|
+ findCurrentEquipCode()
|
|
|
+ }
|
|
|
+ }
|
|
|
doneSwitch.addSwitchObserver { switchView, state ->
|
|
|
when (state) {
|
|
|
RMSwitch.STATE_LEFT -> {
|
|
@@ -243,6 +268,21 @@ class EquipDetailActivity : BaseActivity(), View.OnTouchListener {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private fun findCurrentEquipCode() {
|
|
|
+ for (eq in equips) {
|
|
|
+ if (eq.code == Constant.equipCode) {
|
|
|
+ this.equipEntity = eq
|
|
|
+ pasteDetail.alpha = 1.0f
|
|
|
+ pasteDetail.isEnabled = true
|
|
|
+ equipVM.getRelConfig(eq, deviceId, uuid)
|
|
|
+ equipClass.setTvRight(equipEntity!!.systemName + "/" + equipEntity!!.name + "-" + equipEntity!!.code)
|
|
|
+ equipVM.getEquipInfosConfig(equipEntity!!)
|
|
|
+ equipVM.getEquipment(deviceId)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//重写onTouch方法
|
|
|
override fun onTouch(view: View, motionEvent: MotionEvent): Boolean {
|
|
|
//触摸的是EditText控件,且当前EditText可以滚动,则将事件交给EditText处理;否则将事件交由其父类处理
|
|
@@ -271,16 +311,23 @@ class EquipDetailActivity : BaseActivity(), View.OnTouchListener {
|
|
|
dialog = EquipListDialog(this)
|
|
|
dialog.setOnSubmit {
|
|
|
this.equipEntity = it
|
|
|
+ if (it.code == Constant.equipCode) {
|
|
|
+ pasteDetail.alpha = 1.0f
|
|
|
+ pasteDetail.isEnabled = true
|
|
|
+ }
|
|
|
equipClass.setTvRight(it.systemName + "/" + it.name + "-" + it.code)
|
|
|
equipVM.getEquipInfosConfig(it)
|
|
|
equipVM.getRelConfig(it, deviceId, uuid)
|
|
|
|
|
|
}
|
|
|
staticInfoAdapter = StaticInfoAdapter(this, list)
|
|
|
- staticInfoAdapter.setOnAddPic {
|
|
|
- addPic()
|
|
|
- this.info = it
|
|
|
- }
|
|
|
+ staticInfoAdapter.setOnAddPic(object : StaticInfoAdapter.AddPic {
|
|
|
+ override fun onAddPic(info: Infos?, currentPosition: Int) {
|
|
|
+ addPic()
|
|
|
+ this@EquipDetailActivity.info = info
|
|
|
+ this@EquipDetailActivity.currentPosition = currentPosition
|
|
|
+ }
|
|
|
+ })
|
|
|
staticInfoAdapter.setOnAddDeliveryCode {
|
|
|
if (equipEntity == null) {
|
|
|
ToastUtils.showMyToast("请先选择设备类型")
|
|
@@ -400,6 +447,10 @@ class EquipDetailActivity : BaseActivity(), View.OnTouchListener {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if (Constant.equipCode != equipEntity?.code) {
|
|
|
+ pasteDetail.alpha = 0.5f
|
|
|
+ pasteDetail.isEnabled = false
|
|
|
+ }
|
|
|
}
|
|
|
EquipDetailVM.EQUIP_REL -> {
|
|
|
val hashMap = params as HashMap<String, Any>
|
|
@@ -616,7 +667,21 @@ class EquipDetailActivity : BaseActivity(), View.OnTouchListener {
|
|
|
photos.itemType = 0
|
|
|
photos.path = path
|
|
|
photos.key = key
|
|
|
- beans.add(photos)
|
|
|
+ if (info == null) {
|
|
|
+ beans.add(photos)
|
|
|
+ } else {
|
|
|
+ val photosList = ArrayList<Photos>()
|
|
|
+ if (staticInfoAdapter.hashMap[info!!.code] != null) {
|
|
|
+ val value = Gson().fromJson<ArrayList<Photos>>(
|
|
|
+ Gson().toJson(staticInfoAdapter.hashMap[info!!.code]), object : TypeToken<List<Photos?>?>() {}.type
|
|
|
+ )
|
|
|
+ photosList.addAll(value)
|
|
|
+ }
|
|
|
+ photosList.add(photos)
|
|
|
+ staticInfoAdapter.hashMap.put(info!!.code, photosList)
|
|
|
+ staticInfoAdapter.valueList.remove(info?.code)
|
|
|
+ runOnUiThread { staticInfoAdapter.notifyItemChanged(currentPosition!!) }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -624,7 +689,21 @@ class EquipDetailActivity : BaseActivity(), View.OnTouchListener {
|
|
|
photos.itemType = 0
|
|
|
photos.path = path
|
|
|
photos.key = key
|
|
|
- beans.add(photos)
|
|
|
+ if (info == null) {
|
|
|
+ beans.add(photos)
|
|
|
+ } else {
|
|
|
+ val photosList = ArrayList<Photos>()
|
|
|
+ if (staticInfoAdapter.hashMap[info!!.code] != null) {
|
|
|
+ val value = Gson().fromJson<ArrayList<Photos>>(
|
|
|
+ staticInfoAdapter.hashMap[info!!.code] as String, object : TypeToken<List<Photos?>?>() {}.type
|
|
|
+ )
|
|
|
+ photosList.addAll(value)
|
|
|
+ }
|
|
|
+ photosList.add(photos)
|
|
|
+ staticInfoAdapter.hashMap.put(info!!.code, photosList)
|
|
|
+ staticInfoAdapter.valueList.remove(info?.code)
|
|
|
+ runOnUiThread { staticInfoAdapter.notifyItemChanged(currentPosition!!) }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -632,9 +711,6 @@ class EquipDetailActivity : BaseActivity(), View.OnTouchListener {
|
|
|
}
|
|
|
DEAL_DATA_NEXT -> {
|
|
|
ToastUtils.showMyToast("图片上传完毕")
|
|
|
- pictureAdapter.notifyDataSetChanged()
|
|
|
- staticInfoAdapter.valueList.clear()
|
|
|
- staticInfoAdapter.notifyDataSetChanged()
|
|
|
// if (info != null) {
|
|
|
// staticInfoAdapter.hashMap.put(info.code, beans)
|
|
|
// }
|