Browse Source

优化医生机和其他主机显示

weizhengliang 2 năm trước cách đây
mục cha
commit
2ed136a369

+ 1 - 1
middleware/src/main/code/com/wdkl/ncs/android/middleware/api/DeviceApi.kt

@@ -12,7 +12,7 @@ interface DeviceApi {
     fun getDeviceMessage(@Path("ethMac")ethMac:String): Observable<ResponseBody>
 
     @GET("/deviceNurse/get_devices_by_type_and_part_id/{device_type}/{part_id}")
-    fun getDoctorDevice(@Path("device_type") device_type: Int, @Path("part_id") part_id: Int): Observable<ResponseBody>
+    fun getDevice(@Path("device_type") device_type: Int, @Path("part_id") part_id: Int): Observable<ResponseBody>
 
     //获取全院所有护士主机
     @GET("/deviceNurse/get_host_device_by_parent_part_id/{partId}")

+ 2 - 2
middleware/src/main/code/com/wdkl/ncs/android/middleware/logic/contract/nursehome/OtherHostContract.kt

@@ -15,7 +15,7 @@ interface OtherHostContract {
      */
     interface View:BaseContract.BaseView{
 
-        fun showDevice(devices: ArrayList<DeviceDO>)
+        fun showManageDevice(devices: ArrayList<DeviceDO>)
 
         fun showAllHostDevice(devices: ArrayList<DeviceDO>)
     }
@@ -25,7 +25,7 @@ interface OtherHostContract {
      */
     interface Presenter:BaseContract.BasePresenter{
 
-        fun loadHostDevice(deviceType: Int, partId: Int)
+        fun loadManageDevice(deviceType: Int, partId: Int)
 
         fun loadAllHostDevice(partId: Int)
     }

+ 1 - 1
middleware/src/main/code/com/wdkl/ncs/android/middleware/logic/presenter/nursehome/DoctorHostPresenter.kt

@@ -57,7 +57,7 @@ class DoctorHostPresenter@Inject constructor():RxPresenter<DoctorHostContract.Vi
 
 
     override fun loadDoctorHost(deviceType: Int, partId: Int) {
-        deviceApi.getDoctorDevice(deviceType, partId)
+        deviceApi.getDevice(deviceType, partId)
             .map {
                 val data = it.getJsonString()
                 val gson = GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create()

+ 3 - 3
middleware/src/main/code/com/wdkl/ncs/android/middleware/logic/presenter/nursehome/OtherHostPresenter.kt

@@ -40,7 +40,7 @@ class OtherHostPresenter@Inject constructor():RxPresenter<OtherHostContract.View
 
         override fun onNextWithConnection(result: Any, connectionQuality: ConnectionQuality) {
             providerView().complete()
-            providerView().showDevice(result as ArrayList<DeviceDO>)
+            providerView().showManageDevice(result as ArrayList<DeviceDO>)
         }
 
         override fun onErrorWithConnection(error: ExceptionHandle.ResponeThrowable, connectionQuality: ConnectionQuality) {
@@ -80,8 +80,8 @@ class OtherHostPresenter@Inject constructor():RxPresenter<OtherHostContract.View
     /**
      *获取数据
      */
-    override fun loadHostDevice(deviceType: Int, partId: Int) {
-        deviceApi.getDoctorDevice(deviceType, partId)
+    override fun loadManageDevice(deviceType: Int, partId: Int) {
+        deviceApi.getDevice(deviceType, partId)
             .map {
                 val data = it.getJsonString()
                 val gson = GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create()

+ 16 - 1
nursehome/src/main/java/com/wdkl/ncs/android/component/nursehome/fragment/DoctorHostFragment.kt

@@ -82,6 +82,11 @@ class DoctorHostFragment: BaseFragment<DoctorHostPresenter, FragmentDoctorHostBi
         }
         call_doctor_host.setOnClickListener(this)
 
+        doctor_host_refresh.setOnRefreshListener {
+            if (Constants.part_id != -1) {
+                presenter.loadDoctorHost(DeviceTypeEnum.DOCTOR_HOST.value(), Constants.part_id)
+            }
+        }
     }
     /**
      *页面销毁回调
@@ -93,13 +98,23 @@ class DoctorHostFragment: BaseFragment<DoctorHostPresenter, FragmentDoctorHostBi
      */
     override fun showDoctorDevices(devices: ArrayList<DeviceDO>) {
         doctorHostAdapter!!.data.clear()
-        doctorHostAdapter!!.data.addAll(devices)
+        //排除本机
+        if (devices.size > 0) {
+            for (hostDevice in devices) {
+                if (hostDevice.id != Constants.ids) {
+                    doctorHostAdapter!!.data.add(hostDevice)
+                }
+            }
+        }
         doctorHostAdapter!!.notifyDataSetChanged()
+
+        doctor_host_refresh.finishRefresh()
     }
     /**
      *处理错误信息
      */
     override fun onError(message: String, type: Int) {
+        doctor_host_refresh.finishRefresh()
     }
     /**
      *耗时加载完成

+ 8 - 8
nursehome/src/main/java/com/wdkl/ncs/android/component/nursehome/fragment/OtherHostFragment.kt

@@ -78,13 +78,15 @@ class OtherHostFragment : BaseFragment<OtherHostPresenter, FragmentOtherHostBind
         group_host.setOnCheckedChangeListener { group, checkedId ->
             if (checkedId == R.id.rb_other_host) {
                 //加载所有护士主机
+                otherHostAdapter!!.data.clear()
                 if (Constants.part_id != -1) {
                     presenter.loadAllHostDevice(Constants.part_id)
                 }
             } else if (checkedId == R.id.rb_manager_host) {
                 //加载总控主机
+                otherHostAdapter!!.data.clear()
                 if (Constants.hospital_id != -1) {
-                    presenter.loadHostDevice(DeviceTypeEnum.NURSE_HOST.value(), Constants.hospital_id)
+                    presenter.loadManageDevice(DeviceTypeEnum.NURSE_HOST.value(), Constants.hospital_id)
                 } else {
                     showMessage("hospital_id is null")
                 }
@@ -107,30 +109,28 @@ class OtherHostFragment : BaseFragment<OtherHostPresenter, FragmentOtherHostBind
     /**
      *显示数据
      */
-    override fun showDevice(devices: ArrayList<DeviceDO>) {
-        otherHostAdapter!!.data.clear()
+    override fun showManageDevice(devices: ArrayList<DeviceDO>) {
         otherHostAdapter!!.data.addAll(devices)
-        //Log.i(TAG,"其它主机数量 " + devices.size)
         otherHostAdapter!!.notifyDataSetChanged()
     }
 
     override fun showAllHostDevice(devices: ArrayList<DeviceDO>) {
-        //先后所有护士主机,排除自己
+        //显示所有护士主机,排除自己
         if (devices.size > 0) {
-            otherHostAdapter!!.data.clear()
             for (hostDevice in devices) {
                 if (hostDevice.id != Constants.ids) {
                     otherHostAdapter!!.data.add(hostDevice)
                 }
             }
-            //Log.i(TAG, "其它主机数量 " + devices.size)
-            otherHostAdapter!!.notifyDataSetChanged()
         }
+        //Log.i(TAG, "其它主机数量 " + devices.size)
+        otherHostAdapter!!.notifyDataSetChanged()
     }
     /**
      *处理错误信息
      */
     override fun onError(message: String, type: Int) {
+        otherHostAdapter!!.notifyDataSetChanged()
     }
     /**
      *耗时加载完成