From ee9d75f83fb85f8206c8ea8d08750611bee35856 Mon Sep 17 00:00:00 2001
From: endian11 <Dana_Lee1016@126.com>
Date: 星期五, 18 九月 2020 17:22:32 +0800
Subject: [PATCH] 测试项目采集、路口采集,完成发送0x8017;目前需要加一个发送查询是否在某段路

---
 app/src/main/java/safeluck/drive/evaluation/routecollect/impl/RouteModel.java |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 50 insertions(+), 10 deletions(-)

diff --git a/app/src/main/java/safeluck/drive/evaluation/routecollect/impl/RouteModel.java b/app/src/main/java/safeluck/drive/evaluation/routecollect/impl/RouteModel.java
index cdc1386..1461829 100644
--- a/app/src/main/java/safeluck/drive/evaluation/routecollect/impl/RouteModel.java
+++ b/app/src/main/java/safeluck/drive/evaluation/routecollect/impl/RouteModel.java
@@ -3,16 +3,20 @@
 import android.util.Log;
 
 import com.anyun.exam.lib.IRemoteInterface;
+import com.google.gson.Gson;
 
 import org.json.JSONException;
 import org.json.JSONObject;
 
 import safeluck.drive.evaluation.Constant;
+import safeluck.drive.evaluation.bean.ExamPlatformData;
 import safeluck.drive.evaluation.cEventCenter.CEventCenter;
 import safeluck.drive.evaluation.cEventCenter.ICEventListener;
 import safeluck.drive.evaluation.routecollect.CollectPointResult;
 import safeluck.drive.evaluation.routecollect.ILoadListener;
 import safeluck.drive.evaluation.routecollect.IRouteCollectInterface;
+import safeluck.drive.evaluation.routecollect.bean.RoadCrossInfo;
+import safeluck.drive.evaluation.routecollect.bean.RoadInfo;
 import safeluck.drive.evaluation.util.Utils;
 
 /**
@@ -24,7 +28,32 @@
 public class RouteModel implements IRouteCollectInterface{
 
     ILoadListener iLoadListener;
+    private Gson gson = new Gson();
     private static final String TAG = "RouteModel";
+
+    private ICEventListener icEventListener1= new ICEventListener() {
+        @Override
+        public void onCEvent(String topic, int msgCode, int resultCode, Object obj) {
+
+            if (msgCode == Constant.ENTER_OR_EXIT_ROAD_ID){
+
+                if (iLoadListener != null){
+                    Log.i(TAG,"閬撹矾娑堟伅"+(String)obj);
+                    RoadInfo roadInfo = gson.fromJson((String)obj,RoadInfo.class);
+                    ExamPlatformData.getInstance().setRouteCollectRoadInfo(roadInfo);
+                    iLoadListener.roadInfo(roadInfo);
+                }
+            }
+
+            if (msgCode == Constant.ENTER_OR_EXIT_ROADCROSS_ID){
+                Log.i(TAG,"璺彛娑堟伅"+(String)obj);
+                if (iLoadListener != null){
+                    RoadCrossInfo roadCrossInfo = gson.fromJson((String) obj,RoadCrossInfo.class);
+                    iLoadListener.roadCrossInfo(roadCrossInfo);
+                }
+            }
+        }
+    };
     private ICEventListener icEventListener= new ICEventListener() {
         @Override
         public void onCEvent(String topic, int msgCode, int resultCode, Object obj) {
@@ -48,20 +77,13 @@
                 }
             }
 
-            if (msgCode == Constant.ENTER_OR_EXIT_ROAD_ID){
-                Log.i(TAG,"閬撹矾娑堟伅"+(String)obj);
-            }
-
-            if (msgCode == Constant.ENTER_OR_EXIT_ROADCROSS_ID){
-                Log.i(TAG,"璺彛娑堟伅"+(String)obj);
-            }
 
         }
     };
 
     @Override
-    public void startCollect(ILoadListener listener) {
-        iLoadListener = listener;
+    public void startCollect() {
+
         //璋冪敤AYSdk 鏂规硶鍚姩閲囩偣
         //set IRouteRemotePointCallback
 
@@ -76,7 +98,25 @@
     public void endCollect() {
         //濡傛灉閲囩敤application鐨刢allback 锛屽彲鑳介渶瑕佸弽娉ㄥ唽涓�涓狢EventLisntener 瑙g粦
         CEventCenter.onBindEvent(false,icEventListener,Constant.BIND_RTK_INFO_MAP);
-        iLoadListener = null;
+
+    }
+
+    @Override
+    public void startRoadListener() {
+        Log.i(TAG,"绾胯矾閲囬泦锛屽紑濮嬭矾鐩戝惉");
+        CEventCenter.onBindEvent(true,icEventListener1, Constant.BIND_ROUTE_COLLECT_TOPIC);
+    }
+
+
+
+    @Override
+    public void endRoadListener() {
+        CEventCenter.onBindEvent(false,icEventListener1, Constant.BIND_ROUTE_COLLECT_TOPIC);
+    }
+
+    @Override
+    public void setLoadListener(ILoadListener routeCollectController) {
+        iLoadListener = routeCollectController;
     }
 
 

--
Gitblit v1.8.0