diff --git a/app/build.gradle b/app/build.gradle index 298022e..20dd6c1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -105,6 +105,8 @@ implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' //高德导航 implementation 'com.amap.api:navi-3dmap:8.1.0_3dmap8.1.0' + //定位功能 + implementation 'com.amap.api:location:5.3.1' //日期选择器 implementation 'com.jzxiang.pickerview:TimePickerDialog:1.0.1' //标签流式布局 diff --git a/app/build.gradle b/app/build.gradle index 298022e..20dd6c1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -105,6 +105,8 @@ implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' //高德导航 implementation 'com.amap.api:navi-3dmap:8.1.0_3dmap8.1.0' + //定位功能 + implementation 'com.amap.api:location:5.3.1' //日期选择器 implementation 'com.jzxiang.pickerview:TimePickerDialog:1.0.1' //标签流式布局 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0d66103..d1a6908 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -62,6 +62,9 @@ android:name=".view.BigImageActivity" android:theme="@style/Theme.BigImageActivity" /> + + + + + + + + + = ArrayList() + private var wellModels: MutableList = ArrayList() override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? @@ -109,11 +112,11 @@ DialogHelper.showLoadingDialog(requireActivity(), "数据加载中,请稍后...") //获取所有窨井数据 wellListViewModel.obtainAllWell() - wellListViewModel.listModel.observe(viewLifecycleOwner, { + wellListViewModel.totalWellModel.observe(viewLifecycleOwner, { if (it.code == 200) { val latitudeList: MutableList = ArrayList() val longitudeList: MutableList = ArrayList() - it.data?.rows?.forEach { well -> + it.data?.forEach { well -> val lat = well.latGaode.toString() val lng = well.lngGaode.toString() if (lat.isNotBlank() && lng.isNotBlank()) { @@ -140,12 +143,24 @@ Log.d(kTag, "${well.wellCode}闸井经纬度异常,异常经纬度 ===> [${lng},${lat}]") } } + + LocationHelper.obtainCurrentLocation(requireContext(), object : ILocationListener { + override fun onAMapLocationGet(aMapLocation: AMapLocation?) { + if (aMapLocation != null) { + val centerLatLng = LatLng(aMapLocation.latitude, aMapLocation.longitude) + //移动到指定经纬度 + val cameraPosition = CameraPosition(centerLatLng, 12f, 0f, 0f) + val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) + aMap.animateCamera(cameraUpdate, 1500, null) + } + } + }, false) //计算所有点的中心点位置 - val centerLatLng = LatLng(latitudeList.average(), longitudeList.average()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(centerLatLng, 12f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - aMap.animateCamera(cameraUpdate, 1500, null) +// val centerLatLng = LatLng(latitudeList.average(), longitudeList.average()) +// //移动到指定经纬度 +// val cameraPosition = CameraPosition(centerLatLng, 12f, 0f, 0f) +// val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) +// aMap.animateCamera(cameraUpdate, 1500, null) } }) diff --git a/app/build.gradle b/app/build.gradle index 298022e..20dd6c1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -105,6 +105,8 @@ implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' //高德导航 implementation 'com.amap.api:navi-3dmap:8.1.0_3dmap8.1.0' + //定位功能 + implementation 'com.amap.api:location:5.3.1' //日期选择器 implementation 'com.jzxiang.pickerview:TimePickerDialog:1.0.1' //标签流式布局 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0d66103..d1a6908 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -62,6 +62,9 @@ android:name=".view.BigImageActivity" android:theme="@style/Theme.BigImageActivity" /> + + + = ArrayList() + private var wellModels: MutableList = ArrayList() override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? @@ -109,11 +112,11 @@ DialogHelper.showLoadingDialog(requireActivity(), "数据加载中,请稍后...") //获取所有窨井数据 wellListViewModel.obtainAllWell() - wellListViewModel.listModel.observe(viewLifecycleOwner, { + wellListViewModel.totalWellModel.observe(viewLifecycleOwner, { if (it.code == 200) { val latitudeList: MutableList = ArrayList() val longitudeList: MutableList = ArrayList() - it.data?.rows?.forEach { well -> + it.data?.forEach { well -> val lat = well.latGaode.toString() val lng = well.lngGaode.toString() if (lat.isNotBlank() && lng.isNotBlank()) { @@ -140,12 +143,24 @@ Log.d(kTag, "${well.wellCode}闸井经纬度异常,异常经纬度 ===> [${lng},${lat}]") } } + + LocationHelper.obtainCurrentLocation(requireContext(), object : ILocationListener { + override fun onAMapLocationGet(aMapLocation: AMapLocation?) { + if (aMapLocation != null) { + val centerLatLng = LatLng(aMapLocation.latitude, aMapLocation.longitude) + //移动到指定经纬度 + val cameraPosition = CameraPosition(centerLatLng, 12f, 0f, 0f) + val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) + aMap.animateCamera(cameraUpdate, 1500, null) + } + } + }, false) //计算所有点的中心点位置 - val centerLatLng = LatLng(latitudeList.average(), longitudeList.average()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(centerLatLng, 12f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - aMap.animateCamera(cameraUpdate, 1500, null) +// val centerLatLng = LatLng(latitudeList.average(), longitudeList.average()) +// //移动到指定经纬度 +// val cameraPosition = CameraPosition(centerLatLng, 12f, 0f, 0f) +// val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) +// aMap.animateCamera(cameraUpdate, 1500, null) } }) diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/NoticePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/NoticePageFragment.kt index c509191..ea5d231 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/NoticePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/NoticePageFragment.kt @@ -29,13 +29,13 @@ private val kTag = "NoticePageFragment" private lateinit var weakReferenceHandler: WeakReferenceHandler - private lateinit var userId: String private lateinit var noticeDataAdapter: NoticeDataAdapter private lateinit var deviceViewModel: DeviceViewModel private var dataBeans: MutableList = ArrayList() private var pageIndex = 0 // 本地数据库分页从0开始 private var isRefresh = false private var isLoadMore = false + private var userId = "" override fun initLayoutView(): Int = R.layout.fragment_notice diff --git a/app/build.gradle b/app/build.gradle index 298022e..20dd6c1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -105,6 +105,8 @@ implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' //高德导航 implementation 'com.amap.api:navi-3dmap:8.1.0_3dmap8.1.0' + //定位功能 + implementation 'com.amap.api:location:5.3.1' //日期选择器 implementation 'com.jzxiang.pickerview:TimePickerDialog:1.0.1' //标签流式布局 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0d66103..d1a6908 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -62,6 +62,9 @@ android:name=".view.BigImageActivity" android:theme="@style/Theme.BigImageActivity" /> + + + = ArrayList() + private var wellModels: MutableList = ArrayList() override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? @@ -109,11 +112,11 @@ DialogHelper.showLoadingDialog(requireActivity(), "数据加载中,请稍后...") //获取所有窨井数据 wellListViewModel.obtainAllWell() - wellListViewModel.listModel.observe(viewLifecycleOwner, { + wellListViewModel.totalWellModel.observe(viewLifecycleOwner, { if (it.code == 200) { val latitudeList: MutableList = ArrayList() val longitudeList: MutableList = ArrayList() - it.data?.rows?.forEach { well -> + it.data?.forEach { well -> val lat = well.latGaode.toString() val lng = well.lngGaode.toString() if (lat.isNotBlank() && lng.isNotBlank()) { @@ -140,12 +143,24 @@ Log.d(kTag, "${well.wellCode}闸井经纬度异常,异常经纬度 ===> [${lng},${lat}]") } } + + LocationHelper.obtainCurrentLocation(requireContext(), object : ILocationListener { + override fun onAMapLocationGet(aMapLocation: AMapLocation?) { + if (aMapLocation != null) { + val centerLatLng = LatLng(aMapLocation.latitude, aMapLocation.longitude) + //移动到指定经纬度 + val cameraPosition = CameraPosition(centerLatLng, 12f, 0f, 0f) + val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) + aMap.animateCamera(cameraUpdate, 1500, null) + } + } + }, false) //计算所有点的中心点位置 - val centerLatLng = LatLng(latitudeList.average(), longitudeList.average()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(centerLatLng, 12f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - aMap.animateCamera(cameraUpdate, 1500, null) +// val centerLatLng = LatLng(latitudeList.average(), longitudeList.average()) +// //移动到指定经纬度 +// val cameraPosition = CameraPosition(centerLatLng, 12f, 0f, 0f) +// val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) +// aMap.animateCamera(cameraUpdate, 1500, null) } }) diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/NoticePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/NoticePageFragment.kt index c509191..ea5d231 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/NoticePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/NoticePageFragment.kt @@ -29,13 +29,13 @@ private val kTag = "NoticePageFragment" private lateinit var weakReferenceHandler: WeakReferenceHandler - private lateinit var userId: String private lateinit var noticeDataAdapter: NoticeDataAdapter private lateinit var deviceViewModel: DeviceViewModel private var dataBeans: MutableList = ArrayList() private var pageIndex = 0 // 本地数据库分页从0开始 private var isRefresh = false private var isLoadMore = false + private var userId = "" override fun initLayoutView(): Int = R.layout.fragment_notice diff --git a/app/src/main/java/com/casic/app/smartwell/model/MapWellListModel.java b/app/src/main/java/com/casic/app/smartwell/model/MapWellListModel.java new file mode 100644 index 0000000..1337454 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/MapWellListModel.java @@ -0,0 +1,271 @@ +package com.casic.app.smartwell.model; + +import java.util.List; + +public class MapWellListModel { + + 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 DataModel { + private String area; + private String bfzt; + private String bfztName; + private String coordinateX; + private String coordinateY; + private double deep; + private String deptName; + private String deptid; + 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 staff; + private String tel; + private String ts; + private String valid; + private String watchData; + private String wellCode; + 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 double getDeep() { + return deep; + } + + public void setDeep(double 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 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 getStaff() { + return staff; + } + + public void setStaff(String staff) { + this.staff = staff; + } + + public String getTel() { + return tel; + } + + public void setTel(String tel) { + this.tel = tel; + } + + 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 getWatchData() { + return watchData; + } + + public void setWatchData(String watchData) { + this.watchData = watchData; + } + + public String getWellCode() { + return wellCode; + } + + public void setWellCode(String wellCode) { + this.wellCode = wellCode; + } + + 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; + } + } +} \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 298022e..20dd6c1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -105,6 +105,8 @@ implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' //高德导航 implementation 'com.amap.api:navi-3dmap:8.1.0_3dmap8.1.0' + //定位功能 + implementation 'com.amap.api:location:5.3.1' //日期选择器 implementation 'com.jzxiang.pickerview:TimePickerDialog:1.0.1' //标签流式布局 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0d66103..d1a6908 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -62,6 +62,9 @@ android:name=".view.BigImageActivity" android:theme="@style/Theme.BigImageActivity" /> + + + = ArrayList() + private var wellModels: MutableList = ArrayList() override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? @@ -109,11 +112,11 @@ DialogHelper.showLoadingDialog(requireActivity(), "数据加载中,请稍后...") //获取所有窨井数据 wellListViewModel.obtainAllWell() - wellListViewModel.listModel.observe(viewLifecycleOwner, { + wellListViewModel.totalWellModel.observe(viewLifecycleOwner, { if (it.code == 200) { val latitudeList: MutableList = ArrayList() val longitudeList: MutableList = ArrayList() - it.data?.rows?.forEach { well -> + it.data?.forEach { well -> val lat = well.latGaode.toString() val lng = well.lngGaode.toString() if (lat.isNotBlank() && lng.isNotBlank()) { @@ -140,12 +143,24 @@ Log.d(kTag, "${well.wellCode}闸井经纬度异常,异常经纬度 ===> [${lng},${lat}]") } } + + LocationHelper.obtainCurrentLocation(requireContext(), object : ILocationListener { + override fun onAMapLocationGet(aMapLocation: AMapLocation?) { + if (aMapLocation != null) { + val centerLatLng = LatLng(aMapLocation.latitude, aMapLocation.longitude) + //移动到指定经纬度 + val cameraPosition = CameraPosition(centerLatLng, 12f, 0f, 0f) + val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) + aMap.animateCamera(cameraUpdate, 1500, null) + } + } + }, false) //计算所有点的中心点位置 - val centerLatLng = LatLng(latitudeList.average(), longitudeList.average()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(centerLatLng, 12f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - aMap.animateCamera(cameraUpdate, 1500, null) +// val centerLatLng = LatLng(latitudeList.average(), longitudeList.average()) +// //移动到指定经纬度 +// val cameraPosition = CameraPosition(centerLatLng, 12f, 0f, 0f) +// val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) +// aMap.animateCamera(cameraUpdate, 1500, null) } }) diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/NoticePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/NoticePageFragment.kt index c509191..ea5d231 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/NoticePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/NoticePageFragment.kt @@ -29,13 +29,13 @@ private val kTag = "NoticePageFragment" private lateinit var weakReferenceHandler: WeakReferenceHandler - private lateinit var userId: String private lateinit var noticeDataAdapter: NoticeDataAdapter private lateinit var deviceViewModel: DeviceViewModel private var dataBeans: MutableList = ArrayList() private var pageIndex = 0 // 本地数据库分页从0开始 private var isRefresh = false private var isLoadMore = false + private var userId = "" override fun initLayoutView(): Int = R.layout.fragment_notice diff --git a/app/src/main/java/com/casic/app/smartwell/model/MapWellListModel.java b/app/src/main/java/com/casic/app/smartwell/model/MapWellListModel.java new file mode 100644 index 0000000..1337454 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/MapWellListModel.java @@ -0,0 +1,271 @@ +package com.casic.app.smartwell.model; + +import java.util.List; + +public class MapWellListModel { + + 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 DataModel { + private String area; + private String bfzt; + private String bfztName; + private String coordinateX; + private String coordinateY; + private double deep; + private String deptName; + private String deptid; + 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 staff; + private String tel; + private String ts; + private String valid; + private String watchData; + private String wellCode; + 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 double getDeep() { + return deep; + } + + public void setDeep(double 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 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 getStaff() { + return staff; + } + + public void setStaff(String staff) { + this.staff = staff; + } + + public String getTel() { + return tel; + } + + public void setTel(String tel) { + this.tel = tel; + } + + 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 getWatchData() { + return watchData; + } + + public void setWatchData(String watchData) { + this.watchData = watchData; + } + + public String getWellCode() { + return wellCode; + } + + public void setWellCode(String wellCode) { + this.wellCode = wellCode; + } + + 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; + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/LocationHelper.kt b/app/src/main/java/com/casic/app/smartwell/utils/LocationHelper.kt new file mode 100644 index 0000000..deefa0a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/utils/LocationHelper.kt @@ -0,0 +1,42 @@ +package com.casic.app.smartwell.utils + +import android.content.Context +import android.util.Log +import com.amap.api.location.AMapLocationClient +import com.amap.api.location.AMapLocationClientOption +import com.casic.app.smartwell.callback.ILocationListener + +object LocationHelper { + private const val kTag = "LocationHelper" + + /** + * 高德sdk定位 + */ + fun obtainCurrentLocation(context: Context?, listener: ILocationListener, isOnce: Boolean) { + val locationClient = AMapLocationClient(context) + val locationOption = AMapLocationClientOption() + //设置定位模式为高精度模式,AMapLocationMode.Battery_Saving为低功耗模式,AMapLocationMode.Device_Sensors是仅设备模式 + locationOption.locationMode = AMapLocationClientOption.AMapLocationMode.Hight_Accuracy + locationOption.isOnceLocation = isOnce //设置是否只定位一次,默认为false + locationOption.interval = 15000 //设置定位间隔,单位毫秒,默认为2000ms + //给定位客户端对象设置定位参数 + locationClient.setLocationOption(locationOption) + //设置定位回调监听 + locationClient.setLocationListener { aMapLocation -> + if (aMapLocation != null) { + if (aMapLocation.errorCode == 0) { + listener.onAMapLocationGet(aMapLocation) + } else { + listener.onAMapLocationGet(null) + //显示错误信息ErrCode是错误码,errInfo是错误信息,详见错误码表。 + Log.e( + kTag, "location Error, ErrCode:" + aMapLocation.errorCode + + ", errInfo:" + aMapLocation.errorInfo + ) + } + } + } + //启动定位 + locationClient.startLocation() + } +} \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 298022e..20dd6c1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -105,6 +105,8 @@ implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' //高德导航 implementation 'com.amap.api:navi-3dmap:8.1.0_3dmap8.1.0' + //定位功能 + implementation 'com.amap.api:location:5.3.1' //日期选择器 implementation 'com.jzxiang.pickerview:TimePickerDialog:1.0.1' //标签流式布局 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0d66103..d1a6908 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -62,6 +62,9 @@ android:name=".view.BigImageActivity" android:theme="@style/Theme.BigImageActivity" /> + + + = ArrayList() + private var wellModels: MutableList = ArrayList() override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? @@ -109,11 +112,11 @@ DialogHelper.showLoadingDialog(requireActivity(), "数据加载中,请稍后...") //获取所有窨井数据 wellListViewModel.obtainAllWell() - wellListViewModel.listModel.observe(viewLifecycleOwner, { + wellListViewModel.totalWellModel.observe(viewLifecycleOwner, { if (it.code == 200) { val latitudeList: MutableList = ArrayList() val longitudeList: MutableList = ArrayList() - it.data?.rows?.forEach { well -> + it.data?.forEach { well -> val lat = well.latGaode.toString() val lng = well.lngGaode.toString() if (lat.isNotBlank() && lng.isNotBlank()) { @@ -140,12 +143,24 @@ Log.d(kTag, "${well.wellCode}闸井经纬度异常,异常经纬度 ===> [${lng},${lat}]") } } + + LocationHelper.obtainCurrentLocation(requireContext(), object : ILocationListener { + override fun onAMapLocationGet(aMapLocation: AMapLocation?) { + if (aMapLocation != null) { + val centerLatLng = LatLng(aMapLocation.latitude, aMapLocation.longitude) + //移动到指定经纬度 + val cameraPosition = CameraPosition(centerLatLng, 12f, 0f, 0f) + val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) + aMap.animateCamera(cameraUpdate, 1500, null) + } + } + }, false) //计算所有点的中心点位置 - val centerLatLng = LatLng(latitudeList.average(), longitudeList.average()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(centerLatLng, 12f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - aMap.animateCamera(cameraUpdate, 1500, null) +// val centerLatLng = LatLng(latitudeList.average(), longitudeList.average()) +// //移动到指定经纬度 +// val cameraPosition = CameraPosition(centerLatLng, 12f, 0f, 0f) +// val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) +// aMap.animateCamera(cameraUpdate, 1500, null) } }) diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/NoticePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/NoticePageFragment.kt index c509191..ea5d231 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/NoticePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/NoticePageFragment.kt @@ -29,13 +29,13 @@ private val kTag = "NoticePageFragment" private lateinit var weakReferenceHandler: WeakReferenceHandler - private lateinit var userId: String private lateinit var noticeDataAdapter: NoticeDataAdapter private lateinit var deviceViewModel: DeviceViewModel private var dataBeans: MutableList = ArrayList() private var pageIndex = 0 // 本地数据库分页从0开始 private var isRefresh = false private var isLoadMore = false + private var userId = "" override fun initLayoutView(): Int = R.layout.fragment_notice diff --git a/app/src/main/java/com/casic/app/smartwell/model/MapWellListModel.java b/app/src/main/java/com/casic/app/smartwell/model/MapWellListModel.java new file mode 100644 index 0000000..1337454 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/MapWellListModel.java @@ -0,0 +1,271 @@ +package com.casic.app.smartwell.model; + +import java.util.List; + +public class MapWellListModel { + + 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 DataModel { + private String area; + private String bfzt; + private String bfztName; + private String coordinateX; + private String coordinateY; + private double deep; + private String deptName; + private String deptid; + 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 staff; + private String tel; + private String ts; + private String valid; + private String watchData; + private String wellCode; + 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 double getDeep() { + return deep; + } + + public void setDeep(double 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 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 getStaff() { + return staff; + } + + public void setStaff(String staff) { + this.staff = staff; + } + + public String getTel() { + return tel; + } + + public void setTel(String tel) { + this.tel = tel; + } + + 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 getWatchData() { + return watchData; + } + + public void setWatchData(String watchData) { + this.watchData = watchData; + } + + public String getWellCode() { + return wellCode; + } + + public void setWellCode(String wellCode) { + this.wellCode = wellCode; + } + + 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; + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/LocationHelper.kt b/app/src/main/java/com/casic/app/smartwell/utils/LocationHelper.kt new file mode 100644 index 0000000..deefa0a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/utils/LocationHelper.kt @@ -0,0 +1,42 @@ +package com.casic.app.smartwell.utils + +import android.content.Context +import android.util.Log +import com.amap.api.location.AMapLocationClient +import com.amap.api.location.AMapLocationClientOption +import com.casic.app.smartwell.callback.ILocationListener + +object LocationHelper { + private const val kTag = "LocationHelper" + + /** + * 高德sdk定位 + */ + fun obtainCurrentLocation(context: Context?, listener: ILocationListener, isOnce: Boolean) { + val locationClient = AMapLocationClient(context) + val locationOption = AMapLocationClientOption() + //设置定位模式为高精度模式,AMapLocationMode.Battery_Saving为低功耗模式,AMapLocationMode.Device_Sensors是仅设备模式 + locationOption.locationMode = AMapLocationClientOption.AMapLocationMode.Hight_Accuracy + locationOption.isOnceLocation = isOnce //设置是否只定位一次,默认为false + locationOption.interval = 15000 //设置定位间隔,单位毫秒,默认为2000ms + //给定位客户端对象设置定位参数 + locationClient.setLocationOption(locationOption) + //设置定位回调监听 + locationClient.setLocationListener { aMapLocation -> + if (aMapLocation != null) { + if (aMapLocation.errorCode == 0) { + listener.onAMapLocationGet(aMapLocation) + } else { + listener.onAMapLocationGet(null) + //显示错误信息ErrCode是错误码,errInfo是错误信息,详见错误码表。 + Log.e( + kTag, "location Error, ErrCode:" + aMapLocation.errorCode + + ", errInfo:" + aMapLocation.errorInfo + ) + } + } + } + //启动定位 + locationClient.startLocation() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 7497142..809dabc 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -66,7 +66,7 @@ /** * 获取获取闸井列表-不分页,地图用 */ - @GET("/well/list") + @GET("/overview/wellList") suspend fun obtainAllWell(@Header("token") token: String): String /** @@ -74,7 +74,7 @@ * * @param id 窨井ID */ - @GET("/well/info") + @GET("/overview/wellInfo") suspend fun obtainWellDetail( @Header("token") token: String, @Query("id") id: String diff --git a/app/build.gradle b/app/build.gradle index 298022e..20dd6c1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -105,6 +105,8 @@ implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' //高德导航 implementation 'com.amap.api:navi-3dmap:8.1.0_3dmap8.1.0' + //定位功能 + implementation 'com.amap.api:location:5.3.1' //日期选择器 implementation 'com.jzxiang.pickerview:TimePickerDialog:1.0.1' //标签流式布局 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0d66103..d1a6908 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -62,6 +62,9 @@ android:name=".view.BigImageActivity" android:theme="@style/Theme.BigImageActivity" /> + + + = ArrayList() + private var wellModels: MutableList = ArrayList() override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? @@ -109,11 +112,11 @@ DialogHelper.showLoadingDialog(requireActivity(), "数据加载中,请稍后...") //获取所有窨井数据 wellListViewModel.obtainAllWell() - wellListViewModel.listModel.observe(viewLifecycleOwner, { + wellListViewModel.totalWellModel.observe(viewLifecycleOwner, { if (it.code == 200) { val latitudeList: MutableList = ArrayList() val longitudeList: MutableList = ArrayList() - it.data?.rows?.forEach { well -> + it.data?.forEach { well -> val lat = well.latGaode.toString() val lng = well.lngGaode.toString() if (lat.isNotBlank() && lng.isNotBlank()) { @@ -140,12 +143,24 @@ Log.d(kTag, "${well.wellCode}闸井经纬度异常,异常经纬度 ===> [${lng},${lat}]") } } + + LocationHelper.obtainCurrentLocation(requireContext(), object : ILocationListener { + override fun onAMapLocationGet(aMapLocation: AMapLocation?) { + if (aMapLocation != null) { + val centerLatLng = LatLng(aMapLocation.latitude, aMapLocation.longitude) + //移动到指定经纬度 + val cameraPosition = CameraPosition(centerLatLng, 12f, 0f, 0f) + val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) + aMap.animateCamera(cameraUpdate, 1500, null) + } + } + }, false) //计算所有点的中心点位置 - val centerLatLng = LatLng(latitudeList.average(), longitudeList.average()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(centerLatLng, 12f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - aMap.animateCamera(cameraUpdate, 1500, null) +// val centerLatLng = LatLng(latitudeList.average(), longitudeList.average()) +// //移动到指定经纬度 +// val cameraPosition = CameraPosition(centerLatLng, 12f, 0f, 0f) +// val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) +// aMap.animateCamera(cameraUpdate, 1500, null) } }) diff --git a/app/src/main/java/com/casic/app/smartwell/fragment/NoticePageFragment.kt b/app/src/main/java/com/casic/app/smartwell/fragment/NoticePageFragment.kt index c509191..ea5d231 100644 --- a/app/src/main/java/com/casic/app/smartwell/fragment/NoticePageFragment.kt +++ b/app/src/main/java/com/casic/app/smartwell/fragment/NoticePageFragment.kt @@ -29,13 +29,13 @@ private val kTag = "NoticePageFragment" private lateinit var weakReferenceHandler: WeakReferenceHandler - private lateinit var userId: String private lateinit var noticeDataAdapter: NoticeDataAdapter private lateinit var deviceViewModel: DeviceViewModel private var dataBeans: MutableList = ArrayList() private var pageIndex = 0 // 本地数据库分页从0开始 private var isRefresh = false private var isLoadMore = false + private var userId = "" override fun initLayoutView(): Int = R.layout.fragment_notice diff --git a/app/src/main/java/com/casic/app/smartwell/model/MapWellListModel.java b/app/src/main/java/com/casic/app/smartwell/model/MapWellListModel.java new file mode 100644 index 0000000..1337454 --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/model/MapWellListModel.java @@ -0,0 +1,271 @@ +package com.casic.app.smartwell.model; + +import java.util.List; + +public class MapWellListModel { + + 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 DataModel { + private String area; + private String bfzt; + private String bfztName; + private String coordinateX; + private String coordinateY; + private double deep; + private String deptName; + private String deptid; + 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 staff; + private String tel; + private String ts; + private String valid; + private String watchData; + private String wellCode; + 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 double getDeep() { + return deep; + } + + public void setDeep(double 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 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 getStaff() { + return staff; + } + + public void setStaff(String staff) { + this.staff = staff; + } + + public String getTel() { + return tel; + } + + public void setTel(String tel) { + this.tel = tel; + } + + 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 getWatchData() { + return watchData; + } + + public void setWatchData(String watchData) { + this.watchData = watchData; + } + + public String getWellCode() { + return wellCode; + } + + public void setWellCode(String wellCode) { + this.wellCode = wellCode; + } + + 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; + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/LocationHelper.kt b/app/src/main/java/com/casic/app/smartwell/utils/LocationHelper.kt new file mode 100644 index 0000000..deefa0a --- /dev/null +++ b/app/src/main/java/com/casic/app/smartwell/utils/LocationHelper.kt @@ -0,0 +1,42 @@ +package com.casic.app.smartwell.utils + +import android.content.Context +import android.util.Log +import com.amap.api.location.AMapLocationClient +import com.amap.api.location.AMapLocationClientOption +import com.casic.app.smartwell.callback.ILocationListener + +object LocationHelper { + private const val kTag = "LocationHelper" + + /** + * 高德sdk定位 + */ + fun obtainCurrentLocation(context: Context?, listener: ILocationListener, isOnce: Boolean) { + val locationClient = AMapLocationClient(context) + val locationOption = AMapLocationClientOption() + //设置定位模式为高精度模式,AMapLocationMode.Battery_Saving为低功耗模式,AMapLocationMode.Device_Sensors是仅设备模式 + locationOption.locationMode = AMapLocationClientOption.AMapLocationMode.Hight_Accuracy + locationOption.isOnceLocation = isOnce //设置是否只定位一次,默认为false + locationOption.interval = 15000 //设置定位间隔,单位毫秒,默认为2000ms + //给定位客户端对象设置定位参数 + locationClient.setLocationOption(locationOption) + //设置定位回调监听 + locationClient.setLocationListener { aMapLocation -> + if (aMapLocation != null) { + if (aMapLocation.errorCode == 0) { + listener.onAMapLocationGet(aMapLocation) + } else { + listener.onAMapLocationGet(null) + //显示错误信息ErrCode是错误码,errInfo是错误信息,详见错误码表。 + Log.e( + kTag, "location Error, ErrCode:" + aMapLocation.errorCode + + ", errInfo:" + aMapLocation.errorInfo + ) + } + } + } + //启动定位 + locationClient.startLocation() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt index 7497142..809dabc 100644 --- a/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt +++ b/app/src/main/java/com/casic/app/smartwell/utils/retrofit/RetrofitService.kt @@ -66,7 +66,7 @@ /** * 获取获取闸井列表-不分页,地图用 */ - @GET("/well/list") + @GET("/overview/wellList") suspend fun obtainAllWell(@Header("token") token: String): String /** @@ -74,7 +74,7 @@ * * @param id 窨井ID */ - @GET("/well/info") + @GET("/overview/wellInfo") suspend fun obtainWellDetail( @Header("token") token: String, @Query("id") id: String diff --git a/app/src/main/java/com/casic/app/smartwell/vm/WellListViewModel.kt b/app/src/main/java/com/casic/app/smartwell/vm/WellListViewModel.kt index 2e36288..1ffd840 100644 --- a/app/src/main/java/com/casic/app/smartwell/vm/WellListViewModel.kt +++ b/app/src/main/java/com/casic/app/smartwell/vm/WellListViewModel.kt @@ -4,6 +4,7 @@ import com.casic.app.smartwell.base.BaseApplication import com.casic.app.smartwell.extensions.separateResponseCode import com.casic.app.smartwell.extensions.toErrorMessage +import com.casic.app.smartwell.model.MapWellListModel import com.casic.app.smartwell.model.WellListModel import com.casic.app.smartwell.utils.retrofit.RetrofitServiceManager import com.google.gson.Gson @@ -16,6 +17,7 @@ private val gson = Gson() val listModel = MutableLiveData() + val totalWellModel = MutableLiveData() fun obtainWellList( keywords: String?, @@ -43,8 +45,8 @@ val response = RetrofitServiceManager.obtainAllWell() val responseCode = response.separateResponseCode() if (responseCode == 200) { - listModel.value = gson.fromJson( - response, object : TypeToken() {}.type + totalWellModel.value = gson.fromJson( + response, object : TypeToken() {}.type ) } else { response.toErrorMessage().show(BaseApplication.obtainInstance())