new Thread(() -> { BNRoutePlanInfos routePlaneInfo = BaiduNaviManagerFactory.getRoutePlanManager().getRoutePlanInfo(); if (routePlaneInfo != null) { // 获取限行数据 limitInfo = routePlaneInfo.getLimitInfo(); //3Tab数据 mRoutePlanItems = routePlaneInfo.getRouteTabInfos(); //路线详情 mRouteDetails = routePlaneInfo.getRouteDetailLists(); } // 获取数据后更新 UI runOnUiThread(() -> { if (limitInfo != null) { for (int i = 0; i < limitInfo.size(); i++) { String[] arr = limitInfo.get(i).split(","); Log.e(TAG, "第" + arr[0] + "条路线限行消息:" + arr[1]); } } if (mRoutePlanItems != null) { if (mRoutePlanItems.size() > 0 && mRoutePlanItems.get(0) != null) { initTabView(mLayoutTab0, mRoutePlanItems.get(0)); } if (mRoutePlanItems.size() > 1 && mRoutePlanItems.get(1) != null) { initTabView(mLayoutTab1, mRoutePlanItems.get(1)); mLayoutTab1.setVisibility(View.VISIBLE); } else { mLayoutTab1.setVisibility(View.GONE); } if (mRoutePlanItems.size() > 2 && mRoutePlanItems.get(2) != null) { initTabView(mLayoutTab2, mRoutePlanItems.get(2)); mLayoutTab2.setVisibility(View.VISIBLE); } else { mLayoutTab2.setVisibility(View.GONE); } } mLayoutTab0.setSelected(true); mRouteList.clear(); mRouteList.addAll(mRouteDetails.get(0)); LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); mRecyclerView.setLayoutManager(layoutManager); mResultAdapter = new RouteResultAdapter(mRouteList); mRecyclerView.setAdapter(mResultAdapter); // 展示长途信息 if (BaiduNaviManagerFactory.getRouteResultManager().isLongDistance()) { mLDLayout.setVisibility(View.VISIBLE); } else { mLDLayout.setVisibility(View.GONE); } }); }).start(); 以上代码有问题吗? 如有不安全性问题,帮我修改一下
时间: 2024-01-11 18:02:09 浏览: 135
以上代码并没有明显的安全问题。但是建议将敏感信息进行加密传输或存储,比如限行数据和路线详情等。此外,建议将线程操作封装成方法,提高代码的可读性和可维护性。具体修改代码如下:
```
private void getRoutePlanInfo() {
new Thread(() -> {
BNRoutePlanInfos routePlaneInfo = BaiduNaviManagerFactory.getRoutePlanManager().getRoutePlanInfo();
if (routePlaneInfo != null) {
// 获取限行数据
limitInfo = routePlaneInfo.getLimitInfo();
//3Tab数据
mRoutePlanItems = routePlaneInfo.getRouteTabInfos();
//路线详情
mRouteDetails = routePlaneInfo.getRouteDetailLists();
}
// 获取数据后更新 UI
getActivity().runOnUiThread(() -> {
if (limitInfo != null) {
for (int i = 0; i < limitInfo.size(); i++) {
String[] arr = limitInfo.get(i).split(",");
Log.e(TAG, "第" + arr[0] + "条路线限行消息:" + arr[1]);
}
}
if (mRoutePlanItems != null) {
if (mRoutePlanItems.size() > 0 && mRoutePlanItems.get(0) != null) {
initTabView(mLayoutTab0, mRoutePlanItems.get(0));
}
if (mRoutePlanItems.size() > 1 && mRoutePlanItems.get(1) != null) {
initTabView(mLayoutTab1, mRoutePlanItems.get(1));
mLayoutTab1.setVisibility(View.VISIBLE);
} else {
mLayoutTab1.setVisibility(View.GONE);
}
if (mRoutePlanItems.size() > 2 && mRoutePlanItems.get(2) != null) {
initTabView(mLayoutTab2, mRoutePlanItems.get(2));
mLayoutTab2.setVisibility(View.VISIBLE);
} else {
mLayoutTab2.setVisibility(View.GONE);
}
}
mLayoutTab0.setSelected(true);
mRouteList.clear();
mRouteList.addAll(mRouteDetails.get(0));
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
mRecyclerView.setLayoutManager(layoutManager);
mResultAdapter = new RouteResultAdapter(mRouteList);
mRecyclerView.setAdapter(mResultAdapter);
// 展示长途信息
if (BaiduNaviManagerFactory.getRouteResultManager().isLongDistance()) {
mLDLayout.setVisibility(View.VISIBLE);
} else {
mLDLayout.setVisibility(View.GONE);
}
});
}).start();
}
```
阅读全文