Commit 4009eb8abd179c7c5b66ef7e066d9b52f8dfbfac

Authored by 杨帅
1 parent bf5783f5

1 增加,详情页面,地图根据卡片进行缩放功能

2 修复用户进入详情页面,围栏id为空时,闪退的问题
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunRaceDetailFragmentView.java
... ... @@ -8,6 +8,7 @@ import android.hardware.SensorEvent;
8 8 import android.hardware.SensorEventListener;
9 9 import android.hardware.SensorManager;
10 10 import android.text.TextUtils;
  11 +import android.util.Log;
11 12 import android.view.View;
12 13 import android.view.ViewTreeObserver;
13 14 import android.widget.Toast;
... ... @@ -20,6 +21,7 @@ import com.baidu.mapapi.map.BaiduMap;
20 21 import com.baidu.mapapi.map.BitmapDescriptor;
21 22 import com.baidu.mapapi.map.BitmapDescriptorFactory;
22 23 import com.baidu.mapapi.map.MapStatus;
  24 +import com.baidu.mapapi.map.MapStatusUpdate;
23 25 import com.baidu.mapapi.map.MapStatusUpdateFactory;
24 26 import com.baidu.mapapi.map.MapView;
25 27 import com.baidu.mapapi.map.MarkerOptions;
... ... @@ -44,7 +46,6 @@ import com.baidu.mapapi.search.route.WalkingRouteResult;
44 46 import com.baidu.trace.LBSTraceClient;
45 47 import com.baidu.trace.model.SortType;
46 48 import com.cnlive.moudle.collectionTrace.ui.activity.RaceNameListActivity;
47   -import com.cnlive.moudle.collectionTrace.ui.activity.StartCollectTraceActivity;
48 49 import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunRaceDetailFragment;
49 50 import com.cnlive.moudle.collectionTrace.commonInfo.CollCommonInfo;
50 51 import com.cnlive.moudle.pedometer.model.Constant;
... ... @@ -91,14 +92,15 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen
91 92 private final int DEFULT_ZOOM = 17;
92 93 private RoutePlanSearch routePlanSearch = null; // 路线规划
93 94 private LatLng endLatLng;
94   - private final int START_MARK = 0;//起始点
95   - private final int END_MARK = 1;//终止点
96 95 private String test = "[{\"latitude\":39.933889208848,\"latitudeE6\":3.9933889208848E7,\"longitude\":116.30900265517,\"longitudeE6\":1.1630900265517001E8},{\"latitude\":39.933868507347,\"latitudeE6\":3.9933868507347E7,\"longitude\":116.30865416508,\"longitudeE6\":1.1630865416508E8},{\"latitude\":39.934756505077,\"latitudeE6\":3.9934756505077E7,\"longitude\":116.30860516469,\"longitudeE6\":1.1630860516468999E8},{\"latitude\":39.934781620502,\"latitudeE6\":3.9934781620502E7,\"longitude\":116.30961013007,\"longitudeE6\":1.1630961013007E8},{\"latitude\":39.934881620374,\"latitudeE6\":3.9934881620374E7,\"longitude\":116.30960513008,\"longitudeE6\":1.1630960513008E8},{\"latitude\":39.934077623132,\"latitudeE6\":3.9934077623132E7,\"longitude\":116.30965812942,\"longitudeE6\":1.1630965812942E8},{\"latitude\":39.933972618463,\"latitudeE6\":3.9933972618463E7,\"longitude\":116.30962113087,\"longitudeE6\":1.1630962113087E8},{\"latitude\":39.933932608856,\"latitudeE6\":3.9933932608856E7,\"longitude\":116.30953913383,\"longitudeE6\":1.1630953913383E8}]";
97 96 private LinkedList<LatLng> importLatLngs;//关键点
98   - private LatLng startLatLng = new LatLng(39.934733, 116.308646);//起始点
99   - private List<LatLng> trackPoints;
100 97 public RunRaceDetailInfo runRaceDetailInfo;
101 98 private LBSTraceClient mClient = null;
  99 + private List<LatLng> queryResultPoints;//查询到的历史轨迹
  100 + private boolean isChangeMapState = true;//上滑卡片是否缩放地图与倾斜
  101 + private float initZoom = 0;
  102 + private final float INIT_MAP_OVERLOOK = -40f;//地图倾斜角度
  103 + private final float DEFAULT_MAP_AUTO_ZOOM = -0.8f;//根据点位,自动缩放的比例
102 104  
103 105 public CollRunRaceDetailFragmentView(CollRunRaceDetailFragment fragment) {
104 106 this.fragment = fragment;
... ... @@ -110,6 +112,7 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen
110 112  
111 113  
112 114 public void initView(RunRaceDetailInfo runRaceDetailInfo, String uid) {
  115 + queryResultPoints = new ArrayList<>();
113 116 if (fragment.getActivity() == null) {
114 117 return;
115 118 }
... ... @@ -126,6 +129,7 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen
126 129 fragment.binding.emptyLayout.setVisibility(View.GONE);
127 130 //设置底部卡片第一次可滑动的位置
128 131 fragment.binding.slidingLayout.setAnchorPoint(0.6f);
  132 +
129 133 fragment.binding.slidingLayout.addPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {
130 134 @Override
131 135 public void onPanelSlide(View panel, float slideOffset) {
... ... @@ -133,23 +137,39 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen
133 137  
134 138 @Override
135 139 public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) {
  140 + if (newState == SlidingUpPanelLayout.PanelState.ANCHORED) {
  141 + if (isChangeMapState) {
  142 + if (null != baiduMap) {
  143 + if (null != baiduMap.getMapStatus()) {
  144 + MapStatus mapStatus = new MapStatus
  145 + .Builder(baiduMap.getMapStatus())
  146 + .overlook(0)
  147 + .zoom((float) (baiduMap.getMapStatus().zoom - 1.5)).build();
  148 + MapStatusUpdate mapStatusUpdate = MapStatusUpdateFactory.newMapStatus(mapStatus);
  149 + baiduMap.animateMapStatus(mapStatusUpdate);
  150 + }
  151 + }
  152 + }
  153 + isChangeMapState = false;
  154 + } else if (newState == SlidingUpPanelLayout.PanelState.COLLAPSED) {
  155 +
  156 + if (null != baiduMap) {
  157 + if (0 == initZoom) {
  158 + initZoom = DEFULT_ZOOM;
  159 + }
  160 + MapStatus mapStatus = new MapStatus
  161 + .Builder(baiduMap.getMapStatus())
  162 + .overlook(INIT_MAP_OVERLOOK)
  163 + .zoom(initZoom)
  164 + .build();
  165 + MapStatusUpdate mapStatusUpdate = MapStatusUpdateFactory.newMapStatus(mapStatus);
  166 + baiduMap.animateMapStatus(mapStatusUpdate);
  167 + isChangeMapState = true;
  168 + }
  169 + }
136 170 }
137 171 });
138 172 /*************************设置相关页面数据***************************/
139   - //获取轨迹开始时间
140   - if (!TextUtils.isEmpty(runRaceDetailInfo.getStartTime()) && !TextUtils.isEmpty(runRaceDetailInfo.getEndTime()) && !TextUtils.isEmpty(runRaceDetailInfo.getEntityName())) {
141   - long startTime = Long.parseLong(runRaceDetailInfo.getStartTime());
142   - long endTime = Long.parseLong(runRaceDetailInfo.getEndTime());
143   - String entityName = runRaceDetailInfo.getEntityName();
144   - MyMapUtil.queryHistoryTrace(getContext(), mClient, entityName, startTime, endTime, new MyMapUtil.CallBack() {
145   - @Override
146   - public void success(List<LatLng> resultPoints) {
147   - if (null != resultPoints) {
148   - MyMapUtil.drawHistoryTrack(getContext(), baiduMap, resultPoints, SortType.asc, R.color.green_round, R.drawable.icon_start, R.drawable.icon_end);
149   - }
150   - }
151   - });
152   - }
153 173 //设置标题
154 174 if (!TextUtils.isEmpty(runRaceDetailInfo.getTitle())) {
155 175 fragment.binding.includeStreet.tvRaceTitle.setText(runRaceDetailInfo.getTitle());
... ... @@ -213,8 +233,10 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen
213 233 @Override
214 234 public void success(List<LatLng> resultPoints) {
215 235 if (null != resultPoints && resultPoints.size() > 1) {
  236 + queryResultPoints.clear();
  237 + queryResultPoints.addAll(resultPoints);
216 238 MyMapUtil.drawHistoryTrack(getContext(), baiduMap, resultPoints, SortType.asc, R.color.green_round, R.drawable.icon_start, R.drawable.icon_end);
217   - MyMapUtil.setMapAutoZoom(baiduMap, resultPoints, -1.5f);
  239 + initZoom = MyMapUtil.setMapAutoZoom(baiduMap, resultPoints, DEFAULT_MAP_AUTO_ZOOM);
218 240 }
219 241 }
220 242 });
... ... @@ -287,12 +309,15 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen
287 309 if (baiduMap == null) {
288 310 baiduMap = mMapView.getMap();
289 311 }
290   - if (routePlanSearch == null) {
291   - routePlanSearch = RoutePlanSearch.newInstance();
292   - }
293 312 if (mUiSettings == null) {
294 313 mUiSettings = baiduMap.getUiSettings();
295 314 }
  315 + MapStatus mapStatus = new MapStatus
  316 + .Builder(baiduMap.getMapStatus())
  317 + .overlook(INIT_MAP_OVERLOOK)
  318 + .build();
  319 + MapStatusUpdate mapStatusUpdate = MapStatusUpdateFactory.newMapStatus(mapStatus);
  320 + baiduMap.animateMapStatus(mapStatusUpdate);
296 321 //设置定位模式, 默认为 LocationMode.NORMAL 普通态
297 322 mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL;
298 323 // 设置定位图标修改为自定义marker
... ... @@ -646,19 +671,9 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen
646 671 }
647 672  
648 673 MapStatus.Builder builder = new MapStatus.Builder();
649   -
650   -// if (isFirstLoc) {
651   -// isFirstLoc = false;
652 674 firstLatLng = new LatLng(location.getLatitude(),
653 675 location.getLongitude());
654 676 baiduMap.setMyLocationData(followMyLocation);
655   -// builder.target(firstLatLng).zoom(DEFULT_ZOOM);
656   -// baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
657   -
658   -// //显示当前位置图标
659   -// Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.rt_ic_location), 40, 40);
660   -// currentMark = new MarkerOptions().position(firstLatLng).icon(BitmapDescriptorFactory.fromBitmap(pointBitmap));
661   -// baiduMap.addOverlay(currentMark);
662 677  
663 678 //根据几个关键点进行步行路径规划
664 679 // if (importLatLngs != null) {
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/commonInfo/CommonInfo.java
... ... @@ -279,26 +279,26 @@ public class CommonInfo {
279 279 }
280 280  
281 281  
282   - /**
283   - * 设置赛事标题
284   - *
285   - * @param context
286   - * @param streetTitle
287   - */
288   - public static void setStreetTitle(Context context, String streetTitle) {
289   - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString("runStreetTitle", streetTitle);
290   -
291   - }
292   -
293   - /**
294   - * 获取赛事标题
295   - *
296   - * @param context
297   - */
298   - public static String getStreetTitle(Context context) {
299   - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString("runStreetTitle", "");
300   -
301   - }
  282 +// /**
  283 +// * 设置赛事标题
  284 +// *
  285 +// * @param context
  286 +// * @param streetTitle
  287 +// */
  288 +// public static void setStreetTitle(Context context, String streetTitle) {
  289 +// MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString("runStreetTitle", streetTitle);
  290 +//
  291 +// }
  292 +//
  293 +// /**
  294 +// * 获取赛事标题
  295 +// *
  296 +// * @param context
  297 +// */
  298 +// public static String getStreetTitle(Context context) {
  299 +// return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString("runStreetTitle", "");
  300 +//
  301 +// }
302 302  
303 303 // /**
304 304 // * 设置起点经纬度
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
... ... @@ -26,6 +26,7 @@ import com.baidu.mapapi.map.BaiduMap;
26 26 import com.baidu.mapapi.map.BitmapDescriptor;
27 27 import com.baidu.mapapi.map.BitmapDescriptorFactory;
28 28 import com.baidu.mapapi.map.MapStatus;
  29 +import com.baidu.mapapi.map.MapStatusUpdate;
29 30 import com.baidu.mapapi.map.MapStatusUpdateFactory;
30 31 import com.baidu.mapapi.map.MapView;
31 32 import com.baidu.mapapi.map.MarkerOptions;
... ... @@ -105,6 +106,11 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
105 106 private boolean isDifferentStreet = false;
106 107 private LBSTraceClient mClient = null;
107 108 public LatLng endLatLng;//用于终点判断
  109 + private boolean isChangeMapState = true;//上滑卡片是否缩放地图与倾斜
  110 + private float initZoom = 0;
  111 + private final float INIT_MAP_OVERLOOK = -40f;//地图倾斜角度
  112 + private final float DEFAULT_MAP_AUTO_ZOOM = -0.8f;//根据点位,自动缩放的比例
  113 + private List<LatLng> queryResultPoints;//查询到的历史轨迹
108 114  
109 115 public RunRaceDetailFragmentView(RunRaceDetailFragment fragment) {
110 116 this.fragment = fragment;
... ... @@ -116,57 +122,10 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
116 122  
117 123  
118 124 public void initView(RunRaceDetailInfo runRaceDetailInfo) {
119   - Log.e(TAG, "initView: " + TimeUtil.getNowTimeStamp());
120   -// new Handler().postDelayed(new Runnable() {
121   -// @Override
122   -// public void run() {
123   -// baiduMap.snapshot(new BaiduMap.SnapshotReadyCallback() {
124   -// @Override
125   -// public void onSnapshotReady(Bitmap bitmap) {
126   -// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
127   -// if (null == bitmap) {
128   -// return;
129   -// }
130   -// QMUITipDialogUtil.loadingDialog(getContext(), "上传", false);
131   -// //开始保存截屏
132   -// try {
133   -// File image = new File(getContext().getExternalCacheDir() + "/location_screenshot_" + sdf.format(new Date()) + ".jpeg");
134   -// FileOutputStream fos = new FileOutputStream(image);
135   -// boolean b = bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
136   -// fos.flush();
137   -// fos.close();
138   -// List<String> imagePaths = new ArrayList<>();
139   -// imagePaths.add(image.getAbsolutePath());
140   -// Log.e(TAG, "onSnapshotReady: "+image.getAbsolutePath() );
141   -//
142   -// UploadLogic.uploadAddressPicInfo(getContext(), imagePaths, new Event<String>()
143   -// .setFailureCallback(new FailureCallback() {
144   -// @Override
145   -// public void onFailure(int i, String s) {
146   -// QMUITipDialogUtil.dismessDialog();
147   -// Log.e(TAG, "onFailure: " + s);
148   -// }
149   -// })
150   -// .setSuccessCallback(new SuccessCallback<String>() {
151   -// @Override
152   -// public void onSuccess(String data) {
153   -// QMUITipDialogUtil.dismessDialog();
154   -// Log.e(TAG, "onSuccess: " + data);
155   -// }
156   -// })
157   -// );
158   -// } catch (Exception e) {
159   -// e.printStackTrace();
160   -// }
161   -// }
162   -// });
163   -// //
164   -// }
165   -// },2000);
166   -
167 125 if (fragment.getActivity() == null) {
168 126 return;
169 127 }
  128 + queryResultPoints = new ArrayList<>();
170 129 this.runRaceDetailInfo = runRaceDetailInfo;
171 130 //轨迹开始时间
172 131 long startTime = 0;
... ... @@ -184,17 +143,14 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
184 143 @Override
185 144 public void success(List<LatLng> resultPoints) {
186 145 if (resultPoints != null && resultPoints.size() > 1) {
  146 + queryResultPoints.clear();
  147 + queryResultPoints.addAll(resultPoints);
187 148 startLatLng = resultPoints.get(0);
188 149 endLatLng = resultPoints.get(resultPoints.size() - 1);
189 150 MyMapUtil.drawServerLineTrack(getContext(), baiduMap, resultPoints, SortType.asc, R.color.green_round, R.drawable.icon_start, R.drawable.icon_end);
190 151 // //自动计算地图缩放
191   -// MapStatus.Builder builder = new MapStatus.Builder();
192   -// builder.target(MyMapUtil.getCenterZoomPosition(resultPoints));
193   -// builder.zoom(MyMapUtil.getZoom(resultPoints));
194   -// baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
195   -
196 152 //设置地图自动缩放
197   - MyMapUtil.setMapAutoZoom(baiduMap, resultPoints, -1.5f);
  153 + initZoom = MyMapUtil.setMapAutoZoom(baiduMap, resultPoints, -1.5f);
198 154  
199 155 }
200 156 }
... ... @@ -258,23 +214,10 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
258 214  
259 215 }
260 216  
261   -// if (slideOffset == 0) {
262   -// //在初始位置
263   -// if (fragment.binding.includeStreet.rlStartBtn.getVisibility() == View.GONE) {
264   -// fragment.binding.includeStreet.rlStartBtn.setVisibility(View.VISIBLE);
265   -// }
266   -//
267   -// } else {
268   -// //用户进行滑动
269   -// if (fragment.binding.includeStreet.rlStartBtn.getVisibility() == View.VISIBLE) {
270   -// fragment.binding.includeStreet.rlStartBtn.setVisibility(View.GONE);
271   -// }
272   -// }
273 217 }
274 218  
275 219 @Override
276 220 public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) {
277   -// Log.e(TAG, "previousState: " + previousState + ",newState:" + newState);
278 221 if (previousState == SlidingUpPanelLayout.PanelState.ANCHORED && newState == SlidingUpPanelLayout.PanelState.DRAGGING) {
279 222 if (fragment.binding.flTop.getVisibility() != View.VISIBLE) {
280 223 QMUIStatusBarHelper.setStatusBarDarkMode(fragment.getActivity());
... ... @@ -303,6 +246,39 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
303 246 fragment.binding.flTop.setVisibility(View.GONE);
304 247 }
305 248 }
  249 + //设置地图缩放
  250 + if (newState == SlidingUpPanelLayout.PanelState.ANCHORED) {
  251 + if (isChangeMapState) {
  252 + if (null != baiduMap) {
  253 + if (null != baiduMap.getMapStatus()) {
  254 + MapStatus mapStatus = new MapStatus
  255 + .Builder(baiduMap.getMapStatus())
  256 + .overlook(0)
  257 + .zoom((float) (baiduMap.getMapStatus().zoom - 1.5)).build();
  258 + MapStatusUpdate mapStatusUpdate = MapStatusUpdateFactory.newMapStatus(mapStatus);
  259 + baiduMap.animateMapStatus(mapStatusUpdate);
  260 + }
  261 + }
  262 + }
  263 + isChangeMapState = false;
  264 + } else if (newState == SlidingUpPanelLayout.PanelState.COLLAPSED) {
  265 +
  266 + if (null != baiduMap) {
  267 + if (0 == initZoom) {
  268 + initZoom = DEFULT_ZOOM;
  269 + }
  270 + MapStatus mapStatus = new MapStatus
  271 + .Builder(baiduMap.getMapStatus())
  272 + .overlook(INIT_MAP_OVERLOOK)
  273 + .zoom(initZoom)
  274 + .build();
  275 + MapStatusUpdate mapStatusUpdate = MapStatusUpdateFactory.newMapStatus(mapStatus);
  276 + baiduMap.animateMapStatus(mapStatusUpdate);
  277 + isChangeMapState = true;
  278 + }
  279 + }
  280 +
  281 + //
306 282  
307 283 }
308 284 });
... ... @@ -317,13 +293,12 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
317 293 }
318 294 });
319 295 /*************************设置相关页面数据***************************/
320   - if (runRaceDetailInfo.getFenceId() != null&&!TextUtils.isEmpty(runRaceDetailInfo.getFenceId())) {
  296 + if (runRaceDetailInfo.getFenceId() != null && !TextUtils.isEmpty(runRaceDetailInfo.getFenceId())) {
321 297 //设置围栏ID
322 298 CommonInfo.setFenceId(getContext(), Integer.parseInt(runRaceDetailInfo.getFenceId()));
323 299 }
324 300 //设置标题
325 301 if (!TextUtils.isEmpty(runRaceDetailInfo.getTitle())) {
326   - CommonInfo.setStreetTitle(getContext(),runRaceDetailInfo.getTitle());
327 302 fragment.binding.includeStreet.tvRaceTitle.setText(runRaceDetailInfo.getTitle());
328 303 fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
329 304 @Override
... ... @@ -356,7 +331,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
356 331 fragment.binding.includeStreet.tvAddress.setText(runRaceDetailInfo.getAddress());
357 332 //设置活动距离
358 333 if (!TextUtils.isEmpty(runRaceDetailInfo.getMileage())) {
359   - fragment.binding.includeStreet.tvAddress.append("\t\t全长" + runRaceDetailInfo.getMileage()+"公里");
  334 + fragment.binding.includeStreet.tvAddress.append("\t\t全长" + runRaceDetailInfo.getMileage() + "公里");
360 335 }
361 336 }
362 337  
... ... @@ -444,7 +419,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
444 419 fragment.binding.includeRank.tvKingNickName.setText(runRaceDetailInfo.getFirstName());
445 420 }
446 421 //第一名用时
447   - if (!TextUtils.isEmpty(runRaceDetailInfo.getFirstEmployTime())){
  422 + if (!TextUtils.isEmpty(runRaceDetailInfo.getFirstEmployTime())) {
448 423 fragment.binding.includeRank.tvFirstTime.setText(TimeUtil.stampToChronometer(Long.parseLong(runRaceDetailInfo.getFirstEmployTime())));
449 424 }
450 425 } else {
... ... @@ -1132,6 +1107,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
1132 1107 if (location.getRadius() > Constant.LOCA_ACCURACY) {
1133 1108 Toast.makeText(getContext(), "当前定位精度为:" + location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show();
1134 1109 }
  1110 +
1135 1111 } else {
1136 1112 //过滤定位精度
1137 1113 if (location.getRadius() > Constant.LOCA_ACCURACY) {
... ... @@ -1148,14 +1124,15 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
1148 1124 }
1149 1125  
1150 1126 MapStatus.Builder builder = new MapStatus.Builder();
1151   -
1152   -// if (isFirstLoc) {
1153   -// isFirstLoc = false;
1154 1127 firstLatLng = new LatLng(location.getLatitude(),
1155 1128 location.getLongitude());
1156 1129 baiduMap.setMyLocationData(followMyLocation);
1157   -// builder.target(firstLatLng).zoom(DEFULT_ZOOM);
1158   -// baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
  1130 + //没有获取到轨迹
  1131 + if (0 == initZoom && null != firstLatLng) {
  1132 + builder.target(firstLatLng).zoom(DEFULT_ZOOM);
  1133 + baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
  1134 + }
  1135 +//
1159 1136  
1160 1137 // //显示当前位置图标
1161 1138 // Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.rt_ic_location), 40, 40);
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/StepService.java
... ... @@ -372,7 +372,7 @@ public class StepService extends Service implements SensorEventListener {
372 372 if (null == userStepEntity) {
373 373 return;
374 374 }
375   - if (alarmPushInfo.getFenceId() == userStepEntity.getFenceId() && alarmPushInfo.getFenceName().equals(userStepEntity.getStreetTitle())) {
  375 + if (alarmPushInfo.getFenceId() == userStepEntity.getFenceId()) {
376 376 //超出范围
377 377 if (alarmPushInfo.getMonitoredAction() == MonitoredAction.exit) {
378 378 EventBus.getDefault().post(new MessageEvent(Constant.EXIT_RANGE, ""));
... ... @@ -530,9 +530,6 @@ public class StepService extends Service implements SensorEventListener {
530 530 Log.e(TAG, "onStartTraceCallback: 保存的围栏id" + fenceId);
531 531 //设置围栏id
532 532 StepUtil.setFenceId(getApplicationContext(), CommonInfo.getUserId(getApplicationContext()), fenceId);
533   - //设置赛事标题
534   - String streetTitle = CommonInfo.getStreetTitle(getApplicationContext());
535   - StepUtil.setStreetTitle(getApplicationContext(), CommonInfo.getUserId(getApplicationContext()), streetTitle);
536 533 }
537 534 entityName = userId;
538 535 initTodayData(userId);
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/MyMapUtil.java
... ... @@ -150,7 +150,7 @@ public class MyMapUtil {
150 150 * @param trackPoints
151 151 * @param zoomBy
152 152 */
153   - public static void setMapAutoZoom(BaiduMap baiduMap, List<LatLng> trackPoints, float zoomBy) {
  153 + public static float setMapAutoZoom(BaiduMap baiduMap, List<LatLng> trackPoints, float zoomBy) {
154 154 LatLngBounds.Builder builder = new LatLngBounds.Builder();
155 155 for (LatLng latLng : trackPoints) {
156 156 builder.include(latLng);
... ... @@ -158,7 +158,11 @@ public class MyMapUtil {
158 158 MapStatusUpdate mapStatusUpdate = MapStatusUpdateFactory.newLatLngBounds(builder.build());
159 159 baiduMap.setMapStatus(mapStatusUpdate);
160 160 MapStatusUpdate msu = MapStatusUpdateFactory.zoomBy(zoomBy);
161   - baiduMap.setMapStatus(msu);
  161 + baiduMap.animateMapStatus(msu);
  162 + if (null != baiduMap.getMapStatus()) {
  163 + return baiduMap.getMapStatus().zoom;
  164 + }
  165 + return 0;
162 166 //自动计算地图缩放
163 167 // MapStatus.Builder builder = new MapStatus.Builder();
164 168 // builder.target(MyMapUtil.getCenterZoomPosition(trackPoints));
... ...
moudle_pedometer/src/main/res/layout/fragment_collect_run_race_detail.xml
... ... @@ -2,139 +2,146 @@
2 2 <layout xmlns:android="http://schemas.android.com/apk/res/android"
3 3 xmlns:app="http://schemas.android.com/apk/res-auto">
4 4  
5   - <FrameLayout
  5 + <LinearLayout
6 6 android:layout_width="match_parent"
7   - android:layout_height="match_parent">
  7 + android:layout_height="match_parent"
  8 + android:orientation="vertical">
8 9  
9   - <com.sothree.slidinguppanel.SlidingUpPanelLayout xmlns:sothree="http://schemas.android.com/apk/res-auto"
10   - android:id="@+id/sliding_layout"
  10 + <com.qmuiteam.qmui.widget.QMUITopBar
  11 + android:id="@+id/topbar"
11 12 android:layout_width="match_parent"
12   - android:layout_height="match_parent"
13   - android:gravity="bottom"
14   - sothree:umanoDragView="@+id/dragView"
15   - sothree:umanoFadeColor="@color/black_20"
16   - sothree:umanoOverlay="true"
17   - sothree:umanoParallaxOffset="250dp"
18   - sothree:umanoScrollableView="@+id/scrollView"
19   - sothree:umanoShadowHeight="0dp">
20   -
21   - <!-- MAIN CONTENT -->
22   - <LinearLayout
  13 + android:layout_height="?attr/qmui_topbar_height"
  14 + app:qmui_topbar_text_btn_color_state_list="@color/text_black" />
  15 +
  16 + <FrameLayout
  17 + android:layout_width="match_parent"
  18 + android:layout_height="match_parent">
  19 +
  20 + <com.sothree.slidinguppanel.SlidingUpPanelLayout xmlns:sothree="http://schemas.android.com/apk/res-auto"
  21 + android:id="@+id/sliding_layout"
23 22 android:layout_width="match_parent"
24 23 android:layout_height="match_parent"
25   - android:orientation="vertical">
26   -
27   - <com.qmuiteam.qmui.widget.QMUITopBar
28   - android:id="@+id/topbar"
  24 + android:gravity="bottom"
  25 + sothree:umanoDragView="@+id/dragView"
  26 + sothree:umanoFadeColor="@color/black_20"
  27 + sothree:umanoOverlay="true"
  28 + sothree:umanoParallaxOffset="300dp"
  29 + sothree:umanoScrollableView="@+id/scrollView"
  30 + sothree:umanoShadowHeight="0dp">
  31 +
  32 + <!-- MAIN CONTENT -->
  33 + <LinearLayout
29 34 android:layout_width="match_parent"
30   - android:layout_height="?attr/qmui_topbar_height"
31   - app:qmui_topbar_text_btn_color_state_list="@color/text_black" />
  35 + android:layout_height="match_parent"
  36 + android:orientation="vertical">
32 37  
33   - <FrameLayout
34   - android:id="@+id/fl_root"
35   - android:layout_width="match_parent"
36   - android:layout_height="match_parent">
37 38  
38   - <com.baidu.mapapi.map.MapView
39   - android:id="@+id/mapView"
  39 + <FrameLayout
  40 + android:id="@+id/fl_root"
40 41 android:layout_width="match_parent"
41   - android:layout_height="match_parent"></com.baidu.mapapi.map.MapView>
  42 + android:layout_height="match_parent">
42 43  
43   - <!--地图上面加一层类似于全透明黑色蒙版-->
44   - <LinearLayout
45   - android:layout_width="match_parent"
46   - android:layout_height="match_parent"
47   - android:background="#0D000000"
48   - android:clickable="false"
49   - android:focusable="false"
50   - android:focusableInTouchMode="false"></LinearLayout>
  44 + <com.baidu.mapapi.map.MapView
  45 + android:id="@+id/mapView"
  46 + android:layout_width="match_parent"
  47 + android:layout_height="match_parent"></com.baidu.mapapi.map.MapView>
51 48  
52   - <!---->
  49 + <!--地图上面加一层类似于全透明黑色蒙版-->
  50 + <LinearLayout
  51 + android:layout_width="match_parent"
  52 + android:layout_height="match_parent"
  53 + android:background="#0D000000"
  54 + android:clickable="false"
  55 + android:focusable="false"
  56 + android:focusableInTouchMode="false"></LinearLayout>
53 57  
  58 + <!---->
54 59  
55   - </FrameLayout>
56   - </LinearLayout>
57   - <!-- SLIDING LAYOUT -->
58   - <FrameLayout
59   - android:id="@+id/dragView"
60   - android:layout_width="match_parent"
61   - android:layout_height="match_parent"
62   - android:background="@color/white"
63   - android:clickable="false"
64   - android:focusable="false">
65 60  
66   - <ScrollView
67   - android:id="@+id/scrollView"
  61 + </FrameLayout>
  62 + </LinearLayout>
  63 + <!-- SLIDING LAYOUT -->
  64 + <FrameLayout
  65 + android:id="@+id/dragView"
68 66 android:layout_width="match_parent"
69 67 android:layout_height="match_parent"
70   - android:scrollbars="none">
  68 + android:background="@color/white"
  69 + android:clickable="false"
  70 + android:focusable="false">
71 71  
72   - <LinearLayout
73   - android:id="@+id/ll_root"
  72 + <ScrollView
  73 + android:id="@+id/scrollView"
74 74 android:layout_width="match_parent"
75   - android:layout_height="wrap_content"
76   - android:orientation="vertical">
77   - <!--跑道-->
78   - <include
79   - android:id="@+id/include_street"
80   - layout="@layout/layout_collect_run_detail_street" />
81   - <!---->
82   - <View
  75 + android:layout_height="match_parent"
  76 + android:scrollbars="none">
  77 +
  78 + <LinearLayout
  79 + android:id="@+id/ll_root"
83 80 android:layout_width="match_parent"
84   - android:layout_height="10dp"
85   - android:background="#F4F4F4" />
86   - <!--路线介绍-->
87   - <include
88   - android:id="@+id/include_street_introduce"
89   - layout="@layout/layout_run_detail_street_introduce" />
90   - </LinearLayout>
91   -
92   - </ScrollView>
93   - </FrameLayout>
94   - </com.sothree.slidinguppanel.SlidingUpPanelLayout>
95   - <!--按钮-->
96   - <RelativeLayout
97   - android:id="@+id/rl_scrollView_add_trace"
98   - android:layout_width="match_parent"
99   - android:layout_height="40sp"
100   - android:layout_gravity="bottom"
101   - android:background="@color/green_round"
102   - android:tag="0">
103   -
104   - <TextView
105   - android:id="@+id/tv_run_now"
106   - android:layout_width="wrap_content"
107   - android:layout_height="wrap_content"
108   - android:layout_centerInParent="true"
109   - android:tag="0"
110   - android:text="@string/layout_collect_bind_trace"
111   - android:textColor="@color/white"
112   - android:textSize="18sp" />
113   -
114   - <TextView
115   - android:id="@+id/tv_go_tip"
116   - android:layout_width="wrap_content"
117   - android:layout_height="wrap_content"
118   - android:layout_alignParentRight="true"
119   - android:layout_centerInParent="true"
120   - android:layout_centerVertical="true"
121   - android:layout_marginRight="10dp"
122   - android:text="Go!"
123   - android:textColor="@color/white"
124   - android:textSize="18sp"
  81 + android:layout_height="wrap_content"
  82 + android:orientation="vertical">
  83 + <!--跑道-->
  84 + <include
  85 + android:id="@+id/include_street"
  86 + layout="@layout/layout_collect_run_detail_street" />
  87 + <!---->
  88 + <View
  89 + android:layout_width="match_parent"
  90 + android:layout_height="10dp"
  91 + android:background="#F4F4F4" />
  92 + <!--路线介绍-->
  93 + <include
  94 + android:id="@+id/include_street_introduce"
  95 + layout="@layout/layout_run_detail_street_introduce" />
  96 + </LinearLayout>
  97 +
  98 + </ScrollView>
  99 + </FrameLayout>
  100 + </com.sothree.slidinguppanel.SlidingUpPanelLayout>
  101 + <!--按钮-->
  102 + <RelativeLayout
  103 + android:id="@+id/rl_scrollView_add_trace"
  104 + android:layout_width="match_parent"
  105 + android:layout_height="40sp"
  106 + android:layout_gravity="bottom"
  107 + android:background="@color/green_round"
  108 + android:tag="0">
  109 +
  110 + <TextView
  111 + android:id="@+id/tv_run_now"
  112 + android:layout_width="wrap_content"
  113 + android:layout_height="wrap_content"
  114 + android:layout_centerInParent="true"
  115 + android:tag="0"
  116 + android:text="@string/layout_collect_bind_trace"
  117 + android:textColor="@color/white"
  118 + android:textSize="18sp" />
  119 +
  120 + <TextView
  121 + android:id="@+id/tv_go_tip"
  122 + android:layout_width="wrap_content"
  123 + android:layout_height="wrap_content"
  124 + android:layout_alignParentRight="true"
  125 + android:layout_centerInParent="true"
  126 + android:layout_centerVertical="true"
  127 + android:layout_marginRight="10dp"
  128 + android:text="Go!"
  129 + android:textColor="@color/white"
  130 + android:textSize="18sp"
  131 + android:visibility="gone" />
  132 +
  133 + </RelativeLayout>
  134 +
  135 +
  136 + <com.cnlive.strike.ui.widget.UIEmptyView
  137 + android:id="@+id/empty_layout"
  138 + android:layout_width="match_parent"
  139 + android:layout_height="match_parent"
  140 + android:background="@color/color_fff"
  141 + android:focusable="true"
  142 + android:focusableInTouchMode="true"
125 143 android:visibility="gone" />
126   -
127   - </RelativeLayout>
128   -
129   - <com.cnlive.strike.ui.widget.UIEmptyView
130   - android:id="@+id/empty_layout"
131   - android:layout_width="match_parent"
132   - android:layout_height="match_parent"
133   - android:background="@color/color_fff"
134   - android:focusable="true"
135   - android:focusableInTouchMode="true"
136   - android:visibility="gone" />
137   - </FrameLayout>
138   -
  144 + </FrameLayout>
  145 + </LinearLayout>
139 146  
140 147 </layout>
141 148 \ No newline at end of file
... ...