设备总览-完成 部分

master
wenfei 4 weeks ago
parent b45f9b543a
commit 2b6a435a31

@ -0,0 +1,122 @@
package com.rehome.zhdcoa.adapter
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.Color
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.text.TextUtils
import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
import com.rehome.zhdcoa.Contans
import com.rehome.zhdcoa.Listener.OnItemClickListener
import com.rehome.zhdcoa.R
import com.rehome.zhdcoa.base.BaseViewBindingAdapter
import com.rehome.zhdcoa.bean.DeviceManagerListResultBean
import com.rehome.zhdcoa.databinding.AdapterDeviceOverviewListBinding
import com.rehome.zhdcoa.utils.NohttpUtils
import com.yolanda.nohttp.NoHttp
import com.yolanda.nohttp.rest.CacheMode
import com.yolanda.nohttp.rest.OnResponseListener
import com.yolanda.nohttp.rest.RequestQueue
import com.yolanda.nohttp.rest.Response
import javax.net.ssl.HostnameVerifier
class DeviceOverviewListAdapter(
var context: Context,
var data: MutableList<DeviceManagerListResultBean.DeviceManagerItem>,
var onItemClickListenerDetail: OnItemClickListener
) : BaseViewBindingAdapter<AdapterDeviceOverviewListBinding>(context) {
override fun getCount(): Int {
return data.count()
}
override fun getItem(position: Int): Any {
return data[position]
}
override fun getItemId(position: Int): Long {
return position.toLong()
}
override fun getBinding(inflater: LayoutInflater, parent: ViewGroup?) =
AdapterDeviceOverviewListBinding.inflate(inflater, parent, false)
@SuppressLint("SetTextI18n", "DefaultLocale")
override fun handleData(position: Int, binding: AdapterDeviceOverviewListBinding) {
val itemBean: DeviceManagerListResultBean.DeviceManagerItem = data[position]
if (!TextUtils.isEmpty(itemBean.fileName)) {
val mediaUrl = Contans.IP + Contans.getImgDeviceOnlineBaseUrl+itemBean.fileName
val request = NoHttp.createImageRequest(mediaUrl)
request.cacheMode = CacheMode.NONE_CACHE_REQUEST_NETWORK
if (!TextUtils.isEmpty(mediaUrl)) {
Log.i("app", "fullPath is:$mediaUrl")
if (!TextUtils.isEmpty(request.url())) {
val url = request.url()
if (url.startsWith("https://219.131.195.3:7100") || url.startsWith("https://219.131.195.3:7011") || url.startsWith(
"https://219.131.195.3:7081"
) || url.startsWith("https://219.131.195.3:7082")
) {
val socketFactory = NohttpUtils.getSSLSocketFactory(context)
if (socketFactory != null) {
request.sslSocketFactory = socketFactory
request.hostnameVerifier = HostnameVerifier { s, sslSession -> true }
}
}
}
val queue: RequestQueue = NoHttp.newRequestQueue(1)
queue.add<Bitmap>(6, request, object : OnResponseListener<Bitmap?> {
override fun onStart(what: Int) {
}
override fun onFailed(what: Int, response: Response<Bitmap?>?) {
val bitmap = BitmapFactory.decodeResource(context.resources, R.drawable.icon_device_place)
val drawable: Drawable = BitmapDrawable(context.resources, bitmap)
binding.ivDevicePhoto.setImageDrawable(drawable)
}
override fun onSucceed(what: Int, response: Response<Bitmap?>?) {
val bitmap = response?.get()
if(bitmap!=null){
val drawable: Drawable = BitmapDrawable(context.resources, bitmap)
binding.ivDevicePhoto.setImageDrawable(drawable)
}
}
override fun onFinish(what: Int) {
}
})
}
}else{
val bitmap = BitmapFactory.decodeResource(context.resources, R.drawable.icon_device_place)
val drawable: Drawable = BitmapDrawable(context.resources, bitmap)
binding.ivDevicePhoto.setImageDrawable(drawable)
}
binding.tvMc.text = itemBean.name
if(!TextUtils.isEmpty(itemBean.areaFullName)){
binding.tvArea.text = itemBean.areaFullName
}
binding.tvSbzt.text = itemBean.description
if(itemBean.online){
binding.tvZxzt.text = "在线"
binding.tvZxzt.setTextColor(Color.parseColor("#67C23A"))//0099ff
}else{
binding.tvZxzt.text = "离线"
binding.tvZxzt.setTextColor(Color.parseColor("#ff0000"))
}
binding.tvZtsysc.text = itemBean.continuedTime
binding.tvAzsj.text = itemBean.installTime
binding.tvYczsc.text = itemBean.runningTime
binding.tvSjgxsj.text = itemBean.warningTime
binding.llCwcz.setOnClickListener {
onItemClickListenerDetail.onItemClick(position, binding.llCwcz)
}
}
}

@ -135,11 +135,6 @@ class DeviceManagerListActivity : BaseActivityOaToolbarViewBinding<ActivityDevic
authenticationLoginDeviceAlarmInfoRsa() authenticationLoginDeviceAlarmInfoRsa()
} }
override fun onRestart() {
super.onRestart()
//authenticationLoginDeviceAlarmInfoRsaNoProgress()
}
private fun filterChange(){ private fun filterChange(){
if(deviceManagerList.size>0){ if(deviceManagerList.size>0){
deviceManagerListFilter.clear() deviceManagerListFilter.clear()
@ -168,7 +163,7 @@ class DeviceManagerListActivity : BaseActivityOaToolbarViewBinding<ActivityDevic
} }
deviceManagerListFilter.clear() deviceManagerListFilter.clear()
deviceManagerListFilter.addAll(deviceManagerListFilterKeyFilter) deviceManagerListFilter.addAll(deviceManagerListFilterKeyFilter)
deviceManagerListAdapter.notifyDataSetChanged() //deviceManagerListAdapter.notifyDataSetChanged()
} }
}else{ }else{
if(deviceManagerListFilter.size>0){ if(deviceManagerListFilter.size>0){
@ -180,7 +175,7 @@ class DeviceManagerListActivity : BaseActivityOaToolbarViewBinding<ActivityDevic
} }
deviceManagerListFilter.clear() deviceManagerListFilter.clear()
deviceManagerListFilter.addAll(deviceManagerListFilterKeyFilter) deviceManagerListFilter.addAll(deviceManagerListFilterKeyFilter)
deviceManagerListAdapter.notifyDataSetChanged() //deviceManagerListAdapter.notifyDataSetChanged()
} }
} }
}else{ }else{
@ -194,13 +189,13 @@ class DeviceManagerListActivity : BaseActivityOaToolbarViewBinding<ActivityDevic
} }
deviceManagerListFilter.clear() deviceManagerListFilter.clear()
deviceManagerListFilter.addAll(deviceManagerListFilterKeyFilter) deviceManagerListFilter.addAll(deviceManagerListFilterKeyFilter)
deviceManagerListAdapter.notifyDataSetChanged() //deviceManagerListAdapter.notifyDataSetChanged()
} }
} }
} }
showLog("deviceManagerListFilter size:"+deviceManagerListFilter.size.toString()) showLog("deviceManagerListFilter size:"+deviceManagerListFilter.size.toString())
showLog("deviceManagerList size:"+deviceManagerList.size.toString()) showLog("deviceManagerList size:"+deviceManagerList.size.toString())
//deviceManagerListAdapter.notifyDataSetChanged() deviceManagerListAdapter.notifyDataSetChanged()
binding.tvNodata.visibility = View.GONE binding.tvNodata.visibility = View.GONE
binding.lv.visibility=View.VISIBLE binding.lv.visibility=View.VISIBLE
}else{ }else{
@ -238,33 +233,6 @@ class DeviceManagerListActivity : BaseActivityOaToolbarViewBinding<ActivityDevic
} }
} }
private fun authenticationLoginDeviceAlarmInfoRsaNoProgress() {
try {
//AI三维登录接口
val userName = Contans.SP.DeviceAlermInfoAccount
val strPrivateEncode = RSAAndroid.encryptByPrivateKeyForSpiltStr(
Contans.SP.DeviceAlermInfoPwd,
RSAAndroid.privateRsaKeyLocal)
val strPublicDecode = RSAAndroid.decryptByPublicKeyForSpiltStr(
Contans.SP.DeviceAlermInfoPwd,
RSAAndroid.publicRsaKeyLocal
)
AuthenticationLoginAIUtils.authenticationDeviceAlermInfoRsaNotShowProgress(
this, userName, strPublicDecode
) { _, token ->
if (token != null && token == "") {
showToast("设备状态智能监测及分析平台登录失败")
} else {
//登录成功
//获取区域
getDeviceAreaListNoProgress()
}
}
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun getDeviceManagerListData() { private fun getDeviceManagerListData() {
val request = NoHttp.createStringRequest( val request = NoHttp.createStringRequest(
@ -272,19 +240,6 @@ class DeviceManagerListActivity : BaseActivityOaToolbarViewBinding<ActivityDevic
RequestMethod.GET RequestMethod.GET
) )
// if(binding.rb1.isChecked){
// request.add("online",true)
// }
// if(binding.rb2.isChecked){
// request.add("online",false)
// }
// val keyword = binding.etKey.text.toString().trim()
// if(!TextUtils.isEmpty(keyword)){
// request.add("keyword",keyword)
// }
NohttpUtils.getInstance().add(this, 0, request, object : HttpListener<String?> { NohttpUtils.getInstance().add(this, 0, request, object : HttpListener<String?> {
override fun onSucceed(what: Int, response: Response<String?>?) { override fun onSucceed(what: Int, response: Response<String?>?) {
@ -390,103 +345,6 @@ class DeviceManagerListActivity : BaseActivityOaToolbarViewBinding<ActivityDevic
}) })
} }
private fun getDeviceManagerListDataNoProgress() {
val request = NoHttp.createStringRequest(
Contans.IP + Contans.DeviceManagerListUrl,
RequestMethod.GET
)
// if(binding.rb1.isChecked){
// request.add("online",true)
// }
// if(binding.rb2.isChecked){
// request.add("online",false)
// }
// val keyword = binding.etKey.text.toString().trim()
// if(!TextUtils.isEmpty(keyword)){
// request.add("keyword",keyword)
// }
NohttpUtils.getInstance().addNoProgress(this, 0, request, object : HttpListener<String?> {
override fun onSucceed(what: Int, response: Response<String?>?) {
val result = response?.get()
showLog("----------------")
showLog(result)
val bean = GsonUtils.GsonToBean(
result,
DeviceManagerListResultBean::class.java
)
showLog(GsonUtils.GsonString(bean))
if (bean != null && bean.code == 20000 && bean.isSuccess && bean.data != null&& bean.data.size>0) {
deviceManagerList.clear()
deviceManagerListFilter.clear()
deviceManagerList.addAll(bean.data)
if(areaNodeList.size>0){
for (item in deviceManagerList) {
if(!TextUtils.isEmpty(item.areaId)){
for (itemAreaNode in areaNodeList) {
if(item.areaId==itemAreaNode.nodeKey){
item.areaFullName=itemAreaNode.areaFullName
item.areaFullPath=itemAreaNode.areaFullPath
}
}
}
showLog(GsonUtils.GsonString(item))
}
if(binding.rb1.isChecked){
for (item in deviceManagerList) {
if(item.online){
deviceManagerListFilter.add(item)
}
}
}
if(binding.rb2.isChecked){
for (item in deviceManagerList) {
if(!item.online){
deviceManagerListFilter.add(item)
}
}
}
if(!TextUtils.isEmpty(binding.etKey.text.toString().trim())){
if(deviceManagerListFilter.size>0){
val deviceManagerListFilterKeyFilter: MutableList<DeviceManagerListResultBean.DeviceManagerItem> = mutableListOf()
for (item in deviceManagerListFilter) {
if(!TextUtils.isEmpty(item.name)&&item.name.contains(binding.etKey.text.toString().trim())){
deviceManagerListFilterKeyFilter.add(item)
}
}
deviceManagerListFilter.clear()
deviceManagerListFilter.addAll(deviceManagerListFilterKeyFilter)
}
}
}
deviceManagerListAdapter.notifyDataSetChanged()
binding.tvNodata.visibility = View.GONE
binding.lv.visibility=View.VISIBLE
}else{
deviceManagerList.clear()
deviceManagerListFilter.clear()
deviceManagerListAdapter.notifyDataSetChanged()
binding.tvNodata.visibility = View.VISIBLE
binding.lv.visibility=View.GONE
}
}
override fun onFailed(what: Int, response: Response<String?>?) {
}
})
}
private fun getDeviceAreaList() { private fun getDeviceAreaList() {
//DeviceOnlineStatusAreaBean //DeviceOnlineStatusAreaBean
@ -537,57 +395,6 @@ class DeviceManagerListActivity : BaseActivityOaToolbarViewBinding<ActivityDevic
}) })
} }
private fun getDeviceAreaListNoProgress() {
//DeviceOnlineStatusAreaBean
val request = NoHttp.createStringRequest(
Contans.IP + Contans.DeviceOnlineStatusAreaBeanUrl,
RequestMethod.GET
)
NohttpUtils.getInstance().addNoProgress(this, 0, request, object : HttpListener<String?> {
override fun onSucceed(what: Int, response: Response<String?>?) {
val result = response?.get()
showLog("----------------")
showLog(result)
val bean = GsonUtils.GsonToBean(
result,
DeviceOnlineStatusAreaBean::class.java
)
showLog(GsonUtils.GsonString(bean))
if (bean != null && bean.code == 20000 && bean.isSuccess && bean.data != null && bean.data.size>0) {
areaList.clear()
areaNodeList.clear()
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.cname)) {
itemNodeList.areaFullPath=itemArea.cname+"/"+itemNodeList.cname
itemNodeList.areaFullName=itemArea.cname+">"+itemNodeList.cname
areaNodeList.add(itemNodeList)
}
}
}
}
showLog(GsonUtils.GsonString(areaList))
SPUtils.put(context, Contans.DeviceOnlineStatusAreaBean,result)
//获取设备管理列表
getDeviceManagerListDataNoProgress()
}
}
override fun onFailed(what: Int, response: Response<String?>?) {
}
})
}
//创建一个ActivityResultLauncher,选择区域 //创建一个ActivityResultLauncher,选择区域
private fun createActivityResultLauncher(): ActivityResultLauncher<Intent> { private fun createActivityResultLauncher(): ActivityResultLauncher<Intent> {
//kotlin写法 //kotlin写法

@ -1,25 +1,349 @@
package com.rehome.zhdcoa.ui.activity package com.rehome.zhdcoa.ui.activity
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.text.TextUtils
import android.view.View
import android.widget.RadioGroup
import androidx.activity.enableEdgeToEdge import androidx.activity.enableEdgeToEdge
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsCompat
import com.google.gson.GsonBuilder
import com.rehome.zhdcoa.Contans
import com.rehome.zhdcoa.Listener.OnItemClickListener
import com.rehome.zhdcoa.R import com.rehome.zhdcoa.R
import com.rehome.zhdcoa.adapter.DeviceManagerListAdapter
import com.rehome.zhdcoa.adapter.DeviceOverviewListAdapter
import com.rehome.zhdcoa.base.BaseActivityOaToolbarViewBinding import com.rehome.zhdcoa.base.BaseActivityOaToolbarViewBinding
import com.rehome.zhdcoa.bean.DeviceManagerListResultBean
import com.rehome.zhdcoa.bean.DeviceOnlineStatusAreaBean
import com.rehome.zhdcoa.databinding.ActivityDeviceOverviewListBinding import com.rehome.zhdcoa.databinding.ActivityDeviceOverviewListBinding
import com.rehome.zhdcoa.utils.AuthenticationLoginAIUtils
import com.rehome.zhdcoa.utils.GsonUtils
import com.rehome.zhdcoa.utils.HttpListener
import com.rehome.zhdcoa.utils.NohttpUtils
import com.rehome.zhdcoa.utils.RSAAndroid
import com.rehome.zhdcoa.utils.SPUtils
import com.rehome.zhdcoa.weiget.LoadListView
import com.rehome.zhdcoa.weiget.OAToolbar import com.rehome.zhdcoa.weiget.OAToolbar
import com.yolanda.nohttp.NoHttp
import com.yolanda.nohttp.RequestMethod
import com.yolanda.nohttp.rest.Response
class DeviceOverviewListActivity :
BaseActivityOaToolbarViewBinding<ActivityDeviceOverviewListBinding>() {
private var deviceManagerList: MutableList<DeviceManagerListResultBean.DeviceManagerItem> =
mutableListOf()//设备管理列表
private var deviceManagerListFilter: MutableList<DeviceManagerListResultBean.DeviceManagerItem> =
mutableListOf()//设备管理列表
private var areaList: MutableList<DeviceOnlineStatusAreaBean.DeviceArea> =
mutableListOf()//在线设备区域列表
private var areaNodeList: MutableList<DeviceOnlineStatusAreaBean.NodeList> =
mutableListOf()//在线设备区域列表
private lateinit var deviceOverviewListAdapter: DeviceOverviewListAdapter
private lateinit var launcherResult: ActivityResultLauncher<Intent>
private var nodeKey: String? = null
private var cname: String? = null
class DeviceOverviewListActivity : BaseActivityOaToolbarViewBinding<ActivityDeviceOverviewListBinding>() {
override fun getViewBinding() = ActivityDeviceOverviewListBinding.inflate(layoutInflater) override fun getViewBinding() = ActivityDeviceOverviewListBinding.inflate(layoutInflater)
override fun getToolbar() = binding.toolbarView.toolbar override fun getToolbar() = binding.toolbarView.toolbar
override fun initView() { override fun initView() {
initToolbar("设备总览", "", {
})
launcherResult = createActivityResultLauncher()
binding.etArea.setOnClickListener {
if (areaList.size > 0) {
val intent = Intent(context, DeviceAreaTreeActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
launcherResult.launch(intent)
}
}
binding.lv.emptyView = binding.tvNodata
val gson = GsonBuilder()
.setPrettyPrinting()
.serializeNulls()
.create()
deviceOverviewListAdapter =
DeviceOverviewListAdapter(context, deviceManagerListFilter, object : OnItemClickListener {
override fun onItemClick(position: Int, v: View?) {
val item: DeviceManagerListResultBean.DeviceManagerItem =
deviceManagerListFilter[position]
showLog(GsonUtils.GsonString(item))
val intent = Intent(context, DeviceMonitoringDetailActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
intent.putExtra("deviceName", item.name)
intent.putExtra("deviceId", item.code)
intent.putExtra("areaFullName", item.areaFullName)
startActivity(intent)
}
})
binding.lv.adapter = deviceOverviewListAdapter
binding.tvNodata.visibility = View.VISIBLE
binding.lv.visibility = View.GONE
binding.lv.setInterface(LoadListView.ILoadListener {
binding.lv.loadComplete()
})
binding.rg.setOnCheckedChangeListener(object : RadioGroup.OnCheckedChangeListener {
override fun onCheckedChanged(group: RadioGroup, checkedId: Int) {
filterChange()
}
})
} }
override fun initData() { override fun initData() {
authenticationLoginDeviceAlarmInfoRsa()
}
private fun filterChange() {
if (deviceManagerList.size > 0) {
deviceManagerListFilter.clear()
if (binding.rb1.isChecked) {
for (item in deviceManagerList) {
if (item.online != null && item.online) {
deviceManagerListFilter.add(item)
}
}
}
if (binding.rb2.isChecked) {
for (item in deviceManagerList) {
if (item.online != null && !item.online) {
deviceManagerListFilter.add(item)
}
}
}
if (!TextUtils.isEmpty(binding.etArea.text.toString().trim())) {
if (deviceManagerListFilter.size > 0) {
val deviceManagerListFilterKeyFilter: MutableList<DeviceManagerListResultBean.DeviceManagerItem> =
mutableListOf()
for (item in deviceManagerListFilter) {
if (!TextUtils.isEmpty(item.areaFullName) && item.areaFullName.contains(
binding.etArea.text.toString().trim()
)
) {
deviceManagerListFilterKeyFilter.add(item)
}
}
deviceManagerListFilter.clear()
deviceManagerListFilter.addAll(deviceManagerListFilterKeyFilter)
}
}
showLog("deviceManagerListFilter size:" + deviceManagerListFilter.size.toString())
showLog("deviceManagerList size:" + deviceManagerList.size.toString())
deviceOverviewListAdapter.notifyDataSetChanged()
binding.tvNodata.visibility = View.GONE
binding.lv.visibility = View.VISIBLE
} else {
deviceManagerListFilter.clear()
deviceOverviewListAdapter.notifyDataSetChanged()
binding.tvNodata.visibility = View.VISIBLE
binding.lv.visibility = View.GONE
}
}
private fun authenticationLoginDeviceAlarmInfoRsa() {
try {
//AI三维登录接口
val userName = Contans.SP.DeviceAlermInfoAccount
val strPrivateEncode = RSAAndroid.encryptByPrivateKeyForSpiltStr(
Contans.SP.DeviceAlermInfoPwd,
RSAAndroid.privateRsaKeyLocal
)
val strPublicDecode = RSAAndroid.decryptByPublicKeyForSpiltStr(
Contans.SP.DeviceAlermInfoPwd,
RSAAndroid.publicRsaKeyLocal
)
AuthenticationLoginAIUtils.authenticationDeviceAlermInfoRsaShowProgress(
this, userName, strPublicDecode
) { _, token ->
if (token != null && token == "") {
showToast("设备状态智能监测及分析平台登录失败")
} else {
//登录成功
//获取区域
getDeviceAreaList()
}
}
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun getDeviceManagerListData() {
val request = NoHttp.createStringRequest(
Contans.IP + Contans.DeviceManagerListUrl,
RequestMethod.GET
)
NohttpUtils.getInstance().add(this, 0, request, object : HttpListener<String?> {
override fun onSucceed(what: Int, response: Response<String?>?) {
val result = response?.get()
showLog("----------------")
showLog(result)
val bean = GsonUtils.GsonToBean(
result,
DeviceManagerListResultBean::class.java
)
showLog(GsonUtils.GsonString(bean))
if (bean != null && bean.code == 20000 && bean.isSuccess && bean.data != null && bean.data.size > 0) {
deviceManagerList.clear()
deviceManagerListFilter.clear()
deviceManagerList.addAll(bean.data)
if (areaNodeList.size > 0) {
for (item in deviceManagerList) {
if (!TextUtils.isEmpty(item.areaId)) {
for (itemAreaNode in areaNodeList) {
if (item.areaId == itemAreaNode.nodeKey) {
item.areaFullName = itemAreaNode.areaFullName
item.areaFullPath = itemAreaNode.areaFullPath
}
}
}
showLog(GsonUtils.GsonString(item))
}
if (binding.rb1.isChecked) {
for (item in deviceManagerList) {
if (item.online != null && item.online) {
deviceManagerListFilter.add(item)
}
}
}
if (binding.rb2.isChecked) {
for (item in deviceManagerList) {
if (item.online != null && !item.online) {
deviceManagerListFilter.add(item)
}
}
}
if (!TextUtils.isEmpty(binding.etArea.text.toString().trim())) {
if (deviceManagerListFilter.size > 0) {
val deviceManagerListFilterKeyFilter: MutableList<DeviceManagerListResultBean.DeviceManagerItem> =
mutableListOf()
for (item in deviceManagerListFilter) {
if (!TextUtils.isEmpty(item.areaFullName) && item.areaFullName.contains(
binding.etArea.text.toString().trim()
)
) {
deviceManagerListFilterKeyFilter.add(item)
}
}
deviceManagerListFilter.clear()
deviceManagerListFilter.addAll(deviceManagerListFilterKeyFilter)
}
}
}
deviceOverviewListAdapter.notifyDataSetChanged()
binding.tvNodata.visibility = View.GONE
binding.lv.visibility = View.VISIBLE
} else {
deviceManagerList.clear()
deviceManagerListFilter.clear()
deviceOverviewListAdapter.notifyDataSetChanged()
binding.tvNodata.visibility = View.VISIBLE
binding.lv.visibility = View.GONE
}
}
override fun onFailed(what: Int, response: Response<String?>?) {
}
})
}
private fun getDeviceAreaList() {
//DeviceOnlineStatusAreaBean
val request = NoHttp.createStringRequest(
Contans.IP + Contans.DeviceOnlineStatusAreaBeanUrl,
RequestMethod.GET
)
NohttpUtils.getInstance().add(this, 0, request, object : HttpListener<String?> {
override fun onSucceed(what: Int, response: Response<String?>?) {
val result = response?.get()
showLog("----------------")
showLog(result)
val bean = GsonUtils.GsonToBean(
result,
DeviceOnlineStatusAreaBean::class.java
)
showLog(GsonUtils.GsonString(bean))
if (bean != null && bean.code == 20000 && bean.isSuccess && bean.data != null && bean.data.size > 0) {
areaList.clear()
areaNodeList.clear()
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.cname)) {
itemNodeList.areaFullPath =
itemArea.cname + "/" + itemNodeList.cname
itemNodeList.areaFullName =
itemArea.cname + ">" + itemNodeList.cname
areaNodeList.add(itemNodeList)
}
}
}
}
showLog(GsonUtils.GsonString(areaList))
SPUtils.put(context, Contans.DeviceOnlineStatusAreaBean, result)
//获取设备管理列表
getDeviceManagerListData()
}
}
override fun onFailed(what: Int, response: Response<String?>?) {
}
})
}
//创建一个ActivityResultLauncher,选择区域
private fun createActivityResultLauncher(): ActivityResultLauncher<Intent> {
//kotlin写法
return registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
val data = it.data
val resultCode = it.resultCode
if (resultCode == RESULT_OK) {
if (data != null) {
nodeKey = data.getStringExtra("nodeKey")
cname = data.getStringExtra("cname")
if (cname != null && nodeKey != null) {
binding.etArea.setText(cname)
filterChange()
}
}
}
}
} }
} }

@ -24,39 +24,30 @@
android:layout_gravity="center" android:layout_gravity="center"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
android:id="@+id/tv_sysit" android:id="@+id/tv_area"
android:padding="3dp" android:padding="3dp"
android:textColor="#333333" android:textColor="#333333"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="18sp" android:textSize="18sp"
android:text="专业:" /> android:text="区域筛选:" />
<Spinner <LinearLayout
android:id="@+id/sp_zy"
style="@style/editTextTheme"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="70px" android:layout_height="76px"
android:layout_gravity="center" android:layout_marginEnd="2dp"
android:gravity="center" android:layout_gravity="center_vertical">
android:padding="0px" <EditText
android:textSize="@dimen/px_30" /> android:id="@+id/et_area"
style="@style/editTextTheme"
android:textSize="14sp"
android:editable="false"
android:layout_gravity="center_vertical"
android:layout_width="match_parent"
android:layout_weight="1"
android:hint="请选择区域" />
</LinearLayout>
</LinearLayout> </LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1">
<EditText
android:id="@+id/et_key"
style="@style/editTextTheme"
android:textSize="14sp"
android:layout_width="match_parent"
android:layout_weight="1"
android:hint="请转入关键字" />
</RelativeLayout>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -107,30 +98,6 @@
android:text="离线" /> android:text="离线" />
</RadioGroup> </RadioGroup>
</LinearLayout> </LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_weight="2" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:layout_marginBottom="10dp">
<Button
android:id="@+id/btn_query"
style="@style/button"
android:layout_marginEnd="10dp"
android:layout_weight="1"
android:textSize="18sp"
android:text="查询" />
</LinearLayout> </LinearLayout>
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"

@ -0,0 +1,241 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/ll_cwcz"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:orientation="vertical"
tools:ignore="UselessParent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:ignore="UselessParent">
<LinearLayout
style="@style/dagerListMarginTopStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout
style="@style/dagerListMarginTopStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_device_photo"
android:layout_width="80dp"
android:layout_height="80dp"
android:contentDescription="@string/iv_device_photo"
android:src="@drawable/icon_device_place"/>
</LinearLayout>
<LinearLayout
style="@style/dagerListMarginTopStyle"
android:layout_width="0dp"
android:layout_marginTop="3dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="vertical">
<LinearLayout
style="@style/dagerListMarginTopStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginBottom="5dp"
android:orientation="horizontal">
<TextView
style="@style/deviceManagerStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="设备位置:" />
<TextView
android:id="@+id/tv_area"
style="@style/deviceManagerStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#1锅炉区域 > 1号锅炉0米捞渣机,锅炉区域" />
</LinearLayout>
<LinearLayout
style="@style/dagerListMarginTopStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
style="@style/deviceManagerStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="设备名称:" />
<TextView
android:id="@+id/tv_mc"
style="@style/deviceManagerStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#1-2循环浆液泵电机尾部" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
style="@style/dagerListMarginTopStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
style="@style/dagerListMarginTopStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
style="@style/deviceManagerStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="设备状态:" />
<TextView
android:id="@+id/tv_sbzt"
style="@style/deviceManagerStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
style="@style/dagerListMarginTopStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
style="@style/deviceManagerStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="在线状态:" />
<TextView
android:id="@+id/tv_zxzt"
style="@style/deviceManagerStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
<LinearLayout
style="@style/dagerListMarginTopStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
style="@style/dagerListMarginTopStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
style="@style/deviceManagerStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="状态持续时长:" />
<TextView
android:id="@+id/tv_ztsysc"
style="@style/deviceManagerStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
<LinearLayout
style="@style/dagerListMarginTopStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
style="@style/deviceManagerStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="安装时间:" />
<TextView
android:id="@+id/tv_azsj"
style="@style/deviceManagerStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
style="@style/dagerListMarginTopStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
style="@style/dagerListMarginTopStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
style="@style/deviceManagerStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="运行总时长:" />
<TextView
android:id="@+id/tv_yczsc"
style="@style/deviceManagerStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
<LinearLayout
style="@style/dagerListMarginTopStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
style="@style/deviceManagerStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="数据更新时间:" />
<TextView
android:id="@+id/tv_sjgxsj"
style="@style/deviceManagerStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Loading…
Cancel
Save