From e61eb1c6fe377272b6614dc2b1b7046f007fb69c Mon Sep 17 00:00:00 2001 From: lizhanwei <Dana_Lee1016@126.com> Date: 星期二, 14 一月 2020 18:33:16 +0800 Subject: [PATCH] 动态加载地图根据map_id --- app/src/main/java/safeluck/drive/evaluation/fragment/MapFragment.java | 40 +++++++++++++++++++++++++++++++++++++++- 1 files changed, 39 insertions(+), 1 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 a4c77f5..c403a25 100644 --- a/app/src/main/java/safeluck/drive/evaluation/fragment/MapFragment.java +++ b/app/src/main/java/safeluck/drive/evaluation/fragment/MapFragment.java @@ -24,17 +24,21 @@ import com.anyun.exam.lib.MyLog; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import java.lang.reflect.Type; import java.util.List; import me.yokeyword.fragmentation.SupportFragment; import safeluck.drive.evaluation.Constant; import safeluck.drive.evaluation.R; +import safeluck.drive.evaluation.bean.ExamMap; import safeluck.drive.evaluation.bean.RealTimeCarPos; import safeluck.drive.evaluation.cEventCenter.CEventCenter; import safeluck.drive.evaluation.cEventCenter.ICEventListener; import safeluck.drive.evaluation.util.CThreadPoolExecutor; +import safeluck.drive.evaluation.util.FileUtil; /** @@ -66,6 +70,7 @@ private String osd = null; private String osd2 = null; private String osd3 = null; + private int map_id; double map[][] = {{1, 1}, {10, 1}, {10, 10}, {1, 10}}; double car[][] = {{8.278, 1.467}, {7.2780000000000009, 1.467}, {7.2780000000000009, -1.533}, {8.278, -1.533} , {9.278, -1.5330000000000004}, {9.277999999999999, 1.467000000000001}}; @@ -312,6 +317,7 @@ } int line = 0; + int map_line = 0; private ICEventListener icEventListener = new ICEventListener() { @Override public void onCEvent(String topic, int msgCode, int resultCode, Object obj) { @@ -319,6 +325,7 @@ RealTimeCarPos timeCarPos = gson.fromJson((String) obj, RealTimeCarPos.class); List<Double> points = timeCarPos.getPoint(); line = 0; + map_line = 0; for (int i = 0; i < points.size(); i++) { if ((i % 2) == 0) { @@ -331,7 +338,38 @@ } } - CThreadPoolExecutor.runInBackground(new NeedForSpeed(car,map)); + map_id = timeCarPos.getMap_id(); +// 1 - 鍊掑簱 +// 2 - 鍧¤捣 +// 3 - 渚ф柟鍋滆溅 +// 4 - 鏇茬嚎琛岄┒ +// 5 - 鐩磋杞集 + + + StringBuffer buffer = FileUtil.readTxtFileFromSD(_mActivity,Constant.MAP); + Type type = new TypeToken<List<ExamMap>>(){}.getType(); + if (buffer != null){ + List<ExamMap> examMaps = gson.fromJson(buffer.toString().trim(), type); + for (int i = 0; i < examMaps.size(); i++) { + ExamMap examMap = examMaps.get(i); + if (map_id == examMap.getId()){ + List<ExamMap.PointBean> pointBeanList = examMap.getPoint(); + for(int j=0; j<pointBeanList.size();j++){ + if ((j % 2) == 0) { + map[map_line][0] = points.get(i); + } else { + double value = 0 - points.get(i); + Log.i(TAG, "onCEvent: map鏂板��=" + value + " 浣嶇疆锛�" + i); + map[map_line][1] = value; + map_line++; + } + } + break; + } + } + } + + CThreadPoolExecutor.runInBackground(new NeedForSpeed(car, map)); } }; -- Gitblit v1.8.0