From 03cd18e291173c329356108d5838114fee7b2022 Mon Sep 17 00:00:00 2001 From: lizhanwei <Dana_Lee1016@126.com> Date: 星期三, 15 一月 2020 11:10:51 +0800 Subject: [PATCH] Map收到的消息放子线程处理 --- app/src/main/java/safeluck/drive/evaluation/fragment/MapFragment.java | 32 +++++++++++++++++++++++++------- 1 files changed, 25 insertions(+), 7 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 d944f03..abf6ac4 100644 --- a/app/src/main/java/safeluck/drive/evaluation/fragment/MapFragment.java +++ b/app/src/main/java/safeluck/drive/evaluation/fragment/MapFragment.java @@ -322,8 +322,22 @@ private ICEventListener icEventListener = new ICEventListener() { @Override public void onCEvent(String topic, int msgCode, int resultCode, Object obj) { - MyLog.i(TAG, (String) obj); - RealTimeCarPos timeCarPos = gson.fromJson((String) obj, RealTimeCarPos.class); + + CThreadPoolExecutor.runInBackground(new CalRunnable((String)obj)); + + } + }; + class CalRunnable implements Runnable{ + + private String json; + public CalRunnable(String obj) { + this.json = obj; + } + + @Override + public void run() { + MyLog.i(TAG, json); + RealTimeCarPos timeCarPos = gson.fromJson((String) json, RealTimeCarPos.class); List<Double> points = timeCarPos.getPoint(); line = 0; map_line = 0; @@ -362,7 +376,13 @@ for(int j=0; j<pointBeanList.size();j++){ List<Double> xys = pointBeanList.get(i).getXy(); - map = new double[xys.size()][2]; + if(j==0){ + map = new double[xys.size()][2]; + }else{ + MyLog.i(TAG,"鏆傛椂杩樹笉鏀寔鏇茬嚎"); + break; + } + for (int k=0; k<xys.size();k++){ if ((k % 2) == 0) { map[map_line][0] = xys.get(k); @@ -379,11 +399,9 @@ } } } - - CThreadPoolExecutor.runInBackground(new NeedForSpeed(car, map)); + DrawMap(map,car); } - }; - + } @Override public void onAttach(Context context) { super.onAttach(context); -- Gitblit v1.8.0