From afc53a32075c5570bb8e8064f89b16da12bfc878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9D=9A=E6=8C=81?= <2352009235@qq.com> Date: Fri, 30 Jul 2021 08:12:26 +0000 Subject: [PATCH] update DistributedMapDemo/entry/src/main/java/com/huawei/codelab/map/MapManager.java. fix crash bug --- .../main/java/com/huawei/codelab/map/MapManager.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/DistributedMapDemo/entry/src/main/java/com/huawei/codelab/map/MapManager.java b/DistributedMapDemo/entry/src/main/java/com/huawei/codelab/map/MapManager.java index 0f1bde3a..43307d52 100644 --- a/DistributedMapDemo/entry/src/main/java/com/huawei/codelab/map/MapManager.java +++ b/DistributedMapDemo/entry/src/main/java/com/huawei/codelab/map/MapManager.java @@ -39,6 +39,7 @@ import ohos.rpc.IRemoteObject; import ohos.rpc.RemoteException; import java.util.List; +import java.util.ArrayList; /** * 地图控制类 @@ -132,12 +133,17 @@ public class MapManager { * @param tips tips */ public static void clearEmptyLocation(List tips) { + List newList = new ArrayList<>(); + for (int i = 0; i < tips.size(); i++) { InputTipsResult.TipsEntity tipsEntity = tips.get(i); - if ((tipsEntity.getLocation()).isEmpty()) { - tips.remove(tipsEntity); + if (tipsEntity.getLocation() != null && !(tipsEntity.getLocation()).isEmpty()) { + newList.add(tipsEntity); } } + + tips.clear(); + tips.addAll(newList); } public int getStepPoint() { -- Gitee