From 6121e0bde700d5595d70a03217f92e99929e54b6 Mon Sep 17 00:00:00 2001
From: lizhanwei <Dana_Lee1016@126.com>
Date: 星期三, 04 三月 2020 15:45:00 +0800
Subject: [PATCH] 提交map fragment及driving——

---
 app/src/main/java/safeluck/drive/evaluation/fragment/MapFragment.java |   34 ++++++++++++++++++++++++++++------
 1 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/MapFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/MapFragment.java
index a1c215b..1ee38f5 100644
--- a/app/src/main/java/safeluck/drive/evaluation/fragment/MapFragment.java
+++ b/app/src/main/java/safeluck/drive/evaluation/fragment/MapFragment.java
@@ -8,6 +8,7 @@
 import android.graphics.Path;
 import android.os.Bundle;
 import android.os.Handler;
+import android.text.TextUtils;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.SurfaceHolder;
@@ -21,6 +22,7 @@
 import androidx.appcompat.widget.Toolbar;
 
 
+import com.anyun.exam.lib.AYSdk;
 import com.anyun.exam.lib.MyLog;
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
@@ -42,6 +44,7 @@
 import safeluck.drive.evaluation.Constant;
 import safeluck.drive.evaluation.R;
 import safeluck.drive.evaluation.bean.ExamMap;
+import safeluck.drive.evaluation.bean.ExamPlatformData;
 import safeluck.drive.evaluation.bean.RealTimeCarPos;
 import safeluck.drive.evaluation.cEventCenter.CEventCenter;
 import safeluck.drive.evaluation.cEventCenter.ICEventListener;
@@ -284,7 +287,7 @@
                 paint.setColor(Color.BLACK);
 
                 Path path = new Path();
-
+        Log.i(TAG, "DrawMap: map.length:"+map.length);
                 if (map.length != 9) {
                     Log.d(TAG, "DrawMap X = " + String.format("%f", (float) (base_x + (map[0][0] - min_x) * scale_x)) + " Y = " + String.format("%f", (float) (base_y + (map[0][1] - min_y) * scale_y)));
                     path.moveTo((float) (base_x + (map[0][0] - min_x) * scale_x), (float) (base_y + (map[0][1] - min_y) * scale_y));
@@ -312,8 +315,10 @@
                 canvas2.drawPath(path, paint);
 
                 path.moveTo((float) (base_x + (car[body.get(0)][0] - min_x) * scale_x), (float) (base_y + (car[body.get(0)][1] - min_y) * scale_y));
-                for (int i = 1; i < body.size(); i++)
+                for (int i = 1; i < body.size(); i++){
+                    Log.d(TAG, "for 寰幆 DrawMap to X = " + (float) (base_x + (car[body.get(i)][0] - min_x) * scale_x)+ " Y = " + (float) (base_y + (car[body.get(i)][1] - min_y) * scale_y));
                     path.lineTo((float) (base_x + (car[body.get(i)][0] - min_x) * scale_x), (float) (base_y + (car[body.get(i)][1] - min_y) * scale_y));
+                }
 
                 path.close();
 
@@ -481,12 +486,29 @@
 //            3 - 渚ф柟鍋滆溅
 //            4 - 鏇茬嚎琛岄┒
 //            5 - 鐩磋杞集
+                    StringBuffer buffer=null;
+                    List<ExamMap> examMaps;
+                    String newmap = null;
+                    String mapPath = ExamPlatformData.getInstance().getMapPath();
+                    if (!TextUtils.isEmpty(mapPath)){
+                        MyLog.i("璋冪敤鏇存柊Map璺緞鍚庣殑鍦板浘"+mapPath);
+                        byte[] fileContent = FileUtil.readFile(mapPath);
+                        if (fileContent != null){
+                            newmap= new String(fileContent);
+                            Log.i(TAG, "鏂囦欢鍐呭锛�"+newmap);
+                        }else{
+                            MyLog.i(String.format("鏂囦欢:%s涓嶅瓨鍦�",mapPath));
+                        }
+                    }else{
+                        buffer = FileUtil.readAssetTxtFile(_mActivity,Constant.MAP);
+                    }
 
-
-                    StringBuffer buffer = FileUtil.readAssetTxtFile(_mActivity,Constant.MAP);
                     Type type = new TypeToken<List<ExamMap>>(){}.getType();
                     if (buffer != null){
-                        List<ExamMap> examMaps = gson.fromJson(buffer.toString().trim(), type);
+                       examMaps= gson.fromJson(buffer.toString().trim(), type);
+                    }else{
+                        examMaps = gson.fromJson(newmap.trim(),type);
+                    }
 
 
 
@@ -519,7 +541,7 @@
                                 break;
                             }
                         }
-                    }
+
                     DrawMap(mainAnt, map, car, body, tire);
                 }
             }

--
Gitblit v1.8.0