|
|
|
|
@ -3,17 +3,27 @@ package com.rehome.zhdcoa.adapter
|
|
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint
|
|
|
|
|
import android.content.Context
|
|
|
|
|
import android.text.TextUtils
|
|
|
|
|
import android.util.Log
|
|
|
|
|
import android.view.LayoutInflater
|
|
|
|
|
import android.view.View
|
|
|
|
|
import android.view.ViewGroup
|
|
|
|
|
import com.rehome.zhdcoa.Contans
|
|
|
|
|
import com.rehome.zhdcoa.Listener.OnItemClickListener
|
|
|
|
|
import com.rehome.zhdcoa.base.BaseViewBindingAdapter
|
|
|
|
|
import com.rehome.zhdcoa.bean.DeviceOnlineStatusAreaBean
|
|
|
|
|
import com.rehome.zhdcoa.bean.DeviceOnlineStatusListResultBean
|
|
|
|
|
import com.rehome.zhdcoa.databinding.AdapterDeviceOnlineStatusListBinding
|
|
|
|
|
import com.rehome.zhdcoa.utils.GsonUtils
|
|
|
|
|
import com.rehome.zhdcoa.utils.SPUtils
|
|
|
|
|
import org.w3c.dom.Text
|
|
|
|
|
|
|
|
|
|
class DeviceOnlineStatusListAdapter(var context: Context,var data: MutableList<Any>,var type: String,var onItemClickListener: OnItemClickListener) : BaseViewBindingAdapter<AdapterDeviceOnlineStatusListBinding>(context){
|
|
|
|
|
class DeviceOnlineStatusListAdapter(
|
|
|
|
|
var context: Context,
|
|
|
|
|
var data: MutableList<Any>,
|
|
|
|
|
var type: String,
|
|
|
|
|
var onItemClickListener: OnItemClickListener
|
|
|
|
|
) : BaseViewBindingAdapter<AdapterDeviceOnlineStatusListBinding>(context) {
|
|
|
|
|
override fun getCount(): Int {
|
|
|
|
|
return data.count()
|
|
|
|
|
}
|
|
|
|
|
@ -27,94 +37,227 @@ class DeviceOnlineStatusListAdapter(var context: Context,var data: MutableList<A
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun setTypeTemp(typeTemp: String) {
|
|
|
|
|
this.type=typeTemp
|
|
|
|
|
this.type = typeTemp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun getBinding(inflater: LayoutInflater,parent: ViewGroup?) = AdapterDeviceOnlineStatusListBinding.inflate(inflater, parent, false)
|
|
|
|
|
override fun getBinding(inflater: LayoutInflater, parent: ViewGroup?) =
|
|
|
|
|
AdapterDeviceOnlineStatusListBinding.inflate(inflater, parent, false)
|
|
|
|
|
|
|
|
|
|
@SuppressLint("SetTextI18n", "DefaultLocale")
|
|
|
|
|
override fun handleData(position: Int, binding: AdapterDeviceOnlineStatusListBinding) {
|
|
|
|
|
Log.i("app",type)
|
|
|
|
|
Log.i("app", type)
|
|
|
|
|
val item: Any = data[position]
|
|
|
|
|
|
|
|
|
|
if(type=="测振测温设备"){
|
|
|
|
|
val itemBean:DeviceOnlineStatusListResultBean.DeviceItemCwcz? = GsonUtils.GsonToBean(GsonUtils.GsonString(item),
|
|
|
|
|
DeviceOnlineStatusListResultBean.DeviceItemCwcz::class.java)
|
|
|
|
|
binding.llCwcz.visibility= View.VISIBLE
|
|
|
|
|
binding.llYzjc.visibility= View.GONE
|
|
|
|
|
binding.llLljc.visibility= View.GONE
|
|
|
|
|
binding.llRcx.visibility= View.GONE
|
|
|
|
|
binding.llZigbee.visibility= View.GONE
|
|
|
|
|
if (type == "测振测温设备") {
|
|
|
|
|
val itemBean: DeviceOnlineStatusListResultBean.DeviceItemCwcz? = GsonUtils.GsonToBean(
|
|
|
|
|
GsonUtils.GsonString(item),
|
|
|
|
|
DeviceOnlineStatusListResultBean.DeviceItemCwcz::class.java
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
binding.llCwcz.visibility = View.VISIBLE
|
|
|
|
|
binding.llYzjc.visibility = View.GONE
|
|
|
|
|
binding.llLljc.visibility = View.GONE
|
|
|
|
|
binding.llRcx.visibility = View.GONE
|
|
|
|
|
binding.llZigbee.visibility = View.GONE
|
|
|
|
|
|
|
|
|
|
if (itemBean != null) {
|
|
|
|
|
if(!TextUtils.isEmpty(itemBean.position)){
|
|
|
|
|
val deviceOnlineStatusAreaBeanStr: String? =
|
|
|
|
|
SPUtils.get(context, Contans.DeviceOnlineStatusAreaBean, "") as String?
|
|
|
|
|
if (deviceOnlineStatusAreaBeanStr != null) {
|
|
|
|
|
val bean = GsonUtils.GsonToBean(
|
|
|
|
|
deviceOnlineStatusAreaBeanStr,
|
|
|
|
|
DeviceOnlineStatusAreaBean::class.java
|
|
|
|
|
)
|
|
|
|
|
if (bean != null && bean.code == 20000 && bean.isSuccess && bean.data != null && bean.data.size > 0) {
|
|
|
|
|
val areaList: MutableList<DeviceOnlineStatusAreaBean.DeviceArea> =
|
|
|
|
|
mutableListOf()//在线设备区域列表
|
|
|
|
|
areaList.addAll(bean.data)
|
|
|
|
|
//更新区域
|
|
|
|
|
for (itemArea in areaList) {
|
|
|
|
|
if(itemArea.nodeList!=null&&itemArea.nodeList.size>0){
|
|
|
|
|
for (itemNodeList in itemArea.nodeList) {
|
|
|
|
|
if(!TextUtils.isEmpty(itemNodeList.nodeKey)){
|
|
|
|
|
if(itemNodeList.nodeKey==itemBean.position){
|
|
|
|
|
if(!TextUtils.isEmpty(itemNodeList.cname)){
|
|
|
|
|
itemBean.nodeListCname=itemNodeList.cname
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(itemBean!=null){
|
|
|
|
|
binding.tvSbbh.text = itemBean.id
|
|
|
|
|
binding.tvIp.text = itemBean.ip
|
|
|
|
|
binding.tvPort.text = itemBean.port
|
|
|
|
|
binding.tvDl.text = String.format("%.0f", itemBean.voltage) + "%"
|
|
|
|
|
binding.tvSbmc.text = itemBean.name
|
|
|
|
|
binding.tvSj.text = itemBean.lastOnlineTime
|
|
|
|
|
binding.tvQuYu.text = itemBean.nodeListCname
|
|
|
|
|
binding.tvPhotoManage.setOnClickListener {
|
|
|
|
|
onItemClickListener.onItemClick(position,binding.tvPhotoManage)
|
|
|
|
|
onItemClickListener.onItemClick(position, binding.tvPhotoManage)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(type=="油质监测设备"){
|
|
|
|
|
val itemBean:DeviceOnlineStatusListResultBean.DeviceItemYzjc? = GsonUtils.GsonToBean(GsonUtils.GsonString(item),
|
|
|
|
|
DeviceOnlineStatusListResultBean.DeviceItemYzjc::class.java)
|
|
|
|
|
binding.llCwcz.visibility= View.GONE
|
|
|
|
|
binding.llYzjc.visibility= View.VISIBLE
|
|
|
|
|
binding.llLljc.visibility= View.GONE
|
|
|
|
|
binding.llRcx.visibility= View.GONE
|
|
|
|
|
binding.llZigbee.visibility= View.GONE
|
|
|
|
|
if (type == "油质监测设备") {
|
|
|
|
|
val itemBean: DeviceOnlineStatusListResultBean.DeviceItemYzjc? = GsonUtils.GsonToBean(
|
|
|
|
|
GsonUtils.GsonString(item),
|
|
|
|
|
DeviceOnlineStatusListResultBean.DeviceItemYzjc::class.java
|
|
|
|
|
)
|
|
|
|
|
binding.llCwcz.visibility = View.GONE
|
|
|
|
|
binding.llYzjc.visibility = View.VISIBLE
|
|
|
|
|
binding.llLljc.visibility = View.GONE
|
|
|
|
|
binding.llRcx.visibility = View.GONE
|
|
|
|
|
binding.llZigbee.visibility = View.GONE
|
|
|
|
|
|
|
|
|
|
if(itemBean!=null){
|
|
|
|
|
if (itemBean != null) {
|
|
|
|
|
if(!TextUtils.isEmpty(itemBean.position)){
|
|
|
|
|
val deviceOnlineStatusAreaBeanStr: String? =
|
|
|
|
|
SPUtils.get(context, Contans.DeviceOnlineStatusAreaBean, "") as String?
|
|
|
|
|
if (deviceOnlineStatusAreaBeanStr != null) {
|
|
|
|
|
val bean = GsonUtils.GsonToBean(
|
|
|
|
|
deviceOnlineStatusAreaBeanStr,
|
|
|
|
|
DeviceOnlineStatusAreaBean::class.java
|
|
|
|
|
)
|
|
|
|
|
if (bean != null && bean.code == 20000 && bean.isSuccess && bean.data != null && bean.data.size > 0) {
|
|
|
|
|
val areaList: MutableList<DeviceOnlineStatusAreaBean.DeviceArea> =
|
|
|
|
|
mutableListOf()//在线设备区域列表
|
|
|
|
|
areaList.addAll(bean.data)
|
|
|
|
|
//更新区域
|
|
|
|
|
for (itemArea in areaList) {
|
|
|
|
|
if(itemArea.nodeList!=null&&itemArea.nodeList.size>0){
|
|
|
|
|
for (itemNodeList in itemArea.nodeList) {
|
|
|
|
|
if(!TextUtils.isEmpty(itemNodeList.nodeKey)){
|
|
|
|
|
if(itemNodeList.nodeKey==itemBean.position){
|
|
|
|
|
if(!TextUtils.isEmpty(itemNodeList.cname)){
|
|
|
|
|
itemBean.nodeListCname=itemNodeList.cname
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
binding.tvSbbhYzjc.text = itemBean.id
|
|
|
|
|
binding.tvSbmcYzjc.text = itemBean.name
|
|
|
|
|
binding.tvSjYzjc.text = itemBean.lastOnlineTime
|
|
|
|
|
binding.tvQuYuYzjc.text = itemBean.nodeListCname
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(type=="燃料测温设备"){
|
|
|
|
|
val itemBean:DeviceOnlineStatusListResultBean.DeviceItemRlcw? = GsonUtils.GsonToBean(GsonUtils.GsonString(item),
|
|
|
|
|
DeviceOnlineStatusListResultBean.DeviceItemRlcw::class.java)
|
|
|
|
|
binding.llCwcz.visibility= View.GONE
|
|
|
|
|
binding.llYzjc.visibility= View.GONE
|
|
|
|
|
binding.llLljc.visibility= View.VISIBLE
|
|
|
|
|
binding.llRcx.visibility= View.GONE
|
|
|
|
|
binding.llZigbee.visibility= View.GONE
|
|
|
|
|
if (type == "燃料测温设备") {
|
|
|
|
|
val itemBean: DeviceOnlineStatusListResultBean.DeviceItemRlcw? = GsonUtils.GsonToBean(
|
|
|
|
|
GsonUtils.GsonString(item),
|
|
|
|
|
DeviceOnlineStatusListResultBean.DeviceItemRlcw::class.java
|
|
|
|
|
)
|
|
|
|
|
binding.llCwcz.visibility = View.GONE
|
|
|
|
|
binding.llYzjc.visibility = View.GONE
|
|
|
|
|
binding.llLljc.visibility = View.VISIBLE
|
|
|
|
|
binding.llRcx.visibility = View.GONE
|
|
|
|
|
binding.llZigbee.visibility = View.GONE
|
|
|
|
|
|
|
|
|
|
if(itemBean!=null){
|
|
|
|
|
if (itemBean != null) {
|
|
|
|
|
if(!TextUtils.isEmpty(itemBean.position)){
|
|
|
|
|
val deviceOnlineStatusAreaBeanStr: String? =
|
|
|
|
|
SPUtils.get(context, Contans.DeviceOnlineStatusAreaBean, "") as String?
|
|
|
|
|
if (deviceOnlineStatusAreaBeanStr != null) {
|
|
|
|
|
val bean = GsonUtils.GsonToBean(
|
|
|
|
|
deviceOnlineStatusAreaBeanStr,
|
|
|
|
|
DeviceOnlineStatusAreaBean::class.java
|
|
|
|
|
)
|
|
|
|
|
if (bean != null && bean.code == 20000 && bean.isSuccess && bean.data != null && bean.data.size > 0) {
|
|
|
|
|
val areaList: MutableList<DeviceOnlineStatusAreaBean.DeviceArea> =
|
|
|
|
|
mutableListOf()//在线设备区域列表
|
|
|
|
|
areaList.addAll(bean.data)
|
|
|
|
|
//更新区域
|
|
|
|
|
for (itemArea in areaList) {
|
|
|
|
|
if(itemArea.nodeList!=null&&itemArea.nodeList.size>0){
|
|
|
|
|
for (itemNodeList in itemArea.nodeList) {
|
|
|
|
|
if(!TextUtils.isEmpty(itemNodeList.nodeKey)){
|
|
|
|
|
if(itemNodeList.nodeKey==itemBean.position){
|
|
|
|
|
if(!TextUtils.isEmpty(itemNodeList.cname)){
|
|
|
|
|
itemBean.nodeListCname=itemNodeList.cname
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
binding.tvSbbhLljc.text = itemBean.id
|
|
|
|
|
binding.tvIpLljc.text = itemBean.ip
|
|
|
|
|
binding.tvPortLljc.text = itemBean.port
|
|
|
|
|
binding.tvSbmcLljc.text = itemBean.name
|
|
|
|
|
binding.tvSjLljc.text = itemBean.lastOnlineTime
|
|
|
|
|
binding.tvQuYuLljc.text = itemBean.nodeListCname
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(type=="热成像测温设备"){
|
|
|
|
|
val itemBean:DeviceOnlineStatusListResultBean.DeviceItemRcqcw? = GsonUtils.GsonToBean(GsonUtils.GsonString(item),
|
|
|
|
|
DeviceOnlineStatusListResultBean.DeviceItemRcqcw::class.java)
|
|
|
|
|
binding.llCwcz.visibility= View.GONE
|
|
|
|
|
binding.llYzjc.visibility= View.GONE
|
|
|
|
|
binding.llLljc.visibility= View.GONE
|
|
|
|
|
binding.llRcx.visibility= View.VISIBLE
|
|
|
|
|
binding.llZigbee.visibility= View.GONE
|
|
|
|
|
if (type == "热成像测温设备") {
|
|
|
|
|
val itemBean: DeviceOnlineStatusListResultBean.DeviceItemRcqcw? = GsonUtils.GsonToBean(
|
|
|
|
|
GsonUtils.GsonString(item),
|
|
|
|
|
DeviceOnlineStatusListResultBean.DeviceItemRcqcw::class.java
|
|
|
|
|
)
|
|
|
|
|
binding.llCwcz.visibility = View.GONE
|
|
|
|
|
binding.llYzjc.visibility = View.GONE
|
|
|
|
|
binding.llLljc.visibility = View.GONE
|
|
|
|
|
binding.llRcx.visibility = View.VISIBLE
|
|
|
|
|
binding.llZigbee.visibility = View.GONE
|
|
|
|
|
|
|
|
|
|
if(itemBean!=null){
|
|
|
|
|
if (itemBean != null) {
|
|
|
|
|
if(!TextUtils.isEmpty(itemBean.position)){
|
|
|
|
|
val deviceOnlineStatusAreaBeanStr: String? =
|
|
|
|
|
SPUtils.get(context, Contans.DeviceOnlineStatusAreaBean, "") as String?
|
|
|
|
|
if (deviceOnlineStatusAreaBeanStr != null) {
|
|
|
|
|
val bean = GsonUtils.GsonToBean(
|
|
|
|
|
deviceOnlineStatusAreaBeanStr,
|
|
|
|
|
DeviceOnlineStatusAreaBean::class.java
|
|
|
|
|
)
|
|
|
|
|
if (bean != null && bean.code == 20000 && bean.isSuccess && bean.data != null && bean.data.size > 0) {
|
|
|
|
|
val areaList: MutableList<DeviceOnlineStatusAreaBean.DeviceArea> =
|
|
|
|
|
mutableListOf()//在线设备区域列表
|
|
|
|
|
areaList.addAll(bean.data)
|
|
|
|
|
//更新区域
|
|
|
|
|
for (itemArea in areaList) {
|
|
|
|
|
if(itemArea.nodeList!=null&&itemArea.nodeList.size>0){
|
|
|
|
|
for (itemNodeList in itemArea.nodeList) {
|
|
|
|
|
if(!TextUtils.isEmpty(itemNodeList.nodeKey)){
|
|
|
|
|
if(itemNodeList.nodeKey==itemBean.position){
|
|
|
|
|
if(!TextUtils.isEmpty(itemNodeList.cname)){
|
|
|
|
|
itemBean.nodeListCname=itemNodeList.cname
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
binding.tvSbbhRcx.text = itemBean.id
|
|
|
|
|
binding.tvSbmcRcx.text = itemBean.name
|
|
|
|
|
binding.tvSjRcx.text = itemBean.lastOnlineTime
|
|
|
|
|
binding.tvQuYuRcx.text = itemBean.nodeListCname
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(type=="zigBee 传感器"){
|
|
|
|
|
val itemBean:DeviceOnlineStatusListResultBean.DeviceItemZigBee? = GsonUtils.GsonToBean(GsonUtils.GsonString(item),
|
|
|
|
|
DeviceOnlineStatusListResultBean.DeviceItemZigBee::class.java)
|
|
|
|
|
binding.llCwcz.visibility= View.GONE
|
|
|
|
|
binding.llYzjc.visibility= View.GONE
|
|
|
|
|
binding.llLljc.visibility= View.GONE
|
|
|
|
|
binding.llRcx.visibility= View.GONE
|
|
|
|
|
binding.llZigbee.visibility= View.VISIBLE
|
|
|
|
|
if (type == "zigBee 传感器") {
|
|
|
|
|
val itemBean: DeviceOnlineStatusListResultBean.DeviceItemZigBee? = GsonUtils.GsonToBean(
|
|
|
|
|
GsonUtils.GsonString(item),
|
|
|
|
|
DeviceOnlineStatusListResultBean.DeviceItemZigBee::class.java
|
|
|
|
|
)
|
|
|
|
|
binding.llCwcz.visibility = View.GONE
|
|
|
|
|
binding.llYzjc.visibility = View.GONE
|
|
|
|
|
binding.llLljc.visibility = View.GONE
|
|
|
|
|
binding.llRcx.visibility = View.GONE
|
|
|
|
|
binding.llZigbee.visibility = View.VISIBLE
|
|
|
|
|
|
|
|
|
|
if(itemBean!=null){
|
|
|
|
|
if (itemBean != null) {
|
|
|
|
|
binding.tvSbbhZigbee.text = itemBean.deviceCode
|
|
|
|
|
binding.tvTypeZigbee.text = itemBean.category
|
|
|
|
|
binding.tvLongZigbee.text = String.format("%.0f", itemBean.sampleLength)
|
|
|
|
|
@ -122,7 +265,7 @@ class DeviceOnlineStatusListAdapter(var context: Context,var data: MutableList<A
|
|
|
|
|
binding.tvSbmcZigbee.text = itemBean.name
|
|
|
|
|
binding.tvZcqhZigbee.text = itemBean.bearingNumber
|
|
|
|
|
binding.tvPhotoManageZigbee.setOnClickListener {
|
|
|
|
|
onItemClickListener.onItemClick(position,binding.tvPhotoManage)
|
|
|
|
|
onItemClickListener.onItemClick(position, binding.tvPhotoManage)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|