From 0d3e6fb21efe6f3c748d9bbece41b1a1e728ac07 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期三, 23 十一月 2022 17:34:23 +0800
Subject: [PATCH] 完善

---
 AndroidOpenDemo/app/src/main/java/com/utils/DeviceUtils.java |   42 +++++++++++++++++++++++++++---------------
 1 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/AndroidOpenDemo/app/src/main/java/com/utils/DeviceUtils.java b/AndroidOpenDemo/app/src/main/java/com/utils/DeviceUtils.java
index ac96eb4..05bef9f 100644
--- a/AndroidOpenDemo/app/src/main/java/com/utils/DeviceUtils.java
+++ b/AndroidOpenDemo/app/src/main/java/com/utils/DeviceUtils.java
@@ -28,7 +28,7 @@
     public DeviceUtils(String deviceId){
         this.deviceId=deviceId;
     }
-    private List<DeviceDetailListData.ResponseData.DeviceListBean> datas = new ArrayList<>();
+    private static List<DeviceDetailListData.ResponseData.DeviceListBean> datas = new ArrayList<>();
 
     private void getDeviceList() {
         DeviceSubAccountListService deviceSubAccountListService = ClassInstanceManager.newInstance().getDeviceSubAccountListService();
@@ -36,22 +36,21 @@
     }
 
     public void play() {
-        if (datas.size() == 0) {
-            getDeviceList();
-        } else {
-            for (DeviceDetailListData.ResponseData.DeviceListBean deviceListBean : datas) {
-                if (deviceListBean.deviceId.equals(deviceId)) {
-                    if (!deviceListBean.status.equals("online")) {
-                        return;
-                    }
-                    Bundle bundle = new Bundle();
-                    bundle.putSerializable(MethodConst.ParamConst.deviceDetail, deviceListBean);
-                    Intent intent = new Intent(HdlToLcUtils.getInstance().getActivity(), DeviceOnlineMediaPlayActivity.class);
-                    intent.putExtras(bundle);
-                    HdlToLcUtils.getInstance().getActivity().startActivity(intent);
+        for (DeviceDetailListData.ResponseData.DeviceListBean deviceListBean : datas) {
+            if (deviceListBean.deviceId.equals(deviceId)) {
+                if (!deviceListBean.status.equals("online")) {
+                    return;
                 }
+                Bundle bundle = new Bundle();
+                bundle.putSerializable(MethodConst.ParamConst.deviceDetail, deviceListBean);
+                Intent intent = new Intent(HdlToLcUtils.getInstance().getActivity(), DeviceOnlineMediaPlayActivity.class);
+                intent.putExtras(bundle);
+                HdlToLcUtils.getInstance().getActivity().startActivity(intent);
+
+                return;
             }
         }
+        getDeviceList();
     }
     @Override
     public void DeviceList(DeviceDetailListData.Response responseData) {
@@ -73,7 +72,20 @@
 
         datas.addAll(responseData.data.deviceList);
 
-        play();
+        for (DeviceDetailListData.ResponseData.DeviceListBean deviceListBean : datas) {
+            if (deviceListBean.deviceId.equals(deviceId)) {
+                if (!deviceListBean.status.equals("online")) {
+                    return;
+                }
+                Bundle bundle = new Bundle();
+                bundle.putSerializable(MethodConst.ParamConst.deviceDetail, deviceListBean);
+                Intent intent = new Intent(HdlToLcUtils.getInstance().getActivity(), DeviceOnlineMediaPlayActivity.class);
+                intent.putExtras(bundle);
+                HdlToLcUtils.getInstance().getActivity().startActivity(intent);
+
+                return;
+            }
+        }
     }
     @Override
     public void onError(Throwable throwable) {

--
Gitblit v1.8.0