diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cbc72b6..a9b50c5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,7 +26,7 @@
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
- android:theme="@style/AppTheme"
+ android:theme="@style/QMUI.Compat.NoActionBar"
android:usesCleartextTraffic="true">
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cbc72b6..a9b50c5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,7 +26,7 @@
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
- android:theme="@style/AppTheme"
+ android:theme="@style/QMUI.Compat.NoActionBar"
android:usesCleartextTraffic="true">
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
new file mode 100644
index 0000000..e3c059d
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
@@ -0,0 +1,111 @@
+package com.casic.smarttube.adapter
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+import com.casic.smarttube.R
+import com.casic.smarttube.extensions.arrowAnimation
+import com.casic.smarttube.model.DeviceListModel
+import com.github.mikephil.charting.charts.LineChart
+import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
+
+class DeviceListAdapter(
+ private val context: Context,
+ private val dataRows: MutableList
+) : RecyclerView.Adapter() {
+
+ private var layoutInflater: LayoutInflater = LayoutInflater.from(context)
+ private var isExpand = false
+
+ override fun onCreateViewHolder(
+ parent: ViewGroup, viewType: Int
+ ): DeviceListAdapter.ItemViewHolder {
+ return ItemViewHolder(
+ layoutInflater.inflate(R.layout.item_device_recycleview, parent, false)
+ )
+ }
+
+ override fun getItemCount(): Int = dataRows.size
+
+ override fun onBindViewHolder(holder: DeviceListAdapter.ItemViewHolder, position: Int) {
+ //绑定数据
+ val rowsBean = dataRows[position]
+ holder.deviceStateView.text = rowsBean.onlineStateName
+ if (rowsBean.onlineState == "1") {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_green_radius_5)
+ } else {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_gray_radius_5)
+ }
+ holder.deviceCodeView.text = rowsBean.devcode
+ holder.wellCodeView.text = String.format("井编号:${rowsBean.wellCode}")
+ holder.ownerShipView.text = String.format("权属单位:${rowsBean.deptName}")
+ holder.deviceLocationView.text = String.format("设备位置:${rowsBean.position}")
+ holder.installDateView.text = String.format("安装日期:${rowsBean.installDate}")
+
+
+ if (listener != null) {
+ holder.itemView.setOnClickListener {
+ listener!!.onClicked(position)
+ }
+ holder.dataHistoryButton.setOnClickListener {
+ listener!!.onHistoryClicked(position)
+ }
+ holder.editButton.setOnClickListener {
+ listener!!.onEditClicked(position)
+ }
+ holder.wellDetailButton.setOnClickListener {
+ listener!!.onWellDetailClicked(position)
+ }
+
+ holder.expandableImageView.setOnClickListener {
+ if (!isExpand) {
+ //展开列表动画
+ holder.expandableImageView.arrowAnimation(180f)
+ isExpand = true
+ //子列表绑定数据
+// expandableViewAdapter.setExpandableData(createExpandableList(rowsBean))
+ } else {
+ //关闭列表动画
+ holder.expandableImageView.arrowAnimation(0f)
+ isExpand = false
+ //子列表清空数据
+// expandableViewAdapter.clearAll()
+ }
+ }
+ }
+ }
+
+ inner class ItemViewHolder(view: View) : RecyclerView.ViewHolder(view) {
+ var deviceStateView: TextView = view.findViewById(R.id.deviceStateView)
+ var deviceCodeView: TextView = view.findViewById(R.id.deviceCodeView)
+ var expandableImageView: ImageView = view.findViewById(R.id.expandableImageView)
+ var wellCodeView: TextView = view.findViewById(R.id.wellCodeView)
+ var ownerShipView: TextView = view.findViewById(R.id.ownerShipView)
+ var deviceLocationView: TextView = view.findViewById(R.id.deviceLocationView)
+ var installDateView: TextView = view.findViewById(R.id.installDateView)
+ var dataHistoryButton: QMUIRoundButton = view.findViewById(R.id.dataHistoryButton)
+ var editButton: QMUIRoundButton = view.findViewById(R.id.editButton)
+ var wellDetailButton: QMUIRoundButton = view.findViewById(R.id.wellDetailButton)
+ var expandableChartView: LineChart = view.findViewById(R.id.expandableChartView)
+ }
+
+ private var listener: OnItemClickListener? = null
+
+ interface OnItemClickListener {
+ fun onClicked(position: Int)
+
+ fun onHistoryClicked(position: Int)
+
+ fun onEditClicked(position: Int)
+
+ fun onWellDetailClicked(position: Int)
+ }
+
+ fun setOnItemClickListener(onClickListener: OnItemClickListener?) {
+ this.listener = onClickListener
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cbc72b6..a9b50c5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,7 +26,7 @@
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
- android:theme="@style/AppTheme"
+ android:theme="@style/QMUI.Compat.NoActionBar"
android:usesCleartextTraffic="true">
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
new file mode 100644
index 0000000..e3c059d
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
@@ -0,0 +1,111 @@
+package com.casic.smarttube.adapter
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+import com.casic.smarttube.R
+import com.casic.smarttube.extensions.arrowAnimation
+import com.casic.smarttube.model.DeviceListModel
+import com.github.mikephil.charting.charts.LineChart
+import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
+
+class DeviceListAdapter(
+ private val context: Context,
+ private val dataRows: MutableList
+) : RecyclerView.Adapter() {
+
+ private var layoutInflater: LayoutInflater = LayoutInflater.from(context)
+ private var isExpand = false
+
+ override fun onCreateViewHolder(
+ parent: ViewGroup, viewType: Int
+ ): DeviceListAdapter.ItemViewHolder {
+ return ItemViewHolder(
+ layoutInflater.inflate(R.layout.item_device_recycleview, parent, false)
+ )
+ }
+
+ override fun getItemCount(): Int = dataRows.size
+
+ override fun onBindViewHolder(holder: DeviceListAdapter.ItemViewHolder, position: Int) {
+ //绑定数据
+ val rowsBean = dataRows[position]
+ holder.deviceStateView.text = rowsBean.onlineStateName
+ if (rowsBean.onlineState == "1") {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_green_radius_5)
+ } else {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_gray_radius_5)
+ }
+ holder.deviceCodeView.text = rowsBean.devcode
+ holder.wellCodeView.text = String.format("井编号:${rowsBean.wellCode}")
+ holder.ownerShipView.text = String.format("权属单位:${rowsBean.deptName}")
+ holder.deviceLocationView.text = String.format("设备位置:${rowsBean.position}")
+ holder.installDateView.text = String.format("安装日期:${rowsBean.installDate}")
+
+
+ if (listener != null) {
+ holder.itemView.setOnClickListener {
+ listener!!.onClicked(position)
+ }
+ holder.dataHistoryButton.setOnClickListener {
+ listener!!.onHistoryClicked(position)
+ }
+ holder.editButton.setOnClickListener {
+ listener!!.onEditClicked(position)
+ }
+ holder.wellDetailButton.setOnClickListener {
+ listener!!.onWellDetailClicked(position)
+ }
+
+ holder.expandableImageView.setOnClickListener {
+ if (!isExpand) {
+ //展开列表动画
+ holder.expandableImageView.arrowAnimation(180f)
+ isExpand = true
+ //子列表绑定数据
+// expandableViewAdapter.setExpandableData(createExpandableList(rowsBean))
+ } else {
+ //关闭列表动画
+ holder.expandableImageView.arrowAnimation(0f)
+ isExpand = false
+ //子列表清空数据
+// expandableViewAdapter.clearAll()
+ }
+ }
+ }
+ }
+
+ inner class ItemViewHolder(view: View) : RecyclerView.ViewHolder(view) {
+ var deviceStateView: TextView = view.findViewById(R.id.deviceStateView)
+ var deviceCodeView: TextView = view.findViewById(R.id.deviceCodeView)
+ var expandableImageView: ImageView = view.findViewById(R.id.expandableImageView)
+ var wellCodeView: TextView = view.findViewById(R.id.wellCodeView)
+ var ownerShipView: TextView = view.findViewById(R.id.ownerShipView)
+ var deviceLocationView: TextView = view.findViewById(R.id.deviceLocationView)
+ var installDateView: TextView = view.findViewById(R.id.installDateView)
+ var dataHistoryButton: QMUIRoundButton = view.findViewById(R.id.dataHistoryButton)
+ var editButton: QMUIRoundButton = view.findViewById(R.id.editButton)
+ var wellDetailButton: QMUIRoundButton = view.findViewById(R.id.wellDetailButton)
+ var expandableChartView: LineChart = view.findViewById(R.id.expandableChartView)
+ }
+
+ private var listener: OnItemClickListener? = null
+
+ interface OnItemClickListener {
+ fun onClicked(position: Int)
+
+ fun onHistoryClicked(position: Int)
+
+ fun onEditClicked(position: Int)
+
+ fun onWellDetailClicked(position: Int)
+ }
+
+ fun setOnItemClickListener(onClickListener: OnItemClickListener?) {
+ this.listener = onClickListener
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
new file mode 100644
index 0000000..d185752
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
@@ -0,0 +1,11 @@
+package com.casic.smarttube.extensions
+
+import android.view.animation.LinearInterpolator
+import android.widget.ImageView
+
+fun ImageView.arrowAnimation(angle: Float) {
+ val animation = this.animate()
+ animation.duration = 300
+ animation.interpolator = LinearInterpolator()
+ animation.rotation(angle)
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cbc72b6..a9b50c5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,7 +26,7 @@
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
- android:theme="@style/AppTheme"
+ android:theme="@style/QMUI.Compat.NoActionBar"
android:usesCleartextTraffic="true">
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
new file mode 100644
index 0000000..e3c059d
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
@@ -0,0 +1,111 @@
+package com.casic.smarttube.adapter
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+import com.casic.smarttube.R
+import com.casic.smarttube.extensions.arrowAnimation
+import com.casic.smarttube.model.DeviceListModel
+import com.github.mikephil.charting.charts.LineChart
+import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
+
+class DeviceListAdapter(
+ private val context: Context,
+ private val dataRows: MutableList
+) : RecyclerView.Adapter() {
+
+ private var layoutInflater: LayoutInflater = LayoutInflater.from(context)
+ private var isExpand = false
+
+ override fun onCreateViewHolder(
+ parent: ViewGroup, viewType: Int
+ ): DeviceListAdapter.ItemViewHolder {
+ return ItemViewHolder(
+ layoutInflater.inflate(R.layout.item_device_recycleview, parent, false)
+ )
+ }
+
+ override fun getItemCount(): Int = dataRows.size
+
+ override fun onBindViewHolder(holder: DeviceListAdapter.ItemViewHolder, position: Int) {
+ //绑定数据
+ val rowsBean = dataRows[position]
+ holder.deviceStateView.text = rowsBean.onlineStateName
+ if (rowsBean.onlineState == "1") {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_green_radius_5)
+ } else {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_gray_radius_5)
+ }
+ holder.deviceCodeView.text = rowsBean.devcode
+ holder.wellCodeView.text = String.format("井编号:${rowsBean.wellCode}")
+ holder.ownerShipView.text = String.format("权属单位:${rowsBean.deptName}")
+ holder.deviceLocationView.text = String.format("设备位置:${rowsBean.position}")
+ holder.installDateView.text = String.format("安装日期:${rowsBean.installDate}")
+
+
+ if (listener != null) {
+ holder.itemView.setOnClickListener {
+ listener!!.onClicked(position)
+ }
+ holder.dataHistoryButton.setOnClickListener {
+ listener!!.onHistoryClicked(position)
+ }
+ holder.editButton.setOnClickListener {
+ listener!!.onEditClicked(position)
+ }
+ holder.wellDetailButton.setOnClickListener {
+ listener!!.onWellDetailClicked(position)
+ }
+
+ holder.expandableImageView.setOnClickListener {
+ if (!isExpand) {
+ //展开列表动画
+ holder.expandableImageView.arrowAnimation(180f)
+ isExpand = true
+ //子列表绑定数据
+// expandableViewAdapter.setExpandableData(createExpandableList(rowsBean))
+ } else {
+ //关闭列表动画
+ holder.expandableImageView.arrowAnimation(0f)
+ isExpand = false
+ //子列表清空数据
+// expandableViewAdapter.clearAll()
+ }
+ }
+ }
+ }
+
+ inner class ItemViewHolder(view: View) : RecyclerView.ViewHolder(view) {
+ var deviceStateView: TextView = view.findViewById(R.id.deviceStateView)
+ var deviceCodeView: TextView = view.findViewById(R.id.deviceCodeView)
+ var expandableImageView: ImageView = view.findViewById(R.id.expandableImageView)
+ var wellCodeView: TextView = view.findViewById(R.id.wellCodeView)
+ var ownerShipView: TextView = view.findViewById(R.id.ownerShipView)
+ var deviceLocationView: TextView = view.findViewById(R.id.deviceLocationView)
+ var installDateView: TextView = view.findViewById(R.id.installDateView)
+ var dataHistoryButton: QMUIRoundButton = view.findViewById(R.id.dataHistoryButton)
+ var editButton: QMUIRoundButton = view.findViewById(R.id.editButton)
+ var wellDetailButton: QMUIRoundButton = view.findViewById(R.id.wellDetailButton)
+ var expandableChartView: LineChart = view.findViewById(R.id.expandableChartView)
+ }
+
+ private var listener: OnItemClickListener? = null
+
+ interface OnItemClickListener {
+ fun onClicked(position: Int)
+
+ fun onHistoryClicked(position: Int)
+
+ fun onEditClicked(position: Int)
+
+ fun onWellDetailClicked(position: Int)
+ }
+
+ fun setOnItemClickListener(onClickListener: OnItemClickListener?) {
+ this.listener = onClickListener
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
new file mode 100644
index 0000000..d185752
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
@@ -0,0 +1,11 @@
+package com.casic.smarttube.extensions
+
+import android.view.animation.LinearInterpolator
+import android.widget.ImageView
+
+fun ImageView.arrowAnimation(angle: Float) {
+ val animation = this.animate()
+ animation.duration = 300
+ animation.interpolator = LinearInterpolator()
+ animation.rotation(angle)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
new file mode 100644
index 0000000..22e56d2
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
@@ -0,0 +1,12 @@
+package com.casic.smarttube.extensions
+
+import android.view.View
+import com.qmuiteam.qmui.widget.QMUIEmptyView
+
+fun QMUIEmptyView.showEmptyPage(onButtonClickListener: View.OnClickListener) {
+ this.show(false, "抱歉,无法查询到相关记录", null, "重试", onButtonClickListener)
+}
+
+fun QMUIEmptyView.showEmptyPage(title: String, onButtonClickListener: View.OnClickListener) {
+ this.show(false, title, null, "刷新", onButtonClickListener)
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cbc72b6..a9b50c5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,7 +26,7 @@
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
- android:theme="@style/AppTheme"
+ android:theme="@style/QMUI.Compat.NoActionBar"
android:usesCleartextTraffic="true">
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
new file mode 100644
index 0000000..e3c059d
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
@@ -0,0 +1,111 @@
+package com.casic.smarttube.adapter
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+import com.casic.smarttube.R
+import com.casic.smarttube.extensions.arrowAnimation
+import com.casic.smarttube.model.DeviceListModel
+import com.github.mikephil.charting.charts.LineChart
+import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
+
+class DeviceListAdapter(
+ private val context: Context,
+ private val dataRows: MutableList
+) : RecyclerView.Adapter() {
+
+ private var layoutInflater: LayoutInflater = LayoutInflater.from(context)
+ private var isExpand = false
+
+ override fun onCreateViewHolder(
+ parent: ViewGroup, viewType: Int
+ ): DeviceListAdapter.ItemViewHolder {
+ return ItemViewHolder(
+ layoutInflater.inflate(R.layout.item_device_recycleview, parent, false)
+ )
+ }
+
+ override fun getItemCount(): Int = dataRows.size
+
+ override fun onBindViewHolder(holder: DeviceListAdapter.ItemViewHolder, position: Int) {
+ //绑定数据
+ val rowsBean = dataRows[position]
+ holder.deviceStateView.text = rowsBean.onlineStateName
+ if (rowsBean.onlineState == "1") {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_green_radius_5)
+ } else {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_gray_radius_5)
+ }
+ holder.deviceCodeView.text = rowsBean.devcode
+ holder.wellCodeView.text = String.format("井编号:${rowsBean.wellCode}")
+ holder.ownerShipView.text = String.format("权属单位:${rowsBean.deptName}")
+ holder.deviceLocationView.text = String.format("设备位置:${rowsBean.position}")
+ holder.installDateView.text = String.format("安装日期:${rowsBean.installDate}")
+
+
+ if (listener != null) {
+ holder.itemView.setOnClickListener {
+ listener!!.onClicked(position)
+ }
+ holder.dataHistoryButton.setOnClickListener {
+ listener!!.onHistoryClicked(position)
+ }
+ holder.editButton.setOnClickListener {
+ listener!!.onEditClicked(position)
+ }
+ holder.wellDetailButton.setOnClickListener {
+ listener!!.onWellDetailClicked(position)
+ }
+
+ holder.expandableImageView.setOnClickListener {
+ if (!isExpand) {
+ //展开列表动画
+ holder.expandableImageView.arrowAnimation(180f)
+ isExpand = true
+ //子列表绑定数据
+// expandableViewAdapter.setExpandableData(createExpandableList(rowsBean))
+ } else {
+ //关闭列表动画
+ holder.expandableImageView.arrowAnimation(0f)
+ isExpand = false
+ //子列表清空数据
+// expandableViewAdapter.clearAll()
+ }
+ }
+ }
+ }
+
+ inner class ItemViewHolder(view: View) : RecyclerView.ViewHolder(view) {
+ var deviceStateView: TextView = view.findViewById(R.id.deviceStateView)
+ var deviceCodeView: TextView = view.findViewById(R.id.deviceCodeView)
+ var expandableImageView: ImageView = view.findViewById(R.id.expandableImageView)
+ var wellCodeView: TextView = view.findViewById(R.id.wellCodeView)
+ var ownerShipView: TextView = view.findViewById(R.id.ownerShipView)
+ var deviceLocationView: TextView = view.findViewById(R.id.deviceLocationView)
+ var installDateView: TextView = view.findViewById(R.id.installDateView)
+ var dataHistoryButton: QMUIRoundButton = view.findViewById(R.id.dataHistoryButton)
+ var editButton: QMUIRoundButton = view.findViewById(R.id.editButton)
+ var wellDetailButton: QMUIRoundButton = view.findViewById(R.id.wellDetailButton)
+ var expandableChartView: LineChart = view.findViewById(R.id.expandableChartView)
+ }
+
+ private var listener: OnItemClickListener? = null
+
+ interface OnItemClickListener {
+ fun onClicked(position: Int)
+
+ fun onHistoryClicked(position: Int)
+
+ fun onEditClicked(position: Int)
+
+ fun onWellDetailClicked(position: Int)
+ }
+
+ fun setOnItemClickListener(onClickListener: OnItemClickListener?) {
+ this.listener = onClickListener
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
new file mode 100644
index 0000000..d185752
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
@@ -0,0 +1,11 @@
+package com.casic.smarttube.extensions
+
+import android.view.animation.LinearInterpolator
+import android.widget.ImageView
+
+fun ImageView.arrowAnimation(angle: Float) {
+ val animation = this.animate()
+ animation.duration = 300
+ animation.interpolator = LinearInterpolator()
+ animation.rotation(angle)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
new file mode 100644
index 0000000..22e56d2
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
@@ -0,0 +1,12 @@
+package com.casic.smarttube.extensions
+
+import android.view.View
+import com.qmuiteam.qmui.widget.QMUIEmptyView
+
+fun QMUIEmptyView.showEmptyPage(onButtonClickListener: View.OnClickListener) {
+ this.show(false, "抱歉,无法查询到相关记录", null, "重试", onButtonClickListener)
+}
+
+fun QMUIEmptyView.showEmptyPage(title: String, onButtonClickListener: View.OnClickListener) {
+ this.show(false, title, null, "刷新", onButtonClickListener)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
index 16d7e5c..1ef9226 100644
--- a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
+++ b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
@@ -1,10 +1,31 @@
package com.casic.smarttube.fragment
+import android.os.Handler
+import androidx.lifecycle.ViewModelProvider
+import androidx.recyclerview.widget.LinearLayoutManager
import com.casic.smarttube.R
+import com.casic.smarttube.adapter.DeviceListAdapter
+import com.casic.smarttube.extensions.showEmptyPage
+import com.casic.smarttube.model.DeviceListModel
+import com.casic.smarttube.view.WellDetailActivity
+import com.casic.smarttube.vm.DeviceViewModel
import com.pengxh.kt.lite.base.KotlinBaseFragment
+import com.pengxh.kt.lite.extensions.navigatePageTo
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.utils.WeakReferenceHandler
+import kotlinx.android.synthetic.main.fragment_overview.*
+import kotlinx.android.synthetic.main.include_empty_view.*
class OverviewFragment : KotlinBaseFragment() {
+ private lateinit var weakReferenceHandler: WeakReferenceHandler
+ private lateinit var deviceViewModel: DeviceViewModel
+ private lateinit var deviceAdapter: DeviceListAdapter
+ private var dataBeans: MutableList = ArrayList()
+ private var pageIndex = 1
+ private var isRefresh = false
+ private var isLoadMore = false
+
override fun initLayoutView(): Int = R.layout.fragment_overview
override fun setupTopBarLayout() {
@@ -12,10 +33,101 @@
}
override fun initData() {
+ weakReferenceHandler = WeakReferenceHandler(callback)
+ deviceViewModel = ViewModelProvider(this).get(DeviceViewModel::class.java)
+ }
+ override fun onResume() {
+ //默认加载第一页
+ obtainDeviceList()
+ super.onResume()
}
override fun initEvent() {
+ overviewLayout.setOnRefreshListener {
+ isRefresh = true
+ //刷新之后页码重置
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ overviewLayout.setOnLoadMoreListener {
+ isLoadMore = true
+ pageIndex++
+ obtainDeviceList()
+ }
+ deviceViewModel.deviceListModel.observe(this, {
+ if (it.code == 200) {
+ val dataRows = it.data?.rows
+ when {
+ isRefresh -> {
+ dataBeans.clear()
+ dataBeans = dataRows!!
+ overviewLayout.finishRefresh()
+ isRefresh = false
+ }
+ isLoadMore -> {
+ if (dataRows?.size == 0) {
+ "到底了,别拉了".show(requireContext())
+ }
+ dataBeans.addAll(dataRows!!)
+ overviewLayout.finishLoadMore()
+ isLoadMore = false
+ }
+ else -> {
+ dataBeans = dataRows!!
+ }
+ }
+ weakReferenceHandler.sendEmptyMessage(2022062401)
+ }
+ })
+ }
+
+ private fun obtainDeviceList() {
+ deviceViewModel.obtainDeviceListByType("", "", "", pageIndex)
+ }
+
+ private val callback = Handler.Callback {
+ if (it.what == 2022062401) {
+ if (isRefresh || isLoadMore) {
+ deviceAdapter.notifyDataSetChanged()
+ } else {
+ if (dataBeans.size == 0) {
+ emptyView!!.showEmptyPage("这里什么都没有") {
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ } else {
+ emptyView!!.hide()
+ deviceAdapter = DeviceListAdapter(requireContext(), dataBeans)
+ recyclerView!!.layoutManager = LinearLayoutManager(requireContext())
+ recyclerView!!.adapter = deviceAdapter
+ deviceAdapter.setOnItemClickListener(object :
+ DeviceListAdapter.OnItemClickListener {
+ override fun onClicked(position: Int) {
+// val jobId = dataBeans[position].jobId.toString()
+// if (jobId.isBlank()) {
+// "设备编号异常,无法查看详情".show(requireContext())
+// return
+// }
+// requireContext().navigatePageTo(jobId)
+ }
+
+ override fun onHistoryClicked(position: Int) {
+
+ }
+
+ override fun onEditClicked(position: Int) {
+
+ }
+
+ override fun onWellDetailClicked(position: Int) {
+ requireContext().navigatePageTo(dataBeans[position].wellId)
+ }
+ })
+ }
+ }
+ }
+ true
}
}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cbc72b6..a9b50c5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,7 +26,7 @@
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
- android:theme="@style/AppTheme"
+ android:theme="@style/QMUI.Compat.NoActionBar"
android:usesCleartextTraffic="true">
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
new file mode 100644
index 0000000..e3c059d
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
@@ -0,0 +1,111 @@
+package com.casic.smarttube.adapter
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+import com.casic.smarttube.R
+import com.casic.smarttube.extensions.arrowAnimation
+import com.casic.smarttube.model.DeviceListModel
+import com.github.mikephil.charting.charts.LineChart
+import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
+
+class DeviceListAdapter(
+ private val context: Context,
+ private val dataRows: MutableList
+) : RecyclerView.Adapter() {
+
+ private var layoutInflater: LayoutInflater = LayoutInflater.from(context)
+ private var isExpand = false
+
+ override fun onCreateViewHolder(
+ parent: ViewGroup, viewType: Int
+ ): DeviceListAdapter.ItemViewHolder {
+ return ItemViewHolder(
+ layoutInflater.inflate(R.layout.item_device_recycleview, parent, false)
+ )
+ }
+
+ override fun getItemCount(): Int = dataRows.size
+
+ override fun onBindViewHolder(holder: DeviceListAdapter.ItemViewHolder, position: Int) {
+ //绑定数据
+ val rowsBean = dataRows[position]
+ holder.deviceStateView.text = rowsBean.onlineStateName
+ if (rowsBean.onlineState == "1") {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_green_radius_5)
+ } else {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_gray_radius_5)
+ }
+ holder.deviceCodeView.text = rowsBean.devcode
+ holder.wellCodeView.text = String.format("井编号:${rowsBean.wellCode}")
+ holder.ownerShipView.text = String.format("权属单位:${rowsBean.deptName}")
+ holder.deviceLocationView.text = String.format("设备位置:${rowsBean.position}")
+ holder.installDateView.text = String.format("安装日期:${rowsBean.installDate}")
+
+
+ if (listener != null) {
+ holder.itemView.setOnClickListener {
+ listener!!.onClicked(position)
+ }
+ holder.dataHistoryButton.setOnClickListener {
+ listener!!.onHistoryClicked(position)
+ }
+ holder.editButton.setOnClickListener {
+ listener!!.onEditClicked(position)
+ }
+ holder.wellDetailButton.setOnClickListener {
+ listener!!.onWellDetailClicked(position)
+ }
+
+ holder.expandableImageView.setOnClickListener {
+ if (!isExpand) {
+ //展开列表动画
+ holder.expandableImageView.arrowAnimation(180f)
+ isExpand = true
+ //子列表绑定数据
+// expandableViewAdapter.setExpandableData(createExpandableList(rowsBean))
+ } else {
+ //关闭列表动画
+ holder.expandableImageView.arrowAnimation(0f)
+ isExpand = false
+ //子列表清空数据
+// expandableViewAdapter.clearAll()
+ }
+ }
+ }
+ }
+
+ inner class ItemViewHolder(view: View) : RecyclerView.ViewHolder(view) {
+ var deviceStateView: TextView = view.findViewById(R.id.deviceStateView)
+ var deviceCodeView: TextView = view.findViewById(R.id.deviceCodeView)
+ var expandableImageView: ImageView = view.findViewById(R.id.expandableImageView)
+ var wellCodeView: TextView = view.findViewById(R.id.wellCodeView)
+ var ownerShipView: TextView = view.findViewById(R.id.ownerShipView)
+ var deviceLocationView: TextView = view.findViewById(R.id.deviceLocationView)
+ var installDateView: TextView = view.findViewById(R.id.installDateView)
+ var dataHistoryButton: QMUIRoundButton = view.findViewById(R.id.dataHistoryButton)
+ var editButton: QMUIRoundButton = view.findViewById(R.id.editButton)
+ var wellDetailButton: QMUIRoundButton = view.findViewById(R.id.wellDetailButton)
+ var expandableChartView: LineChart = view.findViewById(R.id.expandableChartView)
+ }
+
+ private var listener: OnItemClickListener? = null
+
+ interface OnItemClickListener {
+ fun onClicked(position: Int)
+
+ fun onHistoryClicked(position: Int)
+
+ fun onEditClicked(position: Int)
+
+ fun onWellDetailClicked(position: Int)
+ }
+
+ fun setOnItemClickListener(onClickListener: OnItemClickListener?) {
+ this.listener = onClickListener
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
new file mode 100644
index 0000000..d185752
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
@@ -0,0 +1,11 @@
+package com.casic.smarttube.extensions
+
+import android.view.animation.LinearInterpolator
+import android.widget.ImageView
+
+fun ImageView.arrowAnimation(angle: Float) {
+ val animation = this.animate()
+ animation.duration = 300
+ animation.interpolator = LinearInterpolator()
+ animation.rotation(angle)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
new file mode 100644
index 0000000..22e56d2
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
@@ -0,0 +1,12 @@
+package com.casic.smarttube.extensions
+
+import android.view.View
+import com.qmuiteam.qmui.widget.QMUIEmptyView
+
+fun QMUIEmptyView.showEmptyPage(onButtonClickListener: View.OnClickListener) {
+ this.show(false, "抱歉,无法查询到相关记录", null, "重试", onButtonClickListener)
+}
+
+fun QMUIEmptyView.showEmptyPage(title: String, onButtonClickListener: View.OnClickListener) {
+ this.show(false, title, null, "刷新", onButtonClickListener)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
index 16d7e5c..1ef9226 100644
--- a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
+++ b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
@@ -1,10 +1,31 @@
package com.casic.smarttube.fragment
+import android.os.Handler
+import androidx.lifecycle.ViewModelProvider
+import androidx.recyclerview.widget.LinearLayoutManager
import com.casic.smarttube.R
+import com.casic.smarttube.adapter.DeviceListAdapter
+import com.casic.smarttube.extensions.showEmptyPage
+import com.casic.smarttube.model.DeviceListModel
+import com.casic.smarttube.view.WellDetailActivity
+import com.casic.smarttube.vm.DeviceViewModel
import com.pengxh.kt.lite.base.KotlinBaseFragment
+import com.pengxh.kt.lite.extensions.navigatePageTo
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.utils.WeakReferenceHandler
+import kotlinx.android.synthetic.main.fragment_overview.*
+import kotlinx.android.synthetic.main.include_empty_view.*
class OverviewFragment : KotlinBaseFragment() {
+ private lateinit var weakReferenceHandler: WeakReferenceHandler
+ private lateinit var deviceViewModel: DeviceViewModel
+ private lateinit var deviceAdapter: DeviceListAdapter
+ private var dataBeans: MutableList = ArrayList()
+ private var pageIndex = 1
+ private var isRefresh = false
+ private var isLoadMore = false
+
override fun initLayoutView(): Int = R.layout.fragment_overview
override fun setupTopBarLayout() {
@@ -12,10 +33,101 @@
}
override fun initData() {
+ weakReferenceHandler = WeakReferenceHandler(callback)
+ deviceViewModel = ViewModelProvider(this).get(DeviceViewModel::class.java)
+ }
+ override fun onResume() {
+ //默认加载第一页
+ obtainDeviceList()
+ super.onResume()
}
override fun initEvent() {
+ overviewLayout.setOnRefreshListener {
+ isRefresh = true
+ //刷新之后页码重置
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ overviewLayout.setOnLoadMoreListener {
+ isLoadMore = true
+ pageIndex++
+ obtainDeviceList()
+ }
+ deviceViewModel.deviceListModel.observe(this, {
+ if (it.code == 200) {
+ val dataRows = it.data?.rows
+ when {
+ isRefresh -> {
+ dataBeans.clear()
+ dataBeans = dataRows!!
+ overviewLayout.finishRefresh()
+ isRefresh = false
+ }
+ isLoadMore -> {
+ if (dataRows?.size == 0) {
+ "到底了,别拉了".show(requireContext())
+ }
+ dataBeans.addAll(dataRows!!)
+ overviewLayout.finishLoadMore()
+ isLoadMore = false
+ }
+ else -> {
+ dataBeans = dataRows!!
+ }
+ }
+ weakReferenceHandler.sendEmptyMessage(2022062401)
+ }
+ })
+ }
+
+ private fun obtainDeviceList() {
+ deviceViewModel.obtainDeviceListByType("", "", "", pageIndex)
+ }
+
+ private val callback = Handler.Callback {
+ if (it.what == 2022062401) {
+ if (isRefresh || isLoadMore) {
+ deviceAdapter.notifyDataSetChanged()
+ } else {
+ if (dataBeans.size == 0) {
+ emptyView!!.showEmptyPage("这里什么都没有") {
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ } else {
+ emptyView!!.hide()
+ deviceAdapter = DeviceListAdapter(requireContext(), dataBeans)
+ recyclerView!!.layoutManager = LinearLayoutManager(requireContext())
+ recyclerView!!.adapter = deviceAdapter
+ deviceAdapter.setOnItemClickListener(object :
+ DeviceListAdapter.OnItemClickListener {
+ override fun onClicked(position: Int) {
+// val jobId = dataBeans[position].jobId.toString()
+// if (jobId.isBlank()) {
+// "设备编号异常,无法查看详情".show(requireContext())
+// return
+// }
+// requireContext().navigatePageTo(jobId)
+ }
+
+ override fun onHistoryClicked(position: Int) {
+
+ }
+
+ override fun onEditClicked(position: Int) {
+
+ }
+
+ override fun onWellDetailClicked(position: Int) {
+ requireContext().navigatePageTo(dataBeans[position].wellId)
+ }
+ })
+ }
+ }
+ }
+ true
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/model/AreaModel.java b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
new file mode 100644
index 0000000..c6f86ef
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
@@ -0,0 +1,125 @@
+package com.casic.smarttube.model;
+
+public class AreaModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String area;
+ private String communications;
+ private String deptid;
+ private String deviceTypes;
+ private String id;
+ private String lat;
+ private String lng;
+ private String map;
+ private String wellTypes;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getCommunications() {
+ return communications;
+ }
+
+ public void setCommunications(String communications) {
+ this.communications = communications;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDeviceTypes() {
+ return deviceTypes;
+ }
+
+ public void setDeviceTypes(String deviceTypes) {
+ this.deviceTypes = deviceTypes;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getMap() {
+ return map;
+ }
+
+ public void setMap(String map) {
+ this.map = map;
+ }
+
+ public String getWellTypes() {
+ return wellTypes;
+ }
+
+ public void setWellTypes(String wellTypes) {
+ this.wellTypes = wellTypes;
+ }
+ }
+}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cbc72b6..a9b50c5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,7 +26,7 @@
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
- android:theme="@style/AppTheme"
+ android:theme="@style/QMUI.Compat.NoActionBar"
android:usesCleartextTraffic="true">
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
new file mode 100644
index 0000000..e3c059d
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
@@ -0,0 +1,111 @@
+package com.casic.smarttube.adapter
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+import com.casic.smarttube.R
+import com.casic.smarttube.extensions.arrowAnimation
+import com.casic.smarttube.model.DeviceListModel
+import com.github.mikephil.charting.charts.LineChart
+import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
+
+class DeviceListAdapter(
+ private val context: Context,
+ private val dataRows: MutableList
+) : RecyclerView.Adapter() {
+
+ private var layoutInflater: LayoutInflater = LayoutInflater.from(context)
+ private var isExpand = false
+
+ override fun onCreateViewHolder(
+ parent: ViewGroup, viewType: Int
+ ): DeviceListAdapter.ItemViewHolder {
+ return ItemViewHolder(
+ layoutInflater.inflate(R.layout.item_device_recycleview, parent, false)
+ )
+ }
+
+ override fun getItemCount(): Int = dataRows.size
+
+ override fun onBindViewHolder(holder: DeviceListAdapter.ItemViewHolder, position: Int) {
+ //绑定数据
+ val rowsBean = dataRows[position]
+ holder.deviceStateView.text = rowsBean.onlineStateName
+ if (rowsBean.onlineState == "1") {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_green_radius_5)
+ } else {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_gray_radius_5)
+ }
+ holder.deviceCodeView.text = rowsBean.devcode
+ holder.wellCodeView.text = String.format("井编号:${rowsBean.wellCode}")
+ holder.ownerShipView.text = String.format("权属单位:${rowsBean.deptName}")
+ holder.deviceLocationView.text = String.format("设备位置:${rowsBean.position}")
+ holder.installDateView.text = String.format("安装日期:${rowsBean.installDate}")
+
+
+ if (listener != null) {
+ holder.itemView.setOnClickListener {
+ listener!!.onClicked(position)
+ }
+ holder.dataHistoryButton.setOnClickListener {
+ listener!!.onHistoryClicked(position)
+ }
+ holder.editButton.setOnClickListener {
+ listener!!.onEditClicked(position)
+ }
+ holder.wellDetailButton.setOnClickListener {
+ listener!!.onWellDetailClicked(position)
+ }
+
+ holder.expandableImageView.setOnClickListener {
+ if (!isExpand) {
+ //展开列表动画
+ holder.expandableImageView.arrowAnimation(180f)
+ isExpand = true
+ //子列表绑定数据
+// expandableViewAdapter.setExpandableData(createExpandableList(rowsBean))
+ } else {
+ //关闭列表动画
+ holder.expandableImageView.arrowAnimation(0f)
+ isExpand = false
+ //子列表清空数据
+// expandableViewAdapter.clearAll()
+ }
+ }
+ }
+ }
+
+ inner class ItemViewHolder(view: View) : RecyclerView.ViewHolder(view) {
+ var deviceStateView: TextView = view.findViewById(R.id.deviceStateView)
+ var deviceCodeView: TextView = view.findViewById(R.id.deviceCodeView)
+ var expandableImageView: ImageView = view.findViewById(R.id.expandableImageView)
+ var wellCodeView: TextView = view.findViewById(R.id.wellCodeView)
+ var ownerShipView: TextView = view.findViewById(R.id.ownerShipView)
+ var deviceLocationView: TextView = view.findViewById(R.id.deviceLocationView)
+ var installDateView: TextView = view.findViewById(R.id.installDateView)
+ var dataHistoryButton: QMUIRoundButton = view.findViewById(R.id.dataHistoryButton)
+ var editButton: QMUIRoundButton = view.findViewById(R.id.editButton)
+ var wellDetailButton: QMUIRoundButton = view.findViewById(R.id.wellDetailButton)
+ var expandableChartView: LineChart = view.findViewById(R.id.expandableChartView)
+ }
+
+ private var listener: OnItemClickListener? = null
+
+ interface OnItemClickListener {
+ fun onClicked(position: Int)
+
+ fun onHistoryClicked(position: Int)
+
+ fun onEditClicked(position: Int)
+
+ fun onWellDetailClicked(position: Int)
+ }
+
+ fun setOnItemClickListener(onClickListener: OnItemClickListener?) {
+ this.listener = onClickListener
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
new file mode 100644
index 0000000..d185752
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
@@ -0,0 +1,11 @@
+package com.casic.smarttube.extensions
+
+import android.view.animation.LinearInterpolator
+import android.widget.ImageView
+
+fun ImageView.arrowAnimation(angle: Float) {
+ val animation = this.animate()
+ animation.duration = 300
+ animation.interpolator = LinearInterpolator()
+ animation.rotation(angle)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
new file mode 100644
index 0000000..22e56d2
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
@@ -0,0 +1,12 @@
+package com.casic.smarttube.extensions
+
+import android.view.View
+import com.qmuiteam.qmui.widget.QMUIEmptyView
+
+fun QMUIEmptyView.showEmptyPage(onButtonClickListener: View.OnClickListener) {
+ this.show(false, "抱歉,无法查询到相关记录", null, "重试", onButtonClickListener)
+}
+
+fun QMUIEmptyView.showEmptyPage(title: String, onButtonClickListener: View.OnClickListener) {
+ this.show(false, title, null, "刷新", onButtonClickListener)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
index 16d7e5c..1ef9226 100644
--- a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
+++ b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
@@ -1,10 +1,31 @@
package com.casic.smarttube.fragment
+import android.os.Handler
+import androidx.lifecycle.ViewModelProvider
+import androidx.recyclerview.widget.LinearLayoutManager
import com.casic.smarttube.R
+import com.casic.smarttube.adapter.DeviceListAdapter
+import com.casic.smarttube.extensions.showEmptyPage
+import com.casic.smarttube.model.DeviceListModel
+import com.casic.smarttube.view.WellDetailActivity
+import com.casic.smarttube.vm.DeviceViewModel
import com.pengxh.kt.lite.base.KotlinBaseFragment
+import com.pengxh.kt.lite.extensions.navigatePageTo
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.utils.WeakReferenceHandler
+import kotlinx.android.synthetic.main.fragment_overview.*
+import kotlinx.android.synthetic.main.include_empty_view.*
class OverviewFragment : KotlinBaseFragment() {
+ private lateinit var weakReferenceHandler: WeakReferenceHandler
+ private lateinit var deviceViewModel: DeviceViewModel
+ private lateinit var deviceAdapter: DeviceListAdapter
+ private var dataBeans: MutableList = ArrayList()
+ private var pageIndex = 1
+ private var isRefresh = false
+ private var isLoadMore = false
+
override fun initLayoutView(): Int = R.layout.fragment_overview
override fun setupTopBarLayout() {
@@ -12,10 +33,101 @@
}
override fun initData() {
+ weakReferenceHandler = WeakReferenceHandler(callback)
+ deviceViewModel = ViewModelProvider(this).get(DeviceViewModel::class.java)
+ }
+ override fun onResume() {
+ //默认加载第一页
+ obtainDeviceList()
+ super.onResume()
}
override fun initEvent() {
+ overviewLayout.setOnRefreshListener {
+ isRefresh = true
+ //刷新之后页码重置
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ overviewLayout.setOnLoadMoreListener {
+ isLoadMore = true
+ pageIndex++
+ obtainDeviceList()
+ }
+ deviceViewModel.deviceListModel.observe(this, {
+ if (it.code == 200) {
+ val dataRows = it.data?.rows
+ when {
+ isRefresh -> {
+ dataBeans.clear()
+ dataBeans = dataRows!!
+ overviewLayout.finishRefresh()
+ isRefresh = false
+ }
+ isLoadMore -> {
+ if (dataRows?.size == 0) {
+ "到底了,别拉了".show(requireContext())
+ }
+ dataBeans.addAll(dataRows!!)
+ overviewLayout.finishLoadMore()
+ isLoadMore = false
+ }
+ else -> {
+ dataBeans = dataRows!!
+ }
+ }
+ weakReferenceHandler.sendEmptyMessage(2022062401)
+ }
+ })
+ }
+
+ private fun obtainDeviceList() {
+ deviceViewModel.obtainDeviceListByType("", "", "", pageIndex)
+ }
+
+ private val callback = Handler.Callback {
+ if (it.what == 2022062401) {
+ if (isRefresh || isLoadMore) {
+ deviceAdapter.notifyDataSetChanged()
+ } else {
+ if (dataBeans.size == 0) {
+ emptyView!!.showEmptyPage("这里什么都没有") {
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ } else {
+ emptyView!!.hide()
+ deviceAdapter = DeviceListAdapter(requireContext(), dataBeans)
+ recyclerView!!.layoutManager = LinearLayoutManager(requireContext())
+ recyclerView!!.adapter = deviceAdapter
+ deviceAdapter.setOnItemClickListener(object :
+ DeviceListAdapter.OnItemClickListener {
+ override fun onClicked(position: Int) {
+// val jobId = dataBeans[position].jobId.toString()
+// if (jobId.isBlank()) {
+// "设备编号异常,无法查看详情".show(requireContext())
+// return
+// }
+// requireContext().navigatePageTo(jobId)
+ }
+
+ override fun onHistoryClicked(position: Int) {
+
+ }
+
+ override fun onEditClicked(position: Int) {
+
+ }
+
+ override fun onWellDetailClicked(position: Int) {
+ requireContext().navigatePageTo(dataBeans[position].wellId)
+ }
+ })
+ }
+ }
+ }
+ true
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/model/AreaModel.java b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
new file mode 100644
index 0000000..c6f86ef
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
@@ -0,0 +1,125 @@
+package com.casic.smarttube.model;
+
+public class AreaModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String area;
+ private String communications;
+ private String deptid;
+ private String deviceTypes;
+ private String id;
+ private String lat;
+ private String lng;
+ private String map;
+ private String wellTypes;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getCommunications() {
+ return communications;
+ }
+
+ public void setCommunications(String communications) {
+ this.communications = communications;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDeviceTypes() {
+ return deviceTypes;
+ }
+
+ public void setDeviceTypes(String deviceTypes) {
+ this.deviceTypes = deviceTypes;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getMap() {
+ return map;
+ }
+
+ public void setMap(String map) {
+ this.map = map;
+ }
+
+ public String getWellTypes() {
+ return wellTypes;
+ }
+
+ public void setWellTypes(String wellTypes) {
+ this.wellTypes = wellTypes;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
new file mode 100644
index 0000000..b34eb55
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
@@ -0,0 +1,274 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DeviceListModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private List rows;
+ private int total;
+
+ public List getRows() {
+ return rows;
+ }
+
+ public void setRows(List rows) {
+ this.rows = rows;
+ }
+
+ public int getTotal() {
+ return total;
+ }
+
+ public void setTotal(int total) {
+ this.total = total;
+ }
+
+ public static class RowsBean {
+ private String bfzt;
+ private String bfztName;
+ private String communication;
+ private String concenCode;
+ private String concenId;
+ private String deptName;
+ private String deptid;
+ private String devcode;
+ private String deviceName;
+ private String deviceType;
+ private String deviceTypeName;
+ private String id;
+ private String installDate;
+ private String modelId;
+ private String modelName;
+ private String onlineState;
+ private String onlineStateName;
+ private String position;
+ private String ts;
+ private String valid;
+ private String watchType;
+ private String wellCode;
+ private String wellId;
+
+ public String getBfzt() {
+ return bfzt;
+ }
+
+ public void setBfzt(String bfzt) {
+ this.bfzt = bfzt;
+ }
+
+ public String getBfztName() {
+ return bfztName;
+ }
+
+ public void setBfztName(String bfztName) {
+ this.bfztName = bfztName;
+ }
+
+ public String getCommunication() {
+ return communication;
+ }
+
+ public void setCommunication(String communication) {
+ this.communication = communication;
+ }
+
+ public String getConcenCode() {
+ return concenCode;
+ }
+
+ public void setConcenCode(String concenCode) {
+ this.concenCode = concenCode;
+ }
+
+ public String getConcenId() {
+ return concenId;
+ }
+
+ public void setConcenId(String concenId) {
+ this.concenId = concenId;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDevcode() {
+ return devcode;
+ }
+
+ public void setDevcode(String devcode) {
+ this.devcode = devcode;
+ }
+
+ public String getDeviceName() {
+ return deviceName;
+ }
+
+ public void setDeviceName(String deviceName) {
+ this.deviceName = deviceName;
+ }
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getDeviceTypeName() {
+ return deviceTypeName;
+ }
+
+ public void setDeviceTypeName(String deviceTypeName) {
+ this.deviceTypeName = deviceTypeName;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getInstallDate() {
+ return installDate;
+ }
+
+ public void setInstallDate(String installDate) {
+ this.installDate = installDate;
+ }
+
+ public String getModelId() {
+ return modelId;
+ }
+
+ public void setModelId(String modelId) {
+ this.modelId = modelId;
+ }
+
+ public String getModelName() {
+ return modelName;
+ }
+
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getOnlineState() {
+ return onlineState;
+ }
+
+ public void setOnlineState(String onlineState) {
+ this.onlineState = onlineState;
+ }
+
+ public String getOnlineStateName() {
+ return onlineStateName;
+ }
+
+ public void setOnlineStateName(String onlineStateName) {
+ this.onlineStateName = onlineStateName;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public String getTs() {
+ return ts;
+ }
+
+ public void setTs(String ts) {
+ this.ts = ts;
+ }
+
+ public String getValid() {
+ return valid;
+ }
+
+ public void setValid(String valid) {
+ this.valid = valid;
+ }
+
+ public String getWatchType() {
+ return watchType;
+ }
+
+ public void setWatchType(String watchType) {
+ this.watchType = watchType;
+ }
+
+ public String getWellCode() {
+ return wellCode;
+ }
+
+ public void setWellCode(String wellCode) {
+ this.wellCode = wellCode;
+ }
+
+ public String getWellId() {
+ return wellId;
+ }
+
+ public void setWellId(String wellId) {
+ this.wellId = wellId;
+ }
+ }
+ }
+}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cbc72b6..a9b50c5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,7 +26,7 @@
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
- android:theme="@style/AppTheme"
+ android:theme="@style/QMUI.Compat.NoActionBar"
android:usesCleartextTraffic="true">
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
new file mode 100644
index 0000000..e3c059d
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
@@ -0,0 +1,111 @@
+package com.casic.smarttube.adapter
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+import com.casic.smarttube.R
+import com.casic.smarttube.extensions.arrowAnimation
+import com.casic.smarttube.model.DeviceListModel
+import com.github.mikephil.charting.charts.LineChart
+import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
+
+class DeviceListAdapter(
+ private val context: Context,
+ private val dataRows: MutableList
+) : RecyclerView.Adapter() {
+
+ private var layoutInflater: LayoutInflater = LayoutInflater.from(context)
+ private var isExpand = false
+
+ override fun onCreateViewHolder(
+ parent: ViewGroup, viewType: Int
+ ): DeviceListAdapter.ItemViewHolder {
+ return ItemViewHolder(
+ layoutInflater.inflate(R.layout.item_device_recycleview, parent, false)
+ )
+ }
+
+ override fun getItemCount(): Int = dataRows.size
+
+ override fun onBindViewHolder(holder: DeviceListAdapter.ItemViewHolder, position: Int) {
+ //绑定数据
+ val rowsBean = dataRows[position]
+ holder.deviceStateView.text = rowsBean.onlineStateName
+ if (rowsBean.onlineState == "1") {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_green_radius_5)
+ } else {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_gray_radius_5)
+ }
+ holder.deviceCodeView.text = rowsBean.devcode
+ holder.wellCodeView.text = String.format("井编号:${rowsBean.wellCode}")
+ holder.ownerShipView.text = String.format("权属单位:${rowsBean.deptName}")
+ holder.deviceLocationView.text = String.format("设备位置:${rowsBean.position}")
+ holder.installDateView.text = String.format("安装日期:${rowsBean.installDate}")
+
+
+ if (listener != null) {
+ holder.itemView.setOnClickListener {
+ listener!!.onClicked(position)
+ }
+ holder.dataHistoryButton.setOnClickListener {
+ listener!!.onHistoryClicked(position)
+ }
+ holder.editButton.setOnClickListener {
+ listener!!.onEditClicked(position)
+ }
+ holder.wellDetailButton.setOnClickListener {
+ listener!!.onWellDetailClicked(position)
+ }
+
+ holder.expandableImageView.setOnClickListener {
+ if (!isExpand) {
+ //展开列表动画
+ holder.expandableImageView.arrowAnimation(180f)
+ isExpand = true
+ //子列表绑定数据
+// expandableViewAdapter.setExpandableData(createExpandableList(rowsBean))
+ } else {
+ //关闭列表动画
+ holder.expandableImageView.arrowAnimation(0f)
+ isExpand = false
+ //子列表清空数据
+// expandableViewAdapter.clearAll()
+ }
+ }
+ }
+ }
+
+ inner class ItemViewHolder(view: View) : RecyclerView.ViewHolder(view) {
+ var deviceStateView: TextView = view.findViewById(R.id.deviceStateView)
+ var deviceCodeView: TextView = view.findViewById(R.id.deviceCodeView)
+ var expandableImageView: ImageView = view.findViewById(R.id.expandableImageView)
+ var wellCodeView: TextView = view.findViewById(R.id.wellCodeView)
+ var ownerShipView: TextView = view.findViewById(R.id.ownerShipView)
+ var deviceLocationView: TextView = view.findViewById(R.id.deviceLocationView)
+ var installDateView: TextView = view.findViewById(R.id.installDateView)
+ var dataHistoryButton: QMUIRoundButton = view.findViewById(R.id.dataHistoryButton)
+ var editButton: QMUIRoundButton = view.findViewById(R.id.editButton)
+ var wellDetailButton: QMUIRoundButton = view.findViewById(R.id.wellDetailButton)
+ var expandableChartView: LineChart = view.findViewById(R.id.expandableChartView)
+ }
+
+ private var listener: OnItemClickListener? = null
+
+ interface OnItemClickListener {
+ fun onClicked(position: Int)
+
+ fun onHistoryClicked(position: Int)
+
+ fun onEditClicked(position: Int)
+
+ fun onWellDetailClicked(position: Int)
+ }
+
+ fun setOnItemClickListener(onClickListener: OnItemClickListener?) {
+ this.listener = onClickListener
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
new file mode 100644
index 0000000..d185752
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
@@ -0,0 +1,11 @@
+package com.casic.smarttube.extensions
+
+import android.view.animation.LinearInterpolator
+import android.widget.ImageView
+
+fun ImageView.arrowAnimation(angle: Float) {
+ val animation = this.animate()
+ animation.duration = 300
+ animation.interpolator = LinearInterpolator()
+ animation.rotation(angle)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
new file mode 100644
index 0000000..22e56d2
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
@@ -0,0 +1,12 @@
+package com.casic.smarttube.extensions
+
+import android.view.View
+import com.qmuiteam.qmui.widget.QMUIEmptyView
+
+fun QMUIEmptyView.showEmptyPage(onButtonClickListener: View.OnClickListener) {
+ this.show(false, "抱歉,无法查询到相关记录", null, "重试", onButtonClickListener)
+}
+
+fun QMUIEmptyView.showEmptyPage(title: String, onButtonClickListener: View.OnClickListener) {
+ this.show(false, title, null, "刷新", onButtonClickListener)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
index 16d7e5c..1ef9226 100644
--- a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
+++ b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
@@ -1,10 +1,31 @@
package com.casic.smarttube.fragment
+import android.os.Handler
+import androidx.lifecycle.ViewModelProvider
+import androidx.recyclerview.widget.LinearLayoutManager
import com.casic.smarttube.R
+import com.casic.smarttube.adapter.DeviceListAdapter
+import com.casic.smarttube.extensions.showEmptyPage
+import com.casic.smarttube.model.DeviceListModel
+import com.casic.smarttube.view.WellDetailActivity
+import com.casic.smarttube.vm.DeviceViewModel
import com.pengxh.kt.lite.base.KotlinBaseFragment
+import com.pengxh.kt.lite.extensions.navigatePageTo
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.utils.WeakReferenceHandler
+import kotlinx.android.synthetic.main.fragment_overview.*
+import kotlinx.android.synthetic.main.include_empty_view.*
class OverviewFragment : KotlinBaseFragment() {
+ private lateinit var weakReferenceHandler: WeakReferenceHandler
+ private lateinit var deviceViewModel: DeviceViewModel
+ private lateinit var deviceAdapter: DeviceListAdapter
+ private var dataBeans: MutableList = ArrayList()
+ private var pageIndex = 1
+ private var isRefresh = false
+ private var isLoadMore = false
+
override fun initLayoutView(): Int = R.layout.fragment_overview
override fun setupTopBarLayout() {
@@ -12,10 +33,101 @@
}
override fun initData() {
+ weakReferenceHandler = WeakReferenceHandler(callback)
+ deviceViewModel = ViewModelProvider(this).get(DeviceViewModel::class.java)
+ }
+ override fun onResume() {
+ //默认加载第一页
+ obtainDeviceList()
+ super.onResume()
}
override fun initEvent() {
+ overviewLayout.setOnRefreshListener {
+ isRefresh = true
+ //刷新之后页码重置
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ overviewLayout.setOnLoadMoreListener {
+ isLoadMore = true
+ pageIndex++
+ obtainDeviceList()
+ }
+ deviceViewModel.deviceListModel.observe(this, {
+ if (it.code == 200) {
+ val dataRows = it.data?.rows
+ when {
+ isRefresh -> {
+ dataBeans.clear()
+ dataBeans = dataRows!!
+ overviewLayout.finishRefresh()
+ isRefresh = false
+ }
+ isLoadMore -> {
+ if (dataRows?.size == 0) {
+ "到底了,别拉了".show(requireContext())
+ }
+ dataBeans.addAll(dataRows!!)
+ overviewLayout.finishLoadMore()
+ isLoadMore = false
+ }
+ else -> {
+ dataBeans = dataRows!!
+ }
+ }
+ weakReferenceHandler.sendEmptyMessage(2022062401)
+ }
+ })
+ }
+
+ private fun obtainDeviceList() {
+ deviceViewModel.obtainDeviceListByType("", "", "", pageIndex)
+ }
+
+ private val callback = Handler.Callback {
+ if (it.what == 2022062401) {
+ if (isRefresh || isLoadMore) {
+ deviceAdapter.notifyDataSetChanged()
+ } else {
+ if (dataBeans.size == 0) {
+ emptyView!!.showEmptyPage("这里什么都没有") {
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ } else {
+ emptyView!!.hide()
+ deviceAdapter = DeviceListAdapter(requireContext(), dataBeans)
+ recyclerView!!.layoutManager = LinearLayoutManager(requireContext())
+ recyclerView!!.adapter = deviceAdapter
+ deviceAdapter.setOnItemClickListener(object :
+ DeviceListAdapter.OnItemClickListener {
+ override fun onClicked(position: Int) {
+// val jobId = dataBeans[position].jobId.toString()
+// if (jobId.isBlank()) {
+// "设备编号异常,无法查看详情".show(requireContext())
+// return
+// }
+// requireContext().navigatePageTo(jobId)
+ }
+
+ override fun onHistoryClicked(position: Int) {
+
+ }
+
+ override fun onEditClicked(position: Int) {
+
+ }
+
+ override fun onWellDetailClicked(position: Int) {
+ requireContext().navigatePageTo(dataBeans[position].wellId)
+ }
+ })
+ }
+ }
+ }
+ true
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/model/AreaModel.java b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
new file mode 100644
index 0000000..c6f86ef
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
@@ -0,0 +1,125 @@
+package com.casic.smarttube.model;
+
+public class AreaModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String area;
+ private String communications;
+ private String deptid;
+ private String deviceTypes;
+ private String id;
+ private String lat;
+ private String lng;
+ private String map;
+ private String wellTypes;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getCommunications() {
+ return communications;
+ }
+
+ public void setCommunications(String communications) {
+ this.communications = communications;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDeviceTypes() {
+ return deviceTypes;
+ }
+
+ public void setDeviceTypes(String deviceTypes) {
+ this.deviceTypes = deviceTypes;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getMap() {
+ return map;
+ }
+
+ public void setMap(String map) {
+ this.map = map;
+ }
+
+ public String getWellTypes() {
+ return wellTypes;
+ }
+
+ public void setWellTypes(String wellTypes) {
+ this.wellTypes = wellTypes;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
new file mode 100644
index 0000000..b34eb55
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
@@ -0,0 +1,274 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DeviceListModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private List rows;
+ private int total;
+
+ public List getRows() {
+ return rows;
+ }
+
+ public void setRows(List rows) {
+ this.rows = rows;
+ }
+
+ public int getTotal() {
+ return total;
+ }
+
+ public void setTotal(int total) {
+ this.total = total;
+ }
+
+ public static class RowsBean {
+ private String bfzt;
+ private String bfztName;
+ private String communication;
+ private String concenCode;
+ private String concenId;
+ private String deptName;
+ private String deptid;
+ private String devcode;
+ private String deviceName;
+ private String deviceType;
+ private String deviceTypeName;
+ private String id;
+ private String installDate;
+ private String modelId;
+ private String modelName;
+ private String onlineState;
+ private String onlineStateName;
+ private String position;
+ private String ts;
+ private String valid;
+ private String watchType;
+ private String wellCode;
+ private String wellId;
+
+ public String getBfzt() {
+ return bfzt;
+ }
+
+ public void setBfzt(String bfzt) {
+ this.bfzt = bfzt;
+ }
+
+ public String getBfztName() {
+ return bfztName;
+ }
+
+ public void setBfztName(String bfztName) {
+ this.bfztName = bfztName;
+ }
+
+ public String getCommunication() {
+ return communication;
+ }
+
+ public void setCommunication(String communication) {
+ this.communication = communication;
+ }
+
+ public String getConcenCode() {
+ return concenCode;
+ }
+
+ public void setConcenCode(String concenCode) {
+ this.concenCode = concenCode;
+ }
+
+ public String getConcenId() {
+ return concenId;
+ }
+
+ public void setConcenId(String concenId) {
+ this.concenId = concenId;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDevcode() {
+ return devcode;
+ }
+
+ public void setDevcode(String devcode) {
+ this.devcode = devcode;
+ }
+
+ public String getDeviceName() {
+ return deviceName;
+ }
+
+ public void setDeviceName(String deviceName) {
+ this.deviceName = deviceName;
+ }
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getDeviceTypeName() {
+ return deviceTypeName;
+ }
+
+ public void setDeviceTypeName(String deviceTypeName) {
+ this.deviceTypeName = deviceTypeName;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getInstallDate() {
+ return installDate;
+ }
+
+ public void setInstallDate(String installDate) {
+ this.installDate = installDate;
+ }
+
+ public String getModelId() {
+ return modelId;
+ }
+
+ public void setModelId(String modelId) {
+ this.modelId = modelId;
+ }
+
+ public String getModelName() {
+ return modelName;
+ }
+
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getOnlineState() {
+ return onlineState;
+ }
+
+ public void setOnlineState(String onlineState) {
+ this.onlineState = onlineState;
+ }
+
+ public String getOnlineStateName() {
+ return onlineStateName;
+ }
+
+ public void setOnlineStateName(String onlineStateName) {
+ this.onlineStateName = onlineStateName;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public String getTs() {
+ return ts;
+ }
+
+ public void setTs(String ts) {
+ this.ts = ts;
+ }
+
+ public String getValid() {
+ return valid;
+ }
+
+ public void setValid(String valid) {
+ this.valid = valid;
+ }
+
+ public String getWatchType() {
+ return watchType;
+ }
+
+ public void setWatchType(String watchType) {
+ this.watchType = watchType;
+ }
+
+ public String getWellCode() {
+ return wellCode;
+ }
+
+ public void setWellCode(String wellCode) {
+ this.wellCode = wellCode;
+ }
+
+ public String getWellId() {
+ return wellId;
+ }
+
+ public void setWellId(String wellId) {
+ this.wellId = wellId;
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DistrictModel.java b/app/src/main/java/com/casic/smarttube/model/DistrictModel.java
new file mode 100644
index 0000000..437405f
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DistrictModel.java
@@ -0,0 +1,172 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DistrictModel {
+
+ private int code;
+ private List data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String id;
+ private String isSync;
+ private String lat;
+ private int level;
+ private String levelName;
+ private String lng;
+ private String name;
+ private int num;
+ private String pName;
+ private String pid;
+ private String pids;
+ private String simplename;
+ private String targetIdSync;
+ private String targetPidSync;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getIsSync() {
+ return isSync;
+ }
+
+ public void setIsSync(String isSync) {
+ this.isSync = isSync;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+
+ public String getLevelName() {
+ return levelName;
+ }
+
+ public void setLevelName(String levelName) {
+ this.levelName = levelName;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public String getPName() {
+ return pName;
+ }
+
+ public void setPName(String pName) {
+ this.pName = pName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getPids() {
+ return pids;
+ }
+
+ public void setPids(String pids) {
+ this.pids = pids;
+ }
+
+ public String getSimplename() {
+ return simplename;
+ }
+
+ public void setSimplename(String simplename) {
+ this.simplename = simplename;
+ }
+
+ public String getTargetIdSync() {
+ return targetIdSync;
+ }
+
+ public void setTargetIdSync(String targetIdSync) {
+ this.targetIdSync = targetIdSync;
+ }
+
+ public String getTargetPidSync() {
+ return targetPidSync;
+ }
+
+ public void setTargetPidSync(String targetPidSync) {
+ this.targetPidSync = targetPidSync;
+ }
+ }
+}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cbc72b6..a9b50c5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,7 +26,7 @@
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
- android:theme="@style/AppTheme"
+ android:theme="@style/QMUI.Compat.NoActionBar"
android:usesCleartextTraffic="true">
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
new file mode 100644
index 0000000..e3c059d
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
@@ -0,0 +1,111 @@
+package com.casic.smarttube.adapter
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+import com.casic.smarttube.R
+import com.casic.smarttube.extensions.arrowAnimation
+import com.casic.smarttube.model.DeviceListModel
+import com.github.mikephil.charting.charts.LineChart
+import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
+
+class DeviceListAdapter(
+ private val context: Context,
+ private val dataRows: MutableList
+) : RecyclerView.Adapter() {
+
+ private var layoutInflater: LayoutInflater = LayoutInflater.from(context)
+ private var isExpand = false
+
+ override fun onCreateViewHolder(
+ parent: ViewGroup, viewType: Int
+ ): DeviceListAdapter.ItemViewHolder {
+ return ItemViewHolder(
+ layoutInflater.inflate(R.layout.item_device_recycleview, parent, false)
+ )
+ }
+
+ override fun getItemCount(): Int = dataRows.size
+
+ override fun onBindViewHolder(holder: DeviceListAdapter.ItemViewHolder, position: Int) {
+ //绑定数据
+ val rowsBean = dataRows[position]
+ holder.deviceStateView.text = rowsBean.onlineStateName
+ if (rowsBean.onlineState == "1") {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_green_radius_5)
+ } else {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_gray_radius_5)
+ }
+ holder.deviceCodeView.text = rowsBean.devcode
+ holder.wellCodeView.text = String.format("井编号:${rowsBean.wellCode}")
+ holder.ownerShipView.text = String.format("权属单位:${rowsBean.deptName}")
+ holder.deviceLocationView.text = String.format("设备位置:${rowsBean.position}")
+ holder.installDateView.text = String.format("安装日期:${rowsBean.installDate}")
+
+
+ if (listener != null) {
+ holder.itemView.setOnClickListener {
+ listener!!.onClicked(position)
+ }
+ holder.dataHistoryButton.setOnClickListener {
+ listener!!.onHistoryClicked(position)
+ }
+ holder.editButton.setOnClickListener {
+ listener!!.onEditClicked(position)
+ }
+ holder.wellDetailButton.setOnClickListener {
+ listener!!.onWellDetailClicked(position)
+ }
+
+ holder.expandableImageView.setOnClickListener {
+ if (!isExpand) {
+ //展开列表动画
+ holder.expandableImageView.arrowAnimation(180f)
+ isExpand = true
+ //子列表绑定数据
+// expandableViewAdapter.setExpandableData(createExpandableList(rowsBean))
+ } else {
+ //关闭列表动画
+ holder.expandableImageView.arrowAnimation(0f)
+ isExpand = false
+ //子列表清空数据
+// expandableViewAdapter.clearAll()
+ }
+ }
+ }
+ }
+
+ inner class ItemViewHolder(view: View) : RecyclerView.ViewHolder(view) {
+ var deviceStateView: TextView = view.findViewById(R.id.deviceStateView)
+ var deviceCodeView: TextView = view.findViewById(R.id.deviceCodeView)
+ var expandableImageView: ImageView = view.findViewById(R.id.expandableImageView)
+ var wellCodeView: TextView = view.findViewById(R.id.wellCodeView)
+ var ownerShipView: TextView = view.findViewById(R.id.ownerShipView)
+ var deviceLocationView: TextView = view.findViewById(R.id.deviceLocationView)
+ var installDateView: TextView = view.findViewById(R.id.installDateView)
+ var dataHistoryButton: QMUIRoundButton = view.findViewById(R.id.dataHistoryButton)
+ var editButton: QMUIRoundButton = view.findViewById(R.id.editButton)
+ var wellDetailButton: QMUIRoundButton = view.findViewById(R.id.wellDetailButton)
+ var expandableChartView: LineChart = view.findViewById(R.id.expandableChartView)
+ }
+
+ private var listener: OnItemClickListener? = null
+
+ interface OnItemClickListener {
+ fun onClicked(position: Int)
+
+ fun onHistoryClicked(position: Int)
+
+ fun onEditClicked(position: Int)
+
+ fun onWellDetailClicked(position: Int)
+ }
+
+ fun setOnItemClickListener(onClickListener: OnItemClickListener?) {
+ this.listener = onClickListener
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
new file mode 100644
index 0000000..d185752
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
@@ -0,0 +1,11 @@
+package com.casic.smarttube.extensions
+
+import android.view.animation.LinearInterpolator
+import android.widget.ImageView
+
+fun ImageView.arrowAnimation(angle: Float) {
+ val animation = this.animate()
+ animation.duration = 300
+ animation.interpolator = LinearInterpolator()
+ animation.rotation(angle)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
new file mode 100644
index 0000000..22e56d2
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
@@ -0,0 +1,12 @@
+package com.casic.smarttube.extensions
+
+import android.view.View
+import com.qmuiteam.qmui.widget.QMUIEmptyView
+
+fun QMUIEmptyView.showEmptyPage(onButtonClickListener: View.OnClickListener) {
+ this.show(false, "抱歉,无法查询到相关记录", null, "重试", onButtonClickListener)
+}
+
+fun QMUIEmptyView.showEmptyPage(title: String, onButtonClickListener: View.OnClickListener) {
+ this.show(false, title, null, "刷新", onButtonClickListener)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
index 16d7e5c..1ef9226 100644
--- a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
+++ b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
@@ -1,10 +1,31 @@
package com.casic.smarttube.fragment
+import android.os.Handler
+import androidx.lifecycle.ViewModelProvider
+import androidx.recyclerview.widget.LinearLayoutManager
import com.casic.smarttube.R
+import com.casic.smarttube.adapter.DeviceListAdapter
+import com.casic.smarttube.extensions.showEmptyPage
+import com.casic.smarttube.model.DeviceListModel
+import com.casic.smarttube.view.WellDetailActivity
+import com.casic.smarttube.vm.DeviceViewModel
import com.pengxh.kt.lite.base.KotlinBaseFragment
+import com.pengxh.kt.lite.extensions.navigatePageTo
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.utils.WeakReferenceHandler
+import kotlinx.android.synthetic.main.fragment_overview.*
+import kotlinx.android.synthetic.main.include_empty_view.*
class OverviewFragment : KotlinBaseFragment() {
+ private lateinit var weakReferenceHandler: WeakReferenceHandler
+ private lateinit var deviceViewModel: DeviceViewModel
+ private lateinit var deviceAdapter: DeviceListAdapter
+ private var dataBeans: MutableList = ArrayList()
+ private var pageIndex = 1
+ private var isRefresh = false
+ private var isLoadMore = false
+
override fun initLayoutView(): Int = R.layout.fragment_overview
override fun setupTopBarLayout() {
@@ -12,10 +33,101 @@
}
override fun initData() {
+ weakReferenceHandler = WeakReferenceHandler(callback)
+ deviceViewModel = ViewModelProvider(this).get(DeviceViewModel::class.java)
+ }
+ override fun onResume() {
+ //默认加载第一页
+ obtainDeviceList()
+ super.onResume()
}
override fun initEvent() {
+ overviewLayout.setOnRefreshListener {
+ isRefresh = true
+ //刷新之后页码重置
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ overviewLayout.setOnLoadMoreListener {
+ isLoadMore = true
+ pageIndex++
+ obtainDeviceList()
+ }
+ deviceViewModel.deviceListModel.observe(this, {
+ if (it.code == 200) {
+ val dataRows = it.data?.rows
+ when {
+ isRefresh -> {
+ dataBeans.clear()
+ dataBeans = dataRows!!
+ overviewLayout.finishRefresh()
+ isRefresh = false
+ }
+ isLoadMore -> {
+ if (dataRows?.size == 0) {
+ "到底了,别拉了".show(requireContext())
+ }
+ dataBeans.addAll(dataRows!!)
+ overviewLayout.finishLoadMore()
+ isLoadMore = false
+ }
+ else -> {
+ dataBeans = dataRows!!
+ }
+ }
+ weakReferenceHandler.sendEmptyMessage(2022062401)
+ }
+ })
+ }
+
+ private fun obtainDeviceList() {
+ deviceViewModel.obtainDeviceListByType("", "", "", pageIndex)
+ }
+
+ private val callback = Handler.Callback {
+ if (it.what == 2022062401) {
+ if (isRefresh || isLoadMore) {
+ deviceAdapter.notifyDataSetChanged()
+ } else {
+ if (dataBeans.size == 0) {
+ emptyView!!.showEmptyPage("这里什么都没有") {
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ } else {
+ emptyView!!.hide()
+ deviceAdapter = DeviceListAdapter(requireContext(), dataBeans)
+ recyclerView!!.layoutManager = LinearLayoutManager(requireContext())
+ recyclerView!!.adapter = deviceAdapter
+ deviceAdapter.setOnItemClickListener(object :
+ DeviceListAdapter.OnItemClickListener {
+ override fun onClicked(position: Int) {
+// val jobId = dataBeans[position].jobId.toString()
+// if (jobId.isBlank()) {
+// "设备编号异常,无法查看详情".show(requireContext())
+// return
+// }
+// requireContext().navigatePageTo(jobId)
+ }
+
+ override fun onHistoryClicked(position: Int) {
+
+ }
+
+ override fun onEditClicked(position: Int) {
+
+ }
+
+ override fun onWellDetailClicked(position: Int) {
+ requireContext().navigatePageTo(dataBeans[position].wellId)
+ }
+ })
+ }
+ }
+ }
+ true
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/model/AreaModel.java b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
new file mode 100644
index 0000000..c6f86ef
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
@@ -0,0 +1,125 @@
+package com.casic.smarttube.model;
+
+public class AreaModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String area;
+ private String communications;
+ private String deptid;
+ private String deviceTypes;
+ private String id;
+ private String lat;
+ private String lng;
+ private String map;
+ private String wellTypes;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getCommunications() {
+ return communications;
+ }
+
+ public void setCommunications(String communications) {
+ this.communications = communications;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDeviceTypes() {
+ return deviceTypes;
+ }
+
+ public void setDeviceTypes(String deviceTypes) {
+ this.deviceTypes = deviceTypes;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getMap() {
+ return map;
+ }
+
+ public void setMap(String map) {
+ this.map = map;
+ }
+
+ public String getWellTypes() {
+ return wellTypes;
+ }
+
+ public void setWellTypes(String wellTypes) {
+ this.wellTypes = wellTypes;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
new file mode 100644
index 0000000..b34eb55
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
@@ -0,0 +1,274 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DeviceListModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private List rows;
+ private int total;
+
+ public List getRows() {
+ return rows;
+ }
+
+ public void setRows(List rows) {
+ this.rows = rows;
+ }
+
+ public int getTotal() {
+ return total;
+ }
+
+ public void setTotal(int total) {
+ this.total = total;
+ }
+
+ public static class RowsBean {
+ private String bfzt;
+ private String bfztName;
+ private String communication;
+ private String concenCode;
+ private String concenId;
+ private String deptName;
+ private String deptid;
+ private String devcode;
+ private String deviceName;
+ private String deviceType;
+ private String deviceTypeName;
+ private String id;
+ private String installDate;
+ private String modelId;
+ private String modelName;
+ private String onlineState;
+ private String onlineStateName;
+ private String position;
+ private String ts;
+ private String valid;
+ private String watchType;
+ private String wellCode;
+ private String wellId;
+
+ public String getBfzt() {
+ return bfzt;
+ }
+
+ public void setBfzt(String bfzt) {
+ this.bfzt = bfzt;
+ }
+
+ public String getBfztName() {
+ return bfztName;
+ }
+
+ public void setBfztName(String bfztName) {
+ this.bfztName = bfztName;
+ }
+
+ public String getCommunication() {
+ return communication;
+ }
+
+ public void setCommunication(String communication) {
+ this.communication = communication;
+ }
+
+ public String getConcenCode() {
+ return concenCode;
+ }
+
+ public void setConcenCode(String concenCode) {
+ this.concenCode = concenCode;
+ }
+
+ public String getConcenId() {
+ return concenId;
+ }
+
+ public void setConcenId(String concenId) {
+ this.concenId = concenId;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDevcode() {
+ return devcode;
+ }
+
+ public void setDevcode(String devcode) {
+ this.devcode = devcode;
+ }
+
+ public String getDeviceName() {
+ return deviceName;
+ }
+
+ public void setDeviceName(String deviceName) {
+ this.deviceName = deviceName;
+ }
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getDeviceTypeName() {
+ return deviceTypeName;
+ }
+
+ public void setDeviceTypeName(String deviceTypeName) {
+ this.deviceTypeName = deviceTypeName;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getInstallDate() {
+ return installDate;
+ }
+
+ public void setInstallDate(String installDate) {
+ this.installDate = installDate;
+ }
+
+ public String getModelId() {
+ return modelId;
+ }
+
+ public void setModelId(String modelId) {
+ this.modelId = modelId;
+ }
+
+ public String getModelName() {
+ return modelName;
+ }
+
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getOnlineState() {
+ return onlineState;
+ }
+
+ public void setOnlineState(String onlineState) {
+ this.onlineState = onlineState;
+ }
+
+ public String getOnlineStateName() {
+ return onlineStateName;
+ }
+
+ public void setOnlineStateName(String onlineStateName) {
+ this.onlineStateName = onlineStateName;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public String getTs() {
+ return ts;
+ }
+
+ public void setTs(String ts) {
+ this.ts = ts;
+ }
+
+ public String getValid() {
+ return valid;
+ }
+
+ public void setValid(String valid) {
+ this.valid = valid;
+ }
+
+ public String getWatchType() {
+ return watchType;
+ }
+
+ public void setWatchType(String watchType) {
+ this.watchType = watchType;
+ }
+
+ public String getWellCode() {
+ return wellCode;
+ }
+
+ public void setWellCode(String wellCode) {
+ this.wellCode = wellCode;
+ }
+
+ public String getWellId() {
+ return wellId;
+ }
+
+ public void setWellId(String wellId) {
+ this.wellId = wellId;
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DistrictModel.java b/app/src/main/java/com/casic/smarttube/model/DistrictModel.java
new file mode 100644
index 0000000..437405f
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DistrictModel.java
@@ -0,0 +1,172 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DistrictModel {
+
+ private int code;
+ private List data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String id;
+ private String isSync;
+ private String lat;
+ private int level;
+ private String levelName;
+ private String lng;
+ private String name;
+ private int num;
+ private String pName;
+ private String pid;
+ private String pids;
+ private String simplename;
+ private String targetIdSync;
+ private String targetPidSync;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getIsSync() {
+ return isSync;
+ }
+
+ public void setIsSync(String isSync) {
+ this.isSync = isSync;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+
+ public String getLevelName() {
+ return levelName;
+ }
+
+ public void setLevelName(String levelName) {
+ this.levelName = levelName;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public String getPName() {
+ return pName;
+ }
+
+ public void setPName(String pName) {
+ this.pName = pName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getPids() {
+ return pids;
+ }
+
+ public void setPids(String pids) {
+ this.pids = pids;
+ }
+
+ public String getSimplename() {
+ return simplename;
+ }
+
+ public void setSimplename(String simplename) {
+ this.simplename = simplename;
+ }
+
+ public String getTargetIdSync() {
+ return targetIdSync;
+ }
+
+ public void setTargetIdSync(String targetIdSync) {
+ this.targetIdSync = targetIdSync;
+ }
+
+ public String getTargetPidSync() {
+ return targetPidSync;
+ }
+
+ public void setTargetPidSync(String targetPidSync) {
+ this.targetPidSync = targetPidSync;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/StreetModel.java b/app/src/main/java/com/casic/smarttube/model/StreetModel.java
new file mode 100644
index 0000000..57fa295
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/StreetModel.java
@@ -0,0 +1,172 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class StreetModel {
+
+ private int code;
+ private List data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String id;
+ private String isSync;
+ private String lat;
+ private int level;
+ private String levelName;
+ private String lng;
+ private String name;
+ private int num;
+ private String pName;
+ private String pid;
+ private String pids;
+ private String simplename;
+ private String targetIdSync;
+ private String targetPidSync;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getIsSync() {
+ return isSync;
+ }
+
+ public void setIsSync(String isSync) {
+ this.isSync = isSync;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+
+ public String getLevelName() {
+ return levelName;
+ }
+
+ public void setLevelName(String levelName) {
+ this.levelName = levelName;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public String getPName() {
+ return pName;
+ }
+
+ public void setPName(String pName) {
+ this.pName = pName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getPids() {
+ return pids;
+ }
+
+ public void setPids(String pids) {
+ this.pids = pids;
+ }
+
+ public String getSimplename() {
+ return simplename;
+ }
+
+ public void setSimplename(String simplename) {
+ this.simplename = simplename;
+ }
+
+ public String getTargetIdSync() {
+ return targetIdSync;
+ }
+
+ public void setTargetIdSync(String targetIdSync) {
+ this.targetIdSync = targetIdSync;
+ }
+
+ public String getTargetPidSync() {
+ return targetPidSync;
+ }
+
+ public void setTargetPidSync(String targetPidSync) {
+ this.targetPidSync = targetPidSync;
+ }
+ }
+}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cbc72b6..a9b50c5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,7 +26,7 @@
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
- android:theme="@style/AppTheme"
+ android:theme="@style/QMUI.Compat.NoActionBar"
android:usesCleartextTraffic="true">
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
new file mode 100644
index 0000000..e3c059d
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
@@ -0,0 +1,111 @@
+package com.casic.smarttube.adapter
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+import com.casic.smarttube.R
+import com.casic.smarttube.extensions.arrowAnimation
+import com.casic.smarttube.model.DeviceListModel
+import com.github.mikephil.charting.charts.LineChart
+import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
+
+class DeviceListAdapter(
+ private val context: Context,
+ private val dataRows: MutableList
+) : RecyclerView.Adapter() {
+
+ private var layoutInflater: LayoutInflater = LayoutInflater.from(context)
+ private var isExpand = false
+
+ override fun onCreateViewHolder(
+ parent: ViewGroup, viewType: Int
+ ): DeviceListAdapter.ItemViewHolder {
+ return ItemViewHolder(
+ layoutInflater.inflate(R.layout.item_device_recycleview, parent, false)
+ )
+ }
+
+ override fun getItemCount(): Int = dataRows.size
+
+ override fun onBindViewHolder(holder: DeviceListAdapter.ItemViewHolder, position: Int) {
+ //绑定数据
+ val rowsBean = dataRows[position]
+ holder.deviceStateView.text = rowsBean.onlineStateName
+ if (rowsBean.onlineState == "1") {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_green_radius_5)
+ } else {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_gray_radius_5)
+ }
+ holder.deviceCodeView.text = rowsBean.devcode
+ holder.wellCodeView.text = String.format("井编号:${rowsBean.wellCode}")
+ holder.ownerShipView.text = String.format("权属单位:${rowsBean.deptName}")
+ holder.deviceLocationView.text = String.format("设备位置:${rowsBean.position}")
+ holder.installDateView.text = String.format("安装日期:${rowsBean.installDate}")
+
+
+ if (listener != null) {
+ holder.itemView.setOnClickListener {
+ listener!!.onClicked(position)
+ }
+ holder.dataHistoryButton.setOnClickListener {
+ listener!!.onHistoryClicked(position)
+ }
+ holder.editButton.setOnClickListener {
+ listener!!.onEditClicked(position)
+ }
+ holder.wellDetailButton.setOnClickListener {
+ listener!!.onWellDetailClicked(position)
+ }
+
+ holder.expandableImageView.setOnClickListener {
+ if (!isExpand) {
+ //展开列表动画
+ holder.expandableImageView.arrowAnimation(180f)
+ isExpand = true
+ //子列表绑定数据
+// expandableViewAdapter.setExpandableData(createExpandableList(rowsBean))
+ } else {
+ //关闭列表动画
+ holder.expandableImageView.arrowAnimation(0f)
+ isExpand = false
+ //子列表清空数据
+// expandableViewAdapter.clearAll()
+ }
+ }
+ }
+ }
+
+ inner class ItemViewHolder(view: View) : RecyclerView.ViewHolder(view) {
+ var deviceStateView: TextView = view.findViewById(R.id.deviceStateView)
+ var deviceCodeView: TextView = view.findViewById(R.id.deviceCodeView)
+ var expandableImageView: ImageView = view.findViewById(R.id.expandableImageView)
+ var wellCodeView: TextView = view.findViewById(R.id.wellCodeView)
+ var ownerShipView: TextView = view.findViewById(R.id.ownerShipView)
+ var deviceLocationView: TextView = view.findViewById(R.id.deviceLocationView)
+ var installDateView: TextView = view.findViewById(R.id.installDateView)
+ var dataHistoryButton: QMUIRoundButton = view.findViewById(R.id.dataHistoryButton)
+ var editButton: QMUIRoundButton = view.findViewById(R.id.editButton)
+ var wellDetailButton: QMUIRoundButton = view.findViewById(R.id.wellDetailButton)
+ var expandableChartView: LineChart = view.findViewById(R.id.expandableChartView)
+ }
+
+ private var listener: OnItemClickListener? = null
+
+ interface OnItemClickListener {
+ fun onClicked(position: Int)
+
+ fun onHistoryClicked(position: Int)
+
+ fun onEditClicked(position: Int)
+
+ fun onWellDetailClicked(position: Int)
+ }
+
+ fun setOnItemClickListener(onClickListener: OnItemClickListener?) {
+ this.listener = onClickListener
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
new file mode 100644
index 0000000..d185752
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
@@ -0,0 +1,11 @@
+package com.casic.smarttube.extensions
+
+import android.view.animation.LinearInterpolator
+import android.widget.ImageView
+
+fun ImageView.arrowAnimation(angle: Float) {
+ val animation = this.animate()
+ animation.duration = 300
+ animation.interpolator = LinearInterpolator()
+ animation.rotation(angle)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
new file mode 100644
index 0000000..22e56d2
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
@@ -0,0 +1,12 @@
+package com.casic.smarttube.extensions
+
+import android.view.View
+import com.qmuiteam.qmui.widget.QMUIEmptyView
+
+fun QMUIEmptyView.showEmptyPage(onButtonClickListener: View.OnClickListener) {
+ this.show(false, "抱歉,无法查询到相关记录", null, "重试", onButtonClickListener)
+}
+
+fun QMUIEmptyView.showEmptyPage(title: String, onButtonClickListener: View.OnClickListener) {
+ this.show(false, title, null, "刷新", onButtonClickListener)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
index 16d7e5c..1ef9226 100644
--- a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
+++ b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
@@ -1,10 +1,31 @@
package com.casic.smarttube.fragment
+import android.os.Handler
+import androidx.lifecycle.ViewModelProvider
+import androidx.recyclerview.widget.LinearLayoutManager
import com.casic.smarttube.R
+import com.casic.smarttube.adapter.DeviceListAdapter
+import com.casic.smarttube.extensions.showEmptyPage
+import com.casic.smarttube.model.DeviceListModel
+import com.casic.smarttube.view.WellDetailActivity
+import com.casic.smarttube.vm.DeviceViewModel
import com.pengxh.kt.lite.base.KotlinBaseFragment
+import com.pengxh.kt.lite.extensions.navigatePageTo
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.utils.WeakReferenceHandler
+import kotlinx.android.synthetic.main.fragment_overview.*
+import kotlinx.android.synthetic.main.include_empty_view.*
class OverviewFragment : KotlinBaseFragment() {
+ private lateinit var weakReferenceHandler: WeakReferenceHandler
+ private lateinit var deviceViewModel: DeviceViewModel
+ private lateinit var deviceAdapter: DeviceListAdapter
+ private var dataBeans: MutableList = ArrayList()
+ private var pageIndex = 1
+ private var isRefresh = false
+ private var isLoadMore = false
+
override fun initLayoutView(): Int = R.layout.fragment_overview
override fun setupTopBarLayout() {
@@ -12,10 +33,101 @@
}
override fun initData() {
+ weakReferenceHandler = WeakReferenceHandler(callback)
+ deviceViewModel = ViewModelProvider(this).get(DeviceViewModel::class.java)
+ }
+ override fun onResume() {
+ //默认加载第一页
+ obtainDeviceList()
+ super.onResume()
}
override fun initEvent() {
+ overviewLayout.setOnRefreshListener {
+ isRefresh = true
+ //刷新之后页码重置
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ overviewLayout.setOnLoadMoreListener {
+ isLoadMore = true
+ pageIndex++
+ obtainDeviceList()
+ }
+ deviceViewModel.deviceListModel.observe(this, {
+ if (it.code == 200) {
+ val dataRows = it.data?.rows
+ when {
+ isRefresh -> {
+ dataBeans.clear()
+ dataBeans = dataRows!!
+ overviewLayout.finishRefresh()
+ isRefresh = false
+ }
+ isLoadMore -> {
+ if (dataRows?.size == 0) {
+ "到底了,别拉了".show(requireContext())
+ }
+ dataBeans.addAll(dataRows!!)
+ overviewLayout.finishLoadMore()
+ isLoadMore = false
+ }
+ else -> {
+ dataBeans = dataRows!!
+ }
+ }
+ weakReferenceHandler.sendEmptyMessage(2022062401)
+ }
+ })
+ }
+
+ private fun obtainDeviceList() {
+ deviceViewModel.obtainDeviceListByType("", "", "", pageIndex)
+ }
+
+ private val callback = Handler.Callback {
+ if (it.what == 2022062401) {
+ if (isRefresh || isLoadMore) {
+ deviceAdapter.notifyDataSetChanged()
+ } else {
+ if (dataBeans.size == 0) {
+ emptyView!!.showEmptyPage("这里什么都没有") {
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ } else {
+ emptyView!!.hide()
+ deviceAdapter = DeviceListAdapter(requireContext(), dataBeans)
+ recyclerView!!.layoutManager = LinearLayoutManager(requireContext())
+ recyclerView!!.adapter = deviceAdapter
+ deviceAdapter.setOnItemClickListener(object :
+ DeviceListAdapter.OnItemClickListener {
+ override fun onClicked(position: Int) {
+// val jobId = dataBeans[position].jobId.toString()
+// if (jobId.isBlank()) {
+// "设备编号异常,无法查看详情".show(requireContext())
+// return
+// }
+// requireContext().navigatePageTo(jobId)
+ }
+
+ override fun onHistoryClicked(position: Int) {
+
+ }
+
+ override fun onEditClicked(position: Int) {
+
+ }
+
+ override fun onWellDetailClicked(position: Int) {
+ requireContext().navigatePageTo(dataBeans[position].wellId)
+ }
+ })
+ }
+ }
+ }
+ true
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/model/AreaModel.java b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
new file mode 100644
index 0000000..c6f86ef
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
@@ -0,0 +1,125 @@
+package com.casic.smarttube.model;
+
+public class AreaModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String area;
+ private String communications;
+ private String deptid;
+ private String deviceTypes;
+ private String id;
+ private String lat;
+ private String lng;
+ private String map;
+ private String wellTypes;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getCommunications() {
+ return communications;
+ }
+
+ public void setCommunications(String communications) {
+ this.communications = communications;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDeviceTypes() {
+ return deviceTypes;
+ }
+
+ public void setDeviceTypes(String deviceTypes) {
+ this.deviceTypes = deviceTypes;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getMap() {
+ return map;
+ }
+
+ public void setMap(String map) {
+ this.map = map;
+ }
+
+ public String getWellTypes() {
+ return wellTypes;
+ }
+
+ public void setWellTypes(String wellTypes) {
+ this.wellTypes = wellTypes;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
new file mode 100644
index 0000000..b34eb55
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
@@ -0,0 +1,274 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DeviceListModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private List rows;
+ private int total;
+
+ public List getRows() {
+ return rows;
+ }
+
+ public void setRows(List rows) {
+ this.rows = rows;
+ }
+
+ public int getTotal() {
+ return total;
+ }
+
+ public void setTotal(int total) {
+ this.total = total;
+ }
+
+ public static class RowsBean {
+ private String bfzt;
+ private String bfztName;
+ private String communication;
+ private String concenCode;
+ private String concenId;
+ private String deptName;
+ private String deptid;
+ private String devcode;
+ private String deviceName;
+ private String deviceType;
+ private String deviceTypeName;
+ private String id;
+ private String installDate;
+ private String modelId;
+ private String modelName;
+ private String onlineState;
+ private String onlineStateName;
+ private String position;
+ private String ts;
+ private String valid;
+ private String watchType;
+ private String wellCode;
+ private String wellId;
+
+ public String getBfzt() {
+ return bfzt;
+ }
+
+ public void setBfzt(String bfzt) {
+ this.bfzt = bfzt;
+ }
+
+ public String getBfztName() {
+ return bfztName;
+ }
+
+ public void setBfztName(String bfztName) {
+ this.bfztName = bfztName;
+ }
+
+ public String getCommunication() {
+ return communication;
+ }
+
+ public void setCommunication(String communication) {
+ this.communication = communication;
+ }
+
+ public String getConcenCode() {
+ return concenCode;
+ }
+
+ public void setConcenCode(String concenCode) {
+ this.concenCode = concenCode;
+ }
+
+ public String getConcenId() {
+ return concenId;
+ }
+
+ public void setConcenId(String concenId) {
+ this.concenId = concenId;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDevcode() {
+ return devcode;
+ }
+
+ public void setDevcode(String devcode) {
+ this.devcode = devcode;
+ }
+
+ public String getDeviceName() {
+ return deviceName;
+ }
+
+ public void setDeviceName(String deviceName) {
+ this.deviceName = deviceName;
+ }
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getDeviceTypeName() {
+ return deviceTypeName;
+ }
+
+ public void setDeviceTypeName(String deviceTypeName) {
+ this.deviceTypeName = deviceTypeName;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getInstallDate() {
+ return installDate;
+ }
+
+ public void setInstallDate(String installDate) {
+ this.installDate = installDate;
+ }
+
+ public String getModelId() {
+ return modelId;
+ }
+
+ public void setModelId(String modelId) {
+ this.modelId = modelId;
+ }
+
+ public String getModelName() {
+ return modelName;
+ }
+
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getOnlineState() {
+ return onlineState;
+ }
+
+ public void setOnlineState(String onlineState) {
+ this.onlineState = onlineState;
+ }
+
+ public String getOnlineStateName() {
+ return onlineStateName;
+ }
+
+ public void setOnlineStateName(String onlineStateName) {
+ this.onlineStateName = onlineStateName;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public String getTs() {
+ return ts;
+ }
+
+ public void setTs(String ts) {
+ this.ts = ts;
+ }
+
+ public String getValid() {
+ return valid;
+ }
+
+ public void setValid(String valid) {
+ this.valid = valid;
+ }
+
+ public String getWatchType() {
+ return watchType;
+ }
+
+ public void setWatchType(String watchType) {
+ this.watchType = watchType;
+ }
+
+ public String getWellCode() {
+ return wellCode;
+ }
+
+ public void setWellCode(String wellCode) {
+ this.wellCode = wellCode;
+ }
+
+ public String getWellId() {
+ return wellId;
+ }
+
+ public void setWellId(String wellId) {
+ this.wellId = wellId;
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DistrictModel.java b/app/src/main/java/com/casic/smarttube/model/DistrictModel.java
new file mode 100644
index 0000000..437405f
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DistrictModel.java
@@ -0,0 +1,172 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DistrictModel {
+
+ private int code;
+ private List data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String id;
+ private String isSync;
+ private String lat;
+ private int level;
+ private String levelName;
+ private String lng;
+ private String name;
+ private int num;
+ private String pName;
+ private String pid;
+ private String pids;
+ private String simplename;
+ private String targetIdSync;
+ private String targetPidSync;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getIsSync() {
+ return isSync;
+ }
+
+ public void setIsSync(String isSync) {
+ this.isSync = isSync;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+
+ public String getLevelName() {
+ return levelName;
+ }
+
+ public void setLevelName(String levelName) {
+ this.levelName = levelName;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public String getPName() {
+ return pName;
+ }
+
+ public void setPName(String pName) {
+ this.pName = pName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getPids() {
+ return pids;
+ }
+
+ public void setPids(String pids) {
+ this.pids = pids;
+ }
+
+ public String getSimplename() {
+ return simplename;
+ }
+
+ public void setSimplename(String simplename) {
+ this.simplename = simplename;
+ }
+
+ public String getTargetIdSync() {
+ return targetIdSync;
+ }
+
+ public void setTargetIdSync(String targetIdSync) {
+ this.targetIdSync = targetIdSync;
+ }
+
+ public String getTargetPidSync() {
+ return targetPidSync;
+ }
+
+ public void setTargetPidSync(String targetPidSync) {
+ this.targetPidSync = targetPidSync;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/StreetModel.java b/app/src/main/java/com/casic/smarttube/model/StreetModel.java
new file mode 100644
index 0000000..57fa295
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/StreetModel.java
@@ -0,0 +1,172 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class StreetModel {
+
+ private int code;
+ private List data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String id;
+ private String isSync;
+ private String lat;
+ private int level;
+ private String levelName;
+ private String lng;
+ private String name;
+ private int num;
+ private String pName;
+ private String pid;
+ private String pids;
+ private String simplename;
+ private String targetIdSync;
+ private String targetPidSync;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getIsSync() {
+ return isSync;
+ }
+
+ public void setIsSync(String isSync) {
+ this.isSync = isSync;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+
+ public String getLevelName() {
+ return levelName;
+ }
+
+ public void setLevelName(String levelName) {
+ this.levelName = levelName;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public String getPName() {
+ return pName;
+ }
+
+ public void setPName(String pName) {
+ this.pName = pName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getPids() {
+ return pids;
+ }
+
+ public void setPids(String pids) {
+ this.pids = pids;
+ }
+
+ public String getSimplename() {
+ return simplename;
+ }
+
+ public void setSimplename(String simplename) {
+ this.simplename = simplename;
+ }
+
+ public String getTargetIdSync() {
+ return targetIdSync;
+ }
+
+ public void setTargetIdSync(String targetIdSync) {
+ this.targetIdSync = targetIdSync;
+ }
+
+ public String getTargetPidSync() {
+ return targetPidSync;
+ }
+
+ public void setTargetPidSync(String targetPidSync) {
+ this.targetPidSync = targetPidSync;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java b/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java
new file mode 100644
index 0000000..c19899a
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java
@@ -0,0 +1,305 @@
+package com.casic.smarttube.model;
+
+public class WellDetailModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String area;
+ private String bfzt;
+ private String bfztName;
+ private String coordinateX;
+ private String coordinateY;
+ private int deep;
+ private String deptName;
+ private String deptid;
+ private String deviceCount;
+ private String id;
+ private String latBaidu;
+ private String latGaode;
+ private String lngBaidu;
+ private String lngGaode;
+ private String notes;
+ private String photos;
+ private String position;
+ private String qu;
+ private String responsibleDept;
+ private String responsibleDeptName;
+ private String ts;
+ private String valid;
+ private String wellCode;
+ private String wellFlag1;
+ private String wellFlag2;
+ private String wellFlag3;
+ private String wellName;
+ private String wellType;
+ private String wellTypeName;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getBfzt() {
+ return bfzt;
+ }
+
+ public void setBfzt(String bfzt) {
+ this.bfzt = bfzt;
+ }
+
+ public String getBfztName() {
+ return bfztName;
+ }
+
+ public void setBfztName(String bfztName) {
+ this.bfztName = bfztName;
+ }
+
+ public String getCoordinateX() {
+ return coordinateX;
+ }
+
+ public void setCoordinateX(String coordinateX) {
+ this.coordinateX = coordinateX;
+ }
+
+ public String getCoordinateY() {
+ return coordinateY;
+ }
+
+ public void setCoordinateY(String coordinateY) {
+ this.coordinateY = coordinateY;
+ }
+
+ public int getDeep() {
+ return deep;
+ }
+
+ public void setDeep(int deep) {
+ this.deep = deep;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDeviceCount() {
+ return deviceCount;
+ }
+
+ public void setDeviceCount(String deviceCount) {
+ this.deviceCount = deviceCount;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLatBaidu() {
+ return latBaidu;
+ }
+
+ public void setLatBaidu(String latBaidu) {
+ this.latBaidu = latBaidu;
+ }
+
+ public String getLatGaode() {
+ return latGaode;
+ }
+
+ public void setLatGaode(String latGaode) {
+ this.latGaode = latGaode;
+ }
+
+ public String getLngBaidu() {
+ return lngBaidu;
+ }
+
+ public void setLngBaidu(String lngBaidu) {
+ this.lngBaidu = lngBaidu;
+ }
+
+ public String getLngGaode() {
+ return lngGaode;
+ }
+
+ public void setLngGaode(String lngGaode) {
+ this.lngGaode = lngGaode;
+ }
+
+ public String getNotes() {
+ return notes;
+ }
+
+ public void setNotes(String notes) {
+ this.notes = notes;
+ }
+
+ public String getPhotos() {
+ return photos;
+ }
+
+ public void setPhotos(String photos) {
+ this.photos = photos;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public String getQu() {
+ return qu;
+ }
+
+ public void setQu(String qu) {
+ this.qu = qu;
+ }
+
+ public String getResponsibleDept() {
+ return responsibleDept;
+ }
+
+ public void setResponsibleDept(String responsibleDept) {
+ this.responsibleDept = responsibleDept;
+ }
+
+ public String getResponsibleDeptName() {
+ return responsibleDeptName;
+ }
+
+ public void setResponsibleDeptName(String responsibleDeptName) {
+ this.responsibleDeptName = responsibleDeptName;
+ }
+
+ public String getTs() {
+ return ts;
+ }
+
+ public void setTs(String ts) {
+ this.ts = ts;
+ }
+
+ public String getValid() {
+ return valid;
+ }
+
+ public void setValid(String valid) {
+ this.valid = valid;
+ }
+
+ public String getWellCode() {
+ return wellCode;
+ }
+
+ public void setWellCode(String wellCode) {
+ this.wellCode = wellCode;
+ }
+
+ public String getWellFlag1() {
+ return wellFlag1;
+ }
+
+ public void setWellFlag1(String wellFlag1) {
+ this.wellFlag1 = wellFlag1;
+ }
+
+ public String getWellFlag2() {
+ return wellFlag2;
+ }
+
+ public void setWellFlag2(String wellFlag2) {
+ this.wellFlag2 = wellFlag2;
+ }
+
+ public String getWellFlag3() {
+ return wellFlag3;
+ }
+
+ public void setWellFlag3(String wellFlag3) {
+ this.wellFlag3 = wellFlag3;
+ }
+
+ public String getWellName() {
+ return wellName;
+ }
+
+ public void setWellName(String wellName) {
+ this.wellName = wellName;
+ }
+
+ public String getWellType() {
+ return wellType;
+ }
+
+ public void setWellType(String wellType) {
+ this.wellType = wellType;
+ }
+
+ public String getWellTypeName() {
+ return wellTypeName;
+ }
+
+ public void setWellTypeName(String wellTypeName) {
+ this.wellTypeName = wellTypeName;
+ }
+ }
+}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cbc72b6..a9b50c5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,7 +26,7 @@
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
- android:theme="@style/AppTheme"
+ android:theme="@style/QMUI.Compat.NoActionBar"
android:usesCleartextTraffic="true">
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
new file mode 100644
index 0000000..e3c059d
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
@@ -0,0 +1,111 @@
+package com.casic.smarttube.adapter
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+import com.casic.smarttube.R
+import com.casic.smarttube.extensions.arrowAnimation
+import com.casic.smarttube.model.DeviceListModel
+import com.github.mikephil.charting.charts.LineChart
+import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
+
+class DeviceListAdapter(
+ private val context: Context,
+ private val dataRows: MutableList
+) : RecyclerView.Adapter() {
+
+ private var layoutInflater: LayoutInflater = LayoutInflater.from(context)
+ private var isExpand = false
+
+ override fun onCreateViewHolder(
+ parent: ViewGroup, viewType: Int
+ ): DeviceListAdapter.ItemViewHolder {
+ return ItemViewHolder(
+ layoutInflater.inflate(R.layout.item_device_recycleview, parent, false)
+ )
+ }
+
+ override fun getItemCount(): Int = dataRows.size
+
+ override fun onBindViewHolder(holder: DeviceListAdapter.ItemViewHolder, position: Int) {
+ //绑定数据
+ val rowsBean = dataRows[position]
+ holder.deviceStateView.text = rowsBean.onlineStateName
+ if (rowsBean.onlineState == "1") {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_green_radius_5)
+ } else {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_gray_radius_5)
+ }
+ holder.deviceCodeView.text = rowsBean.devcode
+ holder.wellCodeView.text = String.format("井编号:${rowsBean.wellCode}")
+ holder.ownerShipView.text = String.format("权属单位:${rowsBean.deptName}")
+ holder.deviceLocationView.text = String.format("设备位置:${rowsBean.position}")
+ holder.installDateView.text = String.format("安装日期:${rowsBean.installDate}")
+
+
+ if (listener != null) {
+ holder.itemView.setOnClickListener {
+ listener!!.onClicked(position)
+ }
+ holder.dataHistoryButton.setOnClickListener {
+ listener!!.onHistoryClicked(position)
+ }
+ holder.editButton.setOnClickListener {
+ listener!!.onEditClicked(position)
+ }
+ holder.wellDetailButton.setOnClickListener {
+ listener!!.onWellDetailClicked(position)
+ }
+
+ holder.expandableImageView.setOnClickListener {
+ if (!isExpand) {
+ //展开列表动画
+ holder.expandableImageView.arrowAnimation(180f)
+ isExpand = true
+ //子列表绑定数据
+// expandableViewAdapter.setExpandableData(createExpandableList(rowsBean))
+ } else {
+ //关闭列表动画
+ holder.expandableImageView.arrowAnimation(0f)
+ isExpand = false
+ //子列表清空数据
+// expandableViewAdapter.clearAll()
+ }
+ }
+ }
+ }
+
+ inner class ItemViewHolder(view: View) : RecyclerView.ViewHolder(view) {
+ var deviceStateView: TextView = view.findViewById(R.id.deviceStateView)
+ var deviceCodeView: TextView = view.findViewById(R.id.deviceCodeView)
+ var expandableImageView: ImageView = view.findViewById(R.id.expandableImageView)
+ var wellCodeView: TextView = view.findViewById(R.id.wellCodeView)
+ var ownerShipView: TextView = view.findViewById(R.id.ownerShipView)
+ var deviceLocationView: TextView = view.findViewById(R.id.deviceLocationView)
+ var installDateView: TextView = view.findViewById(R.id.installDateView)
+ var dataHistoryButton: QMUIRoundButton = view.findViewById(R.id.dataHistoryButton)
+ var editButton: QMUIRoundButton = view.findViewById(R.id.editButton)
+ var wellDetailButton: QMUIRoundButton = view.findViewById(R.id.wellDetailButton)
+ var expandableChartView: LineChart = view.findViewById(R.id.expandableChartView)
+ }
+
+ private var listener: OnItemClickListener? = null
+
+ interface OnItemClickListener {
+ fun onClicked(position: Int)
+
+ fun onHistoryClicked(position: Int)
+
+ fun onEditClicked(position: Int)
+
+ fun onWellDetailClicked(position: Int)
+ }
+
+ fun setOnItemClickListener(onClickListener: OnItemClickListener?) {
+ this.listener = onClickListener
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
new file mode 100644
index 0000000..d185752
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
@@ -0,0 +1,11 @@
+package com.casic.smarttube.extensions
+
+import android.view.animation.LinearInterpolator
+import android.widget.ImageView
+
+fun ImageView.arrowAnimation(angle: Float) {
+ val animation = this.animate()
+ animation.duration = 300
+ animation.interpolator = LinearInterpolator()
+ animation.rotation(angle)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
new file mode 100644
index 0000000..22e56d2
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
@@ -0,0 +1,12 @@
+package com.casic.smarttube.extensions
+
+import android.view.View
+import com.qmuiteam.qmui.widget.QMUIEmptyView
+
+fun QMUIEmptyView.showEmptyPage(onButtonClickListener: View.OnClickListener) {
+ this.show(false, "抱歉,无法查询到相关记录", null, "重试", onButtonClickListener)
+}
+
+fun QMUIEmptyView.showEmptyPage(title: String, onButtonClickListener: View.OnClickListener) {
+ this.show(false, title, null, "刷新", onButtonClickListener)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
index 16d7e5c..1ef9226 100644
--- a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
+++ b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
@@ -1,10 +1,31 @@
package com.casic.smarttube.fragment
+import android.os.Handler
+import androidx.lifecycle.ViewModelProvider
+import androidx.recyclerview.widget.LinearLayoutManager
import com.casic.smarttube.R
+import com.casic.smarttube.adapter.DeviceListAdapter
+import com.casic.smarttube.extensions.showEmptyPage
+import com.casic.smarttube.model.DeviceListModel
+import com.casic.smarttube.view.WellDetailActivity
+import com.casic.smarttube.vm.DeviceViewModel
import com.pengxh.kt.lite.base.KotlinBaseFragment
+import com.pengxh.kt.lite.extensions.navigatePageTo
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.utils.WeakReferenceHandler
+import kotlinx.android.synthetic.main.fragment_overview.*
+import kotlinx.android.synthetic.main.include_empty_view.*
class OverviewFragment : KotlinBaseFragment() {
+ private lateinit var weakReferenceHandler: WeakReferenceHandler
+ private lateinit var deviceViewModel: DeviceViewModel
+ private lateinit var deviceAdapter: DeviceListAdapter
+ private var dataBeans: MutableList = ArrayList()
+ private var pageIndex = 1
+ private var isRefresh = false
+ private var isLoadMore = false
+
override fun initLayoutView(): Int = R.layout.fragment_overview
override fun setupTopBarLayout() {
@@ -12,10 +33,101 @@
}
override fun initData() {
+ weakReferenceHandler = WeakReferenceHandler(callback)
+ deviceViewModel = ViewModelProvider(this).get(DeviceViewModel::class.java)
+ }
+ override fun onResume() {
+ //默认加载第一页
+ obtainDeviceList()
+ super.onResume()
}
override fun initEvent() {
+ overviewLayout.setOnRefreshListener {
+ isRefresh = true
+ //刷新之后页码重置
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ overviewLayout.setOnLoadMoreListener {
+ isLoadMore = true
+ pageIndex++
+ obtainDeviceList()
+ }
+ deviceViewModel.deviceListModel.observe(this, {
+ if (it.code == 200) {
+ val dataRows = it.data?.rows
+ when {
+ isRefresh -> {
+ dataBeans.clear()
+ dataBeans = dataRows!!
+ overviewLayout.finishRefresh()
+ isRefresh = false
+ }
+ isLoadMore -> {
+ if (dataRows?.size == 0) {
+ "到底了,别拉了".show(requireContext())
+ }
+ dataBeans.addAll(dataRows!!)
+ overviewLayout.finishLoadMore()
+ isLoadMore = false
+ }
+ else -> {
+ dataBeans = dataRows!!
+ }
+ }
+ weakReferenceHandler.sendEmptyMessage(2022062401)
+ }
+ })
+ }
+
+ private fun obtainDeviceList() {
+ deviceViewModel.obtainDeviceListByType("", "", "", pageIndex)
+ }
+
+ private val callback = Handler.Callback {
+ if (it.what == 2022062401) {
+ if (isRefresh || isLoadMore) {
+ deviceAdapter.notifyDataSetChanged()
+ } else {
+ if (dataBeans.size == 0) {
+ emptyView!!.showEmptyPage("这里什么都没有") {
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ } else {
+ emptyView!!.hide()
+ deviceAdapter = DeviceListAdapter(requireContext(), dataBeans)
+ recyclerView!!.layoutManager = LinearLayoutManager(requireContext())
+ recyclerView!!.adapter = deviceAdapter
+ deviceAdapter.setOnItemClickListener(object :
+ DeviceListAdapter.OnItemClickListener {
+ override fun onClicked(position: Int) {
+// val jobId = dataBeans[position].jobId.toString()
+// if (jobId.isBlank()) {
+// "设备编号异常,无法查看详情".show(requireContext())
+// return
+// }
+// requireContext().navigatePageTo(jobId)
+ }
+
+ override fun onHistoryClicked(position: Int) {
+
+ }
+
+ override fun onEditClicked(position: Int) {
+
+ }
+
+ override fun onWellDetailClicked(position: Int) {
+ requireContext().navigatePageTo(dataBeans[position].wellId)
+ }
+ })
+ }
+ }
+ }
+ true
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/model/AreaModel.java b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
new file mode 100644
index 0000000..c6f86ef
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
@@ -0,0 +1,125 @@
+package com.casic.smarttube.model;
+
+public class AreaModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String area;
+ private String communications;
+ private String deptid;
+ private String deviceTypes;
+ private String id;
+ private String lat;
+ private String lng;
+ private String map;
+ private String wellTypes;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getCommunications() {
+ return communications;
+ }
+
+ public void setCommunications(String communications) {
+ this.communications = communications;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDeviceTypes() {
+ return deviceTypes;
+ }
+
+ public void setDeviceTypes(String deviceTypes) {
+ this.deviceTypes = deviceTypes;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getMap() {
+ return map;
+ }
+
+ public void setMap(String map) {
+ this.map = map;
+ }
+
+ public String getWellTypes() {
+ return wellTypes;
+ }
+
+ public void setWellTypes(String wellTypes) {
+ this.wellTypes = wellTypes;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
new file mode 100644
index 0000000..b34eb55
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
@@ -0,0 +1,274 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DeviceListModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private List rows;
+ private int total;
+
+ public List getRows() {
+ return rows;
+ }
+
+ public void setRows(List rows) {
+ this.rows = rows;
+ }
+
+ public int getTotal() {
+ return total;
+ }
+
+ public void setTotal(int total) {
+ this.total = total;
+ }
+
+ public static class RowsBean {
+ private String bfzt;
+ private String bfztName;
+ private String communication;
+ private String concenCode;
+ private String concenId;
+ private String deptName;
+ private String deptid;
+ private String devcode;
+ private String deviceName;
+ private String deviceType;
+ private String deviceTypeName;
+ private String id;
+ private String installDate;
+ private String modelId;
+ private String modelName;
+ private String onlineState;
+ private String onlineStateName;
+ private String position;
+ private String ts;
+ private String valid;
+ private String watchType;
+ private String wellCode;
+ private String wellId;
+
+ public String getBfzt() {
+ return bfzt;
+ }
+
+ public void setBfzt(String bfzt) {
+ this.bfzt = bfzt;
+ }
+
+ public String getBfztName() {
+ return bfztName;
+ }
+
+ public void setBfztName(String bfztName) {
+ this.bfztName = bfztName;
+ }
+
+ public String getCommunication() {
+ return communication;
+ }
+
+ public void setCommunication(String communication) {
+ this.communication = communication;
+ }
+
+ public String getConcenCode() {
+ return concenCode;
+ }
+
+ public void setConcenCode(String concenCode) {
+ this.concenCode = concenCode;
+ }
+
+ public String getConcenId() {
+ return concenId;
+ }
+
+ public void setConcenId(String concenId) {
+ this.concenId = concenId;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDevcode() {
+ return devcode;
+ }
+
+ public void setDevcode(String devcode) {
+ this.devcode = devcode;
+ }
+
+ public String getDeviceName() {
+ return deviceName;
+ }
+
+ public void setDeviceName(String deviceName) {
+ this.deviceName = deviceName;
+ }
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getDeviceTypeName() {
+ return deviceTypeName;
+ }
+
+ public void setDeviceTypeName(String deviceTypeName) {
+ this.deviceTypeName = deviceTypeName;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getInstallDate() {
+ return installDate;
+ }
+
+ public void setInstallDate(String installDate) {
+ this.installDate = installDate;
+ }
+
+ public String getModelId() {
+ return modelId;
+ }
+
+ public void setModelId(String modelId) {
+ this.modelId = modelId;
+ }
+
+ public String getModelName() {
+ return modelName;
+ }
+
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getOnlineState() {
+ return onlineState;
+ }
+
+ public void setOnlineState(String onlineState) {
+ this.onlineState = onlineState;
+ }
+
+ public String getOnlineStateName() {
+ return onlineStateName;
+ }
+
+ public void setOnlineStateName(String onlineStateName) {
+ this.onlineStateName = onlineStateName;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public String getTs() {
+ return ts;
+ }
+
+ public void setTs(String ts) {
+ this.ts = ts;
+ }
+
+ public String getValid() {
+ return valid;
+ }
+
+ public void setValid(String valid) {
+ this.valid = valid;
+ }
+
+ public String getWatchType() {
+ return watchType;
+ }
+
+ public void setWatchType(String watchType) {
+ this.watchType = watchType;
+ }
+
+ public String getWellCode() {
+ return wellCode;
+ }
+
+ public void setWellCode(String wellCode) {
+ this.wellCode = wellCode;
+ }
+
+ public String getWellId() {
+ return wellId;
+ }
+
+ public void setWellId(String wellId) {
+ this.wellId = wellId;
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DistrictModel.java b/app/src/main/java/com/casic/smarttube/model/DistrictModel.java
new file mode 100644
index 0000000..437405f
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DistrictModel.java
@@ -0,0 +1,172 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DistrictModel {
+
+ private int code;
+ private List data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String id;
+ private String isSync;
+ private String lat;
+ private int level;
+ private String levelName;
+ private String lng;
+ private String name;
+ private int num;
+ private String pName;
+ private String pid;
+ private String pids;
+ private String simplename;
+ private String targetIdSync;
+ private String targetPidSync;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getIsSync() {
+ return isSync;
+ }
+
+ public void setIsSync(String isSync) {
+ this.isSync = isSync;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+
+ public String getLevelName() {
+ return levelName;
+ }
+
+ public void setLevelName(String levelName) {
+ this.levelName = levelName;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public String getPName() {
+ return pName;
+ }
+
+ public void setPName(String pName) {
+ this.pName = pName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getPids() {
+ return pids;
+ }
+
+ public void setPids(String pids) {
+ this.pids = pids;
+ }
+
+ public String getSimplename() {
+ return simplename;
+ }
+
+ public void setSimplename(String simplename) {
+ this.simplename = simplename;
+ }
+
+ public String getTargetIdSync() {
+ return targetIdSync;
+ }
+
+ public void setTargetIdSync(String targetIdSync) {
+ this.targetIdSync = targetIdSync;
+ }
+
+ public String getTargetPidSync() {
+ return targetPidSync;
+ }
+
+ public void setTargetPidSync(String targetPidSync) {
+ this.targetPidSync = targetPidSync;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/StreetModel.java b/app/src/main/java/com/casic/smarttube/model/StreetModel.java
new file mode 100644
index 0000000..57fa295
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/StreetModel.java
@@ -0,0 +1,172 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class StreetModel {
+
+ private int code;
+ private List data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String id;
+ private String isSync;
+ private String lat;
+ private int level;
+ private String levelName;
+ private String lng;
+ private String name;
+ private int num;
+ private String pName;
+ private String pid;
+ private String pids;
+ private String simplename;
+ private String targetIdSync;
+ private String targetPidSync;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getIsSync() {
+ return isSync;
+ }
+
+ public void setIsSync(String isSync) {
+ this.isSync = isSync;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+
+ public String getLevelName() {
+ return levelName;
+ }
+
+ public void setLevelName(String levelName) {
+ this.levelName = levelName;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public String getPName() {
+ return pName;
+ }
+
+ public void setPName(String pName) {
+ this.pName = pName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getPids() {
+ return pids;
+ }
+
+ public void setPids(String pids) {
+ this.pids = pids;
+ }
+
+ public String getSimplename() {
+ return simplename;
+ }
+
+ public void setSimplename(String simplename) {
+ this.simplename = simplename;
+ }
+
+ public String getTargetIdSync() {
+ return targetIdSync;
+ }
+
+ public void setTargetIdSync(String targetIdSync) {
+ this.targetIdSync = targetIdSync;
+ }
+
+ public String getTargetPidSync() {
+ return targetPidSync;
+ }
+
+ public void setTargetPidSync(String targetPidSync) {
+ this.targetPidSync = targetPidSync;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java b/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java
new file mode 100644
index 0000000..c19899a
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java
@@ -0,0 +1,305 @@
+package com.casic.smarttube.model;
+
+public class WellDetailModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String area;
+ private String bfzt;
+ private String bfztName;
+ private String coordinateX;
+ private String coordinateY;
+ private int deep;
+ private String deptName;
+ private String deptid;
+ private String deviceCount;
+ private String id;
+ private String latBaidu;
+ private String latGaode;
+ private String lngBaidu;
+ private String lngGaode;
+ private String notes;
+ private String photos;
+ private String position;
+ private String qu;
+ private String responsibleDept;
+ private String responsibleDeptName;
+ private String ts;
+ private String valid;
+ private String wellCode;
+ private String wellFlag1;
+ private String wellFlag2;
+ private String wellFlag3;
+ private String wellName;
+ private String wellType;
+ private String wellTypeName;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getBfzt() {
+ return bfzt;
+ }
+
+ public void setBfzt(String bfzt) {
+ this.bfzt = bfzt;
+ }
+
+ public String getBfztName() {
+ return bfztName;
+ }
+
+ public void setBfztName(String bfztName) {
+ this.bfztName = bfztName;
+ }
+
+ public String getCoordinateX() {
+ return coordinateX;
+ }
+
+ public void setCoordinateX(String coordinateX) {
+ this.coordinateX = coordinateX;
+ }
+
+ public String getCoordinateY() {
+ return coordinateY;
+ }
+
+ public void setCoordinateY(String coordinateY) {
+ this.coordinateY = coordinateY;
+ }
+
+ public int getDeep() {
+ return deep;
+ }
+
+ public void setDeep(int deep) {
+ this.deep = deep;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDeviceCount() {
+ return deviceCount;
+ }
+
+ public void setDeviceCount(String deviceCount) {
+ this.deviceCount = deviceCount;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLatBaidu() {
+ return latBaidu;
+ }
+
+ public void setLatBaidu(String latBaidu) {
+ this.latBaidu = latBaidu;
+ }
+
+ public String getLatGaode() {
+ return latGaode;
+ }
+
+ public void setLatGaode(String latGaode) {
+ this.latGaode = latGaode;
+ }
+
+ public String getLngBaidu() {
+ return lngBaidu;
+ }
+
+ public void setLngBaidu(String lngBaidu) {
+ this.lngBaidu = lngBaidu;
+ }
+
+ public String getLngGaode() {
+ return lngGaode;
+ }
+
+ public void setLngGaode(String lngGaode) {
+ this.lngGaode = lngGaode;
+ }
+
+ public String getNotes() {
+ return notes;
+ }
+
+ public void setNotes(String notes) {
+ this.notes = notes;
+ }
+
+ public String getPhotos() {
+ return photos;
+ }
+
+ public void setPhotos(String photos) {
+ this.photos = photos;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public String getQu() {
+ return qu;
+ }
+
+ public void setQu(String qu) {
+ this.qu = qu;
+ }
+
+ public String getResponsibleDept() {
+ return responsibleDept;
+ }
+
+ public void setResponsibleDept(String responsibleDept) {
+ this.responsibleDept = responsibleDept;
+ }
+
+ public String getResponsibleDeptName() {
+ return responsibleDeptName;
+ }
+
+ public void setResponsibleDeptName(String responsibleDeptName) {
+ this.responsibleDeptName = responsibleDeptName;
+ }
+
+ public String getTs() {
+ return ts;
+ }
+
+ public void setTs(String ts) {
+ this.ts = ts;
+ }
+
+ public String getValid() {
+ return valid;
+ }
+
+ public void setValid(String valid) {
+ this.valid = valid;
+ }
+
+ public String getWellCode() {
+ return wellCode;
+ }
+
+ public void setWellCode(String wellCode) {
+ this.wellCode = wellCode;
+ }
+
+ public String getWellFlag1() {
+ return wellFlag1;
+ }
+
+ public void setWellFlag1(String wellFlag1) {
+ this.wellFlag1 = wellFlag1;
+ }
+
+ public String getWellFlag2() {
+ return wellFlag2;
+ }
+
+ public void setWellFlag2(String wellFlag2) {
+ this.wellFlag2 = wellFlag2;
+ }
+
+ public String getWellFlag3() {
+ return wellFlag3;
+ }
+
+ public void setWellFlag3(String wellFlag3) {
+ this.wellFlag3 = wellFlag3;
+ }
+
+ public String getWellName() {
+ return wellName;
+ }
+
+ public void setWellName(String wellName) {
+ this.wellName = wellName;
+ }
+
+ public String getWellType() {
+ return wellType;
+ }
+
+ public void setWellType(String wellType) {
+ this.wellType = wellType;
+ }
+
+ public String getWellTypeName() {
+ return wellTypeName;
+ }
+
+ public void setWellTypeName(String wellTypeName) {
+ this.wellTypeName = wellTypeName;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt b/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
index d5ac3ec..608dd91 100644
--- a/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
+++ b/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
@@ -22,6 +22,7 @@
* =============================================================================================
* */
const val PERMISSIONS_CODE = 999
+ const val PAGE_LIMIT = 20
/**
* =============================================================================================
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cbc72b6..a9b50c5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,7 +26,7 @@
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
- android:theme="@style/AppTheme"
+ android:theme="@style/QMUI.Compat.NoActionBar"
android:usesCleartextTraffic="true">
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
new file mode 100644
index 0000000..e3c059d
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
@@ -0,0 +1,111 @@
+package com.casic.smarttube.adapter
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+import com.casic.smarttube.R
+import com.casic.smarttube.extensions.arrowAnimation
+import com.casic.smarttube.model.DeviceListModel
+import com.github.mikephil.charting.charts.LineChart
+import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
+
+class DeviceListAdapter(
+ private val context: Context,
+ private val dataRows: MutableList
+) : RecyclerView.Adapter() {
+
+ private var layoutInflater: LayoutInflater = LayoutInflater.from(context)
+ private var isExpand = false
+
+ override fun onCreateViewHolder(
+ parent: ViewGroup, viewType: Int
+ ): DeviceListAdapter.ItemViewHolder {
+ return ItemViewHolder(
+ layoutInflater.inflate(R.layout.item_device_recycleview, parent, false)
+ )
+ }
+
+ override fun getItemCount(): Int = dataRows.size
+
+ override fun onBindViewHolder(holder: DeviceListAdapter.ItemViewHolder, position: Int) {
+ //绑定数据
+ val rowsBean = dataRows[position]
+ holder.deviceStateView.text = rowsBean.onlineStateName
+ if (rowsBean.onlineState == "1") {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_green_radius_5)
+ } else {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_gray_radius_5)
+ }
+ holder.deviceCodeView.text = rowsBean.devcode
+ holder.wellCodeView.text = String.format("井编号:${rowsBean.wellCode}")
+ holder.ownerShipView.text = String.format("权属单位:${rowsBean.deptName}")
+ holder.deviceLocationView.text = String.format("设备位置:${rowsBean.position}")
+ holder.installDateView.text = String.format("安装日期:${rowsBean.installDate}")
+
+
+ if (listener != null) {
+ holder.itemView.setOnClickListener {
+ listener!!.onClicked(position)
+ }
+ holder.dataHistoryButton.setOnClickListener {
+ listener!!.onHistoryClicked(position)
+ }
+ holder.editButton.setOnClickListener {
+ listener!!.onEditClicked(position)
+ }
+ holder.wellDetailButton.setOnClickListener {
+ listener!!.onWellDetailClicked(position)
+ }
+
+ holder.expandableImageView.setOnClickListener {
+ if (!isExpand) {
+ //展开列表动画
+ holder.expandableImageView.arrowAnimation(180f)
+ isExpand = true
+ //子列表绑定数据
+// expandableViewAdapter.setExpandableData(createExpandableList(rowsBean))
+ } else {
+ //关闭列表动画
+ holder.expandableImageView.arrowAnimation(0f)
+ isExpand = false
+ //子列表清空数据
+// expandableViewAdapter.clearAll()
+ }
+ }
+ }
+ }
+
+ inner class ItemViewHolder(view: View) : RecyclerView.ViewHolder(view) {
+ var deviceStateView: TextView = view.findViewById(R.id.deviceStateView)
+ var deviceCodeView: TextView = view.findViewById(R.id.deviceCodeView)
+ var expandableImageView: ImageView = view.findViewById(R.id.expandableImageView)
+ var wellCodeView: TextView = view.findViewById(R.id.wellCodeView)
+ var ownerShipView: TextView = view.findViewById(R.id.ownerShipView)
+ var deviceLocationView: TextView = view.findViewById(R.id.deviceLocationView)
+ var installDateView: TextView = view.findViewById(R.id.installDateView)
+ var dataHistoryButton: QMUIRoundButton = view.findViewById(R.id.dataHistoryButton)
+ var editButton: QMUIRoundButton = view.findViewById(R.id.editButton)
+ var wellDetailButton: QMUIRoundButton = view.findViewById(R.id.wellDetailButton)
+ var expandableChartView: LineChart = view.findViewById(R.id.expandableChartView)
+ }
+
+ private var listener: OnItemClickListener? = null
+
+ interface OnItemClickListener {
+ fun onClicked(position: Int)
+
+ fun onHistoryClicked(position: Int)
+
+ fun onEditClicked(position: Int)
+
+ fun onWellDetailClicked(position: Int)
+ }
+
+ fun setOnItemClickListener(onClickListener: OnItemClickListener?) {
+ this.listener = onClickListener
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
new file mode 100644
index 0000000..d185752
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
@@ -0,0 +1,11 @@
+package com.casic.smarttube.extensions
+
+import android.view.animation.LinearInterpolator
+import android.widget.ImageView
+
+fun ImageView.arrowAnimation(angle: Float) {
+ val animation = this.animate()
+ animation.duration = 300
+ animation.interpolator = LinearInterpolator()
+ animation.rotation(angle)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
new file mode 100644
index 0000000..22e56d2
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
@@ -0,0 +1,12 @@
+package com.casic.smarttube.extensions
+
+import android.view.View
+import com.qmuiteam.qmui.widget.QMUIEmptyView
+
+fun QMUIEmptyView.showEmptyPage(onButtonClickListener: View.OnClickListener) {
+ this.show(false, "抱歉,无法查询到相关记录", null, "重试", onButtonClickListener)
+}
+
+fun QMUIEmptyView.showEmptyPage(title: String, onButtonClickListener: View.OnClickListener) {
+ this.show(false, title, null, "刷新", onButtonClickListener)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
index 16d7e5c..1ef9226 100644
--- a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
+++ b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
@@ -1,10 +1,31 @@
package com.casic.smarttube.fragment
+import android.os.Handler
+import androidx.lifecycle.ViewModelProvider
+import androidx.recyclerview.widget.LinearLayoutManager
import com.casic.smarttube.R
+import com.casic.smarttube.adapter.DeviceListAdapter
+import com.casic.smarttube.extensions.showEmptyPage
+import com.casic.smarttube.model.DeviceListModel
+import com.casic.smarttube.view.WellDetailActivity
+import com.casic.smarttube.vm.DeviceViewModel
import com.pengxh.kt.lite.base.KotlinBaseFragment
+import com.pengxh.kt.lite.extensions.navigatePageTo
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.utils.WeakReferenceHandler
+import kotlinx.android.synthetic.main.fragment_overview.*
+import kotlinx.android.synthetic.main.include_empty_view.*
class OverviewFragment : KotlinBaseFragment() {
+ private lateinit var weakReferenceHandler: WeakReferenceHandler
+ private lateinit var deviceViewModel: DeviceViewModel
+ private lateinit var deviceAdapter: DeviceListAdapter
+ private var dataBeans: MutableList = ArrayList()
+ private var pageIndex = 1
+ private var isRefresh = false
+ private var isLoadMore = false
+
override fun initLayoutView(): Int = R.layout.fragment_overview
override fun setupTopBarLayout() {
@@ -12,10 +33,101 @@
}
override fun initData() {
+ weakReferenceHandler = WeakReferenceHandler(callback)
+ deviceViewModel = ViewModelProvider(this).get(DeviceViewModel::class.java)
+ }
+ override fun onResume() {
+ //默认加载第一页
+ obtainDeviceList()
+ super.onResume()
}
override fun initEvent() {
+ overviewLayout.setOnRefreshListener {
+ isRefresh = true
+ //刷新之后页码重置
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ overviewLayout.setOnLoadMoreListener {
+ isLoadMore = true
+ pageIndex++
+ obtainDeviceList()
+ }
+ deviceViewModel.deviceListModel.observe(this, {
+ if (it.code == 200) {
+ val dataRows = it.data?.rows
+ when {
+ isRefresh -> {
+ dataBeans.clear()
+ dataBeans = dataRows!!
+ overviewLayout.finishRefresh()
+ isRefresh = false
+ }
+ isLoadMore -> {
+ if (dataRows?.size == 0) {
+ "到底了,别拉了".show(requireContext())
+ }
+ dataBeans.addAll(dataRows!!)
+ overviewLayout.finishLoadMore()
+ isLoadMore = false
+ }
+ else -> {
+ dataBeans = dataRows!!
+ }
+ }
+ weakReferenceHandler.sendEmptyMessage(2022062401)
+ }
+ })
+ }
+
+ private fun obtainDeviceList() {
+ deviceViewModel.obtainDeviceListByType("", "", "", pageIndex)
+ }
+
+ private val callback = Handler.Callback {
+ if (it.what == 2022062401) {
+ if (isRefresh || isLoadMore) {
+ deviceAdapter.notifyDataSetChanged()
+ } else {
+ if (dataBeans.size == 0) {
+ emptyView!!.showEmptyPage("这里什么都没有") {
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ } else {
+ emptyView!!.hide()
+ deviceAdapter = DeviceListAdapter(requireContext(), dataBeans)
+ recyclerView!!.layoutManager = LinearLayoutManager(requireContext())
+ recyclerView!!.adapter = deviceAdapter
+ deviceAdapter.setOnItemClickListener(object :
+ DeviceListAdapter.OnItemClickListener {
+ override fun onClicked(position: Int) {
+// val jobId = dataBeans[position].jobId.toString()
+// if (jobId.isBlank()) {
+// "设备编号异常,无法查看详情".show(requireContext())
+// return
+// }
+// requireContext().navigatePageTo(jobId)
+ }
+
+ override fun onHistoryClicked(position: Int) {
+
+ }
+
+ override fun onEditClicked(position: Int) {
+
+ }
+
+ override fun onWellDetailClicked(position: Int) {
+ requireContext().navigatePageTo(dataBeans[position].wellId)
+ }
+ })
+ }
+ }
+ }
+ true
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/model/AreaModel.java b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
new file mode 100644
index 0000000..c6f86ef
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
@@ -0,0 +1,125 @@
+package com.casic.smarttube.model;
+
+public class AreaModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String area;
+ private String communications;
+ private String deptid;
+ private String deviceTypes;
+ private String id;
+ private String lat;
+ private String lng;
+ private String map;
+ private String wellTypes;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getCommunications() {
+ return communications;
+ }
+
+ public void setCommunications(String communications) {
+ this.communications = communications;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDeviceTypes() {
+ return deviceTypes;
+ }
+
+ public void setDeviceTypes(String deviceTypes) {
+ this.deviceTypes = deviceTypes;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getMap() {
+ return map;
+ }
+
+ public void setMap(String map) {
+ this.map = map;
+ }
+
+ public String getWellTypes() {
+ return wellTypes;
+ }
+
+ public void setWellTypes(String wellTypes) {
+ this.wellTypes = wellTypes;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
new file mode 100644
index 0000000..b34eb55
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
@@ -0,0 +1,274 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DeviceListModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private List rows;
+ private int total;
+
+ public List getRows() {
+ return rows;
+ }
+
+ public void setRows(List rows) {
+ this.rows = rows;
+ }
+
+ public int getTotal() {
+ return total;
+ }
+
+ public void setTotal(int total) {
+ this.total = total;
+ }
+
+ public static class RowsBean {
+ private String bfzt;
+ private String bfztName;
+ private String communication;
+ private String concenCode;
+ private String concenId;
+ private String deptName;
+ private String deptid;
+ private String devcode;
+ private String deviceName;
+ private String deviceType;
+ private String deviceTypeName;
+ private String id;
+ private String installDate;
+ private String modelId;
+ private String modelName;
+ private String onlineState;
+ private String onlineStateName;
+ private String position;
+ private String ts;
+ private String valid;
+ private String watchType;
+ private String wellCode;
+ private String wellId;
+
+ public String getBfzt() {
+ return bfzt;
+ }
+
+ public void setBfzt(String bfzt) {
+ this.bfzt = bfzt;
+ }
+
+ public String getBfztName() {
+ return bfztName;
+ }
+
+ public void setBfztName(String bfztName) {
+ this.bfztName = bfztName;
+ }
+
+ public String getCommunication() {
+ return communication;
+ }
+
+ public void setCommunication(String communication) {
+ this.communication = communication;
+ }
+
+ public String getConcenCode() {
+ return concenCode;
+ }
+
+ public void setConcenCode(String concenCode) {
+ this.concenCode = concenCode;
+ }
+
+ public String getConcenId() {
+ return concenId;
+ }
+
+ public void setConcenId(String concenId) {
+ this.concenId = concenId;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDevcode() {
+ return devcode;
+ }
+
+ public void setDevcode(String devcode) {
+ this.devcode = devcode;
+ }
+
+ public String getDeviceName() {
+ return deviceName;
+ }
+
+ public void setDeviceName(String deviceName) {
+ this.deviceName = deviceName;
+ }
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getDeviceTypeName() {
+ return deviceTypeName;
+ }
+
+ public void setDeviceTypeName(String deviceTypeName) {
+ this.deviceTypeName = deviceTypeName;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getInstallDate() {
+ return installDate;
+ }
+
+ public void setInstallDate(String installDate) {
+ this.installDate = installDate;
+ }
+
+ public String getModelId() {
+ return modelId;
+ }
+
+ public void setModelId(String modelId) {
+ this.modelId = modelId;
+ }
+
+ public String getModelName() {
+ return modelName;
+ }
+
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getOnlineState() {
+ return onlineState;
+ }
+
+ public void setOnlineState(String onlineState) {
+ this.onlineState = onlineState;
+ }
+
+ public String getOnlineStateName() {
+ return onlineStateName;
+ }
+
+ public void setOnlineStateName(String onlineStateName) {
+ this.onlineStateName = onlineStateName;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public String getTs() {
+ return ts;
+ }
+
+ public void setTs(String ts) {
+ this.ts = ts;
+ }
+
+ public String getValid() {
+ return valid;
+ }
+
+ public void setValid(String valid) {
+ this.valid = valid;
+ }
+
+ public String getWatchType() {
+ return watchType;
+ }
+
+ public void setWatchType(String watchType) {
+ this.watchType = watchType;
+ }
+
+ public String getWellCode() {
+ return wellCode;
+ }
+
+ public void setWellCode(String wellCode) {
+ this.wellCode = wellCode;
+ }
+
+ public String getWellId() {
+ return wellId;
+ }
+
+ public void setWellId(String wellId) {
+ this.wellId = wellId;
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DistrictModel.java b/app/src/main/java/com/casic/smarttube/model/DistrictModel.java
new file mode 100644
index 0000000..437405f
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DistrictModel.java
@@ -0,0 +1,172 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DistrictModel {
+
+ private int code;
+ private List data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String id;
+ private String isSync;
+ private String lat;
+ private int level;
+ private String levelName;
+ private String lng;
+ private String name;
+ private int num;
+ private String pName;
+ private String pid;
+ private String pids;
+ private String simplename;
+ private String targetIdSync;
+ private String targetPidSync;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getIsSync() {
+ return isSync;
+ }
+
+ public void setIsSync(String isSync) {
+ this.isSync = isSync;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+
+ public String getLevelName() {
+ return levelName;
+ }
+
+ public void setLevelName(String levelName) {
+ this.levelName = levelName;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public String getPName() {
+ return pName;
+ }
+
+ public void setPName(String pName) {
+ this.pName = pName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getPids() {
+ return pids;
+ }
+
+ public void setPids(String pids) {
+ this.pids = pids;
+ }
+
+ public String getSimplename() {
+ return simplename;
+ }
+
+ public void setSimplename(String simplename) {
+ this.simplename = simplename;
+ }
+
+ public String getTargetIdSync() {
+ return targetIdSync;
+ }
+
+ public void setTargetIdSync(String targetIdSync) {
+ this.targetIdSync = targetIdSync;
+ }
+
+ public String getTargetPidSync() {
+ return targetPidSync;
+ }
+
+ public void setTargetPidSync(String targetPidSync) {
+ this.targetPidSync = targetPidSync;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/StreetModel.java b/app/src/main/java/com/casic/smarttube/model/StreetModel.java
new file mode 100644
index 0000000..57fa295
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/StreetModel.java
@@ -0,0 +1,172 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class StreetModel {
+
+ private int code;
+ private List data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String id;
+ private String isSync;
+ private String lat;
+ private int level;
+ private String levelName;
+ private String lng;
+ private String name;
+ private int num;
+ private String pName;
+ private String pid;
+ private String pids;
+ private String simplename;
+ private String targetIdSync;
+ private String targetPidSync;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getIsSync() {
+ return isSync;
+ }
+
+ public void setIsSync(String isSync) {
+ this.isSync = isSync;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+
+ public String getLevelName() {
+ return levelName;
+ }
+
+ public void setLevelName(String levelName) {
+ this.levelName = levelName;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public String getPName() {
+ return pName;
+ }
+
+ public void setPName(String pName) {
+ this.pName = pName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getPids() {
+ return pids;
+ }
+
+ public void setPids(String pids) {
+ this.pids = pids;
+ }
+
+ public String getSimplename() {
+ return simplename;
+ }
+
+ public void setSimplename(String simplename) {
+ this.simplename = simplename;
+ }
+
+ public String getTargetIdSync() {
+ return targetIdSync;
+ }
+
+ public void setTargetIdSync(String targetIdSync) {
+ this.targetIdSync = targetIdSync;
+ }
+
+ public String getTargetPidSync() {
+ return targetPidSync;
+ }
+
+ public void setTargetPidSync(String targetPidSync) {
+ this.targetPidSync = targetPidSync;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java b/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java
new file mode 100644
index 0000000..c19899a
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java
@@ -0,0 +1,305 @@
+package com.casic.smarttube.model;
+
+public class WellDetailModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String area;
+ private String bfzt;
+ private String bfztName;
+ private String coordinateX;
+ private String coordinateY;
+ private int deep;
+ private String deptName;
+ private String deptid;
+ private String deviceCount;
+ private String id;
+ private String latBaidu;
+ private String latGaode;
+ private String lngBaidu;
+ private String lngGaode;
+ private String notes;
+ private String photos;
+ private String position;
+ private String qu;
+ private String responsibleDept;
+ private String responsibleDeptName;
+ private String ts;
+ private String valid;
+ private String wellCode;
+ private String wellFlag1;
+ private String wellFlag2;
+ private String wellFlag3;
+ private String wellName;
+ private String wellType;
+ private String wellTypeName;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getBfzt() {
+ return bfzt;
+ }
+
+ public void setBfzt(String bfzt) {
+ this.bfzt = bfzt;
+ }
+
+ public String getBfztName() {
+ return bfztName;
+ }
+
+ public void setBfztName(String bfztName) {
+ this.bfztName = bfztName;
+ }
+
+ public String getCoordinateX() {
+ return coordinateX;
+ }
+
+ public void setCoordinateX(String coordinateX) {
+ this.coordinateX = coordinateX;
+ }
+
+ public String getCoordinateY() {
+ return coordinateY;
+ }
+
+ public void setCoordinateY(String coordinateY) {
+ this.coordinateY = coordinateY;
+ }
+
+ public int getDeep() {
+ return deep;
+ }
+
+ public void setDeep(int deep) {
+ this.deep = deep;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDeviceCount() {
+ return deviceCount;
+ }
+
+ public void setDeviceCount(String deviceCount) {
+ this.deviceCount = deviceCount;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLatBaidu() {
+ return latBaidu;
+ }
+
+ public void setLatBaidu(String latBaidu) {
+ this.latBaidu = latBaidu;
+ }
+
+ public String getLatGaode() {
+ return latGaode;
+ }
+
+ public void setLatGaode(String latGaode) {
+ this.latGaode = latGaode;
+ }
+
+ public String getLngBaidu() {
+ return lngBaidu;
+ }
+
+ public void setLngBaidu(String lngBaidu) {
+ this.lngBaidu = lngBaidu;
+ }
+
+ public String getLngGaode() {
+ return lngGaode;
+ }
+
+ public void setLngGaode(String lngGaode) {
+ this.lngGaode = lngGaode;
+ }
+
+ public String getNotes() {
+ return notes;
+ }
+
+ public void setNotes(String notes) {
+ this.notes = notes;
+ }
+
+ public String getPhotos() {
+ return photos;
+ }
+
+ public void setPhotos(String photos) {
+ this.photos = photos;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public String getQu() {
+ return qu;
+ }
+
+ public void setQu(String qu) {
+ this.qu = qu;
+ }
+
+ public String getResponsibleDept() {
+ return responsibleDept;
+ }
+
+ public void setResponsibleDept(String responsibleDept) {
+ this.responsibleDept = responsibleDept;
+ }
+
+ public String getResponsibleDeptName() {
+ return responsibleDeptName;
+ }
+
+ public void setResponsibleDeptName(String responsibleDeptName) {
+ this.responsibleDeptName = responsibleDeptName;
+ }
+
+ public String getTs() {
+ return ts;
+ }
+
+ public void setTs(String ts) {
+ this.ts = ts;
+ }
+
+ public String getValid() {
+ return valid;
+ }
+
+ public void setValid(String valid) {
+ this.valid = valid;
+ }
+
+ public String getWellCode() {
+ return wellCode;
+ }
+
+ public void setWellCode(String wellCode) {
+ this.wellCode = wellCode;
+ }
+
+ public String getWellFlag1() {
+ return wellFlag1;
+ }
+
+ public void setWellFlag1(String wellFlag1) {
+ this.wellFlag1 = wellFlag1;
+ }
+
+ public String getWellFlag2() {
+ return wellFlag2;
+ }
+
+ public void setWellFlag2(String wellFlag2) {
+ this.wellFlag2 = wellFlag2;
+ }
+
+ public String getWellFlag3() {
+ return wellFlag3;
+ }
+
+ public void setWellFlag3(String wellFlag3) {
+ this.wellFlag3 = wellFlag3;
+ }
+
+ public String getWellName() {
+ return wellName;
+ }
+
+ public void setWellName(String wellName) {
+ this.wellName = wellName;
+ }
+
+ public String getWellType() {
+ return wellType;
+ }
+
+ public void setWellType(String wellType) {
+ this.wellType = wellType;
+ }
+
+ public String getWellTypeName() {
+ return wellTypeName;
+ }
+
+ public void setWellTypeName(String wellTypeName) {
+ this.wellTypeName = wellTypeName;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt b/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
index d5ac3ec..608dd91 100644
--- a/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
+++ b/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
@@ -22,6 +22,7 @@
* =============================================================================================
* */
const val PERMISSIONS_CODE = 999
+ const val PAGE_LIMIT = 20
/**
* =============================================================================================
diff --git a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt
index 64c5402..f715247 100644
--- a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt
+++ b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt
@@ -69,4 +69,64 @@
*/
@POST("/app/checkVersion")
suspend fun obtainVersionResult(@Header("token") token: String): String
+
+ /**
+ * 获取管盯分页列表
+ * */
+ @GET("/device/list")
+ suspend fun obtainDeviceListByType(
+ @Header("token") token: String,
+ @Query("deptid") deptid: String?,
+ @Query("keywords") keywords: String?,
+ @Query("deviceType") deviceType: String?,
+ @Query("isOnline") isOnline: String?,
+ @Query("sort") sort: String?,
+ @Query("order") order: String?,
+ @Query("offset") offset: Int,
+ @Query("limit") limit: Int
+ ): String
+
+ /**
+ * 获取闸井详情
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/info")
+ suspend fun obtainWellDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 根据部门获取区ID
+ *
+ * @param deptId
+ */
+ @GET("/config/getAreaByDept")
+ suspend fun obtainAreaByDept(
+ @Header("token") token: String,
+ @Query("deptId") deptId: String
+ ): String
+
+ /**
+ * 获取区/县等
+ *
+ * @param pid
+ */
+ @GET("/area/list")
+ suspend fun obtainDistrict(
+ @Header("token") token: String,
+ @Query("pid") pid: String
+ ): String
+
+ /**
+ * 获取街道
+ *
+ * @param pid
+ */
+ @GET("/area/list")
+ suspend fun obtainStreet(
+ @Header("token") token: String,
+ @Query("pid") pid: String
+ ): String
}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cbc72b6..a9b50c5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,7 +26,7 @@
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
- android:theme="@style/AppTheme"
+ android:theme="@style/QMUI.Compat.NoActionBar"
android:usesCleartextTraffic="true">
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
new file mode 100644
index 0000000..e3c059d
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
@@ -0,0 +1,111 @@
+package com.casic.smarttube.adapter
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+import com.casic.smarttube.R
+import com.casic.smarttube.extensions.arrowAnimation
+import com.casic.smarttube.model.DeviceListModel
+import com.github.mikephil.charting.charts.LineChart
+import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
+
+class DeviceListAdapter(
+ private val context: Context,
+ private val dataRows: MutableList
+) : RecyclerView.Adapter() {
+
+ private var layoutInflater: LayoutInflater = LayoutInflater.from(context)
+ private var isExpand = false
+
+ override fun onCreateViewHolder(
+ parent: ViewGroup, viewType: Int
+ ): DeviceListAdapter.ItemViewHolder {
+ return ItemViewHolder(
+ layoutInflater.inflate(R.layout.item_device_recycleview, parent, false)
+ )
+ }
+
+ override fun getItemCount(): Int = dataRows.size
+
+ override fun onBindViewHolder(holder: DeviceListAdapter.ItemViewHolder, position: Int) {
+ //绑定数据
+ val rowsBean = dataRows[position]
+ holder.deviceStateView.text = rowsBean.onlineStateName
+ if (rowsBean.onlineState == "1") {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_green_radius_5)
+ } else {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_gray_radius_5)
+ }
+ holder.deviceCodeView.text = rowsBean.devcode
+ holder.wellCodeView.text = String.format("井编号:${rowsBean.wellCode}")
+ holder.ownerShipView.text = String.format("权属单位:${rowsBean.deptName}")
+ holder.deviceLocationView.text = String.format("设备位置:${rowsBean.position}")
+ holder.installDateView.text = String.format("安装日期:${rowsBean.installDate}")
+
+
+ if (listener != null) {
+ holder.itemView.setOnClickListener {
+ listener!!.onClicked(position)
+ }
+ holder.dataHistoryButton.setOnClickListener {
+ listener!!.onHistoryClicked(position)
+ }
+ holder.editButton.setOnClickListener {
+ listener!!.onEditClicked(position)
+ }
+ holder.wellDetailButton.setOnClickListener {
+ listener!!.onWellDetailClicked(position)
+ }
+
+ holder.expandableImageView.setOnClickListener {
+ if (!isExpand) {
+ //展开列表动画
+ holder.expandableImageView.arrowAnimation(180f)
+ isExpand = true
+ //子列表绑定数据
+// expandableViewAdapter.setExpandableData(createExpandableList(rowsBean))
+ } else {
+ //关闭列表动画
+ holder.expandableImageView.arrowAnimation(0f)
+ isExpand = false
+ //子列表清空数据
+// expandableViewAdapter.clearAll()
+ }
+ }
+ }
+ }
+
+ inner class ItemViewHolder(view: View) : RecyclerView.ViewHolder(view) {
+ var deviceStateView: TextView = view.findViewById(R.id.deviceStateView)
+ var deviceCodeView: TextView = view.findViewById(R.id.deviceCodeView)
+ var expandableImageView: ImageView = view.findViewById(R.id.expandableImageView)
+ var wellCodeView: TextView = view.findViewById(R.id.wellCodeView)
+ var ownerShipView: TextView = view.findViewById(R.id.ownerShipView)
+ var deviceLocationView: TextView = view.findViewById(R.id.deviceLocationView)
+ var installDateView: TextView = view.findViewById(R.id.installDateView)
+ var dataHistoryButton: QMUIRoundButton = view.findViewById(R.id.dataHistoryButton)
+ var editButton: QMUIRoundButton = view.findViewById(R.id.editButton)
+ var wellDetailButton: QMUIRoundButton = view.findViewById(R.id.wellDetailButton)
+ var expandableChartView: LineChart = view.findViewById(R.id.expandableChartView)
+ }
+
+ private var listener: OnItemClickListener? = null
+
+ interface OnItemClickListener {
+ fun onClicked(position: Int)
+
+ fun onHistoryClicked(position: Int)
+
+ fun onEditClicked(position: Int)
+
+ fun onWellDetailClicked(position: Int)
+ }
+
+ fun setOnItemClickListener(onClickListener: OnItemClickListener?) {
+ this.listener = onClickListener
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
new file mode 100644
index 0000000..d185752
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
@@ -0,0 +1,11 @@
+package com.casic.smarttube.extensions
+
+import android.view.animation.LinearInterpolator
+import android.widget.ImageView
+
+fun ImageView.arrowAnimation(angle: Float) {
+ val animation = this.animate()
+ animation.duration = 300
+ animation.interpolator = LinearInterpolator()
+ animation.rotation(angle)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
new file mode 100644
index 0000000..22e56d2
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
@@ -0,0 +1,12 @@
+package com.casic.smarttube.extensions
+
+import android.view.View
+import com.qmuiteam.qmui.widget.QMUIEmptyView
+
+fun QMUIEmptyView.showEmptyPage(onButtonClickListener: View.OnClickListener) {
+ this.show(false, "抱歉,无法查询到相关记录", null, "重试", onButtonClickListener)
+}
+
+fun QMUIEmptyView.showEmptyPage(title: String, onButtonClickListener: View.OnClickListener) {
+ this.show(false, title, null, "刷新", onButtonClickListener)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
index 16d7e5c..1ef9226 100644
--- a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
+++ b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
@@ -1,10 +1,31 @@
package com.casic.smarttube.fragment
+import android.os.Handler
+import androidx.lifecycle.ViewModelProvider
+import androidx.recyclerview.widget.LinearLayoutManager
import com.casic.smarttube.R
+import com.casic.smarttube.adapter.DeviceListAdapter
+import com.casic.smarttube.extensions.showEmptyPage
+import com.casic.smarttube.model.DeviceListModel
+import com.casic.smarttube.view.WellDetailActivity
+import com.casic.smarttube.vm.DeviceViewModel
import com.pengxh.kt.lite.base.KotlinBaseFragment
+import com.pengxh.kt.lite.extensions.navigatePageTo
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.utils.WeakReferenceHandler
+import kotlinx.android.synthetic.main.fragment_overview.*
+import kotlinx.android.synthetic.main.include_empty_view.*
class OverviewFragment : KotlinBaseFragment() {
+ private lateinit var weakReferenceHandler: WeakReferenceHandler
+ private lateinit var deviceViewModel: DeviceViewModel
+ private lateinit var deviceAdapter: DeviceListAdapter
+ private var dataBeans: MutableList = ArrayList()
+ private var pageIndex = 1
+ private var isRefresh = false
+ private var isLoadMore = false
+
override fun initLayoutView(): Int = R.layout.fragment_overview
override fun setupTopBarLayout() {
@@ -12,10 +33,101 @@
}
override fun initData() {
+ weakReferenceHandler = WeakReferenceHandler(callback)
+ deviceViewModel = ViewModelProvider(this).get(DeviceViewModel::class.java)
+ }
+ override fun onResume() {
+ //默认加载第一页
+ obtainDeviceList()
+ super.onResume()
}
override fun initEvent() {
+ overviewLayout.setOnRefreshListener {
+ isRefresh = true
+ //刷新之后页码重置
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ overviewLayout.setOnLoadMoreListener {
+ isLoadMore = true
+ pageIndex++
+ obtainDeviceList()
+ }
+ deviceViewModel.deviceListModel.observe(this, {
+ if (it.code == 200) {
+ val dataRows = it.data?.rows
+ when {
+ isRefresh -> {
+ dataBeans.clear()
+ dataBeans = dataRows!!
+ overviewLayout.finishRefresh()
+ isRefresh = false
+ }
+ isLoadMore -> {
+ if (dataRows?.size == 0) {
+ "到底了,别拉了".show(requireContext())
+ }
+ dataBeans.addAll(dataRows!!)
+ overviewLayout.finishLoadMore()
+ isLoadMore = false
+ }
+ else -> {
+ dataBeans = dataRows!!
+ }
+ }
+ weakReferenceHandler.sendEmptyMessage(2022062401)
+ }
+ })
+ }
+
+ private fun obtainDeviceList() {
+ deviceViewModel.obtainDeviceListByType("", "", "", pageIndex)
+ }
+
+ private val callback = Handler.Callback {
+ if (it.what == 2022062401) {
+ if (isRefresh || isLoadMore) {
+ deviceAdapter.notifyDataSetChanged()
+ } else {
+ if (dataBeans.size == 0) {
+ emptyView!!.showEmptyPage("这里什么都没有") {
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ } else {
+ emptyView!!.hide()
+ deviceAdapter = DeviceListAdapter(requireContext(), dataBeans)
+ recyclerView!!.layoutManager = LinearLayoutManager(requireContext())
+ recyclerView!!.adapter = deviceAdapter
+ deviceAdapter.setOnItemClickListener(object :
+ DeviceListAdapter.OnItemClickListener {
+ override fun onClicked(position: Int) {
+// val jobId = dataBeans[position].jobId.toString()
+// if (jobId.isBlank()) {
+// "设备编号异常,无法查看详情".show(requireContext())
+// return
+// }
+// requireContext().navigatePageTo(jobId)
+ }
+
+ override fun onHistoryClicked(position: Int) {
+
+ }
+
+ override fun onEditClicked(position: Int) {
+
+ }
+
+ override fun onWellDetailClicked(position: Int) {
+ requireContext().navigatePageTo(dataBeans[position].wellId)
+ }
+ })
+ }
+ }
+ }
+ true
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/model/AreaModel.java b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
new file mode 100644
index 0000000..c6f86ef
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
@@ -0,0 +1,125 @@
+package com.casic.smarttube.model;
+
+public class AreaModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String area;
+ private String communications;
+ private String deptid;
+ private String deviceTypes;
+ private String id;
+ private String lat;
+ private String lng;
+ private String map;
+ private String wellTypes;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getCommunications() {
+ return communications;
+ }
+
+ public void setCommunications(String communications) {
+ this.communications = communications;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDeviceTypes() {
+ return deviceTypes;
+ }
+
+ public void setDeviceTypes(String deviceTypes) {
+ this.deviceTypes = deviceTypes;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getMap() {
+ return map;
+ }
+
+ public void setMap(String map) {
+ this.map = map;
+ }
+
+ public String getWellTypes() {
+ return wellTypes;
+ }
+
+ public void setWellTypes(String wellTypes) {
+ this.wellTypes = wellTypes;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
new file mode 100644
index 0000000..b34eb55
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
@@ -0,0 +1,274 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DeviceListModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private List rows;
+ private int total;
+
+ public List getRows() {
+ return rows;
+ }
+
+ public void setRows(List rows) {
+ this.rows = rows;
+ }
+
+ public int getTotal() {
+ return total;
+ }
+
+ public void setTotal(int total) {
+ this.total = total;
+ }
+
+ public static class RowsBean {
+ private String bfzt;
+ private String bfztName;
+ private String communication;
+ private String concenCode;
+ private String concenId;
+ private String deptName;
+ private String deptid;
+ private String devcode;
+ private String deviceName;
+ private String deviceType;
+ private String deviceTypeName;
+ private String id;
+ private String installDate;
+ private String modelId;
+ private String modelName;
+ private String onlineState;
+ private String onlineStateName;
+ private String position;
+ private String ts;
+ private String valid;
+ private String watchType;
+ private String wellCode;
+ private String wellId;
+
+ public String getBfzt() {
+ return bfzt;
+ }
+
+ public void setBfzt(String bfzt) {
+ this.bfzt = bfzt;
+ }
+
+ public String getBfztName() {
+ return bfztName;
+ }
+
+ public void setBfztName(String bfztName) {
+ this.bfztName = bfztName;
+ }
+
+ public String getCommunication() {
+ return communication;
+ }
+
+ public void setCommunication(String communication) {
+ this.communication = communication;
+ }
+
+ public String getConcenCode() {
+ return concenCode;
+ }
+
+ public void setConcenCode(String concenCode) {
+ this.concenCode = concenCode;
+ }
+
+ public String getConcenId() {
+ return concenId;
+ }
+
+ public void setConcenId(String concenId) {
+ this.concenId = concenId;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDevcode() {
+ return devcode;
+ }
+
+ public void setDevcode(String devcode) {
+ this.devcode = devcode;
+ }
+
+ public String getDeviceName() {
+ return deviceName;
+ }
+
+ public void setDeviceName(String deviceName) {
+ this.deviceName = deviceName;
+ }
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getDeviceTypeName() {
+ return deviceTypeName;
+ }
+
+ public void setDeviceTypeName(String deviceTypeName) {
+ this.deviceTypeName = deviceTypeName;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getInstallDate() {
+ return installDate;
+ }
+
+ public void setInstallDate(String installDate) {
+ this.installDate = installDate;
+ }
+
+ public String getModelId() {
+ return modelId;
+ }
+
+ public void setModelId(String modelId) {
+ this.modelId = modelId;
+ }
+
+ public String getModelName() {
+ return modelName;
+ }
+
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getOnlineState() {
+ return onlineState;
+ }
+
+ public void setOnlineState(String onlineState) {
+ this.onlineState = onlineState;
+ }
+
+ public String getOnlineStateName() {
+ return onlineStateName;
+ }
+
+ public void setOnlineStateName(String onlineStateName) {
+ this.onlineStateName = onlineStateName;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public String getTs() {
+ return ts;
+ }
+
+ public void setTs(String ts) {
+ this.ts = ts;
+ }
+
+ public String getValid() {
+ return valid;
+ }
+
+ public void setValid(String valid) {
+ this.valid = valid;
+ }
+
+ public String getWatchType() {
+ return watchType;
+ }
+
+ public void setWatchType(String watchType) {
+ this.watchType = watchType;
+ }
+
+ public String getWellCode() {
+ return wellCode;
+ }
+
+ public void setWellCode(String wellCode) {
+ this.wellCode = wellCode;
+ }
+
+ public String getWellId() {
+ return wellId;
+ }
+
+ public void setWellId(String wellId) {
+ this.wellId = wellId;
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DistrictModel.java b/app/src/main/java/com/casic/smarttube/model/DistrictModel.java
new file mode 100644
index 0000000..437405f
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DistrictModel.java
@@ -0,0 +1,172 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DistrictModel {
+
+ private int code;
+ private List data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String id;
+ private String isSync;
+ private String lat;
+ private int level;
+ private String levelName;
+ private String lng;
+ private String name;
+ private int num;
+ private String pName;
+ private String pid;
+ private String pids;
+ private String simplename;
+ private String targetIdSync;
+ private String targetPidSync;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getIsSync() {
+ return isSync;
+ }
+
+ public void setIsSync(String isSync) {
+ this.isSync = isSync;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+
+ public String getLevelName() {
+ return levelName;
+ }
+
+ public void setLevelName(String levelName) {
+ this.levelName = levelName;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public String getPName() {
+ return pName;
+ }
+
+ public void setPName(String pName) {
+ this.pName = pName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getPids() {
+ return pids;
+ }
+
+ public void setPids(String pids) {
+ this.pids = pids;
+ }
+
+ public String getSimplename() {
+ return simplename;
+ }
+
+ public void setSimplename(String simplename) {
+ this.simplename = simplename;
+ }
+
+ public String getTargetIdSync() {
+ return targetIdSync;
+ }
+
+ public void setTargetIdSync(String targetIdSync) {
+ this.targetIdSync = targetIdSync;
+ }
+
+ public String getTargetPidSync() {
+ return targetPidSync;
+ }
+
+ public void setTargetPidSync(String targetPidSync) {
+ this.targetPidSync = targetPidSync;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/StreetModel.java b/app/src/main/java/com/casic/smarttube/model/StreetModel.java
new file mode 100644
index 0000000..57fa295
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/StreetModel.java
@@ -0,0 +1,172 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class StreetModel {
+
+ private int code;
+ private List data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String id;
+ private String isSync;
+ private String lat;
+ private int level;
+ private String levelName;
+ private String lng;
+ private String name;
+ private int num;
+ private String pName;
+ private String pid;
+ private String pids;
+ private String simplename;
+ private String targetIdSync;
+ private String targetPidSync;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getIsSync() {
+ return isSync;
+ }
+
+ public void setIsSync(String isSync) {
+ this.isSync = isSync;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+
+ public String getLevelName() {
+ return levelName;
+ }
+
+ public void setLevelName(String levelName) {
+ this.levelName = levelName;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public String getPName() {
+ return pName;
+ }
+
+ public void setPName(String pName) {
+ this.pName = pName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getPids() {
+ return pids;
+ }
+
+ public void setPids(String pids) {
+ this.pids = pids;
+ }
+
+ public String getSimplename() {
+ return simplename;
+ }
+
+ public void setSimplename(String simplename) {
+ this.simplename = simplename;
+ }
+
+ public String getTargetIdSync() {
+ return targetIdSync;
+ }
+
+ public void setTargetIdSync(String targetIdSync) {
+ this.targetIdSync = targetIdSync;
+ }
+
+ public String getTargetPidSync() {
+ return targetPidSync;
+ }
+
+ public void setTargetPidSync(String targetPidSync) {
+ this.targetPidSync = targetPidSync;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java b/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java
new file mode 100644
index 0000000..c19899a
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java
@@ -0,0 +1,305 @@
+package com.casic.smarttube.model;
+
+public class WellDetailModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String area;
+ private String bfzt;
+ private String bfztName;
+ private String coordinateX;
+ private String coordinateY;
+ private int deep;
+ private String deptName;
+ private String deptid;
+ private String deviceCount;
+ private String id;
+ private String latBaidu;
+ private String latGaode;
+ private String lngBaidu;
+ private String lngGaode;
+ private String notes;
+ private String photos;
+ private String position;
+ private String qu;
+ private String responsibleDept;
+ private String responsibleDeptName;
+ private String ts;
+ private String valid;
+ private String wellCode;
+ private String wellFlag1;
+ private String wellFlag2;
+ private String wellFlag3;
+ private String wellName;
+ private String wellType;
+ private String wellTypeName;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getBfzt() {
+ return bfzt;
+ }
+
+ public void setBfzt(String bfzt) {
+ this.bfzt = bfzt;
+ }
+
+ public String getBfztName() {
+ return bfztName;
+ }
+
+ public void setBfztName(String bfztName) {
+ this.bfztName = bfztName;
+ }
+
+ public String getCoordinateX() {
+ return coordinateX;
+ }
+
+ public void setCoordinateX(String coordinateX) {
+ this.coordinateX = coordinateX;
+ }
+
+ public String getCoordinateY() {
+ return coordinateY;
+ }
+
+ public void setCoordinateY(String coordinateY) {
+ this.coordinateY = coordinateY;
+ }
+
+ public int getDeep() {
+ return deep;
+ }
+
+ public void setDeep(int deep) {
+ this.deep = deep;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDeviceCount() {
+ return deviceCount;
+ }
+
+ public void setDeviceCount(String deviceCount) {
+ this.deviceCount = deviceCount;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLatBaidu() {
+ return latBaidu;
+ }
+
+ public void setLatBaidu(String latBaidu) {
+ this.latBaidu = latBaidu;
+ }
+
+ public String getLatGaode() {
+ return latGaode;
+ }
+
+ public void setLatGaode(String latGaode) {
+ this.latGaode = latGaode;
+ }
+
+ public String getLngBaidu() {
+ return lngBaidu;
+ }
+
+ public void setLngBaidu(String lngBaidu) {
+ this.lngBaidu = lngBaidu;
+ }
+
+ public String getLngGaode() {
+ return lngGaode;
+ }
+
+ public void setLngGaode(String lngGaode) {
+ this.lngGaode = lngGaode;
+ }
+
+ public String getNotes() {
+ return notes;
+ }
+
+ public void setNotes(String notes) {
+ this.notes = notes;
+ }
+
+ public String getPhotos() {
+ return photos;
+ }
+
+ public void setPhotos(String photos) {
+ this.photos = photos;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public String getQu() {
+ return qu;
+ }
+
+ public void setQu(String qu) {
+ this.qu = qu;
+ }
+
+ public String getResponsibleDept() {
+ return responsibleDept;
+ }
+
+ public void setResponsibleDept(String responsibleDept) {
+ this.responsibleDept = responsibleDept;
+ }
+
+ public String getResponsibleDeptName() {
+ return responsibleDeptName;
+ }
+
+ public void setResponsibleDeptName(String responsibleDeptName) {
+ this.responsibleDeptName = responsibleDeptName;
+ }
+
+ public String getTs() {
+ return ts;
+ }
+
+ public void setTs(String ts) {
+ this.ts = ts;
+ }
+
+ public String getValid() {
+ return valid;
+ }
+
+ public void setValid(String valid) {
+ this.valid = valid;
+ }
+
+ public String getWellCode() {
+ return wellCode;
+ }
+
+ public void setWellCode(String wellCode) {
+ this.wellCode = wellCode;
+ }
+
+ public String getWellFlag1() {
+ return wellFlag1;
+ }
+
+ public void setWellFlag1(String wellFlag1) {
+ this.wellFlag1 = wellFlag1;
+ }
+
+ public String getWellFlag2() {
+ return wellFlag2;
+ }
+
+ public void setWellFlag2(String wellFlag2) {
+ this.wellFlag2 = wellFlag2;
+ }
+
+ public String getWellFlag3() {
+ return wellFlag3;
+ }
+
+ public void setWellFlag3(String wellFlag3) {
+ this.wellFlag3 = wellFlag3;
+ }
+
+ public String getWellName() {
+ return wellName;
+ }
+
+ public void setWellName(String wellName) {
+ this.wellName = wellName;
+ }
+
+ public String getWellType() {
+ return wellType;
+ }
+
+ public void setWellType(String wellType) {
+ this.wellType = wellType;
+ }
+
+ public String getWellTypeName() {
+ return wellTypeName;
+ }
+
+ public void setWellTypeName(String wellTypeName) {
+ this.wellTypeName = wellTypeName;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt b/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
index d5ac3ec..608dd91 100644
--- a/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
+++ b/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
@@ -22,6 +22,7 @@
* =============================================================================================
* */
const val PERMISSIONS_CODE = 999
+ const val PAGE_LIMIT = 20
/**
* =============================================================================================
diff --git a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt
index 64c5402..f715247 100644
--- a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt
+++ b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt
@@ -69,4 +69,64 @@
*/
@POST("/app/checkVersion")
suspend fun obtainVersionResult(@Header("token") token: String): String
+
+ /**
+ * 获取管盯分页列表
+ * */
+ @GET("/device/list")
+ suspend fun obtainDeviceListByType(
+ @Header("token") token: String,
+ @Query("deptid") deptid: String?,
+ @Query("keywords") keywords: String?,
+ @Query("deviceType") deviceType: String?,
+ @Query("isOnline") isOnline: String?,
+ @Query("sort") sort: String?,
+ @Query("order") order: String?,
+ @Query("offset") offset: Int,
+ @Query("limit") limit: Int
+ ): String
+
+ /**
+ * 获取闸井详情
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/info")
+ suspend fun obtainWellDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 根据部门获取区ID
+ *
+ * @param deptId
+ */
+ @GET("/config/getAreaByDept")
+ suspend fun obtainAreaByDept(
+ @Header("token") token: String,
+ @Query("deptId") deptId: String
+ ): String
+
+ /**
+ * 获取区/县等
+ *
+ * @param pid
+ */
+ @GET("/area/list")
+ suspend fun obtainDistrict(
+ @Header("token") token: String,
+ @Query("pid") pid: String
+ ): String
+
+ /**
+ * 获取街道
+ *
+ * @param pid
+ */
+ @GET("/area/list")
+ suspend fun obtainStreet(
+ @Header("token") token: String,
+ @Query("pid") pid: String
+ ): String
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt
index 2af9a24..d888e59 100644
--- a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt
+++ b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt
@@ -1,6 +1,7 @@
package com.casic.smarttube.utils.retrofit
import com.casic.smarttube.utils.AuthenticationHelper
+import com.casic.smarttube.utils.LocalConstant
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.MultipartBody
import okhttp3.RequestBody
@@ -54,6 +55,46 @@
}
/**
+ * 根据设备类型获取设备分页列表
+ */
+ suspend fun obtainDeviceListByType(
+ deptid: String, keywords: String, isOnline: String, page: Int
+ ): String {
+ return api.obtainDeviceListByType(
+ AuthenticationHelper.token!!, deptid, keywords, "12", isOnline,
+ "id", "asc", page, LocalConstant.PAGE_LIMIT
+ )
+ }
+
+ /**
+ * 获取闸井详情
+ */
+ suspend fun obtainWellDetail(id: String): String {
+ return api.obtainWellDetail(AuthenticationHelper.token!!, id)
+ }
+
+ /**
+ * 根据部门获取区ID
+ */
+ suspend fun obtainAreaByDept(deptId: String): String {
+ return api.obtainAreaByDept(AuthenticationHelper.token!!, deptId)
+ }
+
+ /**
+ * 获取区/县等
+ */
+ suspend fun obtainDistrict(pid: String): String {
+ return api.obtainDistrict(AuthenticationHelper.token!!, pid)
+ }
+
+ /**
+ * 获取街道
+ */
+ suspend fun obtainStreet(pid: String): String {
+ return api.obtainStreet(AuthenticationHelper.token!!, pid)
+ }
+
+ /**
* 上传图片
*/
suspend fun uploadImage(image: File): String {
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cbc72b6..a9b50c5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,7 +26,7 @@
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
- android:theme="@style/AppTheme"
+ android:theme="@style/QMUI.Compat.NoActionBar"
android:usesCleartextTraffic="true">
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
new file mode 100644
index 0000000..e3c059d
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
@@ -0,0 +1,111 @@
+package com.casic.smarttube.adapter
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+import com.casic.smarttube.R
+import com.casic.smarttube.extensions.arrowAnimation
+import com.casic.smarttube.model.DeviceListModel
+import com.github.mikephil.charting.charts.LineChart
+import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
+
+class DeviceListAdapter(
+ private val context: Context,
+ private val dataRows: MutableList
+) : RecyclerView.Adapter() {
+
+ private var layoutInflater: LayoutInflater = LayoutInflater.from(context)
+ private var isExpand = false
+
+ override fun onCreateViewHolder(
+ parent: ViewGroup, viewType: Int
+ ): DeviceListAdapter.ItemViewHolder {
+ return ItemViewHolder(
+ layoutInflater.inflate(R.layout.item_device_recycleview, parent, false)
+ )
+ }
+
+ override fun getItemCount(): Int = dataRows.size
+
+ override fun onBindViewHolder(holder: DeviceListAdapter.ItemViewHolder, position: Int) {
+ //绑定数据
+ val rowsBean = dataRows[position]
+ holder.deviceStateView.text = rowsBean.onlineStateName
+ if (rowsBean.onlineState == "1") {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_green_radius_5)
+ } else {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_gray_radius_5)
+ }
+ holder.deviceCodeView.text = rowsBean.devcode
+ holder.wellCodeView.text = String.format("井编号:${rowsBean.wellCode}")
+ holder.ownerShipView.text = String.format("权属单位:${rowsBean.deptName}")
+ holder.deviceLocationView.text = String.format("设备位置:${rowsBean.position}")
+ holder.installDateView.text = String.format("安装日期:${rowsBean.installDate}")
+
+
+ if (listener != null) {
+ holder.itemView.setOnClickListener {
+ listener!!.onClicked(position)
+ }
+ holder.dataHistoryButton.setOnClickListener {
+ listener!!.onHistoryClicked(position)
+ }
+ holder.editButton.setOnClickListener {
+ listener!!.onEditClicked(position)
+ }
+ holder.wellDetailButton.setOnClickListener {
+ listener!!.onWellDetailClicked(position)
+ }
+
+ holder.expandableImageView.setOnClickListener {
+ if (!isExpand) {
+ //展开列表动画
+ holder.expandableImageView.arrowAnimation(180f)
+ isExpand = true
+ //子列表绑定数据
+// expandableViewAdapter.setExpandableData(createExpandableList(rowsBean))
+ } else {
+ //关闭列表动画
+ holder.expandableImageView.arrowAnimation(0f)
+ isExpand = false
+ //子列表清空数据
+// expandableViewAdapter.clearAll()
+ }
+ }
+ }
+ }
+
+ inner class ItemViewHolder(view: View) : RecyclerView.ViewHolder(view) {
+ var deviceStateView: TextView = view.findViewById(R.id.deviceStateView)
+ var deviceCodeView: TextView = view.findViewById(R.id.deviceCodeView)
+ var expandableImageView: ImageView = view.findViewById(R.id.expandableImageView)
+ var wellCodeView: TextView = view.findViewById(R.id.wellCodeView)
+ var ownerShipView: TextView = view.findViewById(R.id.ownerShipView)
+ var deviceLocationView: TextView = view.findViewById(R.id.deviceLocationView)
+ var installDateView: TextView = view.findViewById(R.id.installDateView)
+ var dataHistoryButton: QMUIRoundButton = view.findViewById(R.id.dataHistoryButton)
+ var editButton: QMUIRoundButton = view.findViewById(R.id.editButton)
+ var wellDetailButton: QMUIRoundButton = view.findViewById(R.id.wellDetailButton)
+ var expandableChartView: LineChart = view.findViewById(R.id.expandableChartView)
+ }
+
+ private var listener: OnItemClickListener? = null
+
+ interface OnItemClickListener {
+ fun onClicked(position: Int)
+
+ fun onHistoryClicked(position: Int)
+
+ fun onEditClicked(position: Int)
+
+ fun onWellDetailClicked(position: Int)
+ }
+
+ fun setOnItemClickListener(onClickListener: OnItemClickListener?) {
+ this.listener = onClickListener
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
new file mode 100644
index 0000000..d185752
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
@@ -0,0 +1,11 @@
+package com.casic.smarttube.extensions
+
+import android.view.animation.LinearInterpolator
+import android.widget.ImageView
+
+fun ImageView.arrowAnimation(angle: Float) {
+ val animation = this.animate()
+ animation.duration = 300
+ animation.interpolator = LinearInterpolator()
+ animation.rotation(angle)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
new file mode 100644
index 0000000..22e56d2
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
@@ -0,0 +1,12 @@
+package com.casic.smarttube.extensions
+
+import android.view.View
+import com.qmuiteam.qmui.widget.QMUIEmptyView
+
+fun QMUIEmptyView.showEmptyPage(onButtonClickListener: View.OnClickListener) {
+ this.show(false, "抱歉,无法查询到相关记录", null, "重试", onButtonClickListener)
+}
+
+fun QMUIEmptyView.showEmptyPage(title: String, onButtonClickListener: View.OnClickListener) {
+ this.show(false, title, null, "刷新", onButtonClickListener)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
index 16d7e5c..1ef9226 100644
--- a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
+++ b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
@@ -1,10 +1,31 @@
package com.casic.smarttube.fragment
+import android.os.Handler
+import androidx.lifecycle.ViewModelProvider
+import androidx.recyclerview.widget.LinearLayoutManager
import com.casic.smarttube.R
+import com.casic.smarttube.adapter.DeviceListAdapter
+import com.casic.smarttube.extensions.showEmptyPage
+import com.casic.smarttube.model.DeviceListModel
+import com.casic.smarttube.view.WellDetailActivity
+import com.casic.smarttube.vm.DeviceViewModel
import com.pengxh.kt.lite.base.KotlinBaseFragment
+import com.pengxh.kt.lite.extensions.navigatePageTo
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.utils.WeakReferenceHandler
+import kotlinx.android.synthetic.main.fragment_overview.*
+import kotlinx.android.synthetic.main.include_empty_view.*
class OverviewFragment : KotlinBaseFragment() {
+ private lateinit var weakReferenceHandler: WeakReferenceHandler
+ private lateinit var deviceViewModel: DeviceViewModel
+ private lateinit var deviceAdapter: DeviceListAdapter
+ private var dataBeans: MutableList = ArrayList()
+ private var pageIndex = 1
+ private var isRefresh = false
+ private var isLoadMore = false
+
override fun initLayoutView(): Int = R.layout.fragment_overview
override fun setupTopBarLayout() {
@@ -12,10 +33,101 @@
}
override fun initData() {
+ weakReferenceHandler = WeakReferenceHandler(callback)
+ deviceViewModel = ViewModelProvider(this).get(DeviceViewModel::class.java)
+ }
+ override fun onResume() {
+ //默认加载第一页
+ obtainDeviceList()
+ super.onResume()
}
override fun initEvent() {
+ overviewLayout.setOnRefreshListener {
+ isRefresh = true
+ //刷新之后页码重置
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ overviewLayout.setOnLoadMoreListener {
+ isLoadMore = true
+ pageIndex++
+ obtainDeviceList()
+ }
+ deviceViewModel.deviceListModel.observe(this, {
+ if (it.code == 200) {
+ val dataRows = it.data?.rows
+ when {
+ isRefresh -> {
+ dataBeans.clear()
+ dataBeans = dataRows!!
+ overviewLayout.finishRefresh()
+ isRefresh = false
+ }
+ isLoadMore -> {
+ if (dataRows?.size == 0) {
+ "到底了,别拉了".show(requireContext())
+ }
+ dataBeans.addAll(dataRows!!)
+ overviewLayout.finishLoadMore()
+ isLoadMore = false
+ }
+ else -> {
+ dataBeans = dataRows!!
+ }
+ }
+ weakReferenceHandler.sendEmptyMessage(2022062401)
+ }
+ })
+ }
+
+ private fun obtainDeviceList() {
+ deviceViewModel.obtainDeviceListByType("", "", "", pageIndex)
+ }
+
+ private val callback = Handler.Callback {
+ if (it.what == 2022062401) {
+ if (isRefresh || isLoadMore) {
+ deviceAdapter.notifyDataSetChanged()
+ } else {
+ if (dataBeans.size == 0) {
+ emptyView!!.showEmptyPage("这里什么都没有") {
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ } else {
+ emptyView!!.hide()
+ deviceAdapter = DeviceListAdapter(requireContext(), dataBeans)
+ recyclerView!!.layoutManager = LinearLayoutManager(requireContext())
+ recyclerView!!.adapter = deviceAdapter
+ deviceAdapter.setOnItemClickListener(object :
+ DeviceListAdapter.OnItemClickListener {
+ override fun onClicked(position: Int) {
+// val jobId = dataBeans[position].jobId.toString()
+// if (jobId.isBlank()) {
+// "设备编号异常,无法查看详情".show(requireContext())
+// return
+// }
+// requireContext().navigatePageTo(jobId)
+ }
+
+ override fun onHistoryClicked(position: Int) {
+
+ }
+
+ override fun onEditClicked(position: Int) {
+
+ }
+
+ override fun onWellDetailClicked(position: Int) {
+ requireContext().navigatePageTo(dataBeans[position].wellId)
+ }
+ })
+ }
+ }
+ }
+ true
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/model/AreaModel.java b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
new file mode 100644
index 0000000..c6f86ef
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
@@ -0,0 +1,125 @@
+package com.casic.smarttube.model;
+
+public class AreaModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String area;
+ private String communications;
+ private String deptid;
+ private String deviceTypes;
+ private String id;
+ private String lat;
+ private String lng;
+ private String map;
+ private String wellTypes;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getCommunications() {
+ return communications;
+ }
+
+ public void setCommunications(String communications) {
+ this.communications = communications;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDeviceTypes() {
+ return deviceTypes;
+ }
+
+ public void setDeviceTypes(String deviceTypes) {
+ this.deviceTypes = deviceTypes;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getMap() {
+ return map;
+ }
+
+ public void setMap(String map) {
+ this.map = map;
+ }
+
+ public String getWellTypes() {
+ return wellTypes;
+ }
+
+ public void setWellTypes(String wellTypes) {
+ this.wellTypes = wellTypes;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
new file mode 100644
index 0000000..b34eb55
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
@@ -0,0 +1,274 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DeviceListModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private List rows;
+ private int total;
+
+ public List getRows() {
+ return rows;
+ }
+
+ public void setRows(List rows) {
+ this.rows = rows;
+ }
+
+ public int getTotal() {
+ return total;
+ }
+
+ public void setTotal(int total) {
+ this.total = total;
+ }
+
+ public static class RowsBean {
+ private String bfzt;
+ private String bfztName;
+ private String communication;
+ private String concenCode;
+ private String concenId;
+ private String deptName;
+ private String deptid;
+ private String devcode;
+ private String deviceName;
+ private String deviceType;
+ private String deviceTypeName;
+ private String id;
+ private String installDate;
+ private String modelId;
+ private String modelName;
+ private String onlineState;
+ private String onlineStateName;
+ private String position;
+ private String ts;
+ private String valid;
+ private String watchType;
+ private String wellCode;
+ private String wellId;
+
+ public String getBfzt() {
+ return bfzt;
+ }
+
+ public void setBfzt(String bfzt) {
+ this.bfzt = bfzt;
+ }
+
+ public String getBfztName() {
+ return bfztName;
+ }
+
+ public void setBfztName(String bfztName) {
+ this.bfztName = bfztName;
+ }
+
+ public String getCommunication() {
+ return communication;
+ }
+
+ public void setCommunication(String communication) {
+ this.communication = communication;
+ }
+
+ public String getConcenCode() {
+ return concenCode;
+ }
+
+ public void setConcenCode(String concenCode) {
+ this.concenCode = concenCode;
+ }
+
+ public String getConcenId() {
+ return concenId;
+ }
+
+ public void setConcenId(String concenId) {
+ this.concenId = concenId;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDevcode() {
+ return devcode;
+ }
+
+ public void setDevcode(String devcode) {
+ this.devcode = devcode;
+ }
+
+ public String getDeviceName() {
+ return deviceName;
+ }
+
+ public void setDeviceName(String deviceName) {
+ this.deviceName = deviceName;
+ }
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getDeviceTypeName() {
+ return deviceTypeName;
+ }
+
+ public void setDeviceTypeName(String deviceTypeName) {
+ this.deviceTypeName = deviceTypeName;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getInstallDate() {
+ return installDate;
+ }
+
+ public void setInstallDate(String installDate) {
+ this.installDate = installDate;
+ }
+
+ public String getModelId() {
+ return modelId;
+ }
+
+ public void setModelId(String modelId) {
+ this.modelId = modelId;
+ }
+
+ public String getModelName() {
+ return modelName;
+ }
+
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getOnlineState() {
+ return onlineState;
+ }
+
+ public void setOnlineState(String onlineState) {
+ this.onlineState = onlineState;
+ }
+
+ public String getOnlineStateName() {
+ return onlineStateName;
+ }
+
+ public void setOnlineStateName(String onlineStateName) {
+ this.onlineStateName = onlineStateName;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public String getTs() {
+ return ts;
+ }
+
+ public void setTs(String ts) {
+ this.ts = ts;
+ }
+
+ public String getValid() {
+ return valid;
+ }
+
+ public void setValid(String valid) {
+ this.valid = valid;
+ }
+
+ public String getWatchType() {
+ return watchType;
+ }
+
+ public void setWatchType(String watchType) {
+ this.watchType = watchType;
+ }
+
+ public String getWellCode() {
+ return wellCode;
+ }
+
+ public void setWellCode(String wellCode) {
+ this.wellCode = wellCode;
+ }
+
+ public String getWellId() {
+ return wellId;
+ }
+
+ public void setWellId(String wellId) {
+ this.wellId = wellId;
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DistrictModel.java b/app/src/main/java/com/casic/smarttube/model/DistrictModel.java
new file mode 100644
index 0000000..437405f
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DistrictModel.java
@@ -0,0 +1,172 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DistrictModel {
+
+ private int code;
+ private List data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String id;
+ private String isSync;
+ private String lat;
+ private int level;
+ private String levelName;
+ private String lng;
+ private String name;
+ private int num;
+ private String pName;
+ private String pid;
+ private String pids;
+ private String simplename;
+ private String targetIdSync;
+ private String targetPidSync;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getIsSync() {
+ return isSync;
+ }
+
+ public void setIsSync(String isSync) {
+ this.isSync = isSync;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+
+ public String getLevelName() {
+ return levelName;
+ }
+
+ public void setLevelName(String levelName) {
+ this.levelName = levelName;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public String getPName() {
+ return pName;
+ }
+
+ public void setPName(String pName) {
+ this.pName = pName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getPids() {
+ return pids;
+ }
+
+ public void setPids(String pids) {
+ this.pids = pids;
+ }
+
+ public String getSimplename() {
+ return simplename;
+ }
+
+ public void setSimplename(String simplename) {
+ this.simplename = simplename;
+ }
+
+ public String getTargetIdSync() {
+ return targetIdSync;
+ }
+
+ public void setTargetIdSync(String targetIdSync) {
+ this.targetIdSync = targetIdSync;
+ }
+
+ public String getTargetPidSync() {
+ return targetPidSync;
+ }
+
+ public void setTargetPidSync(String targetPidSync) {
+ this.targetPidSync = targetPidSync;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/StreetModel.java b/app/src/main/java/com/casic/smarttube/model/StreetModel.java
new file mode 100644
index 0000000..57fa295
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/StreetModel.java
@@ -0,0 +1,172 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class StreetModel {
+
+ private int code;
+ private List data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String id;
+ private String isSync;
+ private String lat;
+ private int level;
+ private String levelName;
+ private String lng;
+ private String name;
+ private int num;
+ private String pName;
+ private String pid;
+ private String pids;
+ private String simplename;
+ private String targetIdSync;
+ private String targetPidSync;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getIsSync() {
+ return isSync;
+ }
+
+ public void setIsSync(String isSync) {
+ this.isSync = isSync;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+
+ public String getLevelName() {
+ return levelName;
+ }
+
+ public void setLevelName(String levelName) {
+ this.levelName = levelName;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public String getPName() {
+ return pName;
+ }
+
+ public void setPName(String pName) {
+ this.pName = pName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getPids() {
+ return pids;
+ }
+
+ public void setPids(String pids) {
+ this.pids = pids;
+ }
+
+ public String getSimplename() {
+ return simplename;
+ }
+
+ public void setSimplename(String simplename) {
+ this.simplename = simplename;
+ }
+
+ public String getTargetIdSync() {
+ return targetIdSync;
+ }
+
+ public void setTargetIdSync(String targetIdSync) {
+ this.targetIdSync = targetIdSync;
+ }
+
+ public String getTargetPidSync() {
+ return targetPidSync;
+ }
+
+ public void setTargetPidSync(String targetPidSync) {
+ this.targetPidSync = targetPidSync;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java b/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java
new file mode 100644
index 0000000..c19899a
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java
@@ -0,0 +1,305 @@
+package com.casic.smarttube.model;
+
+public class WellDetailModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String area;
+ private String bfzt;
+ private String bfztName;
+ private String coordinateX;
+ private String coordinateY;
+ private int deep;
+ private String deptName;
+ private String deptid;
+ private String deviceCount;
+ private String id;
+ private String latBaidu;
+ private String latGaode;
+ private String lngBaidu;
+ private String lngGaode;
+ private String notes;
+ private String photos;
+ private String position;
+ private String qu;
+ private String responsibleDept;
+ private String responsibleDeptName;
+ private String ts;
+ private String valid;
+ private String wellCode;
+ private String wellFlag1;
+ private String wellFlag2;
+ private String wellFlag3;
+ private String wellName;
+ private String wellType;
+ private String wellTypeName;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getBfzt() {
+ return bfzt;
+ }
+
+ public void setBfzt(String bfzt) {
+ this.bfzt = bfzt;
+ }
+
+ public String getBfztName() {
+ return bfztName;
+ }
+
+ public void setBfztName(String bfztName) {
+ this.bfztName = bfztName;
+ }
+
+ public String getCoordinateX() {
+ return coordinateX;
+ }
+
+ public void setCoordinateX(String coordinateX) {
+ this.coordinateX = coordinateX;
+ }
+
+ public String getCoordinateY() {
+ return coordinateY;
+ }
+
+ public void setCoordinateY(String coordinateY) {
+ this.coordinateY = coordinateY;
+ }
+
+ public int getDeep() {
+ return deep;
+ }
+
+ public void setDeep(int deep) {
+ this.deep = deep;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDeviceCount() {
+ return deviceCount;
+ }
+
+ public void setDeviceCount(String deviceCount) {
+ this.deviceCount = deviceCount;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLatBaidu() {
+ return latBaidu;
+ }
+
+ public void setLatBaidu(String latBaidu) {
+ this.latBaidu = latBaidu;
+ }
+
+ public String getLatGaode() {
+ return latGaode;
+ }
+
+ public void setLatGaode(String latGaode) {
+ this.latGaode = latGaode;
+ }
+
+ public String getLngBaidu() {
+ return lngBaidu;
+ }
+
+ public void setLngBaidu(String lngBaidu) {
+ this.lngBaidu = lngBaidu;
+ }
+
+ public String getLngGaode() {
+ return lngGaode;
+ }
+
+ public void setLngGaode(String lngGaode) {
+ this.lngGaode = lngGaode;
+ }
+
+ public String getNotes() {
+ return notes;
+ }
+
+ public void setNotes(String notes) {
+ this.notes = notes;
+ }
+
+ public String getPhotos() {
+ return photos;
+ }
+
+ public void setPhotos(String photos) {
+ this.photos = photos;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public String getQu() {
+ return qu;
+ }
+
+ public void setQu(String qu) {
+ this.qu = qu;
+ }
+
+ public String getResponsibleDept() {
+ return responsibleDept;
+ }
+
+ public void setResponsibleDept(String responsibleDept) {
+ this.responsibleDept = responsibleDept;
+ }
+
+ public String getResponsibleDeptName() {
+ return responsibleDeptName;
+ }
+
+ public void setResponsibleDeptName(String responsibleDeptName) {
+ this.responsibleDeptName = responsibleDeptName;
+ }
+
+ public String getTs() {
+ return ts;
+ }
+
+ public void setTs(String ts) {
+ this.ts = ts;
+ }
+
+ public String getValid() {
+ return valid;
+ }
+
+ public void setValid(String valid) {
+ this.valid = valid;
+ }
+
+ public String getWellCode() {
+ return wellCode;
+ }
+
+ public void setWellCode(String wellCode) {
+ this.wellCode = wellCode;
+ }
+
+ public String getWellFlag1() {
+ return wellFlag1;
+ }
+
+ public void setWellFlag1(String wellFlag1) {
+ this.wellFlag1 = wellFlag1;
+ }
+
+ public String getWellFlag2() {
+ return wellFlag2;
+ }
+
+ public void setWellFlag2(String wellFlag2) {
+ this.wellFlag2 = wellFlag2;
+ }
+
+ public String getWellFlag3() {
+ return wellFlag3;
+ }
+
+ public void setWellFlag3(String wellFlag3) {
+ this.wellFlag3 = wellFlag3;
+ }
+
+ public String getWellName() {
+ return wellName;
+ }
+
+ public void setWellName(String wellName) {
+ this.wellName = wellName;
+ }
+
+ public String getWellType() {
+ return wellType;
+ }
+
+ public void setWellType(String wellType) {
+ this.wellType = wellType;
+ }
+
+ public String getWellTypeName() {
+ return wellTypeName;
+ }
+
+ public void setWellTypeName(String wellTypeName) {
+ this.wellTypeName = wellTypeName;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt b/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
index d5ac3ec..608dd91 100644
--- a/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
+++ b/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
@@ -22,6 +22,7 @@
* =============================================================================================
* */
const val PERMISSIONS_CODE = 999
+ const val PAGE_LIMIT = 20
/**
* =============================================================================================
diff --git a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt
index 64c5402..f715247 100644
--- a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt
+++ b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt
@@ -69,4 +69,64 @@
*/
@POST("/app/checkVersion")
suspend fun obtainVersionResult(@Header("token") token: String): String
+
+ /**
+ * 获取管盯分页列表
+ * */
+ @GET("/device/list")
+ suspend fun obtainDeviceListByType(
+ @Header("token") token: String,
+ @Query("deptid") deptid: String?,
+ @Query("keywords") keywords: String?,
+ @Query("deviceType") deviceType: String?,
+ @Query("isOnline") isOnline: String?,
+ @Query("sort") sort: String?,
+ @Query("order") order: String?,
+ @Query("offset") offset: Int,
+ @Query("limit") limit: Int
+ ): String
+
+ /**
+ * 获取闸井详情
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/info")
+ suspend fun obtainWellDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 根据部门获取区ID
+ *
+ * @param deptId
+ */
+ @GET("/config/getAreaByDept")
+ suspend fun obtainAreaByDept(
+ @Header("token") token: String,
+ @Query("deptId") deptId: String
+ ): String
+
+ /**
+ * 获取区/县等
+ *
+ * @param pid
+ */
+ @GET("/area/list")
+ suspend fun obtainDistrict(
+ @Header("token") token: String,
+ @Query("pid") pid: String
+ ): String
+
+ /**
+ * 获取街道
+ *
+ * @param pid
+ */
+ @GET("/area/list")
+ suspend fun obtainStreet(
+ @Header("token") token: String,
+ @Query("pid") pid: String
+ ): String
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt
index 2af9a24..d888e59 100644
--- a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt
+++ b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt
@@ -1,6 +1,7 @@
package com.casic.smarttube.utils.retrofit
import com.casic.smarttube.utils.AuthenticationHelper
+import com.casic.smarttube.utils.LocalConstant
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.MultipartBody
import okhttp3.RequestBody
@@ -54,6 +55,46 @@
}
/**
+ * 根据设备类型获取设备分页列表
+ */
+ suspend fun obtainDeviceListByType(
+ deptid: String, keywords: String, isOnline: String, page: Int
+ ): String {
+ return api.obtainDeviceListByType(
+ AuthenticationHelper.token!!, deptid, keywords, "12", isOnline,
+ "id", "asc", page, LocalConstant.PAGE_LIMIT
+ )
+ }
+
+ /**
+ * 获取闸井详情
+ */
+ suspend fun obtainWellDetail(id: String): String {
+ return api.obtainWellDetail(AuthenticationHelper.token!!, id)
+ }
+
+ /**
+ * 根据部门获取区ID
+ */
+ suspend fun obtainAreaByDept(deptId: String): String {
+ return api.obtainAreaByDept(AuthenticationHelper.token!!, deptId)
+ }
+
+ /**
+ * 获取区/县等
+ */
+ suspend fun obtainDistrict(pid: String): String {
+ return api.obtainDistrict(AuthenticationHelper.token!!, pid)
+ }
+
+ /**
+ * 获取街道
+ */
+ suspend fun obtainStreet(pid: String): String {
+ return api.obtainStreet(AuthenticationHelper.token!!, pid)
+ }
+
+ /**
* 上传图片
*/
suspend fun uploadImage(image: File): String {
diff --git a/app/src/main/java/com/casic/smarttube/view/WellDetailActivity.kt b/app/src/main/java/com/casic/smarttube/view/WellDetailActivity.kt
new file mode 100644
index 0000000..457c06f
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/view/WellDetailActivity.kt
@@ -0,0 +1,173 @@
+package com.casic.smarttube.view
+
+import android.os.Bundle
+import androidx.lifecycle.ViewModelProvider
+import com.amap.api.maps.AMap
+import com.amap.api.maps.AMapOptions
+import com.amap.api.maps.CameraUpdateFactory
+import com.amap.api.maps.model.BitmapDescriptorFactory
+import com.amap.api.maps.model.CameraPosition
+import com.amap.api.maps.model.LatLng
+import com.amap.api.maps.model.MarkerOptions
+import com.casic.smarttube.R
+import com.casic.smarttube.utils.DialogHelper
+import com.casic.smarttube.vm.AuthenticateViewModel
+import com.casic.smarttube.vm.WellViewModel
+import com.gyf.immersionbar.ImmersionBar
+import com.pengxh.kt.lite.base.KotlinBaseActivity
+import com.pengxh.kt.lite.extensions.convertColor
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.utils.Constant
+import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil
+import com.pengxh.kt.lite.vm.LoadState
+import kotlinx.android.synthetic.main.activity_well_detail.*
+import kotlinx.android.synthetic.main.include_base_title.*
+
+
+class WellDetailActivity : KotlinBaseActivity(), AMap.OnMapLoadedListener {
+
+ private lateinit var wellViewModel: WellViewModel
+ private lateinit var authenticateViewModel: AuthenticateViewModel
+ private lateinit var wellId: String
+ private lateinit var aMap: AMap
+ private var latLng: LatLng? = null
+
+
+ override fun initLayoutView(): Int = R.layout.activity_well_detail
+
+ override fun setupTopBarLayout() {
+ ImmersionBar.with(this).statusBarDarkFont(false).init()
+ ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this))
+ leftBackView.setOnClickListener { finish() }
+ titleView.text = "井详情"
+ }
+
+ override fun initData() {
+ wellId = intent.getStringExtra(Constant.INTENT_PARAM)!!
+ wellViewModel = ViewModelProvider(this).get(WellViewModel::class.java)
+ authenticateViewModel = ViewModelProvider(this).get(AuthenticateViewModel::class.java)
+
+ aMap = wellMapView.map
+ aMap.mapType = AMap.MAP_TYPE_NORMAL
+ val uiSettings = aMap.uiSettings
+ uiSettings.isCompassEnabled = true
+ uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER
+ uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度
+ uiSettings.isRotateGesturesEnabled = false//不允许地图旋转
+
+ //地图加载成功之后调用
+ aMap.addOnMapLoadedListener(this)
+ }
+
+ override fun onMapLoaded() {
+ if (latLng == null) {
+ "该闸井经纬度异常,无法在地图显示".show(this)
+ return
+ }
+ /**
+ * 参数1---要移动到的经纬度
+ * 参数2---地图的放缩级别zoom
+ * 参数3---地图倾斜度
+ * 参数4---地图的旋转角度
+ * */
+ val cameraPosition = CameraPosition(latLng, 13f, 0f, 0f)
+ val newCameraPosition = CameraUpdateFactory.newCameraPosition(cameraPosition)
+ aMap.animateCamera(newCameraPosition, 3000, object : AMap.CancelableCallback {
+ override fun onFinish() {
+ //添加Marker
+ val markerOptions = MarkerOptions()
+ .position(latLng)
+ .icon(BitmapDescriptorFactory.fromResource(R.mipmap.well_location))
+ .draggable(true)
+ aMap.addMarker(markerOptions)
+ }
+
+ override fun onCancel() {
+
+ }
+ })
+ }
+
+ override fun initEvent() {
+ wellViewModel.obtainWellDetail(wellId)
+ wellViewModel.detailModel.observe(this, {
+ if (it.code == 200) {
+ val wellDetail = it.data!!
+
+ wellNameView.text = wellDetail.wellName
+ wellTypeView.text = wellDetail.wellTypeName
+ wellCodeView.text = wellDetail.wellCode
+ ownerShipView.text = wellDetail.deptName
+ wellStateView.text = wellDetail.bfztName
+ wellDepthView.text = wellDetail.deep.toString()
+ //绑定窨井位置
+ if (wellDetail.latGaode.isBlank() || wellDetail.lngGaode.isBlank()) {
+ wellLocationView.text = wellDetail.position
+ return@observe
+ }
+ this.latLng = LatLng(wellDetail.latGaode.toDouble(), wellDetail.lngGaode.toDouble())
+ authenticateViewModel.obtainAreaByDept(wellDetail.deptid)
+ authenticateViewModel.areaModel.observe(this, { areaModel ->
+ if (areaModel.code == 200) {
+ authenticateViewModel.obtainDistrict(areaModel.data.area)
+ }
+ })
+ authenticateViewModel.districtModel.observe(this, { districtModel ->
+ if (districtModel.code == 200) {
+ districtModel.data.forEach { area ->
+ if (area.id == wellDetail.qu) {
+ authenticateViewModel.obtainStreet(area.id)
+ authenticateViewModel.streetModel.observe(this, { street ->
+ if (street.code == 200) {
+ street.data.forEach { streetData ->
+ if (streetData.id == wellDetail.area) {
+ wellLocationView.text =
+ String.format("${area.name}${streetData.name}-${wellDetail.position}")
+ }
+ }
+ }
+ })
+ }
+ }
+ }
+ })
+ }
+ })
+ wellViewModel.loadState.observe(this, {
+ when (it) {
+ is LoadState.Loading -> {
+ DialogHelper.showLoadingDialog(this, "数据加载中,请稍后")
+ }
+ else -> {
+ DialogHelper.dismissLoadingDialog()
+ }
+ }
+ })
+ }
+
+ /**地图相关*********/
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ wellMapView.onCreate(savedInstanceState)
+ }
+
+ override fun onResume() {
+ super.onResume()
+ wellMapView.onResume()
+ }
+
+ override fun onPause() {
+ super.onPause()
+ wellMapView.onPause()
+ }
+
+ override fun onDestroy() {
+ wellMapView.onDestroy()
+ super.onDestroy()
+ }
+
+ override fun onSaveInstanceState(outState: Bundle) {
+ super.onSaveInstanceState(outState)
+ wellMapView.onSaveInstanceState(outState)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cbc72b6..a9b50c5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,7 +26,7 @@
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
- android:theme="@style/AppTheme"
+ android:theme="@style/QMUI.Compat.NoActionBar"
android:usesCleartextTraffic="true">
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
new file mode 100644
index 0000000..e3c059d
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
@@ -0,0 +1,111 @@
+package com.casic.smarttube.adapter
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+import com.casic.smarttube.R
+import com.casic.smarttube.extensions.arrowAnimation
+import com.casic.smarttube.model.DeviceListModel
+import com.github.mikephil.charting.charts.LineChart
+import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
+
+class DeviceListAdapter(
+ private val context: Context,
+ private val dataRows: MutableList
+) : RecyclerView.Adapter() {
+
+ private var layoutInflater: LayoutInflater = LayoutInflater.from(context)
+ private var isExpand = false
+
+ override fun onCreateViewHolder(
+ parent: ViewGroup, viewType: Int
+ ): DeviceListAdapter.ItemViewHolder {
+ return ItemViewHolder(
+ layoutInflater.inflate(R.layout.item_device_recycleview, parent, false)
+ )
+ }
+
+ override fun getItemCount(): Int = dataRows.size
+
+ override fun onBindViewHolder(holder: DeviceListAdapter.ItemViewHolder, position: Int) {
+ //绑定数据
+ val rowsBean = dataRows[position]
+ holder.deviceStateView.text = rowsBean.onlineStateName
+ if (rowsBean.onlineState == "1") {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_green_radius_5)
+ } else {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_gray_radius_5)
+ }
+ holder.deviceCodeView.text = rowsBean.devcode
+ holder.wellCodeView.text = String.format("井编号:${rowsBean.wellCode}")
+ holder.ownerShipView.text = String.format("权属单位:${rowsBean.deptName}")
+ holder.deviceLocationView.text = String.format("设备位置:${rowsBean.position}")
+ holder.installDateView.text = String.format("安装日期:${rowsBean.installDate}")
+
+
+ if (listener != null) {
+ holder.itemView.setOnClickListener {
+ listener!!.onClicked(position)
+ }
+ holder.dataHistoryButton.setOnClickListener {
+ listener!!.onHistoryClicked(position)
+ }
+ holder.editButton.setOnClickListener {
+ listener!!.onEditClicked(position)
+ }
+ holder.wellDetailButton.setOnClickListener {
+ listener!!.onWellDetailClicked(position)
+ }
+
+ holder.expandableImageView.setOnClickListener {
+ if (!isExpand) {
+ //展开列表动画
+ holder.expandableImageView.arrowAnimation(180f)
+ isExpand = true
+ //子列表绑定数据
+// expandableViewAdapter.setExpandableData(createExpandableList(rowsBean))
+ } else {
+ //关闭列表动画
+ holder.expandableImageView.arrowAnimation(0f)
+ isExpand = false
+ //子列表清空数据
+// expandableViewAdapter.clearAll()
+ }
+ }
+ }
+ }
+
+ inner class ItemViewHolder(view: View) : RecyclerView.ViewHolder(view) {
+ var deviceStateView: TextView = view.findViewById(R.id.deviceStateView)
+ var deviceCodeView: TextView = view.findViewById(R.id.deviceCodeView)
+ var expandableImageView: ImageView = view.findViewById(R.id.expandableImageView)
+ var wellCodeView: TextView = view.findViewById(R.id.wellCodeView)
+ var ownerShipView: TextView = view.findViewById(R.id.ownerShipView)
+ var deviceLocationView: TextView = view.findViewById(R.id.deviceLocationView)
+ var installDateView: TextView = view.findViewById(R.id.installDateView)
+ var dataHistoryButton: QMUIRoundButton = view.findViewById(R.id.dataHistoryButton)
+ var editButton: QMUIRoundButton = view.findViewById(R.id.editButton)
+ var wellDetailButton: QMUIRoundButton = view.findViewById(R.id.wellDetailButton)
+ var expandableChartView: LineChart = view.findViewById(R.id.expandableChartView)
+ }
+
+ private var listener: OnItemClickListener? = null
+
+ interface OnItemClickListener {
+ fun onClicked(position: Int)
+
+ fun onHistoryClicked(position: Int)
+
+ fun onEditClicked(position: Int)
+
+ fun onWellDetailClicked(position: Int)
+ }
+
+ fun setOnItemClickListener(onClickListener: OnItemClickListener?) {
+ this.listener = onClickListener
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
new file mode 100644
index 0000000..d185752
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
@@ -0,0 +1,11 @@
+package com.casic.smarttube.extensions
+
+import android.view.animation.LinearInterpolator
+import android.widget.ImageView
+
+fun ImageView.arrowAnimation(angle: Float) {
+ val animation = this.animate()
+ animation.duration = 300
+ animation.interpolator = LinearInterpolator()
+ animation.rotation(angle)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
new file mode 100644
index 0000000..22e56d2
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
@@ -0,0 +1,12 @@
+package com.casic.smarttube.extensions
+
+import android.view.View
+import com.qmuiteam.qmui.widget.QMUIEmptyView
+
+fun QMUIEmptyView.showEmptyPage(onButtonClickListener: View.OnClickListener) {
+ this.show(false, "抱歉,无法查询到相关记录", null, "重试", onButtonClickListener)
+}
+
+fun QMUIEmptyView.showEmptyPage(title: String, onButtonClickListener: View.OnClickListener) {
+ this.show(false, title, null, "刷新", onButtonClickListener)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
index 16d7e5c..1ef9226 100644
--- a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
+++ b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
@@ -1,10 +1,31 @@
package com.casic.smarttube.fragment
+import android.os.Handler
+import androidx.lifecycle.ViewModelProvider
+import androidx.recyclerview.widget.LinearLayoutManager
import com.casic.smarttube.R
+import com.casic.smarttube.adapter.DeviceListAdapter
+import com.casic.smarttube.extensions.showEmptyPage
+import com.casic.smarttube.model.DeviceListModel
+import com.casic.smarttube.view.WellDetailActivity
+import com.casic.smarttube.vm.DeviceViewModel
import com.pengxh.kt.lite.base.KotlinBaseFragment
+import com.pengxh.kt.lite.extensions.navigatePageTo
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.utils.WeakReferenceHandler
+import kotlinx.android.synthetic.main.fragment_overview.*
+import kotlinx.android.synthetic.main.include_empty_view.*
class OverviewFragment : KotlinBaseFragment() {
+ private lateinit var weakReferenceHandler: WeakReferenceHandler
+ private lateinit var deviceViewModel: DeviceViewModel
+ private lateinit var deviceAdapter: DeviceListAdapter
+ private var dataBeans: MutableList = ArrayList()
+ private var pageIndex = 1
+ private var isRefresh = false
+ private var isLoadMore = false
+
override fun initLayoutView(): Int = R.layout.fragment_overview
override fun setupTopBarLayout() {
@@ -12,10 +33,101 @@
}
override fun initData() {
+ weakReferenceHandler = WeakReferenceHandler(callback)
+ deviceViewModel = ViewModelProvider(this).get(DeviceViewModel::class.java)
+ }
+ override fun onResume() {
+ //默认加载第一页
+ obtainDeviceList()
+ super.onResume()
}
override fun initEvent() {
+ overviewLayout.setOnRefreshListener {
+ isRefresh = true
+ //刷新之后页码重置
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ overviewLayout.setOnLoadMoreListener {
+ isLoadMore = true
+ pageIndex++
+ obtainDeviceList()
+ }
+ deviceViewModel.deviceListModel.observe(this, {
+ if (it.code == 200) {
+ val dataRows = it.data?.rows
+ when {
+ isRefresh -> {
+ dataBeans.clear()
+ dataBeans = dataRows!!
+ overviewLayout.finishRefresh()
+ isRefresh = false
+ }
+ isLoadMore -> {
+ if (dataRows?.size == 0) {
+ "到底了,别拉了".show(requireContext())
+ }
+ dataBeans.addAll(dataRows!!)
+ overviewLayout.finishLoadMore()
+ isLoadMore = false
+ }
+ else -> {
+ dataBeans = dataRows!!
+ }
+ }
+ weakReferenceHandler.sendEmptyMessage(2022062401)
+ }
+ })
+ }
+
+ private fun obtainDeviceList() {
+ deviceViewModel.obtainDeviceListByType("", "", "", pageIndex)
+ }
+
+ private val callback = Handler.Callback {
+ if (it.what == 2022062401) {
+ if (isRefresh || isLoadMore) {
+ deviceAdapter.notifyDataSetChanged()
+ } else {
+ if (dataBeans.size == 0) {
+ emptyView!!.showEmptyPage("这里什么都没有") {
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ } else {
+ emptyView!!.hide()
+ deviceAdapter = DeviceListAdapter(requireContext(), dataBeans)
+ recyclerView!!.layoutManager = LinearLayoutManager(requireContext())
+ recyclerView!!.adapter = deviceAdapter
+ deviceAdapter.setOnItemClickListener(object :
+ DeviceListAdapter.OnItemClickListener {
+ override fun onClicked(position: Int) {
+// val jobId = dataBeans[position].jobId.toString()
+// if (jobId.isBlank()) {
+// "设备编号异常,无法查看详情".show(requireContext())
+// return
+// }
+// requireContext().navigatePageTo(jobId)
+ }
+
+ override fun onHistoryClicked(position: Int) {
+
+ }
+
+ override fun onEditClicked(position: Int) {
+
+ }
+
+ override fun onWellDetailClicked(position: Int) {
+ requireContext().navigatePageTo(dataBeans[position].wellId)
+ }
+ })
+ }
+ }
+ }
+ true
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/model/AreaModel.java b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
new file mode 100644
index 0000000..c6f86ef
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
@@ -0,0 +1,125 @@
+package com.casic.smarttube.model;
+
+public class AreaModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String area;
+ private String communications;
+ private String deptid;
+ private String deviceTypes;
+ private String id;
+ private String lat;
+ private String lng;
+ private String map;
+ private String wellTypes;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getCommunications() {
+ return communications;
+ }
+
+ public void setCommunications(String communications) {
+ this.communications = communications;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDeviceTypes() {
+ return deviceTypes;
+ }
+
+ public void setDeviceTypes(String deviceTypes) {
+ this.deviceTypes = deviceTypes;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getMap() {
+ return map;
+ }
+
+ public void setMap(String map) {
+ this.map = map;
+ }
+
+ public String getWellTypes() {
+ return wellTypes;
+ }
+
+ public void setWellTypes(String wellTypes) {
+ this.wellTypes = wellTypes;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
new file mode 100644
index 0000000..b34eb55
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
@@ -0,0 +1,274 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DeviceListModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private List rows;
+ private int total;
+
+ public List getRows() {
+ return rows;
+ }
+
+ public void setRows(List rows) {
+ this.rows = rows;
+ }
+
+ public int getTotal() {
+ return total;
+ }
+
+ public void setTotal(int total) {
+ this.total = total;
+ }
+
+ public static class RowsBean {
+ private String bfzt;
+ private String bfztName;
+ private String communication;
+ private String concenCode;
+ private String concenId;
+ private String deptName;
+ private String deptid;
+ private String devcode;
+ private String deviceName;
+ private String deviceType;
+ private String deviceTypeName;
+ private String id;
+ private String installDate;
+ private String modelId;
+ private String modelName;
+ private String onlineState;
+ private String onlineStateName;
+ private String position;
+ private String ts;
+ private String valid;
+ private String watchType;
+ private String wellCode;
+ private String wellId;
+
+ public String getBfzt() {
+ return bfzt;
+ }
+
+ public void setBfzt(String bfzt) {
+ this.bfzt = bfzt;
+ }
+
+ public String getBfztName() {
+ return bfztName;
+ }
+
+ public void setBfztName(String bfztName) {
+ this.bfztName = bfztName;
+ }
+
+ public String getCommunication() {
+ return communication;
+ }
+
+ public void setCommunication(String communication) {
+ this.communication = communication;
+ }
+
+ public String getConcenCode() {
+ return concenCode;
+ }
+
+ public void setConcenCode(String concenCode) {
+ this.concenCode = concenCode;
+ }
+
+ public String getConcenId() {
+ return concenId;
+ }
+
+ public void setConcenId(String concenId) {
+ this.concenId = concenId;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDevcode() {
+ return devcode;
+ }
+
+ public void setDevcode(String devcode) {
+ this.devcode = devcode;
+ }
+
+ public String getDeviceName() {
+ return deviceName;
+ }
+
+ public void setDeviceName(String deviceName) {
+ this.deviceName = deviceName;
+ }
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getDeviceTypeName() {
+ return deviceTypeName;
+ }
+
+ public void setDeviceTypeName(String deviceTypeName) {
+ this.deviceTypeName = deviceTypeName;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getInstallDate() {
+ return installDate;
+ }
+
+ public void setInstallDate(String installDate) {
+ this.installDate = installDate;
+ }
+
+ public String getModelId() {
+ return modelId;
+ }
+
+ public void setModelId(String modelId) {
+ this.modelId = modelId;
+ }
+
+ public String getModelName() {
+ return modelName;
+ }
+
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getOnlineState() {
+ return onlineState;
+ }
+
+ public void setOnlineState(String onlineState) {
+ this.onlineState = onlineState;
+ }
+
+ public String getOnlineStateName() {
+ return onlineStateName;
+ }
+
+ public void setOnlineStateName(String onlineStateName) {
+ this.onlineStateName = onlineStateName;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public String getTs() {
+ return ts;
+ }
+
+ public void setTs(String ts) {
+ this.ts = ts;
+ }
+
+ public String getValid() {
+ return valid;
+ }
+
+ public void setValid(String valid) {
+ this.valid = valid;
+ }
+
+ public String getWatchType() {
+ return watchType;
+ }
+
+ public void setWatchType(String watchType) {
+ this.watchType = watchType;
+ }
+
+ public String getWellCode() {
+ return wellCode;
+ }
+
+ public void setWellCode(String wellCode) {
+ this.wellCode = wellCode;
+ }
+
+ public String getWellId() {
+ return wellId;
+ }
+
+ public void setWellId(String wellId) {
+ this.wellId = wellId;
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DistrictModel.java b/app/src/main/java/com/casic/smarttube/model/DistrictModel.java
new file mode 100644
index 0000000..437405f
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DistrictModel.java
@@ -0,0 +1,172 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DistrictModel {
+
+ private int code;
+ private List data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String id;
+ private String isSync;
+ private String lat;
+ private int level;
+ private String levelName;
+ private String lng;
+ private String name;
+ private int num;
+ private String pName;
+ private String pid;
+ private String pids;
+ private String simplename;
+ private String targetIdSync;
+ private String targetPidSync;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getIsSync() {
+ return isSync;
+ }
+
+ public void setIsSync(String isSync) {
+ this.isSync = isSync;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+
+ public String getLevelName() {
+ return levelName;
+ }
+
+ public void setLevelName(String levelName) {
+ this.levelName = levelName;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public String getPName() {
+ return pName;
+ }
+
+ public void setPName(String pName) {
+ this.pName = pName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getPids() {
+ return pids;
+ }
+
+ public void setPids(String pids) {
+ this.pids = pids;
+ }
+
+ public String getSimplename() {
+ return simplename;
+ }
+
+ public void setSimplename(String simplename) {
+ this.simplename = simplename;
+ }
+
+ public String getTargetIdSync() {
+ return targetIdSync;
+ }
+
+ public void setTargetIdSync(String targetIdSync) {
+ this.targetIdSync = targetIdSync;
+ }
+
+ public String getTargetPidSync() {
+ return targetPidSync;
+ }
+
+ public void setTargetPidSync(String targetPidSync) {
+ this.targetPidSync = targetPidSync;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/StreetModel.java b/app/src/main/java/com/casic/smarttube/model/StreetModel.java
new file mode 100644
index 0000000..57fa295
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/StreetModel.java
@@ -0,0 +1,172 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class StreetModel {
+
+ private int code;
+ private List data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String id;
+ private String isSync;
+ private String lat;
+ private int level;
+ private String levelName;
+ private String lng;
+ private String name;
+ private int num;
+ private String pName;
+ private String pid;
+ private String pids;
+ private String simplename;
+ private String targetIdSync;
+ private String targetPidSync;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getIsSync() {
+ return isSync;
+ }
+
+ public void setIsSync(String isSync) {
+ this.isSync = isSync;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+
+ public String getLevelName() {
+ return levelName;
+ }
+
+ public void setLevelName(String levelName) {
+ this.levelName = levelName;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public String getPName() {
+ return pName;
+ }
+
+ public void setPName(String pName) {
+ this.pName = pName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getPids() {
+ return pids;
+ }
+
+ public void setPids(String pids) {
+ this.pids = pids;
+ }
+
+ public String getSimplename() {
+ return simplename;
+ }
+
+ public void setSimplename(String simplename) {
+ this.simplename = simplename;
+ }
+
+ public String getTargetIdSync() {
+ return targetIdSync;
+ }
+
+ public void setTargetIdSync(String targetIdSync) {
+ this.targetIdSync = targetIdSync;
+ }
+
+ public String getTargetPidSync() {
+ return targetPidSync;
+ }
+
+ public void setTargetPidSync(String targetPidSync) {
+ this.targetPidSync = targetPidSync;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java b/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java
new file mode 100644
index 0000000..c19899a
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java
@@ -0,0 +1,305 @@
+package com.casic.smarttube.model;
+
+public class WellDetailModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String area;
+ private String bfzt;
+ private String bfztName;
+ private String coordinateX;
+ private String coordinateY;
+ private int deep;
+ private String deptName;
+ private String deptid;
+ private String deviceCount;
+ private String id;
+ private String latBaidu;
+ private String latGaode;
+ private String lngBaidu;
+ private String lngGaode;
+ private String notes;
+ private String photos;
+ private String position;
+ private String qu;
+ private String responsibleDept;
+ private String responsibleDeptName;
+ private String ts;
+ private String valid;
+ private String wellCode;
+ private String wellFlag1;
+ private String wellFlag2;
+ private String wellFlag3;
+ private String wellName;
+ private String wellType;
+ private String wellTypeName;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getBfzt() {
+ return bfzt;
+ }
+
+ public void setBfzt(String bfzt) {
+ this.bfzt = bfzt;
+ }
+
+ public String getBfztName() {
+ return bfztName;
+ }
+
+ public void setBfztName(String bfztName) {
+ this.bfztName = bfztName;
+ }
+
+ public String getCoordinateX() {
+ return coordinateX;
+ }
+
+ public void setCoordinateX(String coordinateX) {
+ this.coordinateX = coordinateX;
+ }
+
+ public String getCoordinateY() {
+ return coordinateY;
+ }
+
+ public void setCoordinateY(String coordinateY) {
+ this.coordinateY = coordinateY;
+ }
+
+ public int getDeep() {
+ return deep;
+ }
+
+ public void setDeep(int deep) {
+ this.deep = deep;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDeviceCount() {
+ return deviceCount;
+ }
+
+ public void setDeviceCount(String deviceCount) {
+ this.deviceCount = deviceCount;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLatBaidu() {
+ return latBaidu;
+ }
+
+ public void setLatBaidu(String latBaidu) {
+ this.latBaidu = latBaidu;
+ }
+
+ public String getLatGaode() {
+ return latGaode;
+ }
+
+ public void setLatGaode(String latGaode) {
+ this.latGaode = latGaode;
+ }
+
+ public String getLngBaidu() {
+ return lngBaidu;
+ }
+
+ public void setLngBaidu(String lngBaidu) {
+ this.lngBaidu = lngBaidu;
+ }
+
+ public String getLngGaode() {
+ return lngGaode;
+ }
+
+ public void setLngGaode(String lngGaode) {
+ this.lngGaode = lngGaode;
+ }
+
+ public String getNotes() {
+ return notes;
+ }
+
+ public void setNotes(String notes) {
+ this.notes = notes;
+ }
+
+ public String getPhotos() {
+ return photos;
+ }
+
+ public void setPhotos(String photos) {
+ this.photos = photos;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public String getQu() {
+ return qu;
+ }
+
+ public void setQu(String qu) {
+ this.qu = qu;
+ }
+
+ public String getResponsibleDept() {
+ return responsibleDept;
+ }
+
+ public void setResponsibleDept(String responsibleDept) {
+ this.responsibleDept = responsibleDept;
+ }
+
+ public String getResponsibleDeptName() {
+ return responsibleDeptName;
+ }
+
+ public void setResponsibleDeptName(String responsibleDeptName) {
+ this.responsibleDeptName = responsibleDeptName;
+ }
+
+ public String getTs() {
+ return ts;
+ }
+
+ public void setTs(String ts) {
+ this.ts = ts;
+ }
+
+ public String getValid() {
+ return valid;
+ }
+
+ public void setValid(String valid) {
+ this.valid = valid;
+ }
+
+ public String getWellCode() {
+ return wellCode;
+ }
+
+ public void setWellCode(String wellCode) {
+ this.wellCode = wellCode;
+ }
+
+ public String getWellFlag1() {
+ return wellFlag1;
+ }
+
+ public void setWellFlag1(String wellFlag1) {
+ this.wellFlag1 = wellFlag1;
+ }
+
+ public String getWellFlag2() {
+ return wellFlag2;
+ }
+
+ public void setWellFlag2(String wellFlag2) {
+ this.wellFlag2 = wellFlag2;
+ }
+
+ public String getWellFlag3() {
+ return wellFlag3;
+ }
+
+ public void setWellFlag3(String wellFlag3) {
+ this.wellFlag3 = wellFlag3;
+ }
+
+ public String getWellName() {
+ return wellName;
+ }
+
+ public void setWellName(String wellName) {
+ this.wellName = wellName;
+ }
+
+ public String getWellType() {
+ return wellType;
+ }
+
+ public void setWellType(String wellType) {
+ this.wellType = wellType;
+ }
+
+ public String getWellTypeName() {
+ return wellTypeName;
+ }
+
+ public void setWellTypeName(String wellTypeName) {
+ this.wellTypeName = wellTypeName;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt b/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
index d5ac3ec..608dd91 100644
--- a/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
+++ b/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
@@ -22,6 +22,7 @@
* =============================================================================================
* */
const val PERMISSIONS_CODE = 999
+ const val PAGE_LIMIT = 20
/**
* =============================================================================================
diff --git a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt
index 64c5402..f715247 100644
--- a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt
+++ b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt
@@ -69,4 +69,64 @@
*/
@POST("/app/checkVersion")
suspend fun obtainVersionResult(@Header("token") token: String): String
+
+ /**
+ * 获取管盯分页列表
+ * */
+ @GET("/device/list")
+ suspend fun obtainDeviceListByType(
+ @Header("token") token: String,
+ @Query("deptid") deptid: String?,
+ @Query("keywords") keywords: String?,
+ @Query("deviceType") deviceType: String?,
+ @Query("isOnline") isOnline: String?,
+ @Query("sort") sort: String?,
+ @Query("order") order: String?,
+ @Query("offset") offset: Int,
+ @Query("limit") limit: Int
+ ): String
+
+ /**
+ * 获取闸井详情
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/info")
+ suspend fun obtainWellDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 根据部门获取区ID
+ *
+ * @param deptId
+ */
+ @GET("/config/getAreaByDept")
+ suspend fun obtainAreaByDept(
+ @Header("token") token: String,
+ @Query("deptId") deptId: String
+ ): String
+
+ /**
+ * 获取区/县等
+ *
+ * @param pid
+ */
+ @GET("/area/list")
+ suspend fun obtainDistrict(
+ @Header("token") token: String,
+ @Query("pid") pid: String
+ ): String
+
+ /**
+ * 获取街道
+ *
+ * @param pid
+ */
+ @GET("/area/list")
+ suspend fun obtainStreet(
+ @Header("token") token: String,
+ @Query("pid") pid: String
+ ): String
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt
index 2af9a24..d888e59 100644
--- a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt
+++ b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt
@@ -1,6 +1,7 @@
package com.casic.smarttube.utils.retrofit
import com.casic.smarttube.utils.AuthenticationHelper
+import com.casic.smarttube.utils.LocalConstant
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.MultipartBody
import okhttp3.RequestBody
@@ -54,6 +55,46 @@
}
/**
+ * 根据设备类型获取设备分页列表
+ */
+ suspend fun obtainDeviceListByType(
+ deptid: String, keywords: String, isOnline: String, page: Int
+ ): String {
+ return api.obtainDeviceListByType(
+ AuthenticationHelper.token!!, deptid, keywords, "12", isOnline,
+ "id", "asc", page, LocalConstant.PAGE_LIMIT
+ )
+ }
+
+ /**
+ * 获取闸井详情
+ */
+ suspend fun obtainWellDetail(id: String): String {
+ return api.obtainWellDetail(AuthenticationHelper.token!!, id)
+ }
+
+ /**
+ * 根据部门获取区ID
+ */
+ suspend fun obtainAreaByDept(deptId: String): String {
+ return api.obtainAreaByDept(AuthenticationHelper.token!!, deptId)
+ }
+
+ /**
+ * 获取区/县等
+ */
+ suspend fun obtainDistrict(pid: String): String {
+ return api.obtainDistrict(AuthenticationHelper.token!!, pid)
+ }
+
+ /**
+ * 获取街道
+ */
+ suspend fun obtainStreet(pid: String): String {
+ return api.obtainStreet(AuthenticationHelper.token!!, pid)
+ }
+
+ /**
* 上传图片
*/
suspend fun uploadImage(image: File): String {
diff --git a/app/src/main/java/com/casic/smarttube/view/WellDetailActivity.kt b/app/src/main/java/com/casic/smarttube/view/WellDetailActivity.kt
new file mode 100644
index 0000000..457c06f
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/view/WellDetailActivity.kt
@@ -0,0 +1,173 @@
+package com.casic.smarttube.view
+
+import android.os.Bundle
+import androidx.lifecycle.ViewModelProvider
+import com.amap.api.maps.AMap
+import com.amap.api.maps.AMapOptions
+import com.amap.api.maps.CameraUpdateFactory
+import com.amap.api.maps.model.BitmapDescriptorFactory
+import com.amap.api.maps.model.CameraPosition
+import com.amap.api.maps.model.LatLng
+import com.amap.api.maps.model.MarkerOptions
+import com.casic.smarttube.R
+import com.casic.smarttube.utils.DialogHelper
+import com.casic.smarttube.vm.AuthenticateViewModel
+import com.casic.smarttube.vm.WellViewModel
+import com.gyf.immersionbar.ImmersionBar
+import com.pengxh.kt.lite.base.KotlinBaseActivity
+import com.pengxh.kt.lite.extensions.convertColor
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.utils.Constant
+import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil
+import com.pengxh.kt.lite.vm.LoadState
+import kotlinx.android.synthetic.main.activity_well_detail.*
+import kotlinx.android.synthetic.main.include_base_title.*
+
+
+class WellDetailActivity : KotlinBaseActivity(), AMap.OnMapLoadedListener {
+
+ private lateinit var wellViewModel: WellViewModel
+ private lateinit var authenticateViewModel: AuthenticateViewModel
+ private lateinit var wellId: String
+ private lateinit var aMap: AMap
+ private var latLng: LatLng? = null
+
+
+ override fun initLayoutView(): Int = R.layout.activity_well_detail
+
+ override fun setupTopBarLayout() {
+ ImmersionBar.with(this).statusBarDarkFont(false).init()
+ ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this))
+ leftBackView.setOnClickListener { finish() }
+ titleView.text = "井详情"
+ }
+
+ override fun initData() {
+ wellId = intent.getStringExtra(Constant.INTENT_PARAM)!!
+ wellViewModel = ViewModelProvider(this).get(WellViewModel::class.java)
+ authenticateViewModel = ViewModelProvider(this).get(AuthenticateViewModel::class.java)
+
+ aMap = wellMapView.map
+ aMap.mapType = AMap.MAP_TYPE_NORMAL
+ val uiSettings = aMap.uiSettings
+ uiSettings.isCompassEnabled = true
+ uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER
+ uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度
+ uiSettings.isRotateGesturesEnabled = false//不允许地图旋转
+
+ //地图加载成功之后调用
+ aMap.addOnMapLoadedListener(this)
+ }
+
+ override fun onMapLoaded() {
+ if (latLng == null) {
+ "该闸井经纬度异常,无法在地图显示".show(this)
+ return
+ }
+ /**
+ * 参数1---要移动到的经纬度
+ * 参数2---地图的放缩级别zoom
+ * 参数3---地图倾斜度
+ * 参数4---地图的旋转角度
+ * */
+ val cameraPosition = CameraPosition(latLng, 13f, 0f, 0f)
+ val newCameraPosition = CameraUpdateFactory.newCameraPosition(cameraPosition)
+ aMap.animateCamera(newCameraPosition, 3000, object : AMap.CancelableCallback {
+ override fun onFinish() {
+ //添加Marker
+ val markerOptions = MarkerOptions()
+ .position(latLng)
+ .icon(BitmapDescriptorFactory.fromResource(R.mipmap.well_location))
+ .draggable(true)
+ aMap.addMarker(markerOptions)
+ }
+
+ override fun onCancel() {
+
+ }
+ })
+ }
+
+ override fun initEvent() {
+ wellViewModel.obtainWellDetail(wellId)
+ wellViewModel.detailModel.observe(this, {
+ if (it.code == 200) {
+ val wellDetail = it.data!!
+
+ wellNameView.text = wellDetail.wellName
+ wellTypeView.text = wellDetail.wellTypeName
+ wellCodeView.text = wellDetail.wellCode
+ ownerShipView.text = wellDetail.deptName
+ wellStateView.text = wellDetail.bfztName
+ wellDepthView.text = wellDetail.deep.toString()
+ //绑定窨井位置
+ if (wellDetail.latGaode.isBlank() || wellDetail.lngGaode.isBlank()) {
+ wellLocationView.text = wellDetail.position
+ return@observe
+ }
+ this.latLng = LatLng(wellDetail.latGaode.toDouble(), wellDetail.lngGaode.toDouble())
+ authenticateViewModel.obtainAreaByDept(wellDetail.deptid)
+ authenticateViewModel.areaModel.observe(this, { areaModel ->
+ if (areaModel.code == 200) {
+ authenticateViewModel.obtainDistrict(areaModel.data.area)
+ }
+ })
+ authenticateViewModel.districtModel.observe(this, { districtModel ->
+ if (districtModel.code == 200) {
+ districtModel.data.forEach { area ->
+ if (area.id == wellDetail.qu) {
+ authenticateViewModel.obtainStreet(area.id)
+ authenticateViewModel.streetModel.observe(this, { street ->
+ if (street.code == 200) {
+ street.data.forEach { streetData ->
+ if (streetData.id == wellDetail.area) {
+ wellLocationView.text =
+ String.format("${area.name}${streetData.name}-${wellDetail.position}")
+ }
+ }
+ }
+ })
+ }
+ }
+ }
+ })
+ }
+ })
+ wellViewModel.loadState.observe(this, {
+ when (it) {
+ is LoadState.Loading -> {
+ DialogHelper.showLoadingDialog(this, "数据加载中,请稍后")
+ }
+ else -> {
+ DialogHelper.dismissLoadingDialog()
+ }
+ }
+ })
+ }
+
+ /**地图相关*********/
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ wellMapView.onCreate(savedInstanceState)
+ }
+
+ override fun onResume() {
+ super.onResume()
+ wellMapView.onResume()
+ }
+
+ override fun onPause() {
+ super.onPause()
+ wellMapView.onPause()
+ }
+
+ override fun onDestroy() {
+ wellMapView.onDestroy()
+ super.onDestroy()
+ }
+
+ override fun onSaveInstanceState(outState: Bundle) {
+ super.onSaveInstanceState(outState)
+ wellMapView.onSaveInstanceState(outState)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/vm/AuthenticateViewModel.kt b/app/src/main/java/com/casic/smarttube/vm/AuthenticateViewModel.kt
index 7ad6379..882fea2 100644
--- a/app/src/main/java/com/casic/smarttube/vm/AuthenticateViewModel.kt
+++ b/app/src/main/java/com/casic/smarttube/vm/AuthenticateViewModel.kt
@@ -4,7 +4,10 @@
import com.casic.smarttube.base.BaseApplication
import com.casic.smarttube.extensions.separateResponseCode
import com.casic.smarttube.extensions.toErrorMessage
+import com.casic.smarttube.model.AreaModel
+import com.casic.smarttube.model.DistrictModel
import com.casic.smarttube.model.PublicKeyModel
+import com.casic.smarttube.model.StreetModel
import com.casic.smarttube.utils.retrofit.RetrofitServiceManager
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
@@ -16,6 +19,9 @@
private val gson = Gson()
val keyModel = MutableLiveData()
+ val areaModel = MutableLiveData()
+ val districtModel = MutableLiveData()
+ val streetModel = MutableLiveData()
fun obtainPublicKey() = launch({
val response = RetrofitServiceManager.authenticate()
@@ -30,4 +36,55 @@
}, {
it.printStackTrace()
})
+
+ /**
+ * 根据部门获取区ID
+ */
+ fun obtainAreaByDept(deptId: String) = launch({
+ val response = RetrofitServiceManager.obtainAreaByDept(deptId)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ areaModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ response.toErrorMessage().show(BaseApplication.obtainInstance())
+ }
+ }, {
+ it.printStackTrace()
+ })
+
+ /**
+ * 区/县等
+ */
+ fun obtainDistrict(pid: String) = launch({
+ val response = RetrofitServiceManager.obtainDistrict(pid)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ districtModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ response.toErrorMessage().show(BaseApplication.obtainInstance())
+ }
+ }, {
+ it.printStackTrace()
+ })
+
+ /**
+ * 街道
+ */
+ fun obtainStreet(areaId: String) = launch({
+ val response = RetrofitServiceManager.obtainStreet(areaId)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ streetModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ response.toErrorMessage().show(BaseApplication.obtainInstance())
+ }
+ }, {
+ it.printStackTrace()
+ })
}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cbc72b6..a9b50c5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,7 +26,7 @@
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
- android:theme="@style/AppTheme"
+ android:theme="@style/QMUI.Compat.NoActionBar"
android:usesCleartextTraffic="true">
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
new file mode 100644
index 0000000..e3c059d
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
@@ -0,0 +1,111 @@
+package com.casic.smarttube.adapter
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+import com.casic.smarttube.R
+import com.casic.smarttube.extensions.arrowAnimation
+import com.casic.smarttube.model.DeviceListModel
+import com.github.mikephil.charting.charts.LineChart
+import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
+
+class DeviceListAdapter(
+ private val context: Context,
+ private val dataRows: MutableList
+) : RecyclerView.Adapter() {
+
+ private var layoutInflater: LayoutInflater = LayoutInflater.from(context)
+ private var isExpand = false
+
+ override fun onCreateViewHolder(
+ parent: ViewGroup, viewType: Int
+ ): DeviceListAdapter.ItemViewHolder {
+ return ItemViewHolder(
+ layoutInflater.inflate(R.layout.item_device_recycleview, parent, false)
+ )
+ }
+
+ override fun getItemCount(): Int = dataRows.size
+
+ override fun onBindViewHolder(holder: DeviceListAdapter.ItemViewHolder, position: Int) {
+ //绑定数据
+ val rowsBean = dataRows[position]
+ holder.deviceStateView.text = rowsBean.onlineStateName
+ if (rowsBean.onlineState == "1") {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_green_radius_5)
+ } else {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_gray_radius_5)
+ }
+ holder.deviceCodeView.text = rowsBean.devcode
+ holder.wellCodeView.text = String.format("井编号:${rowsBean.wellCode}")
+ holder.ownerShipView.text = String.format("权属单位:${rowsBean.deptName}")
+ holder.deviceLocationView.text = String.format("设备位置:${rowsBean.position}")
+ holder.installDateView.text = String.format("安装日期:${rowsBean.installDate}")
+
+
+ if (listener != null) {
+ holder.itemView.setOnClickListener {
+ listener!!.onClicked(position)
+ }
+ holder.dataHistoryButton.setOnClickListener {
+ listener!!.onHistoryClicked(position)
+ }
+ holder.editButton.setOnClickListener {
+ listener!!.onEditClicked(position)
+ }
+ holder.wellDetailButton.setOnClickListener {
+ listener!!.onWellDetailClicked(position)
+ }
+
+ holder.expandableImageView.setOnClickListener {
+ if (!isExpand) {
+ //展开列表动画
+ holder.expandableImageView.arrowAnimation(180f)
+ isExpand = true
+ //子列表绑定数据
+// expandableViewAdapter.setExpandableData(createExpandableList(rowsBean))
+ } else {
+ //关闭列表动画
+ holder.expandableImageView.arrowAnimation(0f)
+ isExpand = false
+ //子列表清空数据
+// expandableViewAdapter.clearAll()
+ }
+ }
+ }
+ }
+
+ inner class ItemViewHolder(view: View) : RecyclerView.ViewHolder(view) {
+ var deviceStateView: TextView = view.findViewById(R.id.deviceStateView)
+ var deviceCodeView: TextView = view.findViewById(R.id.deviceCodeView)
+ var expandableImageView: ImageView = view.findViewById(R.id.expandableImageView)
+ var wellCodeView: TextView = view.findViewById(R.id.wellCodeView)
+ var ownerShipView: TextView = view.findViewById(R.id.ownerShipView)
+ var deviceLocationView: TextView = view.findViewById(R.id.deviceLocationView)
+ var installDateView: TextView = view.findViewById(R.id.installDateView)
+ var dataHistoryButton: QMUIRoundButton = view.findViewById(R.id.dataHistoryButton)
+ var editButton: QMUIRoundButton = view.findViewById(R.id.editButton)
+ var wellDetailButton: QMUIRoundButton = view.findViewById(R.id.wellDetailButton)
+ var expandableChartView: LineChart = view.findViewById(R.id.expandableChartView)
+ }
+
+ private var listener: OnItemClickListener? = null
+
+ interface OnItemClickListener {
+ fun onClicked(position: Int)
+
+ fun onHistoryClicked(position: Int)
+
+ fun onEditClicked(position: Int)
+
+ fun onWellDetailClicked(position: Int)
+ }
+
+ fun setOnItemClickListener(onClickListener: OnItemClickListener?) {
+ this.listener = onClickListener
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
new file mode 100644
index 0000000..d185752
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
@@ -0,0 +1,11 @@
+package com.casic.smarttube.extensions
+
+import android.view.animation.LinearInterpolator
+import android.widget.ImageView
+
+fun ImageView.arrowAnimation(angle: Float) {
+ val animation = this.animate()
+ animation.duration = 300
+ animation.interpolator = LinearInterpolator()
+ animation.rotation(angle)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
new file mode 100644
index 0000000..22e56d2
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
@@ -0,0 +1,12 @@
+package com.casic.smarttube.extensions
+
+import android.view.View
+import com.qmuiteam.qmui.widget.QMUIEmptyView
+
+fun QMUIEmptyView.showEmptyPage(onButtonClickListener: View.OnClickListener) {
+ this.show(false, "抱歉,无法查询到相关记录", null, "重试", onButtonClickListener)
+}
+
+fun QMUIEmptyView.showEmptyPage(title: String, onButtonClickListener: View.OnClickListener) {
+ this.show(false, title, null, "刷新", onButtonClickListener)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
index 16d7e5c..1ef9226 100644
--- a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
+++ b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
@@ -1,10 +1,31 @@
package com.casic.smarttube.fragment
+import android.os.Handler
+import androidx.lifecycle.ViewModelProvider
+import androidx.recyclerview.widget.LinearLayoutManager
import com.casic.smarttube.R
+import com.casic.smarttube.adapter.DeviceListAdapter
+import com.casic.smarttube.extensions.showEmptyPage
+import com.casic.smarttube.model.DeviceListModel
+import com.casic.smarttube.view.WellDetailActivity
+import com.casic.smarttube.vm.DeviceViewModel
import com.pengxh.kt.lite.base.KotlinBaseFragment
+import com.pengxh.kt.lite.extensions.navigatePageTo
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.utils.WeakReferenceHandler
+import kotlinx.android.synthetic.main.fragment_overview.*
+import kotlinx.android.synthetic.main.include_empty_view.*
class OverviewFragment : KotlinBaseFragment() {
+ private lateinit var weakReferenceHandler: WeakReferenceHandler
+ private lateinit var deviceViewModel: DeviceViewModel
+ private lateinit var deviceAdapter: DeviceListAdapter
+ private var dataBeans: MutableList = ArrayList()
+ private var pageIndex = 1
+ private var isRefresh = false
+ private var isLoadMore = false
+
override fun initLayoutView(): Int = R.layout.fragment_overview
override fun setupTopBarLayout() {
@@ -12,10 +33,101 @@
}
override fun initData() {
+ weakReferenceHandler = WeakReferenceHandler(callback)
+ deviceViewModel = ViewModelProvider(this).get(DeviceViewModel::class.java)
+ }
+ override fun onResume() {
+ //默认加载第一页
+ obtainDeviceList()
+ super.onResume()
}
override fun initEvent() {
+ overviewLayout.setOnRefreshListener {
+ isRefresh = true
+ //刷新之后页码重置
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ overviewLayout.setOnLoadMoreListener {
+ isLoadMore = true
+ pageIndex++
+ obtainDeviceList()
+ }
+ deviceViewModel.deviceListModel.observe(this, {
+ if (it.code == 200) {
+ val dataRows = it.data?.rows
+ when {
+ isRefresh -> {
+ dataBeans.clear()
+ dataBeans = dataRows!!
+ overviewLayout.finishRefresh()
+ isRefresh = false
+ }
+ isLoadMore -> {
+ if (dataRows?.size == 0) {
+ "到底了,别拉了".show(requireContext())
+ }
+ dataBeans.addAll(dataRows!!)
+ overviewLayout.finishLoadMore()
+ isLoadMore = false
+ }
+ else -> {
+ dataBeans = dataRows!!
+ }
+ }
+ weakReferenceHandler.sendEmptyMessage(2022062401)
+ }
+ })
+ }
+
+ private fun obtainDeviceList() {
+ deviceViewModel.obtainDeviceListByType("", "", "", pageIndex)
+ }
+
+ private val callback = Handler.Callback {
+ if (it.what == 2022062401) {
+ if (isRefresh || isLoadMore) {
+ deviceAdapter.notifyDataSetChanged()
+ } else {
+ if (dataBeans.size == 0) {
+ emptyView!!.showEmptyPage("这里什么都没有") {
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ } else {
+ emptyView!!.hide()
+ deviceAdapter = DeviceListAdapter(requireContext(), dataBeans)
+ recyclerView!!.layoutManager = LinearLayoutManager(requireContext())
+ recyclerView!!.adapter = deviceAdapter
+ deviceAdapter.setOnItemClickListener(object :
+ DeviceListAdapter.OnItemClickListener {
+ override fun onClicked(position: Int) {
+// val jobId = dataBeans[position].jobId.toString()
+// if (jobId.isBlank()) {
+// "设备编号异常,无法查看详情".show(requireContext())
+// return
+// }
+// requireContext().navigatePageTo(jobId)
+ }
+
+ override fun onHistoryClicked(position: Int) {
+
+ }
+
+ override fun onEditClicked(position: Int) {
+
+ }
+
+ override fun onWellDetailClicked(position: Int) {
+ requireContext().navigatePageTo(dataBeans[position].wellId)
+ }
+ })
+ }
+ }
+ }
+ true
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/model/AreaModel.java b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
new file mode 100644
index 0000000..c6f86ef
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
@@ -0,0 +1,125 @@
+package com.casic.smarttube.model;
+
+public class AreaModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String area;
+ private String communications;
+ private String deptid;
+ private String deviceTypes;
+ private String id;
+ private String lat;
+ private String lng;
+ private String map;
+ private String wellTypes;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getCommunications() {
+ return communications;
+ }
+
+ public void setCommunications(String communications) {
+ this.communications = communications;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDeviceTypes() {
+ return deviceTypes;
+ }
+
+ public void setDeviceTypes(String deviceTypes) {
+ this.deviceTypes = deviceTypes;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getMap() {
+ return map;
+ }
+
+ public void setMap(String map) {
+ this.map = map;
+ }
+
+ public String getWellTypes() {
+ return wellTypes;
+ }
+
+ public void setWellTypes(String wellTypes) {
+ this.wellTypes = wellTypes;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
new file mode 100644
index 0000000..b34eb55
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
@@ -0,0 +1,274 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DeviceListModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private List rows;
+ private int total;
+
+ public List getRows() {
+ return rows;
+ }
+
+ public void setRows(List rows) {
+ this.rows = rows;
+ }
+
+ public int getTotal() {
+ return total;
+ }
+
+ public void setTotal(int total) {
+ this.total = total;
+ }
+
+ public static class RowsBean {
+ private String bfzt;
+ private String bfztName;
+ private String communication;
+ private String concenCode;
+ private String concenId;
+ private String deptName;
+ private String deptid;
+ private String devcode;
+ private String deviceName;
+ private String deviceType;
+ private String deviceTypeName;
+ private String id;
+ private String installDate;
+ private String modelId;
+ private String modelName;
+ private String onlineState;
+ private String onlineStateName;
+ private String position;
+ private String ts;
+ private String valid;
+ private String watchType;
+ private String wellCode;
+ private String wellId;
+
+ public String getBfzt() {
+ return bfzt;
+ }
+
+ public void setBfzt(String bfzt) {
+ this.bfzt = bfzt;
+ }
+
+ public String getBfztName() {
+ return bfztName;
+ }
+
+ public void setBfztName(String bfztName) {
+ this.bfztName = bfztName;
+ }
+
+ public String getCommunication() {
+ return communication;
+ }
+
+ public void setCommunication(String communication) {
+ this.communication = communication;
+ }
+
+ public String getConcenCode() {
+ return concenCode;
+ }
+
+ public void setConcenCode(String concenCode) {
+ this.concenCode = concenCode;
+ }
+
+ public String getConcenId() {
+ return concenId;
+ }
+
+ public void setConcenId(String concenId) {
+ this.concenId = concenId;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDevcode() {
+ return devcode;
+ }
+
+ public void setDevcode(String devcode) {
+ this.devcode = devcode;
+ }
+
+ public String getDeviceName() {
+ return deviceName;
+ }
+
+ public void setDeviceName(String deviceName) {
+ this.deviceName = deviceName;
+ }
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getDeviceTypeName() {
+ return deviceTypeName;
+ }
+
+ public void setDeviceTypeName(String deviceTypeName) {
+ this.deviceTypeName = deviceTypeName;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getInstallDate() {
+ return installDate;
+ }
+
+ public void setInstallDate(String installDate) {
+ this.installDate = installDate;
+ }
+
+ public String getModelId() {
+ return modelId;
+ }
+
+ public void setModelId(String modelId) {
+ this.modelId = modelId;
+ }
+
+ public String getModelName() {
+ return modelName;
+ }
+
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getOnlineState() {
+ return onlineState;
+ }
+
+ public void setOnlineState(String onlineState) {
+ this.onlineState = onlineState;
+ }
+
+ public String getOnlineStateName() {
+ return onlineStateName;
+ }
+
+ public void setOnlineStateName(String onlineStateName) {
+ this.onlineStateName = onlineStateName;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public String getTs() {
+ return ts;
+ }
+
+ public void setTs(String ts) {
+ this.ts = ts;
+ }
+
+ public String getValid() {
+ return valid;
+ }
+
+ public void setValid(String valid) {
+ this.valid = valid;
+ }
+
+ public String getWatchType() {
+ return watchType;
+ }
+
+ public void setWatchType(String watchType) {
+ this.watchType = watchType;
+ }
+
+ public String getWellCode() {
+ return wellCode;
+ }
+
+ public void setWellCode(String wellCode) {
+ this.wellCode = wellCode;
+ }
+
+ public String getWellId() {
+ return wellId;
+ }
+
+ public void setWellId(String wellId) {
+ this.wellId = wellId;
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DistrictModel.java b/app/src/main/java/com/casic/smarttube/model/DistrictModel.java
new file mode 100644
index 0000000..437405f
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DistrictModel.java
@@ -0,0 +1,172 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DistrictModel {
+
+ private int code;
+ private List data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String id;
+ private String isSync;
+ private String lat;
+ private int level;
+ private String levelName;
+ private String lng;
+ private String name;
+ private int num;
+ private String pName;
+ private String pid;
+ private String pids;
+ private String simplename;
+ private String targetIdSync;
+ private String targetPidSync;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getIsSync() {
+ return isSync;
+ }
+
+ public void setIsSync(String isSync) {
+ this.isSync = isSync;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+
+ public String getLevelName() {
+ return levelName;
+ }
+
+ public void setLevelName(String levelName) {
+ this.levelName = levelName;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public String getPName() {
+ return pName;
+ }
+
+ public void setPName(String pName) {
+ this.pName = pName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getPids() {
+ return pids;
+ }
+
+ public void setPids(String pids) {
+ this.pids = pids;
+ }
+
+ public String getSimplename() {
+ return simplename;
+ }
+
+ public void setSimplename(String simplename) {
+ this.simplename = simplename;
+ }
+
+ public String getTargetIdSync() {
+ return targetIdSync;
+ }
+
+ public void setTargetIdSync(String targetIdSync) {
+ this.targetIdSync = targetIdSync;
+ }
+
+ public String getTargetPidSync() {
+ return targetPidSync;
+ }
+
+ public void setTargetPidSync(String targetPidSync) {
+ this.targetPidSync = targetPidSync;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/StreetModel.java b/app/src/main/java/com/casic/smarttube/model/StreetModel.java
new file mode 100644
index 0000000..57fa295
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/StreetModel.java
@@ -0,0 +1,172 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class StreetModel {
+
+ private int code;
+ private List data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String id;
+ private String isSync;
+ private String lat;
+ private int level;
+ private String levelName;
+ private String lng;
+ private String name;
+ private int num;
+ private String pName;
+ private String pid;
+ private String pids;
+ private String simplename;
+ private String targetIdSync;
+ private String targetPidSync;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getIsSync() {
+ return isSync;
+ }
+
+ public void setIsSync(String isSync) {
+ this.isSync = isSync;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+
+ public String getLevelName() {
+ return levelName;
+ }
+
+ public void setLevelName(String levelName) {
+ this.levelName = levelName;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public String getPName() {
+ return pName;
+ }
+
+ public void setPName(String pName) {
+ this.pName = pName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getPids() {
+ return pids;
+ }
+
+ public void setPids(String pids) {
+ this.pids = pids;
+ }
+
+ public String getSimplename() {
+ return simplename;
+ }
+
+ public void setSimplename(String simplename) {
+ this.simplename = simplename;
+ }
+
+ public String getTargetIdSync() {
+ return targetIdSync;
+ }
+
+ public void setTargetIdSync(String targetIdSync) {
+ this.targetIdSync = targetIdSync;
+ }
+
+ public String getTargetPidSync() {
+ return targetPidSync;
+ }
+
+ public void setTargetPidSync(String targetPidSync) {
+ this.targetPidSync = targetPidSync;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java b/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java
new file mode 100644
index 0000000..c19899a
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java
@@ -0,0 +1,305 @@
+package com.casic.smarttube.model;
+
+public class WellDetailModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String area;
+ private String bfzt;
+ private String bfztName;
+ private String coordinateX;
+ private String coordinateY;
+ private int deep;
+ private String deptName;
+ private String deptid;
+ private String deviceCount;
+ private String id;
+ private String latBaidu;
+ private String latGaode;
+ private String lngBaidu;
+ private String lngGaode;
+ private String notes;
+ private String photos;
+ private String position;
+ private String qu;
+ private String responsibleDept;
+ private String responsibleDeptName;
+ private String ts;
+ private String valid;
+ private String wellCode;
+ private String wellFlag1;
+ private String wellFlag2;
+ private String wellFlag3;
+ private String wellName;
+ private String wellType;
+ private String wellTypeName;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getBfzt() {
+ return bfzt;
+ }
+
+ public void setBfzt(String bfzt) {
+ this.bfzt = bfzt;
+ }
+
+ public String getBfztName() {
+ return bfztName;
+ }
+
+ public void setBfztName(String bfztName) {
+ this.bfztName = bfztName;
+ }
+
+ public String getCoordinateX() {
+ return coordinateX;
+ }
+
+ public void setCoordinateX(String coordinateX) {
+ this.coordinateX = coordinateX;
+ }
+
+ public String getCoordinateY() {
+ return coordinateY;
+ }
+
+ public void setCoordinateY(String coordinateY) {
+ this.coordinateY = coordinateY;
+ }
+
+ public int getDeep() {
+ return deep;
+ }
+
+ public void setDeep(int deep) {
+ this.deep = deep;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDeviceCount() {
+ return deviceCount;
+ }
+
+ public void setDeviceCount(String deviceCount) {
+ this.deviceCount = deviceCount;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLatBaidu() {
+ return latBaidu;
+ }
+
+ public void setLatBaidu(String latBaidu) {
+ this.latBaidu = latBaidu;
+ }
+
+ public String getLatGaode() {
+ return latGaode;
+ }
+
+ public void setLatGaode(String latGaode) {
+ this.latGaode = latGaode;
+ }
+
+ public String getLngBaidu() {
+ return lngBaidu;
+ }
+
+ public void setLngBaidu(String lngBaidu) {
+ this.lngBaidu = lngBaidu;
+ }
+
+ public String getLngGaode() {
+ return lngGaode;
+ }
+
+ public void setLngGaode(String lngGaode) {
+ this.lngGaode = lngGaode;
+ }
+
+ public String getNotes() {
+ return notes;
+ }
+
+ public void setNotes(String notes) {
+ this.notes = notes;
+ }
+
+ public String getPhotos() {
+ return photos;
+ }
+
+ public void setPhotos(String photos) {
+ this.photos = photos;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public String getQu() {
+ return qu;
+ }
+
+ public void setQu(String qu) {
+ this.qu = qu;
+ }
+
+ public String getResponsibleDept() {
+ return responsibleDept;
+ }
+
+ public void setResponsibleDept(String responsibleDept) {
+ this.responsibleDept = responsibleDept;
+ }
+
+ public String getResponsibleDeptName() {
+ return responsibleDeptName;
+ }
+
+ public void setResponsibleDeptName(String responsibleDeptName) {
+ this.responsibleDeptName = responsibleDeptName;
+ }
+
+ public String getTs() {
+ return ts;
+ }
+
+ public void setTs(String ts) {
+ this.ts = ts;
+ }
+
+ public String getValid() {
+ return valid;
+ }
+
+ public void setValid(String valid) {
+ this.valid = valid;
+ }
+
+ public String getWellCode() {
+ return wellCode;
+ }
+
+ public void setWellCode(String wellCode) {
+ this.wellCode = wellCode;
+ }
+
+ public String getWellFlag1() {
+ return wellFlag1;
+ }
+
+ public void setWellFlag1(String wellFlag1) {
+ this.wellFlag1 = wellFlag1;
+ }
+
+ public String getWellFlag2() {
+ return wellFlag2;
+ }
+
+ public void setWellFlag2(String wellFlag2) {
+ this.wellFlag2 = wellFlag2;
+ }
+
+ public String getWellFlag3() {
+ return wellFlag3;
+ }
+
+ public void setWellFlag3(String wellFlag3) {
+ this.wellFlag3 = wellFlag3;
+ }
+
+ public String getWellName() {
+ return wellName;
+ }
+
+ public void setWellName(String wellName) {
+ this.wellName = wellName;
+ }
+
+ public String getWellType() {
+ return wellType;
+ }
+
+ public void setWellType(String wellType) {
+ this.wellType = wellType;
+ }
+
+ public String getWellTypeName() {
+ return wellTypeName;
+ }
+
+ public void setWellTypeName(String wellTypeName) {
+ this.wellTypeName = wellTypeName;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt b/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
index d5ac3ec..608dd91 100644
--- a/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
+++ b/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
@@ -22,6 +22,7 @@
* =============================================================================================
* */
const val PERMISSIONS_CODE = 999
+ const val PAGE_LIMIT = 20
/**
* =============================================================================================
diff --git a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt
index 64c5402..f715247 100644
--- a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt
+++ b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt
@@ -69,4 +69,64 @@
*/
@POST("/app/checkVersion")
suspend fun obtainVersionResult(@Header("token") token: String): String
+
+ /**
+ * 获取管盯分页列表
+ * */
+ @GET("/device/list")
+ suspend fun obtainDeviceListByType(
+ @Header("token") token: String,
+ @Query("deptid") deptid: String?,
+ @Query("keywords") keywords: String?,
+ @Query("deviceType") deviceType: String?,
+ @Query("isOnline") isOnline: String?,
+ @Query("sort") sort: String?,
+ @Query("order") order: String?,
+ @Query("offset") offset: Int,
+ @Query("limit") limit: Int
+ ): String
+
+ /**
+ * 获取闸井详情
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/info")
+ suspend fun obtainWellDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 根据部门获取区ID
+ *
+ * @param deptId
+ */
+ @GET("/config/getAreaByDept")
+ suspend fun obtainAreaByDept(
+ @Header("token") token: String,
+ @Query("deptId") deptId: String
+ ): String
+
+ /**
+ * 获取区/县等
+ *
+ * @param pid
+ */
+ @GET("/area/list")
+ suspend fun obtainDistrict(
+ @Header("token") token: String,
+ @Query("pid") pid: String
+ ): String
+
+ /**
+ * 获取街道
+ *
+ * @param pid
+ */
+ @GET("/area/list")
+ suspend fun obtainStreet(
+ @Header("token") token: String,
+ @Query("pid") pid: String
+ ): String
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt
index 2af9a24..d888e59 100644
--- a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt
+++ b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt
@@ -1,6 +1,7 @@
package com.casic.smarttube.utils.retrofit
import com.casic.smarttube.utils.AuthenticationHelper
+import com.casic.smarttube.utils.LocalConstant
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.MultipartBody
import okhttp3.RequestBody
@@ -54,6 +55,46 @@
}
/**
+ * 根据设备类型获取设备分页列表
+ */
+ suspend fun obtainDeviceListByType(
+ deptid: String, keywords: String, isOnline: String, page: Int
+ ): String {
+ return api.obtainDeviceListByType(
+ AuthenticationHelper.token!!, deptid, keywords, "12", isOnline,
+ "id", "asc", page, LocalConstant.PAGE_LIMIT
+ )
+ }
+
+ /**
+ * 获取闸井详情
+ */
+ suspend fun obtainWellDetail(id: String): String {
+ return api.obtainWellDetail(AuthenticationHelper.token!!, id)
+ }
+
+ /**
+ * 根据部门获取区ID
+ */
+ suspend fun obtainAreaByDept(deptId: String): String {
+ return api.obtainAreaByDept(AuthenticationHelper.token!!, deptId)
+ }
+
+ /**
+ * 获取区/县等
+ */
+ suspend fun obtainDistrict(pid: String): String {
+ return api.obtainDistrict(AuthenticationHelper.token!!, pid)
+ }
+
+ /**
+ * 获取街道
+ */
+ suspend fun obtainStreet(pid: String): String {
+ return api.obtainStreet(AuthenticationHelper.token!!, pid)
+ }
+
+ /**
* 上传图片
*/
suspend fun uploadImage(image: File): String {
diff --git a/app/src/main/java/com/casic/smarttube/view/WellDetailActivity.kt b/app/src/main/java/com/casic/smarttube/view/WellDetailActivity.kt
new file mode 100644
index 0000000..457c06f
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/view/WellDetailActivity.kt
@@ -0,0 +1,173 @@
+package com.casic.smarttube.view
+
+import android.os.Bundle
+import androidx.lifecycle.ViewModelProvider
+import com.amap.api.maps.AMap
+import com.amap.api.maps.AMapOptions
+import com.amap.api.maps.CameraUpdateFactory
+import com.amap.api.maps.model.BitmapDescriptorFactory
+import com.amap.api.maps.model.CameraPosition
+import com.amap.api.maps.model.LatLng
+import com.amap.api.maps.model.MarkerOptions
+import com.casic.smarttube.R
+import com.casic.smarttube.utils.DialogHelper
+import com.casic.smarttube.vm.AuthenticateViewModel
+import com.casic.smarttube.vm.WellViewModel
+import com.gyf.immersionbar.ImmersionBar
+import com.pengxh.kt.lite.base.KotlinBaseActivity
+import com.pengxh.kt.lite.extensions.convertColor
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.utils.Constant
+import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil
+import com.pengxh.kt.lite.vm.LoadState
+import kotlinx.android.synthetic.main.activity_well_detail.*
+import kotlinx.android.synthetic.main.include_base_title.*
+
+
+class WellDetailActivity : KotlinBaseActivity(), AMap.OnMapLoadedListener {
+
+ private lateinit var wellViewModel: WellViewModel
+ private lateinit var authenticateViewModel: AuthenticateViewModel
+ private lateinit var wellId: String
+ private lateinit var aMap: AMap
+ private var latLng: LatLng? = null
+
+
+ override fun initLayoutView(): Int = R.layout.activity_well_detail
+
+ override fun setupTopBarLayout() {
+ ImmersionBar.with(this).statusBarDarkFont(false).init()
+ ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this))
+ leftBackView.setOnClickListener { finish() }
+ titleView.text = "井详情"
+ }
+
+ override fun initData() {
+ wellId = intent.getStringExtra(Constant.INTENT_PARAM)!!
+ wellViewModel = ViewModelProvider(this).get(WellViewModel::class.java)
+ authenticateViewModel = ViewModelProvider(this).get(AuthenticateViewModel::class.java)
+
+ aMap = wellMapView.map
+ aMap.mapType = AMap.MAP_TYPE_NORMAL
+ val uiSettings = aMap.uiSettings
+ uiSettings.isCompassEnabled = true
+ uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER
+ uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度
+ uiSettings.isRotateGesturesEnabled = false//不允许地图旋转
+
+ //地图加载成功之后调用
+ aMap.addOnMapLoadedListener(this)
+ }
+
+ override fun onMapLoaded() {
+ if (latLng == null) {
+ "该闸井经纬度异常,无法在地图显示".show(this)
+ return
+ }
+ /**
+ * 参数1---要移动到的经纬度
+ * 参数2---地图的放缩级别zoom
+ * 参数3---地图倾斜度
+ * 参数4---地图的旋转角度
+ * */
+ val cameraPosition = CameraPosition(latLng, 13f, 0f, 0f)
+ val newCameraPosition = CameraUpdateFactory.newCameraPosition(cameraPosition)
+ aMap.animateCamera(newCameraPosition, 3000, object : AMap.CancelableCallback {
+ override fun onFinish() {
+ //添加Marker
+ val markerOptions = MarkerOptions()
+ .position(latLng)
+ .icon(BitmapDescriptorFactory.fromResource(R.mipmap.well_location))
+ .draggable(true)
+ aMap.addMarker(markerOptions)
+ }
+
+ override fun onCancel() {
+
+ }
+ })
+ }
+
+ override fun initEvent() {
+ wellViewModel.obtainWellDetail(wellId)
+ wellViewModel.detailModel.observe(this, {
+ if (it.code == 200) {
+ val wellDetail = it.data!!
+
+ wellNameView.text = wellDetail.wellName
+ wellTypeView.text = wellDetail.wellTypeName
+ wellCodeView.text = wellDetail.wellCode
+ ownerShipView.text = wellDetail.deptName
+ wellStateView.text = wellDetail.bfztName
+ wellDepthView.text = wellDetail.deep.toString()
+ //绑定窨井位置
+ if (wellDetail.latGaode.isBlank() || wellDetail.lngGaode.isBlank()) {
+ wellLocationView.text = wellDetail.position
+ return@observe
+ }
+ this.latLng = LatLng(wellDetail.latGaode.toDouble(), wellDetail.lngGaode.toDouble())
+ authenticateViewModel.obtainAreaByDept(wellDetail.deptid)
+ authenticateViewModel.areaModel.observe(this, { areaModel ->
+ if (areaModel.code == 200) {
+ authenticateViewModel.obtainDistrict(areaModel.data.area)
+ }
+ })
+ authenticateViewModel.districtModel.observe(this, { districtModel ->
+ if (districtModel.code == 200) {
+ districtModel.data.forEach { area ->
+ if (area.id == wellDetail.qu) {
+ authenticateViewModel.obtainStreet(area.id)
+ authenticateViewModel.streetModel.observe(this, { street ->
+ if (street.code == 200) {
+ street.data.forEach { streetData ->
+ if (streetData.id == wellDetail.area) {
+ wellLocationView.text =
+ String.format("${area.name}${streetData.name}-${wellDetail.position}")
+ }
+ }
+ }
+ })
+ }
+ }
+ }
+ })
+ }
+ })
+ wellViewModel.loadState.observe(this, {
+ when (it) {
+ is LoadState.Loading -> {
+ DialogHelper.showLoadingDialog(this, "数据加载中,请稍后")
+ }
+ else -> {
+ DialogHelper.dismissLoadingDialog()
+ }
+ }
+ })
+ }
+
+ /**地图相关*********/
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ wellMapView.onCreate(savedInstanceState)
+ }
+
+ override fun onResume() {
+ super.onResume()
+ wellMapView.onResume()
+ }
+
+ override fun onPause() {
+ super.onPause()
+ wellMapView.onPause()
+ }
+
+ override fun onDestroy() {
+ wellMapView.onDestroy()
+ super.onDestroy()
+ }
+
+ override fun onSaveInstanceState(outState: Bundle) {
+ super.onSaveInstanceState(outState)
+ wellMapView.onSaveInstanceState(outState)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/vm/AuthenticateViewModel.kt b/app/src/main/java/com/casic/smarttube/vm/AuthenticateViewModel.kt
index 7ad6379..882fea2 100644
--- a/app/src/main/java/com/casic/smarttube/vm/AuthenticateViewModel.kt
+++ b/app/src/main/java/com/casic/smarttube/vm/AuthenticateViewModel.kt
@@ -4,7 +4,10 @@
import com.casic.smarttube.base.BaseApplication
import com.casic.smarttube.extensions.separateResponseCode
import com.casic.smarttube.extensions.toErrorMessage
+import com.casic.smarttube.model.AreaModel
+import com.casic.smarttube.model.DistrictModel
import com.casic.smarttube.model.PublicKeyModel
+import com.casic.smarttube.model.StreetModel
import com.casic.smarttube.utils.retrofit.RetrofitServiceManager
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
@@ -16,6 +19,9 @@
private val gson = Gson()
val keyModel = MutableLiveData()
+ val areaModel = MutableLiveData()
+ val districtModel = MutableLiveData()
+ val streetModel = MutableLiveData()
fun obtainPublicKey() = launch({
val response = RetrofitServiceManager.authenticate()
@@ -30,4 +36,55 @@
}, {
it.printStackTrace()
})
+
+ /**
+ * 根据部门获取区ID
+ */
+ fun obtainAreaByDept(deptId: String) = launch({
+ val response = RetrofitServiceManager.obtainAreaByDept(deptId)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ areaModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ response.toErrorMessage().show(BaseApplication.obtainInstance())
+ }
+ }, {
+ it.printStackTrace()
+ })
+
+ /**
+ * 区/县等
+ */
+ fun obtainDistrict(pid: String) = launch({
+ val response = RetrofitServiceManager.obtainDistrict(pid)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ districtModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ response.toErrorMessage().show(BaseApplication.obtainInstance())
+ }
+ }, {
+ it.printStackTrace()
+ })
+
+ /**
+ * 街道
+ */
+ fun obtainStreet(areaId: String) = launch({
+ val response = RetrofitServiceManager.obtainStreet(areaId)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ streetModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ response.toErrorMessage().show(BaseApplication.obtainInstance())
+ }
+ }, {
+ it.printStackTrace()
+ })
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/vm/DeviceViewModel.kt b/app/src/main/java/com/casic/smarttube/vm/DeviceViewModel.kt
new file mode 100644
index 0000000..6a12e14
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/vm/DeviceViewModel.kt
@@ -0,0 +1,35 @@
+package com.casic.smarttube.vm
+
+import androidx.lifecycle.MutableLiveData
+import com.casic.smarttube.base.BaseApplication
+import com.casic.smarttube.extensions.separateResponseCode
+import com.casic.smarttube.extensions.toErrorMessage
+import com.casic.smarttube.model.DeviceListModel
+import com.casic.smarttube.utils.retrofit.RetrofitServiceManager
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import com.pengxh.kt.lite.extensions.launch
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.vm.BaseViewModel
+
+class DeviceViewModel : BaseViewModel() {
+
+ private val gson = Gson()
+ val deviceListModel = MutableLiveData()
+
+ fun obtainDeviceListByType(deptid: String, keywords: String, isOnline: String, page: Int) =
+ launch({
+ val response =
+ RetrofitServiceManager.obtainDeviceListByType(deptid, keywords, isOnline, page)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ deviceListModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ response.toErrorMessage().show(BaseApplication.obtainInstance())
+ }
+ }, {
+ it.printStackTrace()
+ })
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cbc72b6..a9b50c5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,7 +26,7 @@
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
- android:theme="@style/AppTheme"
+ android:theme="@style/QMUI.Compat.NoActionBar"
android:usesCleartextTraffic="true">
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
new file mode 100644
index 0000000..e3c059d
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
@@ -0,0 +1,111 @@
+package com.casic.smarttube.adapter
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+import com.casic.smarttube.R
+import com.casic.smarttube.extensions.arrowAnimation
+import com.casic.smarttube.model.DeviceListModel
+import com.github.mikephil.charting.charts.LineChart
+import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
+
+class DeviceListAdapter(
+ private val context: Context,
+ private val dataRows: MutableList
+) : RecyclerView.Adapter() {
+
+ private var layoutInflater: LayoutInflater = LayoutInflater.from(context)
+ private var isExpand = false
+
+ override fun onCreateViewHolder(
+ parent: ViewGroup, viewType: Int
+ ): DeviceListAdapter.ItemViewHolder {
+ return ItemViewHolder(
+ layoutInflater.inflate(R.layout.item_device_recycleview, parent, false)
+ )
+ }
+
+ override fun getItemCount(): Int = dataRows.size
+
+ override fun onBindViewHolder(holder: DeviceListAdapter.ItemViewHolder, position: Int) {
+ //绑定数据
+ val rowsBean = dataRows[position]
+ holder.deviceStateView.text = rowsBean.onlineStateName
+ if (rowsBean.onlineState == "1") {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_green_radius_5)
+ } else {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_gray_radius_5)
+ }
+ holder.deviceCodeView.text = rowsBean.devcode
+ holder.wellCodeView.text = String.format("井编号:${rowsBean.wellCode}")
+ holder.ownerShipView.text = String.format("权属单位:${rowsBean.deptName}")
+ holder.deviceLocationView.text = String.format("设备位置:${rowsBean.position}")
+ holder.installDateView.text = String.format("安装日期:${rowsBean.installDate}")
+
+
+ if (listener != null) {
+ holder.itemView.setOnClickListener {
+ listener!!.onClicked(position)
+ }
+ holder.dataHistoryButton.setOnClickListener {
+ listener!!.onHistoryClicked(position)
+ }
+ holder.editButton.setOnClickListener {
+ listener!!.onEditClicked(position)
+ }
+ holder.wellDetailButton.setOnClickListener {
+ listener!!.onWellDetailClicked(position)
+ }
+
+ holder.expandableImageView.setOnClickListener {
+ if (!isExpand) {
+ //展开列表动画
+ holder.expandableImageView.arrowAnimation(180f)
+ isExpand = true
+ //子列表绑定数据
+// expandableViewAdapter.setExpandableData(createExpandableList(rowsBean))
+ } else {
+ //关闭列表动画
+ holder.expandableImageView.arrowAnimation(0f)
+ isExpand = false
+ //子列表清空数据
+// expandableViewAdapter.clearAll()
+ }
+ }
+ }
+ }
+
+ inner class ItemViewHolder(view: View) : RecyclerView.ViewHolder(view) {
+ var deviceStateView: TextView = view.findViewById(R.id.deviceStateView)
+ var deviceCodeView: TextView = view.findViewById(R.id.deviceCodeView)
+ var expandableImageView: ImageView = view.findViewById(R.id.expandableImageView)
+ var wellCodeView: TextView = view.findViewById(R.id.wellCodeView)
+ var ownerShipView: TextView = view.findViewById(R.id.ownerShipView)
+ var deviceLocationView: TextView = view.findViewById(R.id.deviceLocationView)
+ var installDateView: TextView = view.findViewById(R.id.installDateView)
+ var dataHistoryButton: QMUIRoundButton = view.findViewById(R.id.dataHistoryButton)
+ var editButton: QMUIRoundButton = view.findViewById(R.id.editButton)
+ var wellDetailButton: QMUIRoundButton = view.findViewById(R.id.wellDetailButton)
+ var expandableChartView: LineChart = view.findViewById(R.id.expandableChartView)
+ }
+
+ private var listener: OnItemClickListener? = null
+
+ interface OnItemClickListener {
+ fun onClicked(position: Int)
+
+ fun onHistoryClicked(position: Int)
+
+ fun onEditClicked(position: Int)
+
+ fun onWellDetailClicked(position: Int)
+ }
+
+ fun setOnItemClickListener(onClickListener: OnItemClickListener?) {
+ this.listener = onClickListener
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
new file mode 100644
index 0000000..d185752
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
@@ -0,0 +1,11 @@
+package com.casic.smarttube.extensions
+
+import android.view.animation.LinearInterpolator
+import android.widget.ImageView
+
+fun ImageView.arrowAnimation(angle: Float) {
+ val animation = this.animate()
+ animation.duration = 300
+ animation.interpolator = LinearInterpolator()
+ animation.rotation(angle)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
new file mode 100644
index 0000000..22e56d2
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
@@ -0,0 +1,12 @@
+package com.casic.smarttube.extensions
+
+import android.view.View
+import com.qmuiteam.qmui.widget.QMUIEmptyView
+
+fun QMUIEmptyView.showEmptyPage(onButtonClickListener: View.OnClickListener) {
+ this.show(false, "抱歉,无法查询到相关记录", null, "重试", onButtonClickListener)
+}
+
+fun QMUIEmptyView.showEmptyPage(title: String, onButtonClickListener: View.OnClickListener) {
+ this.show(false, title, null, "刷新", onButtonClickListener)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
index 16d7e5c..1ef9226 100644
--- a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
+++ b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
@@ -1,10 +1,31 @@
package com.casic.smarttube.fragment
+import android.os.Handler
+import androidx.lifecycle.ViewModelProvider
+import androidx.recyclerview.widget.LinearLayoutManager
import com.casic.smarttube.R
+import com.casic.smarttube.adapter.DeviceListAdapter
+import com.casic.smarttube.extensions.showEmptyPage
+import com.casic.smarttube.model.DeviceListModel
+import com.casic.smarttube.view.WellDetailActivity
+import com.casic.smarttube.vm.DeviceViewModel
import com.pengxh.kt.lite.base.KotlinBaseFragment
+import com.pengxh.kt.lite.extensions.navigatePageTo
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.utils.WeakReferenceHandler
+import kotlinx.android.synthetic.main.fragment_overview.*
+import kotlinx.android.synthetic.main.include_empty_view.*
class OverviewFragment : KotlinBaseFragment() {
+ private lateinit var weakReferenceHandler: WeakReferenceHandler
+ private lateinit var deviceViewModel: DeviceViewModel
+ private lateinit var deviceAdapter: DeviceListAdapter
+ private var dataBeans: MutableList = ArrayList()
+ private var pageIndex = 1
+ private var isRefresh = false
+ private var isLoadMore = false
+
override fun initLayoutView(): Int = R.layout.fragment_overview
override fun setupTopBarLayout() {
@@ -12,10 +33,101 @@
}
override fun initData() {
+ weakReferenceHandler = WeakReferenceHandler(callback)
+ deviceViewModel = ViewModelProvider(this).get(DeviceViewModel::class.java)
+ }
+ override fun onResume() {
+ //默认加载第一页
+ obtainDeviceList()
+ super.onResume()
}
override fun initEvent() {
+ overviewLayout.setOnRefreshListener {
+ isRefresh = true
+ //刷新之后页码重置
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ overviewLayout.setOnLoadMoreListener {
+ isLoadMore = true
+ pageIndex++
+ obtainDeviceList()
+ }
+ deviceViewModel.deviceListModel.observe(this, {
+ if (it.code == 200) {
+ val dataRows = it.data?.rows
+ when {
+ isRefresh -> {
+ dataBeans.clear()
+ dataBeans = dataRows!!
+ overviewLayout.finishRefresh()
+ isRefresh = false
+ }
+ isLoadMore -> {
+ if (dataRows?.size == 0) {
+ "到底了,别拉了".show(requireContext())
+ }
+ dataBeans.addAll(dataRows!!)
+ overviewLayout.finishLoadMore()
+ isLoadMore = false
+ }
+ else -> {
+ dataBeans = dataRows!!
+ }
+ }
+ weakReferenceHandler.sendEmptyMessage(2022062401)
+ }
+ })
+ }
+
+ private fun obtainDeviceList() {
+ deviceViewModel.obtainDeviceListByType("", "", "", pageIndex)
+ }
+
+ private val callback = Handler.Callback {
+ if (it.what == 2022062401) {
+ if (isRefresh || isLoadMore) {
+ deviceAdapter.notifyDataSetChanged()
+ } else {
+ if (dataBeans.size == 0) {
+ emptyView!!.showEmptyPage("这里什么都没有") {
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ } else {
+ emptyView!!.hide()
+ deviceAdapter = DeviceListAdapter(requireContext(), dataBeans)
+ recyclerView!!.layoutManager = LinearLayoutManager(requireContext())
+ recyclerView!!.adapter = deviceAdapter
+ deviceAdapter.setOnItemClickListener(object :
+ DeviceListAdapter.OnItemClickListener {
+ override fun onClicked(position: Int) {
+// val jobId = dataBeans[position].jobId.toString()
+// if (jobId.isBlank()) {
+// "设备编号异常,无法查看详情".show(requireContext())
+// return
+// }
+// requireContext().navigatePageTo(jobId)
+ }
+
+ override fun onHistoryClicked(position: Int) {
+
+ }
+
+ override fun onEditClicked(position: Int) {
+
+ }
+
+ override fun onWellDetailClicked(position: Int) {
+ requireContext().navigatePageTo(dataBeans[position].wellId)
+ }
+ })
+ }
+ }
+ }
+ true
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/model/AreaModel.java b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
new file mode 100644
index 0000000..c6f86ef
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
@@ -0,0 +1,125 @@
+package com.casic.smarttube.model;
+
+public class AreaModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String area;
+ private String communications;
+ private String deptid;
+ private String deviceTypes;
+ private String id;
+ private String lat;
+ private String lng;
+ private String map;
+ private String wellTypes;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getCommunications() {
+ return communications;
+ }
+
+ public void setCommunications(String communications) {
+ this.communications = communications;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDeviceTypes() {
+ return deviceTypes;
+ }
+
+ public void setDeviceTypes(String deviceTypes) {
+ this.deviceTypes = deviceTypes;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getMap() {
+ return map;
+ }
+
+ public void setMap(String map) {
+ this.map = map;
+ }
+
+ public String getWellTypes() {
+ return wellTypes;
+ }
+
+ public void setWellTypes(String wellTypes) {
+ this.wellTypes = wellTypes;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
new file mode 100644
index 0000000..b34eb55
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
@@ -0,0 +1,274 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DeviceListModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private List rows;
+ private int total;
+
+ public List getRows() {
+ return rows;
+ }
+
+ public void setRows(List rows) {
+ this.rows = rows;
+ }
+
+ public int getTotal() {
+ return total;
+ }
+
+ public void setTotal(int total) {
+ this.total = total;
+ }
+
+ public static class RowsBean {
+ private String bfzt;
+ private String bfztName;
+ private String communication;
+ private String concenCode;
+ private String concenId;
+ private String deptName;
+ private String deptid;
+ private String devcode;
+ private String deviceName;
+ private String deviceType;
+ private String deviceTypeName;
+ private String id;
+ private String installDate;
+ private String modelId;
+ private String modelName;
+ private String onlineState;
+ private String onlineStateName;
+ private String position;
+ private String ts;
+ private String valid;
+ private String watchType;
+ private String wellCode;
+ private String wellId;
+
+ public String getBfzt() {
+ return bfzt;
+ }
+
+ public void setBfzt(String bfzt) {
+ this.bfzt = bfzt;
+ }
+
+ public String getBfztName() {
+ return bfztName;
+ }
+
+ public void setBfztName(String bfztName) {
+ this.bfztName = bfztName;
+ }
+
+ public String getCommunication() {
+ return communication;
+ }
+
+ public void setCommunication(String communication) {
+ this.communication = communication;
+ }
+
+ public String getConcenCode() {
+ return concenCode;
+ }
+
+ public void setConcenCode(String concenCode) {
+ this.concenCode = concenCode;
+ }
+
+ public String getConcenId() {
+ return concenId;
+ }
+
+ public void setConcenId(String concenId) {
+ this.concenId = concenId;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDevcode() {
+ return devcode;
+ }
+
+ public void setDevcode(String devcode) {
+ this.devcode = devcode;
+ }
+
+ public String getDeviceName() {
+ return deviceName;
+ }
+
+ public void setDeviceName(String deviceName) {
+ this.deviceName = deviceName;
+ }
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getDeviceTypeName() {
+ return deviceTypeName;
+ }
+
+ public void setDeviceTypeName(String deviceTypeName) {
+ this.deviceTypeName = deviceTypeName;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getInstallDate() {
+ return installDate;
+ }
+
+ public void setInstallDate(String installDate) {
+ this.installDate = installDate;
+ }
+
+ public String getModelId() {
+ return modelId;
+ }
+
+ public void setModelId(String modelId) {
+ this.modelId = modelId;
+ }
+
+ public String getModelName() {
+ return modelName;
+ }
+
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getOnlineState() {
+ return onlineState;
+ }
+
+ public void setOnlineState(String onlineState) {
+ this.onlineState = onlineState;
+ }
+
+ public String getOnlineStateName() {
+ return onlineStateName;
+ }
+
+ public void setOnlineStateName(String onlineStateName) {
+ this.onlineStateName = onlineStateName;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public String getTs() {
+ return ts;
+ }
+
+ public void setTs(String ts) {
+ this.ts = ts;
+ }
+
+ public String getValid() {
+ return valid;
+ }
+
+ public void setValid(String valid) {
+ this.valid = valid;
+ }
+
+ public String getWatchType() {
+ return watchType;
+ }
+
+ public void setWatchType(String watchType) {
+ this.watchType = watchType;
+ }
+
+ public String getWellCode() {
+ return wellCode;
+ }
+
+ public void setWellCode(String wellCode) {
+ this.wellCode = wellCode;
+ }
+
+ public String getWellId() {
+ return wellId;
+ }
+
+ public void setWellId(String wellId) {
+ this.wellId = wellId;
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DistrictModel.java b/app/src/main/java/com/casic/smarttube/model/DistrictModel.java
new file mode 100644
index 0000000..437405f
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DistrictModel.java
@@ -0,0 +1,172 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DistrictModel {
+
+ private int code;
+ private List data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String id;
+ private String isSync;
+ private String lat;
+ private int level;
+ private String levelName;
+ private String lng;
+ private String name;
+ private int num;
+ private String pName;
+ private String pid;
+ private String pids;
+ private String simplename;
+ private String targetIdSync;
+ private String targetPidSync;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getIsSync() {
+ return isSync;
+ }
+
+ public void setIsSync(String isSync) {
+ this.isSync = isSync;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+
+ public String getLevelName() {
+ return levelName;
+ }
+
+ public void setLevelName(String levelName) {
+ this.levelName = levelName;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public String getPName() {
+ return pName;
+ }
+
+ public void setPName(String pName) {
+ this.pName = pName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getPids() {
+ return pids;
+ }
+
+ public void setPids(String pids) {
+ this.pids = pids;
+ }
+
+ public String getSimplename() {
+ return simplename;
+ }
+
+ public void setSimplename(String simplename) {
+ this.simplename = simplename;
+ }
+
+ public String getTargetIdSync() {
+ return targetIdSync;
+ }
+
+ public void setTargetIdSync(String targetIdSync) {
+ this.targetIdSync = targetIdSync;
+ }
+
+ public String getTargetPidSync() {
+ return targetPidSync;
+ }
+
+ public void setTargetPidSync(String targetPidSync) {
+ this.targetPidSync = targetPidSync;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/StreetModel.java b/app/src/main/java/com/casic/smarttube/model/StreetModel.java
new file mode 100644
index 0000000..57fa295
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/StreetModel.java
@@ -0,0 +1,172 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class StreetModel {
+
+ private int code;
+ private List data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String id;
+ private String isSync;
+ private String lat;
+ private int level;
+ private String levelName;
+ private String lng;
+ private String name;
+ private int num;
+ private String pName;
+ private String pid;
+ private String pids;
+ private String simplename;
+ private String targetIdSync;
+ private String targetPidSync;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getIsSync() {
+ return isSync;
+ }
+
+ public void setIsSync(String isSync) {
+ this.isSync = isSync;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+
+ public String getLevelName() {
+ return levelName;
+ }
+
+ public void setLevelName(String levelName) {
+ this.levelName = levelName;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public String getPName() {
+ return pName;
+ }
+
+ public void setPName(String pName) {
+ this.pName = pName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getPids() {
+ return pids;
+ }
+
+ public void setPids(String pids) {
+ this.pids = pids;
+ }
+
+ public String getSimplename() {
+ return simplename;
+ }
+
+ public void setSimplename(String simplename) {
+ this.simplename = simplename;
+ }
+
+ public String getTargetIdSync() {
+ return targetIdSync;
+ }
+
+ public void setTargetIdSync(String targetIdSync) {
+ this.targetIdSync = targetIdSync;
+ }
+
+ public String getTargetPidSync() {
+ return targetPidSync;
+ }
+
+ public void setTargetPidSync(String targetPidSync) {
+ this.targetPidSync = targetPidSync;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java b/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java
new file mode 100644
index 0000000..c19899a
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java
@@ -0,0 +1,305 @@
+package com.casic.smarttube.model;
+
+public class WellDetailModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String area;
+ private String bfzt;
+ private String bfztName;
+ private String coordinateX;
+ private String coordinateY;
+ private int deep;
+ private String deptName;
+ private String deptid;
+ private String deviceCount;
+ private String id;
+ private String latBaidu;
+ private String latGaode;
+ private String lngBaidu;
+ private String lngGaode;
+ private String notes;
+ private String photos;
+ private String position;
+ private String qu;
+ private String responsibleDept;
+ private String responsibleDeptName;
+ private String ts;
+ private String valid;
+ private String wellCode;
+ private String wellFlag1;
+ private String wellFlag2;
+ private String wellFlag3;
+ private String wellName;
+ private String wellType;
+ private String wellTypeName;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getBfzt() {
+ return bfzt;
+ }
+
+ public void setBfzt(String bfzt) {
+ this.bfzt = bfzt;
+ }
+
+ public String getBfztName() {
+ return bfztName;
+ }
+
+ public void setBfztName(String bfztName) {
+ this.bfztName = bfztName;
+ }
+
+ public String getCoordinateX() {
+ return coordinateX;
+ }
+
+ public void setCoordinateX(String coordinateX) {
+ this.coordinateX = coordinateX;
+ }
+
+ public String getCoordinateY() {
+ return coordinateY;
+ }
+
+ public void setCoordinateY(String coordinateY) {
+ this.coordinateY = coordinateY;
+ }
+
+ public int getDeep() {
+ return deep;
+ }
+
+ public void setDeep(int deep) {
+ this.deep = deep;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDeviceCount() {
+ return deviceCount;
+ }
+
+ public void setDeviceCount(String deviceCount) {
+ this.deviceCount = deviceCount;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLatBaidu() {
+ return latBaidu;
+ }
+
+ public void setLatBaidu(String latBaidu) {
+ this.latBaidu = latBaidu;
+ }
+
+ public String getLatGaode() {
+ return latGaode;
+ }
+
+ public void setLatGaode(String latGaode) {
+ this.latGaode = latGaode;
+ }
+
+ public String getLngBaidu() {
+ return lngBaidu;
+ }
+
+ public void setLngBaidu(String lngBaidu) {
+ this.lngBaidu = lngBaidu;
+ }
+
+ public String getLngGaode() {
+ return lngGaode;
+ }
+
+ public void setLngGaode(String lngGaode) {
+ this.lngGaode = lngGaode;
+ }
+
+ public String getNotes() {
+ return notes;
+ }
+
+ public void setNotes(String notes) {
+ this.notes = notes;
+ }
+
+ public String getPhotos() {
+ return photos;
+ }
+
+ public void setPhotos(String photos) {
+ this.photos = photos;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public String getQu() {
+ return qu;
+ }
+
+ public void setQu(String qu) {
+ this.qu = qu;
+ }
+
+ public String getResponsibleDept() {
+ return responsibleDept;
+ }
+
+ public void setResponsibleDept(String responsibleDept) {
+ this.responsibleDept = responsibleDept;
+ }
+
+ public String getResponsibleDeptName() {
+ return responsibleDeptName;
+ }
+
+ public void setResponsibleDeptName(String responsibleDeptName) {
+ this.responsibleDeptName = responsibleDeptName;
+ }
+
+ public String getTs() {
+ return ts;
+ }
+
+ public void setTs(String ts) {
+ this.ts = ts;
+ }
+
+ public String getValid() {
+ return valid;
+ }
+
+ public void setValid(String valid) {
+ this.valid = valid;
+ }
+
+ public String getWellCode() {
+ return wellCode;
+ }
+
+ public void setWellCode(String wellCode) {
+ this.wellCode = wellCode;
+ }
+
+ public String getWellFlag1() {
+ return wellFlag1;
+ }
+
+ public void setWellFlag1(String wellFlag1) {
+ this.wellFlag1 = wellFlag1;
+ }
+
+ public String getWellFlag2() {
+ return wellFlag2;
+ }
+
+ public void setWellFlag2(String wellFlag2) {
+ this.wellFlag2 = wellFlag2;
+ }
+
+ public String getWellFlag3() {
+ return wellFlag3;
+ }
+
+ public void setWellFlag3(String wellFlag3) {
+ this.wellFlag3 = wellFlag3;
+ }
+
+ public String getWellName() {
+ return wellName;
+ }
+
+ public void setWellName(String wellName) {
+ this.wellName = wellName;
+ }
+
+ public String getWellType() {
+ return wellType;
+ }
+
+ public void setWellType(String wellType) {
+ this.wellType = wellType;
+ }
+
+ public String getWellTypeName() {
+ return wellTypeName;
+ }
+
+ public void setWellTypeName(String wellTypeName) {
+ this.wellTypeName = wellTypeName;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt b/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
index d5ac3ec..608dd91 100644
--- a/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
+++ b/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
@@ -22,6 +22,7 @@
* =============================================================================================
* */
const val PERMISSIONS_CODE = 999
+ const val PAGE_LIMIT = 20
/**
* =============================================================================================
diff --git a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt
index 64c5402..f715247 100644
--- a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt
+++ b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt
@@ -69,4 +69,64 @@
*/
@POST("/app/checkVersion")
suspend fun obtainVersionResult(@Header("token") token: String): String
+
+ /**
+ * 获取管盯分页列表
+ * */
+ @GET("/device/list")
+ suspend fun obtainDeviceListByType(
+ @Header("token") token: String,
+ @Query("deptid") deptid: String?,
+ @Query("keywords") keywords: String?,
+ @Query("deviceType") deviceType: String?,
+ @Query("isOnline") isOnline: String?,
+ @Query("sort") sort: String?,
+ @Query("order") order: String?,
+ @Query("offset") offset: Int,
+ @Query("limit") limit: Int
+ ): String
+
+ /**
+ * 获取闸井详情
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/info")
+ suspend fun obtainWellDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 根据部门获取区ID
+ *
+ * @param deptId
+ */
+ @GET("/config/getAreaByDept")
+ suspend fun obtainAreaByDept(
+ @Header("token") token: String,
+ @Query("deptId") deptId: String
+ ): String
+
+ /**
+ * 获取区/县等
+ *
+ * @param pid
+ */
+ @GET("/area/list")
+ suspend fun obtainDistrict(
+ @Header("token") token: String,
+ @Query("pid") pid: String
+ ): String
+
+ /**
+ * 获取街道
+ *
+ * @param pid
+ */
+ @GET("/area/list")
+ suspend fun obtainStreet(
+ @Header("token") token: String,
+ @Query("pid") pid: String
+ ): String
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt
index 2af9a24..d888e59 100644
--- a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt
+++ b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt
@@ -1,6 +1,7 @@
package com.casic.smarttube.utils.retrofit
import com.casic.smarttube.utils.AuthenticationHelper
+import com.casic.smarttube.utils.LocalConstant
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.MultipartBody
import okhttp3.RequestBody
@@ -54,6 +55,46 @@
}
/**
+ * 根据设备类型获取设备分页列表
+ */
+ suspend fun obtainDeviceListByType(
+ deptid: String, keywords: String, isOnline: String, page: Int
+ ): String {
+ return api.obtainDeviceListByType(
+ AuthenticationHelper.token!!, deptid, keywords, "12", isOnline,
+ "id", "asc", page, LocalConstant.PAGE_LIMIT
+ )
+ }
+
+ /**
+ * 获取闸井详情
+ */
+ suspend fun obtainWellDetail(id: String): String {
+ return api.obtainWellDetail(AuthenticationHelper.token!!, id)
+ }
+
+ /**
+ * 根据部门获取区ID
+ */
+ suspend fun obtainAreaByDept(deptId: String): String {
+ return api.obtainAreaByDept(AuthenticationHelper.token!!, deptId)
+ }
+
+ /**
+ * 获取区/县等
+ */
+ suspend fun obtainDistrict(pid: String): String {
+ return api.obtainDistrict(AuthenticationHelper.token!!, pid)
+ }
+
+ /**
+ * 获取街道
+ */
+ suspend fun obtainStreet(pid: String): String {
+ return api.obtainStreet(AuthenticationHelper.token!!, pid)
+ }
+
+ /**
* 上传图片
*/
suspend fun uploadImage(image: File): String {
diff --git a/app/src/main/java/com/casic/smarttube/view/WellDetailActivity.kt b/app/src/main/java/com/casic/smarttube/view/WellDetailActivity.kt
new file mode 100644
index 0000000..457c06f
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/view/WellDetailActivity.kt
@@ -0,0 +1,173 @@
+package com.casic.smarttube.view
+
+import android.os.Bundle
+import androidx.lifecycle.ViewModelProvider
+import com.amap.api.maps.AMap
+import com.amap.api.maps.AMapOptions
+import com.amap.api.maps.CameraUpdateFactory
+import com.amap.api.maps.model.BitmapDescriptorFactory
+import com.amap.api.maps.model.CameraPosition
+import com.amap.api.maps.model.LatLng
+import com.amap.api.maps.model.MarkerOptions
+import com.casic.smarttube.R
+import com.casic.smarttube.utils.DialogHelper
+import com.casic.smarttube.vm.AuthenticateViewModel
+import com.casic.smarttube.vm.WellViewModel
+import com.gyf.immersionbar.ImmersionBar
+import com.pengxh.kt.lite.base.KotlinBaseActivity
+import com.pengxh.kt.lite.extensions.convertColor
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.utils.Constant
+import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil
+import com.pengxh.kt.lite.vm.LoadState
+import kotlinx.android.synthetic.main.activity_well_detail.*
+import kotlinx.android.synthetic.main.include_base_title.*
+
+
+class WellDetailActivity : KotlinBaseActivity(), AMap.OnMapLoadedListener {
+
+ private lateinit var wellViewModel: WellViewModel
+ private lateinit var authenticateViewModel: AuthenticateViewModel
+ private lateinit var wellId: String
+ private lateinit var aMap: AMap
+ private var latLng: LatLng? = null
+
+
+ override fun initLayoutView(): Int = R.layout.activity_well_detail
+
+ override fun setupTopBarLayout() {
+ ImmersionBar.with(this).statusBarDarkFont(false).init()
+ ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this))
+ leftBackView.setOnClickListener { finish() }
+ titleView.text = "井详情"
+ }
+
+ override fun initData() {
+ wellId = intent.getStringExtra(Constant.INTENT_PARAM)!!
+ wellViewModel = ViewModelProvider(this).get(WellViewModel::class.java)
+ authenticateViewModel = ViewModelProvider(this).get(AuthenticateViewModel::class.java)
+
+ aMap = wellMapView.map
+ aMap.mapType = AMap.MAP_TYPE_NORMAL
+ val uiSettings = aMap.uiSettings
+ uiSettings.isCompassEnabled = true
+ uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER
+ uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度
+ uiSettings.isRotateGesturesEnabled = false//不允许地图旋转
+
+ //地图加载成功之后调用
+ aMap.addOnMapLoadedListener(this)
+ }
+
+ override fun onMapLoaded() {
+ if (latLng == null) {
+ "该闸井经纬度异常,无法在地图显示".show(this)
+ return
+ }
+ /**
+ * 参数1---要移动到的经纬度
+ * 参数2---地图的放缩级别zoom
+ * 参数3---地图倾斜度
+ * 参数4---地图的旋转角度
+ * */
+ val cameraPosition = CameraPosition(latLng, 13f, 0f, 0f)
+ val newCameraPosition = CameraUpdateFactory.newCameraPosition(cameraPosition)
+ aMap.animateCamera(newCameraPosition, 3000, object : AMap.CancelableCallback {
+ override fun onFinish() {
+ //添加Marker
+ val markerOptions = MarkerOptions()
+ .position(latLng)
+ .icon(BitmapDescriptorFactory.fromResource(R.mipmap.well_location))
+ .draggable(true)
+ aMap.addMarker(markerOptions)
+ }
+
+ override fun onCancel() {
+
+ }
+ })
+ }
+
+ override fun initEvent() {
+ wellViewModel.obtainWellDetail(wellId)
+ wellViewModel.detailModel.observe(this, {
+ if (it.code == 200) {
+ val wellDetail = it.data!!
+
+ wellNameView.text = wellDetail.wellName
+ wellTypeView.text = wellDetail.wellTypeName
+ wellCodeView.text = wellDetail.wellCode
+ ownerShipView.text = wellDetail.deptName
+ wellStateView.text = wellDetail.bfztName
+ wellDepthView.text = wellDetail.deep.toString()
+ //绑定窨井位置
+ if (wellDetail.latGaode.isBlank() || wellDetail.lngGaode.isBlank()) {
+ wellLocationView.text = wellDetail.position
+ return@observe
+ }
+ this.latLng = LatLng(wellDetail.latGaode.toDouble(), wellDetail.lngGaode.toDouble())
+ authenticateViewModel.obtainAreaByDept(wellDetail.deptid)
+ authenticateViewModel.areaModel.observe(this, { areaModel ->
+ if (areaModel.code == 200) {
+ authenticateViewModel.obtainDistrict(areaModel.data.area)
+ }
+ })
+ authenticateViewModel.districtModel.observe(this, { districtModel ->
+ if (districtModel.code == 200) {
+ districtModel.data.forEach { area ->
+ if (area.id == wellDetail.qu) {
+ authenticateViewModel.obtainStreet(area.id)
+ authenticateViewModel.streetModel.observe(this, { street ->
+ if (street.code == 200) {
+ street.data.forEach { streetData ->
+ if (streetData.id == wellDetail.area) {
+ wellLocationView.text =
+ String.format("${area.name}${streetData.name}-${wellDetail.position}")
+ }
+ }
+ }
+ })
+ }
+ }
+ }
+ })
+ }
+ })
+ wellViewModel.loadState.observe(this, {
+ when (it) {
+ is LoadState.Loading -> {
+ DialogHelper.showLoadingDialog(this, "数据加载中,请稍后")
+ }
+ else -> {
+ DialogHelper.dismissLoadingDialog()
+ }
+ }
+ })
+ }
+
+ /**地图相关*********/
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ wellMapView.onCreate(savedInstanceState)
+ }
+
+ override fun onResume() {
+ super.onResume()
+ wellMapView.onResume()
+ }
+
+ override fun onPause() {
+ super.onPause()
+ wellMapView.onPause()
+ }
+
+ override fun onDestroy() {
+ wellMapView.onDestroy()
+ super.onDestroy()
+ }
+
+ override fun onSaveInstanceState(outState: Bundle) {
+ super.onSaveInstanceState(outState)
+ wellMapView.onSaveInstanceState(outState)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/vm/AuthenticateViewModel.kt b/app/src/main/java/com/casic/smarttube/vm/AuthenticateViewModel.kt
index 7ad6379..882fea2 100644
--- a/app/src/main/java/com/casic/smarttube/vm/AuthenticateViewModel.kt
+++ b/app/src/main/java/com/casic/smarttube/vm/AuthenticateViewModel.kt
@@ -4,7 +4,10 @@
import com.casic.smarttube.base.BaseApplication
import com.casic.smarttube.extensions.separateResponseCode
import com.casic.smarttube.extensions.toErrorMessage
+import com.casic.smarttube.model.AreaModel
+import com.casic.smarttube.model.DistrictModel
import com.casic.smarttube.model.PublicKeyModel
+import com.casic.smarttube.model.StreetModel
import com.casic.smarttube.utils.retrofit.RetrofitServiceManager
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
@@ -16,6 +19,9 @@
private val gson = Gson()
val keyModel = MutableLiveData()
+ val areaModel = MutableLiveData()
+ val districtModel = MutableLiveData()
+ val streetModel = MutableLiveData()
fun obtainPublicKey() = launch({
val response = RetrofitServiceManager.authenticate()
@@ -30,4 +36,55 @@
}, {
it.printStackTrace()
})
+
+ /**
+ * 根据部门获取区ID
+ */
+ fun obtainAreaByDept(deptId: String) = launch({
+ val response = RetrofitServiceManager.obtainAreaByDept(deptId)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ areaModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ response.toErrorMessage().show(BaseApplication.obtainInstance())
+ }
+ }, {
+ it.printStackTrace()
+ })
+
+ /**
+ * 区/县等
+ */
+ fun obtainDistrict(pid: String) = launch({
+ val response = RetrofitServiceManager.obtainDistrict(pid)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ districtModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ response.toErrorMessage().show(BaseApplication.obtainInstance())
+ }
+ }, {
+ it.printStackTrace()
+ })
+
+ /**
+ * 街道
+ */
+ fun obtainStreet(areaId: String) = launch({
+ val response = RetrofitServiceManager.obtainStreet(areaId)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ streetModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ response.toErrorMessage().show(BaseApplication.obtainInstance())
+ }
+ }, {
+ it.printStackTrace()
+ })
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/vm/DeviceViewModel.kt b/app/src/main/java/com/casic/smarttube/vm/DeviceViewModel.kt
new file mode 100644
index 0000000..6a12e14
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/vm/DeviceViewModel.kt
@@ -0,0 +1,35 @@
+package com.casic.smarttube.vm
+
+import androidx.lifecycle.MutableLiveData
+import com.casic.smarttube.base.BaseApplication
+import com.casic.smarttube.extensions.separateResponseCode
+import com.casic.smarttube.extensions.toErrorMessage
+import com.casic.smarttube.model.DeviceListModel
+import com.casic.smarttube.utils.retrofit.RetrofitServiceManager
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import com.pengxh.kt.lite.extensions.launch
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.vm.BaseViewModel
+
+class DeviceViewModel : BaseViewModel() {
+
+ private val gson = Gson()
+ val deviceListModel = MutableLiveData()
+
+ fun obtainDeviceListByType(deptid: String, keywords: String, isOnline: String, page: Int) =
+ launch({
+ val response =
+ RetrofitServiceManager.obtainDeviceListByType(deptid, keywords, isOnline, page)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ deviceListModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ response.toErrorMessage().show(BaseApplication.obtainInstance())
+ }
+ }, {
+ it.printStackTrace()
+ })
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/vm/WellViewModel.kt b/app/src/main/java/com/casic/smarttube/vm/WellViewModel.kt
new file mode 100644
index 0000000..71b14d5
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/vm/WellViewModel.kt
@@ -0,0 +1,209 @@
+package com.casic.smarttube.vm
+
+import androidx.lifecycle.MutableLiveData
+import com.casic.smarttube.base.BaseApplication
+import com.casic.smarttube.extensions.separateResponseCode
+import com.casic.smarttube.extensions.toErrorMessage
+import com.casic.smarttube.model.WellDetailModel
+import com.casic.smarttube.utils.retrofit.RetrofitServiceManager
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import com.pengxh.kt.lite.extensions.launch
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.vm.BaseViewModel
+import com.pengxh.kt.lite.vm.LoadState
+
+class WellViewModel : BaseViewModel() {
+
+ private val gson = Gson()
+ val detailModel = MutableLiveData()
+// val allWellModel = MutableLiveData()
+// val countResultModel = MutableLiveData>()
+// val wellTypeAndCountModel = MutableLiveData()
+// val wellListPageModel = MutableLiveData()
+// val wellTypeModel = MutableLiveData()
+// val deviceDataModel = MutableLiveData()
+// val commonResultModel = MutableLiveData()
+
+ fun obtainWellDetail(id: String) = launch({
+ loadState.value = LoadState.Loading
+ val response = RetrofitServiceManager.obtainWellDetail(id)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ loadState.value = LoadState.Success
+ detailModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ loadState.value = LoadState.Fail
+ response.toErrorMessage().show(BaseApplication.obtainInstance())
+ }
+ }, {
+ loadState.value = LoadState.Fail
+ it.printStackTrace()
+ })
+
+// fun obtainAllWell() = launch({
+// val response = RetrofitServiceManager.obtainAllWell()
+// val responseCode = response.separateResponseCode()
+// if (responseCode == 200) {
+// allWellModel.value = gson.fromJson(
+// response, object : TypeToken() {}.type
+// )
+// } else {
+// response.toErrorMessage().show()
+// }
+// }, {
+// it.printStackTrace()
+// })
+//
+// fun countWellByState() = launch({
+// val response = RetrofitServiceManager.countWellByState()
+// val responseCode = response.separateResponseCode()
+// if (responseCode == 200) {
+// val map = HashMap(3)
+//
+// val jsonObject = JSONObject(response)
+// val data = jsonObject.getJSONObject("data")
+// map["bfWell"] = data.getString("bfWell")
+// map["cfWell"] = data.getString("cfWell")
+// map["total"] = data.getString("total")
+// countResultModel.value = map
+// } else {
+// response.toErrorMessage().show()
+// }
+// }, {
+// it.printStackTrace()
+// })
+//
+// fun obtainWellTypeAndCount() = launch({
+// val response = RetrofitServiceManager.obtainWellTypeAndCount()
+// val responseCode = response.separateResponseCode()
+// if (responseCode == 200) {
+// wellTypeAndCountModel.value = gson.fromJson(
+// response, object : TypeToken() {}.type
+// )
+// } else {
+// response.toErrorMessage().show()
+// }
+// }, {
+// it.printStackTrace()
+// })
+//
+// fun obtainWellPageList(keywords: String?, wellType: String?, deptid: String?, offset: Int) =
+// launch({
+// val response =
+// RetrofitServiceManager.obtainWellPageList(keywords, wellType, deptid, offset)
+// val responseCode = response.separateResponseCode()
+// if (responseCode == 200) {
+// wellListPageModel.value = gson.fromJson(
+// response, object : TypeToken() {}.type
+// )
+// } else {
+// response.toErrorMessage().show()
+// }
+// }, {
+// it.printStackTrace()
+// })
+//
+// fun obtainWellType() = launch({
+// val response = RetrofitServiceManager.obtainWellType()
+// val responseCode = response.separateResponseCode()
+// if (responseCode == 200) {
+// wellTypeModel.value = gson.fromJson(
+// response, object : TypeToken() {}.type
+// )
+// } else {
+// response.toErrorMessage().show()
+// }
+// }, {
+// it.printStackTrace()
+// })
+//
+// fun obtainDeviceDataByWell(id: String) = launch({
+// val response = RetrofitServiceManager.obtainDeviceDataByWell(id)
+// val responseCode = response.separateResponseCode()
+// if (responseCode == 200) {
+// deviceDataModel.value = gson.fromJson(
+// response, object : TypeToken() {}.type
+// )
+// } else {
+// response.toErrorMessage().show()
+// }
+// }, {
+// it.printStackTrace()
+// })
+//
+// fun obtainOperationResult(id: String, state: String) = launch({
+// loadState.value = LoadState.Loading
+// val response = RetrofitServiceManager.obtainOperationResult(id, state)
+// val responseCode = response.separateResponseCode()
+// if (responseCode == 200) {
+// loadState.value = LoadState.Success
+// "操作成功".show()
+// commonResultModel.value = gson.fromJson(
+// response, object : TypeToken() {}.type
+// )
+// } else {
+// loadState.value = LoadState.Fail
+// response.toErrorMessage().show()
+// }
+// }, {
+// loadState.value = LoadState.Fail
+// it.printStackTrace()
+// })
+//
+// /**
+// * 编辑更新井信息
+// * */
+// fun updateWellDetail(
+// id: String,
+// wellCode: String,
+// wellName: String,
+// wellType: String,
+// deptid: String,
+// deep: String,
+// position: String,
+// coordinateX: String,
+// coordinateY: String,
+// photos: String,
+// notes: String?,
+// qu: String,
+// area: String,
+// responsibleDept: String,
+// responsibleDeptName: String
+// ) = launch({
+// loadState.value = LoadState.Loading
+// val response = RetrofitServiceManager.updateWellDetail(
+// id,
+// wellCode,
+// wellName,
+// wellType,
+// deptid,
+// deep,
+// position,
+// coordinateX,
+// coordinateY,
+// photos,
+// notes,
+// qu,
+// area,
+// responsibleDept,
+// responsibleDeptName
+// )
+// val responseCode = response.separateResponseCode()
+// if (responseCode == 200) {
+// loadState.value = LoadState.Success
+// "更新成功".show()
+// commonResultModel.value = gson.fromJson(
+// response, object : TypeToken() {}.type
+// )
+// } else {
+// loadState.value = LoadState.Fail
+// response.toErrorMessage().show()
+// }
+// }, {
+// loadState.value = LoadState.Fail
+// it.printStackTrace()
+// })
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cbc72b6..a9b50c5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,7 +26,7 @@
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true"
- android:theme="@style/AppTheme"
+ android:theme="@style/QMUI.Compat.NoActionBar"
android:usesCleartextTraffic="true">
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
new file mode 100644
index 0000000..e3c059d
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/adapter/DeviceListAdapter.kt
@@ -0,0 +1,111 @@
+package com.casic.smarttube.adapter
+
+import android.content.Context
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import android.widget.ImageView
+import android.widget.TextView
+import androidx.recyclerview.widget.RecyclerView
+import com.casic.smarttube.R
+import com.casic.smarttube.extensions.arrowAnimation
+import com.casic.smarttube.model.DeviceListModel
+import com.github.mikephil.charting.charts.LineChart
+import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
+
+class DeviceListAdapter(
+ private val context: Context,
+ private val dataRows: MutableList
+) : RecyclerView.Adapter() {
+
+ private var layoutInflater: LayoutInflater = LayoutInflater.from(context)
+ private var isExpand = false
+
+ override fun onCreateViewHolder(
+ parent: ViewGroup, viewType: Int
+ ): DeviceListAdapter.ItemViewHolder {
+ return ItemViewHolder(
+ layoutInflater.inflate(R.layout.item_device_recycleview, parent, false)
+ )
+ }
+
+ override fun getItemCount(): Int = dataRows.size
+
+ override fun onBindViewHolder(holder: DeviceListAdapter.ItemViewHolder, position: Int) {
+ //绑定数据
+ val rowsBean = dataRows[position]
+ holder.deviceStateView.text = rowsBean.onlineStateName
+ if (rowsBean.onlineState == "1") {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_green_radius_5)
+ } else {
+ holder.deviceStateView.setBackgroundResource(R.drawable.bg_solid_text_gray_radius_5)
+ }
+ holder.deviceCodeView.text = rowsBean.devcode
+ holder.wellCodeView.text = String.format("井编号:${rowsBean.wellCode}")
+ holder.ownerShipView.text = String.format("权属单位:${rowsBean.deptName}")
+ holder.deviceLocationView.text = String.format("设备位置:${rowsBean.position}")
+ holder.installDateView.text = String.format("安装日期:${rowsBean.installDate}")
+
+
+ if (listener != null) {
+ holder.itemView.setOnClickListener {
+ listener!!.onClicked(position)
+ }
+ holder.dataHistoryButton.setOnClickListener {
+ listener!!.onHistoryClicked(position)
+ }
+ holder.editButton.setOnClickListener {
+ listener!!.onEditClicked(position)
+ }
+ holder.wellDetailButton.setOnClickListener {
+ listener!!.onWellDetailClicked(position)
+ }
+
+ holder.expandableImageView.setOnClickListener {
+ if (!isExpand) {
+ //展开列表动画
+ holder.expandableImageView.arrowAnimation(180f)
+ isExpand = true
+ //子列表绑定数据
+// expandableViewAdapter.setExpandableData(createExpandableList(rowsBean))
+ } else {
+ //关闭列表动画
+ holder.expandableImageView.arrowAnimation(0f)
+ isExpand = false
+ //子列表清空数据
+// expandableViewAdapter.clearAll()
+ }
+ }
+ }
+ }
+
+ inner class ItemViewHolder(view: View) : RecyclerView.ViewHolder(view) {
+ var deviceStateView: TextView = view.findViewById(R.id.deviceStateView)
+ var deviceCodeView: TextView = view.findViewById(R.id.deviceCodeView)
+ var expandableImageView: ImageView = view.findViewById(R.id.expandableImageView)
+ var wellCodeView: TextView = view.findViewById(R.id.wellCodeView)
+ var ownerShipView: TextView = view.findViewById(R.id.ownerShipView)
+ var deviceLocationView: TextView = view.findViewById(R.id.deviceLocationView)
+ var installDateView: TextView = view.findViewById(R.id.installDateView)
+ var dataHistoryButton: QMUIRoundButton = view.findViewById(R.id.dataHistoryButton)
+ var editButton: QMUIRoundButton = view.findViewById(R.id.editButton)
+ var wellDetailButton: QMUIRoundButton = view.findViewById(R.id.wellDetailButton)
+ var expandableChartView: LineChart = view.findViewById(R.id.expandableChartView)
+ }
+
+ private var listener: OnItemClickListener? = null
+
+ interface OnItemClickListener {
+ fun onClicked(position: Int)
+
+ fun onHistoryClicked(position: Int)
+
+ fun onEditClicked(position: Int)
+
+ fun onWellDetailClicked(position: Int)
+ }
+
+ fun setOnItemClickListener(onClickListener: OnItemClickListener?) {
+ this.listener = onClickListener
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
new file mode 100644
index 0000000..d185752
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/ImageView.kt
@@ -0,0 +1,11 @@
+package com.casic.smarttube.extensions
+
+import android.view.animation.LinearInterpolator
+import android.widget.ImageView
+
+fun ImageView.arrowAnimation(angle: Float) {
+ val animation = this.animate()
+ animation.duration = 300
+ animation.interpolator = LinearInterpolator()
+ animation.rotation(angle)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
new file mode 100644
index 0000000..22e56d2
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/extensions/QMUIEmptyView.kt
@@ -0,0 +1,12 @@
+package com.casic.smarttube.extensions
+
+import android.view.View
+import com.qmuiteam.qmui.widget.QMUIEmptyView
+
+fun QMUIEmptyView.showEmptyPage(onButtonClickListener: View.OnClickListener) {
+ this.show(false, "抱歉,无法查询到相关记录", null, "重试", onButtonClickListener)
+}
+
+fun QMUIEmptyView.showEmptyPage(title: String, onButtonClickListener: View.OnClickListener) {
+ this.show(false, title, null, "刷新", onButtonClickListener)
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
index 16d7e5c..1ef9226 100644
--- a/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
+++ b/app/src/main/java/com/casic/smarttube/fragment/OverviewFragment.kt
@@ -1,10 +1,31 @@
package com.casic.smarttube.fragment
+import android.os.Handler
+import androidx.lifecycle.ViewModelProvider
+import androidx.recyclerview.widget.LinearLayoutManager
import com.casic.smarttube.R
+import com.casic.smarttube.adapter.DeviceListAdapter
+import com.casic.smarttube.extensions.showEmptyPage
+import com.casic.smarttube.model.DeviceListModel
+import com.casic.smarttube.view.WellDetailActivity
+import com.casic.smarttube.vm.DeviceViewModel
import com.pengxh.kt.lite.base.KotlinBaseFragment
+import com.pengxh.kt.lite.extensions.navigatePageTo
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.utils.WeakReferenceHandler
+import kotlinx.android.synthetic.main.fragment_overview.*
+import kotlinx.android.synthetic.main.include_empty_view.*
class OverviewFragment : KotlinBaseFragment() {
+ private lateinit var weakReferenceHandler: WeakReferenceHandler
+ private lateinit var deviceViewModel: DeviceViewModel
+ private lateinit var deviceAdapter: DeviceListAdapter
+ private var dataBeans: MutableList = ArrayList()
+ private var pageIndex = 1
+ private var isRefresh = false
+ private var isLoadMore = false
+
override fun initLayoutView(): Int = R.layout.fragment_overview
override fun setupTopBarLayout() {
@@ -12,10 +33,101 @@
}
override fun initData() {
+ weakReferenceHandler = WeakReferenceHandler(callback)
+ deviceViewModel = ViewModelProvider(this).get(DeviceViewModel::class.java)
+ }
+ override fun onResume() {
+ //默认加载第一页
+ obtainDeviceList()
+ super.onResume()
}
override fun initEvent() {
+ overviewLayout.setOnRefreshListener {
+ isRefresh = true
+ //刷新之后页码重置
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ overviewLayout.setOnLoadMoreListener {
+ isLoadMore = true
+ pageIndex++
+ obtainDeviceList()
+ }
+ deviceViewModel.deviceListModel.observe(this, {
+ if (it.code == 200) {
+ val dataRows = it.data?.rows
+ when {
+ isRefresh -> {
+ dataBeans.clear()
+ dataBeans = dataRows!!
+ overviewLayout.finishRefresh()
+ isRefresh = false
+ }
+ isLoadMore -> {
+ if (dataRows?.size == 0) {
+ "到底了,别拉了".show(requireContext())
+ }
+ dataBeans.addAll(dataRows!!)
+ overviewLayout.finishLoadMore()
+ isLoadMore = false
+ }
+ else -> {
+ dataBeans = dataRows!!
+ }
+ }
+ weakReferenceHandler.sendEmptyMessage(2022062401)
+ }
+ })
+ }
+
+ private fun obtainDeviceList() {
+ deviceViewModel.obtainDeviceListByType("", "", "", pageIndex)
+ }
+
+ private val callback = Handler.Callback {
+ if (it.what == 2022062401) {
+ if (isRefresh || isLoadMore) {
+ deviceAdapter.notifyDataSetChanged()
+ } else {
+ if (dataBeans.size == 0) {
+ emptyView!!.showEmptyPage("这里什么都没有") {
+ pageIndex = 1
+ obtainDeviceList()
+ }
+ } else {
+ emptyView!!.hide()
+ deviceAdapter = DeviceListAdapter(requireContext(), dataBeans)
+ recyclerView!!.layoutManager = LinearLayoutManager(requireContext())
+ recyclerView!!.adapter = deviceAdapter
+ deviceAdapter.setOnItemClickListener(object :
+ DeviceListAdapter.OnItemClickListener {
+ override fun onClicked(position: Int) {
+// val jobId = dataBeans[position].jobId.toString()
+// if (jobId.isBlank()) {
+// "设备编号异常,无法查看详情".show(requireContext())
+// return
+// }
+// requireContext().navigatePageTo(jobId)
+ }
+
+ override fun onHistoryClicked(position: Int) {
+
+ }
+
+ override fun onEditClicked(position: Int) {
+
+ }
+
+ override fun onWellDetailClicked(position: Int) {
+ requireContext().navigatePageTo(dataBeans[position].wellId)
+ }
+ })
+ }
+ }
+ }
+ true
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/model/AreaModel.java b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
new file mode 100644
index 0000000..c6f86ef
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/AreaModel.java
@@ -0,0 +1,125 @@
+package com.casic.smarttube.model;
+
+public class AreaModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String area;
+ private String communications;
+ private String deptid;
+ private String deviceTypes;
+ private String id;
+ private String lat;
+ private String lng;
+ private String map;
+ private String wellTypes;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getCommunications() {
+ return communications;
+ }
+
+ public void setCommunications(String communications) {
+ this.communications = communications;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDeviceTypes() {
+ return deviceTypes;
+ }
+
+ public void setDeviceTypes(String deviceTypes) {
+ this.deviceTypes = deviceTypes;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getMap() {
+ return map;
+ }
+
+ public void setMap(String map) {
+ this.map = map;
+ }
+
+ public String getWellTypes() {
+ return wellTypes;
+ }
+
+ public void setWellTypes(String wellTypes) {
+ this.wellTypes = wellTypes;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
new file mode 100644
index 0000000..b34eb55
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DeviceListModel.java
@@ -0,0 +1,274 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DeviceListModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private List rows;
+ private int total;
+
+ public List getRows() {
+ return rows;
+ }
+
+ public void setRows(List rows) {
+ this.rows = rows;
+ }
+
+ public int getTotal() {
+ return total;
+ }
+
+ public void setTotal(int total) {
+ this.total = total;
+ }
+
+ public static class RowsBean {
+ private String bfzt;
+ private String bfztName;
+ private String communication;
+ private String concenCode;
+ private String concenId;
+ private String deptName;
+ private String deptid;
+ private String devcode;
+ private String deviceName;
+ private String deviceType;
+ private String deviceTypeName;
+ private String id;
+ private String installDate;
+ private String modelId;
+ private String modelName;
+ private String onlineState;
+ private String onlineStateName;
+ private String position;
+ private String ts;
+ private String valid;
+ private String watchType;
+ private String wellCode;
+ private String wellId;
+
+ public String getBfzt() {
+ return bfzt;
+ }
+
+ public void setBfzt(String bfzt) {
+ this.bfzt = bfzt;
+ }
+
+ public String getBfztName() {
+ return bfztName;
+ }
+
+ public void setBfztName(String bfztName) {
+ this.bfztName = bfztName;
+ }
+
+ public String getCommunication() {
+ return communication;
+ }
+
+ public void setCommunication(String communication) {
+ this.communication = communication;
+ }
+
+ public String getConcenCode() {
+ return concenCode;
+ }
+
+ public void setConcenCode(String concenCode) {
+ this.concenCode = concenCode;
+ }
+
+ public String getConcenId() {
+ return concenId;
+ }
+
+ public void setConcenId(String concenId) {
+ this.concenId = concenId;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDevcode() {
+ return devcode;
+ }
+
+ public void setDevcode(String devcode) {
+ this.devcode = devcode;
+ }
+
+ public String getDeviceName() {
+ return deviceName;
+ }
+
+ public void setDeviceName(String deviceName) {
+ this.deviceName = deviceName;
+ }
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public void setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ }
+
+ public String getDeviceTypeName() {
+ return deviceTypeName;
+ }
+
+ public void setDeviceTypeName(String deviceTypeName) {
+ this.deviceTypeName = deviceTypeName;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getInstallDate() {
+ return installDate;
+ }
+
+ public void setInstallDate(String installDate) {
+ this.installDate = installDate;
+ }
+
+ public String getModelId() {
+ return modelId;
+ }
+
+ public void setModelId(String modelId) {
+ this.modelId = modelId;
+ }
+
+ public String getModelName() {
+ return modelName;
+ }
+
+ public void setModelName(String modelName) {
+ this.modelName = modelName;
+ }
+
+ public String getOnlineState() {
+ return onlineState;
+ }
+
+ public void setOnlineState(String onlineState) {
+ this.onlineState = onlineState;
+ }
+
+ public String getOnlineStateName() {
+ return onlineStateName;
+ }
+
+ public void setOnlineStateName(String onlineStateName) {
+ this.onlineStateName = onlineStateName;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public String getTs() {
+ return ts;
+ }
+
+ public void setTs(String ts) {
+ this.ts = ts;
+ }
+
+ public String getValid() {
+ return valid;
+ }
+
+ public void setValid(String valid) {
+ this.valid = valid;
+ }
+
+ public String getWatchType() {
+ return watchType;
+ }
+
+ public void setWatchType(String watchType) {
+ this.watchType = watchType;
+ }
+
+ public String getWellCode() {
+ return wellCode;
+ }
+
+ public void setWellCode(String wellCode) {
+ this.wellCode = wellCode;
+ }
+
+ public String getWellId() {
+ return wellId;
+ }
+
+ public void setWellId(String wellId) {
+ this.wellId = wellId;
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/DistrictModel.java b/app/src/main/java/com/casic/smarttube/model/DistrictModel.java
new file mode 100644
index 0000000..437405f
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/DistrictModel.java
@@ -0,0 +1,172 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class DistrictModel {
+
+ private int code;
+ private List data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String id;
+ private String isSync;
+ private String lat;
+ private int level;
+ private String levelName;
+ private String lng;
+ private String name;
+ private int num;
+ private String pName;
+ private String pid;
+ private String pids;
+ private String simplename;
+ private String targetIdSync;
+ private String targetPidSync;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getIsSync() {
+ return isSync;
+ }
+
+ public void setIsSync(String isSync) {
+ this.isSync = isSync;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+
+ public String getLevelName() {
+ return levelName;
+ }
+
+ public void setLevelName(String levelName) {
+ this.levelName = levelName;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public String getPName() {
+ return pName;
+ }
+
+ public void setPName(String pName) {
+ this.pName = pName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getPids() {
+ return pids;
+ }
+
+ public void setPids(String pids) {
+ this.pids = pids;
+ }
+
+ public String getSimplename() {
+ return simplename;
+ }
+
+ public void setSimplename(String simplename) {
+ this.simplename = simplename;
+ }
+
+ public String getTargetIdSync() {
+ return targetIdSync;
+ }
+
+ public void setTargetIdSync(String targetIdSync) {
+ this.targetIdSync = targetIdSync;
+ }
+
+ public String getTargetPidSync() {
+ return targetPidSync;
+ }
+
+ public void setTargetPidSync(String targetPidSync) {
+ this.targetPidSync = targetPidSync;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/StreetModel.java b/app/src/main/java/com/casic/smarttube/model/StreetModel.java
new file mode 100644
index 0000000..57fa295
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/StreetModel.java
@@ -0,0 +1,172 @@
+package com.casic.smarttube.model;
+
+import java.util.List;
+
+public class StreetModel {
+
+ private int code;
+ private List data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public List getData() {
+ return data;
+ }
+
+ public void setData(List data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String id;
+ private String isSync;
+ private String lat;
+ private int level;
+ private String levelName;
+ private String lng;
+ private String name;
+ private int num;
+ private String pName;
+ private String pid;
+ private String pids;
+ private String simplename;
+ private String targetIdSync;
+ private String targetPidSync;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getIsSync() {
+ return isSync;
+ }
+
+ public void setIsSync(String isSync) {
+ this.isSync = isSync;
+ }
+
+ public String getLat() {
+ return lat;
+ }
+
+ public void setLat(String lat) {
+ this.lat = lat;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+
+ public String getLevelName() {
+ return levelName;
+ }
+
+ public void setLevelName(String levelName) {
+ this.levelName = levelName;
+ }
+
+ public String getLng() {
+ return lng;
+ }
+
+ public void setLng(String lng) {
+ this.lng = lng;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNum() {
+ return num;
+ }
+
+ public void setNum(int num) {
+ this.num = num;
+ }
+
+ public String getPName() {
+ return pName;
+ }
+
+ public void setPName(String pName) {
+ this.pName = pName;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public String getPids() {
+ return pids;
+ }
+
+ public void setPids(String pids) {
+ this.pids = pids;
+ }
+
+ public String getSimplename() {
+ return simplename;
+ }
+
+ public void setSimplename(String simplename) {
+ this.simplename = simplename;
+ }
+
+ public String getTargetIdSync() {
+ return targetIdSync;
+ }
+
+ public void setTargetIdSync(String targetIdSync) {
+ this.targetIdSync = targetIdSync;
+ }
+
+ public String getTargetPidSync() {
+ return targetPidSync;
+ }
+
+ public void setTargetPidSync(String targetPidSync) {
+ this.targetPidSync = targetPidSync;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java b/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java
new file mode 100644
index 0000000..c19899a
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/model/WellDetailModel.java
@@ -0,0 +1,305 @@
+package com.casic.smarttube.model;
+
+public class WellDetailModel {
+
+ private int code;
+ private DataBean data;
+ private String message;
+ private boolean success;
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public DataBean getData() {
+ return data;
+ }
+
+ public void setData(DataBean data) {
+ this.data = data;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public void setSuccess(boolean success) {
+ this.success = success;
+ }
+
+ public static class DataBean {
+ private String area;
+ private String bfzt;
+ private String bfztName;
+ private String coordinateX;
+ private String coordinateY;
+ private int deep;
+ private String deptName;
+ private String deptid;
+ private String deviceCount;
+ private String id;
+ private String latBaidu;
+ private String latGaode;
+ private String lngBaidu;
+ private String lngGaode;
+ private String notes;
+ private String photos;
+ private String position;
+ private String qu;
+ private String responsibleDept;
+ private String responsibleDeptName;
+ private String ts;
+ private String valid;
+ private String wellCode;
+ private String wellFlag1;
+ private String wellFlag2;
+ private String wellFlag3;
+ private String wellName;
+ private String wellType;
+ private String wellTypeName;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ public String getBfzt() {
+ return bfzt;
+ }
+
+ public void setBfzt(String bfzt) {
+ this.bfzt = bfzt;
+ }
+
+ public String getBfztName() {
+ return bfztName;
+ }
+
+ public void setBfztName(String bfztName) {
+ this.bfztName = bfztName;
+ }
+
+ public String getCoordinateX() {
+ return coordinateX;
+ }
+
+ public void setCoordinateX(String coordinateX) {
+ this.coordinateX = coordinateX;
+ }
+
+ public String getCoordinateY() {
+ return coordinateY;
+ }
+
+ public void setCoordinateY(String coordinateY) {
+ this.coordinateY = coordinateY;
+ }
+
+ public int getDeep() {
+ return deep;
+ }
+
+ public void setDeep(int deep) {
+ this.deep = deep;
+ }
+
+ public String getDeptName() {
+ return deptName;
+ }
+
+ public void setDeptName(String deptName) {
+ this.deptName = deptName;
+ }
+
+ public String getDeptid() {
+ return deptid;
+ }
+
+ public void setDeptid(String deptid) {
+ this.deptid = deptid;
+ }
+
+ public String getDeviceCount() {
+ return deviceCount;
+ }
+
+ public void setDeviceCount(String deviceCount) {
+ this.deviceCount = deviceCount;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLatBaidu() {
+ return latBaidu;
+ }
+
+ public void setLatBaidu(String latBaidu) {
+ this.latBaidu = latBaidu;
+ }
+
+ public String getLatGaode() {
+ return latGaode;
+ }
+
+ public void setLatGaode(String latGaode) {
+ this.latGaode = latGaode;
+ }
+
+ public String getLngBaidu() {
+ return lngBaidu;
+ }
+
+ public void setLngBaidu(String lngBaidu) {
+ this.lngBaidu = lngBaidu;
+ }
+
+ public String getLngGaode() {
+ return lngGaode;
+ }
+
+ public void setLngGaode(String lngGaode) {
+ this.lngGaode = lngGaode;
+ }
+
+ public String getNotes() {
+ return notes;
+ }
+
+ public void setNotes(String notes) {
+ this.notes = notes;
+ }
+
+ public String getPhotos() {
+ return photos;
+ }
+
+ public void setPhotos(String photos) {
+ this.photos = photos;
+ }
+
+ public String getPosition() {
+ return position;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public String getQu() {
+ return qu;
+ }
+
+ public void setQu(String qu) {
+ this.qu = qu;
+ }
+
+ public String getResponsibleDept() {
+ return responsibleDept;
+ }
+
+ public void setResponsibleDept(String responsibleDept) {
+ this.responsibleDept = responsibleDept;
+ }
+
+ public String getResponsibleDeptName() {
+ return responsibleDeptName;
+ }
+
+ public void setResponsibleDeptName(String responsibleDeptName) {
+ this.responsibleDeptName = responsibleDeptName;
+ }
+
+ public String getTs() {
+ return ts;
+ }
+
+ public void setTs(String ts) {
+ this.ts = ts;
+ }
+
+ public String getValid() {
+ return valid;
+ }
+
+ public void setValid(String valid) {
+ this.valid = valid;
+ }
+
+ public String getWellCode() {
+ return wellCode;
+ }
+
+ public void setWellCode(String wellCode) {
+ this.wellCode = wellCode;
+ }
+
+ public String getWellFlag1() {
+ return wellFlag1;
+ }
+
+ public void setWellFlag1(String wellFlag1) {
+ this.wellFlag1 = wellFlag1;
+ }
+
+ public String getWellFlag2() {
+ return wellFlag2;
+ }
+
+ public void setWellFlag2(String wellFlag2) {
+ this.wellFlag2 = wellFlag2;
+ }
+
+ public String getWellFlag3() {
+ return wellFlag3;
+ }
+
+ public void setWellFlag3(String wellFlag3) {
+ this.wellFlag3 = wellFlag3;
+ }
+
+ public String getWellName() {
+ return wellName;
+ }
+
+ public void setWellName(String wellName) {
+ this.wellName = wellName;
+ }
+
+ public String getWellType() {
+ return wellType;
+ }
+
+ public void setWellType(String wellType) {
+ this.wellType = wellType;
+ }
+
+ public String getWellTypeName() {
+ return wellTypeName;
+ }
+
+ public void setWellTypeName(String wellTypeName) {
+ this.wellTypeName = wellTypeName;
+ }
+ }
+}
diff --git a/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt b/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
index d5ac3ec..608dd91 100644
--- a/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
+++ b/app/src/main/java/com/casic/smarttube/utils/LocalConstant.kt
@@ -22,6 +22,7 @@
* =============================================================================================
* */
const val PERMISSIONS_CODE = 999
+ const val PAGE_LIMIT = 20
/**
* =============================================================================================
diff --git a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt
index 64c5402..f715247 100644
--- a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt
+++ b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitService.kt
@@ -69,4 +69,64 @@
*/
@POST("/app/checkVersion")
suspend fun obtainVersionResult(@Header("token") token: String): String
+
+ /**
+ * 获取管盯分页列表
+ * */
+ @GET("/device/list")
+ suspend fun obtainDeviceListByType(
+ @Header("token") token: String,
+ @Query("deptid") deptid: String?,
+ @Query("keywords") keywords: String?,
+ @Query("deviceType") deviceType: String?,
+ @Query("isOnline") isOnline: String?,
+ @Query("sort") sort: String?,
+ @Query("order") order: String?,
+ @Query("offset") offset: Int,
+ @Query("limit") limit: Int
+ ): String
+
+ /**
+ * 获取闸井详情
+ *
+ * @param id 窨井ID
+ */
+ @GET("/well/info")
+ suspend fun obtainWellDetail(
+ @Header("token") token: String,
+ @Query("id") id: String
+ ): String
+
+ /**
+ * 根据部门获取区ID
+ *
+ * @param deptId
+ */
+ @GET("/config/getAreaByDept")
+ suspend fun obtainAreaByDept(
+ @Header("token") token: String,
+ @Query("deptId") deptId: String
+ ): String
+
+ /**
+ * 获取区/县等
+ *
+ * @param pid
+ */
+ @GET("/area/list")
+ suspend fun obtainDistrict(
+ @Header("token") token: String,
+ @Query("pid") pid: String
+ ): String
+
+ /**
+ * 获取街道
+ *
+ * @param pid
+ */
+ @GET("/area/list")
+ suspend fun obtainStreet(
+ @Header("token") token: String,
+ @Query("pid") pid: String
+ ): String
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt
index 2af9a24..d888e59 100644
--- a/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt
+++ b/app/src/main/java/com/casic/smarttube/utils/retrofit/RetrofitServiceManager.kt
@@ -1,6 +1,7 @@
package com.casic.smarttube.utils.retrofit
import com.casic.smarttube.utils.AuthenticationHelper
+import com.casic.smarttube.utils.LocalConstant
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.MultipartBody
import okhttp3.RequestBody
@@ -54,6 +55,46 @@
}
/**
+ * 根据设备类型获取设备分页列表
+ */
+ suspend fun obtainDeviceListByType(
+ deptid: String, keywords: String, isOnline: String, page: Int
+ ): String {
+ return api.obtainDeviceListByType(
+ AuthenticationHelper.token!!, deptid, keywords, "12", isOnline,
+ "id", "asc", page, LocalConstant.PAGE_LIMIT
+ )
+ }
+
+ /**
+ * 获取闸井详情
+ */
+ suspend fun obtainWellDetail(id: String): String {
+ return api.obtainWellDetail(AuthenticationHelper.token!!, id)
+ }
+
+ /**
+ * 根据部门获取区ID
+ */
+ suspend fun obtainAreaByDept(deptId: String): String {
+ return api.obtainAreaByDept(AuthenticationHelper.token!!, deptId)
+ }
+
+ /**
+ * 获取区/县等
+ */
+ suspend fun obtainDistrict(pid: String): String {
+ return api.obtainDistrict(AuthenticationHelper.token!!, pid)
+ }
+
+ /**
+ * 获取街道
+ */
+ suspend fun obtainStreet(pid: String): String {
+ return api.obtainStreet(AuthenticationHelper.token!!, pid)
+ }
+
+ /**
* 上传图片
*/
suspend fun uploadImage(image: File): String {
diff --git a/app/src/main/java/com/casic/smarttube/view/WellDetailActivity.kt b/app/src/main/java/com/casic/smarttube/view/WellDetailActivity.kt
new file mode 100644
index 0000000..457c06f
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/view/WellDetailActivity.kt
@@ -0,0 +1,173 @@
+package com.casic.smarttube.view
+
+import android.os.Bundle
+import androidx.lifecycle.ViewModelProvider
+import com.amap.api.maps.AMap
+import com.amap.api.maps.AMapOptions
+import com.amap.api.maps.CameraUpdateFactory
+import com.amap.api.maps.model.BitmapDescriptorFactory
+import com.amap.api.maps.model.CameraPosition
+import com.amap.api.maps.model.LatLng
+import com.amap.api.maps.model.MarkerOptions
+import com.casic.smarttube.R
+import com.casic.smarttube.utils.DialogHelper
+import com.casic.smarttube.vm.AuthenticateViewModel
+import com.casic.smarttube.vm.WellViewModel
+import com.gyf.immersionbar.ImmersionBar
+import com.pengxh.kt.lite.base.KotlinBaseActivity
+import com.pengxh.kt.lite.extensions.convertColor
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.utils.Constant
+import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil
+import com.pengxh.kt.lite.vm.LoadState
+import kotlinx.android.synthetic.main.activity_well_detail.*
+import kotlinx.android.synthetic.main.include_base_title.*
+
+
+class WellDetailActivity : KotlinBaseActivity(), AMap.OnMapLoadedListener {
+
+ private lateinit var wellViewModel: WellViewModel
+ private lateinit var authenticateViewModel: AuthenticateViewModel
+ private lateinit var wellId: String
+ private lateinit var aMap: AMap
+ private var latLng: LatLng? = null
+
+
+ override fun initLayoutView(): Int = R.layout.activity_well_detail
+
+ override fun setupTopBarLayout() {
+ ImmersionBar.with(this).statusBarDarkFont(false).init()
+ ImmerseStatusBarUtil.setColor(this, R.color.mainThemeColor.convertColor(this))
+ leftBackView.setOnClickListener { finish() }
+ titleView.text = "井详情"
+ }
+
+ override fun initData() {
+ wellId = intent.getStringExtra(Constant.INTENT_PARAM)!!
+ wellViewModel = ViewModelProvider(this).get(WellViewModel::class.java)
+ authenticateViewModel = ViewModelProvider(this).get(AuthenticateViewModel::class.java)
+
+ aMap = wellMapView.map
+ aMap.mapType = AMap.MAP_TYPE_NORMAL
+ val uiSettings = aMap.uiSettings
+ uiSettings.isCompassEnabled = true
+ uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER
+ uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度
+ uiSettings.isRotateGesturesEnabled = false//不允许地图旋转
+
+ //地图加载成功之后调用
+ aMap.addOnMapLoadedListener(this)
+ }
+
+ override fun onMapLoaded() {
+ if (latLng == null) {
+ "该闸井经纬度异常,无法在地图显示".show(this)
+ return
+ }
+ /**
+ * 参数1---要移动到的经纬度
+ * 参数2---地图的放缩级别zoom
+ * 参数3---地图倾斜度
+ * 参数4---地图的旋转角度
+ * */
+ val cameraPosition = CameraPosition(latLng, 13f, 0f, 0f)
+ val newCameraPosition = CameraUpdateFactory.newCameraPosition(cameraPosition)
+ aMap.animateCamera(newCameraPosition, 3000, object : AMap.CancelableCallback {
+ override fun onFinish() {
+ //添加Marker
+ val markerOptions = MarkerOptions()
+ .position(latLng)
+ .icon(BitmapDescriptorFactory.fromResource(R.mipmap.well_location))
+ .draggable(true)
+ aMap.addMarker(markerOptions)
+ }
+
+ override fun onCancel() {
+
+ }
+ })
+ }
+
+ override fun initEvent() {
+ wellViewModel.obtainWellDetail(wellId)
+ wellViewModel.detailModel.observe(this, {
+ if (it.code == 200) {
+ val wellDetail = it.data!!
+
+ wellNameView.text = wellDetail.wellName
+ wellTypeView.text = wellDetail.wellTypeName
+ wellCodeView.text = wellDetail.wellCode
+ ownerShipView.text = wellDetail.deptName
+ wellStateView.text = wellDetail.bfztName
+ wellDepthView.text = wellDetail.deep.toString()
+ //绑定窨井位置
+ if (wellDetail.latGaode.isBlank() || wellDetail.lngGaode.isBlank()) {
+ wellLocationView.text = wellDetail.position
+ return@observe
+ }
+ this.latLng = LatLng(wellDetail.latGaode.toDouble(), wellDetail.lngGaode.toDouble())
+ authenticateViewModel.obtainAreaByDept(wellDetail.deptid)
+ authenticateViewModel.areaModel.observe(this, { areaModel ->
+ if (areaModel.code == 200) {
+ authenticateViewModel.obtainDistrict(areaModel.data.area)
+ }
+ })
+ authenticateViewModel.districtModel.observe(this, { districtModel ->
+ if (districtModel.code == 200) {
+ districtModel.data.forEach { area ->
+ if (area.id == wellDetail.qu) {
+ authenticateViewModel.obtainStreet(area.id)
+ authenticateViewModel.streetModel.observe(this, { street ->
+ if (street.code == 200) {
+ street.data.forEach { streetData ->
+ if (streetData.id == wellDetail.area) {
+ wellLocationView.text =
+ String.format("${area.name}${streetData.name}-${wellDetail.position}")
+ }
+ }
+ }
+ })
+ }
+ }
+ }
+ })
+ }
+ })
+ wellViewModel.loadState.observe(this, {
+ when (it) {
+ is LoadState.Loading -> {
+ DialogHelper.showLoadingDialog(this, "数据加载中,请稍后")
+ }
+ else -> {
+ DialogHelper.dismissLoadingDialog()
+ }
+ }
+ })
+ }
+
+ /**地图相关*********/
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ wellMapView.onCreate(savedInstanceState)
+ }
+
+ override fun onResume() {
+ super.onResume()
+ wellMapView.onResume()
+ }
+
+ override fun onPause() {
+ super.onPause()
+ wellMapView.onPause()
+ }
+
+ override fun onDestroy() {
+ wellMapView.onDestroy()
+ super.onDestroy()
+ }
+
+ override fun onSaveInstanceState(outState: Bundle) {
+ super.onSaveInstanceState(outState)
+ wellMapView.onSaveInstanceState(outState)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/vm/AuthenticateViewModel.kt b/app/src/main/java/com/casic/smarttube/vm/AuthenticateViewModel.kt
index 7ad6379..882fea2 100644
--- a/app/src/main/java/com/casic/smarttube/vm/AuthenticateViewModel.kt
+++ b/app/src/main/java/com/casic/smarttube/vm/AuthenticateViewModel.kt
@@ -4,7 +4,10 @@
import com.casic.smarttube.base.BaseApplication
import com.casic.smarttube.extensions.separateResponseCode
import com.casic.smarttube.extensions.toErrorMessage
+import com.casic.smarttube.model.AreaModel
+import com.casic.smarttube.model.DistrictModel
import com.casic.smarttube.model.PublicKeyModel
+import com.casic.smarttube.model.StreetModel
import com.casic.smarttube.utils.retrofit.RetrofitServiceManager
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
@@ -16,6 +19,9 @@
private val gson = Gson()
val keyModel = MutableLiveData()
+ val areaModel = MutableLiveData()
+ val districtModel = MutableLiveData()
+ val streetModel = MutableLiveData()
fun obtainPublicKey() = launch({
val response = RetrofitServiceManager.authenticate()
@@ -30,4 +36,55 @@
}, {
it.printStackTrace()
})
+
+ /**
+ * 根据部门获取区ID
+ */
+ fun obtainAreaByDept(deptId: String) = launch({
+ val response = RetrofitServiceManager.obtainAreaByDept(deptId)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ areaModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ response.toErrorMessage().show(BaseApplication.obtainInstance())
+ }
+ }, {
+ it.printStackTrace()
+ })
+
+ /**
+ * 区/县等
+ */
+ fun obtainDistrict(pid: String) = launch({
+ val response = RetrofitServiceManager.obtainDistrict(pid)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ districtModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ response.toErrorMessage().show(BaseApplication.obtainInstance())
+ }
+ }, {
+ it.printStackTrace()
+ })
+
+ /**
+ * 街道
+ */
+ fun obtainStreet(areaId: String) = launch({
+ val response = RetrofitServiceManager.obtainStreet(areaId)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ streetModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ response.toErrorMessage().show(BaseApplication.obtainInstance())
+ }
+ }, {
+ it.printStackTrace()
+ })
}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/vm/DeviceViewModel.kt b/app/src/main/java/com/casic/smarttube/vm/DeviceViewModel.kt
new file mode 100644
index 0000000..6a12e14
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/vm/DeviceViewModel.kt
@@ -0,0 +1,35 @@
+package com.casic.smarttube.vm
+
+import androidx.lifecycle.MutableLiveData
+import com.casic.smarttube.base.BaseApplication
+import com.casic.smarttube.extensions.separateResponseCode
+import com.casic.smarttube.extensions.toErrorMessage
+import com.casic.smarttube.model.DeviceListModel
+import com.casic.smarttube.utils.retrofit.RetrofitServiceManager
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import com.pengxh.kt.lite.extensions.launch
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.vm.BaseViewModel
+
+class DeviceViewModel : BaseViewModel() {
+
+ private val gson = Gson()
+ val deviceListModel = MutableLiveData()
+
+ fun obtainDeviceListByType(deptid: String, keywords: String, isOnline: String, page: Int) =
+ launch({
+ val response =
+ RetrofitServiceManager.obtainDeviceListByType(deptid, keywords, isOnline, page)
+ val responseCode = response.separateResponseCode()
+ if (responseCode == 200) {
+ deviceListModel.value = gson.fromJson(
+ response, object : TypeToken() {}.type
+ )
+ } else {
+ response.toErrorMessage().show(BaseApplication.obtainInstance())
+ }
+ }, {
+ it.printStackTrace()
+ })
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/casic/smarttube/vm/WellViewModel.kt b/app/src/main/java/com/casic/smarttube/vm/WellViewModel.kt
new file mode 100644
index 0000000..71b14d5
--- /dev/null
+++ b/app/src/main/java/com/casic/smarttube/vm/WellViewModel.kt
@@ -0,0 +1,209 @@
+package com.casic.smarttube.vm
+
+import androidx.lifecycle.MutableLiveData
+import com.casic.smarttube.base.BaseApplication
+import com.casic.smarttube.extensions.separateResponseCode
+import com.casic.smarttube.extensions.toErrorMessage
+import com.casic.smarttube.model.WellDetailModel
+import com.casic.smarttube.utils.retrofit.RetrofitServiceManager
+import com.google.gson.Gson
+import com.google.gson.reflect.TypeToken
+import com.pengxh.kt.lite.extensions.launch
+import com.pengxh.kt.lite.extensions.show
+import com.pengxh.kt.lite.vm.BaseViewModel
+import com.pengxh.kt.lite.vm.LoadState
+
+class WellViewModel : BaseViewModel() {
+
+ private val gson = Gson()
+ val detailModel = MutableLiveData()
+// val allWellModel = MutableLiveData()
+// val countResultModel = MutableLiveData>()
+// val wellTypeAndCountModel = MutableLiveData()
+// val wellListPageModel = MutableLiveData()
+// val wellTypeModel = MutableLiveData