Commit df1d278c97e8a4df7395c08af9ae27c617ce0e49

Authored by 杨帅
1 parent 28020dea

1 修改用户进入详情页,保存运营人员打点信息到数据库的逻辑

moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunMainFragmentView.java
... ... @@ -139,10 +139,6 @@ public class RunMainFragmentView implements MvpView {
139 139 long endTime = Long.parseLong(runRaceDetailInfo.getEndTime());
140 140 StepUtil.setQueryTraceTime(getContext(), CommonInfo.getUserId(getContext()), startTime, endTime, runRaceDetailInfo.getEntityName());
141 141 }
142   - //设置重要点
143   - if (TextUtils.isEmpty(userStepEntity.getImportPoint())) {
144   - StepUtil.setImportPoints(getContext(), CommonInfo.getUserId(getContext()), runRaceDetailInfo.getLatLongitude());
145   - }
146 142 //设置开始时间和赛事id
147 143 if (TextUtils.isEmpty(userStepEntity.getStreetId())) {
148 144 StepUtil.setStepStartData(getContext(), uid, TimeUtil.getNowTimeStamp(), CommonInfo.getStreetId(getContext()));
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
1   -package com.cnlive.moudle.pedometer.frame.view;
2   -
3   -import android.content.Context;
4   -import android.content.Intent;
5   -import android.graphics.Bitmap;
6   -import android.graphics.BitmapFactory;
7   -import android.hardware.Sensor;
8   -import android.hardware.SensorEvent;
9   -import android.hardware.SensorEventListener;
10   -import android.hardware.SensorManager;
11   -import android.os.SystemClock;
12   -import android.support.v4.content.ContextCompat;
13   -import android.text.TextUtils;
14   -import android.util.Log;
15   -import android.view.View;
16   -import android.view.ViewTreeObserver;
17   -import android.widget.LinearLayout;
18   -import android.widget.Toast;
19   -
20   -import com.alibaba.android.arouter.launcher.ARouter;
21   -import com.baidu.location.BDAbstractLocationListener;
22   -import com.baidu.location.BDLocation;
23   -import com.baidu.location.LocationClient;
24   -import com.baidu.location.LocationClientOption;
25   -import com.baidu.mapapi.map.BaiduMap;
26   -import com.baidu.mapapi.map.BitmapDescriptor;
27   -import com.baidu.mapapi.map.BitmapDescriptorFactory;
28   -import com.baidu.mapapi.map.MapStatus;
29   -import com.baidu.mapapi.map.MapStatusUpdate;
30   -import com.baidu.mapapi.map.MapStatusUpdateFactory;
31   -import com.baidu.mapapi.map.MapView;
32   -import com.baidu.mapapi.map.MarkerOptions;
33   -import com.baidu.mapapi.map.MyLocationConfiguration;
34   -import com.baidu.mapapi.map.MyLocationData;
35   -import com.baidu.mapapi.map.UiSettings;
36   -import com.baidu.mapapi.model.LatLng;
37   -import com.baidu.mapapi.search.route.RoutePlanSearch;
38   -import com.baidu.mapapi.utils.DistanceUtil;
39   -import com.baidu.trace.LBSTraceClient;
40   -import com.baidu.trace.model.SortType;
41   -import com.cnlive.libs.base.application.AppConfig;
42   -import com.cnlive.libs.base.util.StatusBarUtil2;
43   -import com.cnlive.moudle.pedometer.commonInfo.CommonInfo;
44   -import com.cnlive.moudle.pedometer.model.Constant;
45   -import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo;
46   -import com.cnlive.moudle.pedometer.service.KeepLiveService;
47   -import com.cnlive.moudle.pedometer.service.StepService;
48   -import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity;
49   -import com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity;
50   -import com.cnlive.moudle.pedometer.ui.activity.RaceRecordActivity;
51   -import com.cnlive.moudle.pedometer.ui.activity.RegistrationInfoActivity;
52   -import com.cnlive.moudle.pedometer.ui.activity.TakePartActivity;
53   -import com.cnlive.moudle.pedometer.ui.fragment.RunRaceDetailFragment;
54   -import com.cnlive.moudle.pedometer.ui.widget.SelectDialog;
55   -import com.cnlive.moudle.pedometer.ui.widget.TipDialog;
56   -import com.cnlive.moudle.pedometer.utils.BitmapUtil;
57   -import com.cnlive.moudle.pedometer.utils.GsonUtil;
58   -import com.cnlive.moudle.pedometer.utils.MyMapUtil;
59   -import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil;
60   -import com.cnlive.moudle.pedometer.utils.ScreenUtil;
61   -import com.cnlive.moudle.pedometer.utils.ServiceUtils;
62   -import com.cnlive.moudle.pedometer.utils.StepUtil;
63   -import com.cnlive.moudle.pedometer.utils.TimeUtil;
64   -import com.cnlive.strike.application.GlideApp;
65   -import com.example.moudle_pedometer.R;
66   -import com.hannesdorfmann.mosby3.mvp.MvpView;
67   -import com.qmuiteam.qmui.util.QMUIStatusBarHelper;
68   -import com.sothree.slidinguppanel.SlidingUpPanelLayout;
69   -
70   -import java.util.ArrayList;
71   -import java.util.List;
72   -
73   -public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
74   - private static final String TAG = "RunRaceDetailView";
75   -
76   - private RunRaceDetailFragment fragment;
77   - private BaiduMap baiduMap;
78   - private MapView mMapView;
79   - private UiSettings mUiSettings;
80   - private MyLocationConfiguration.LocationMode mCurrentMode;//定位模式
81   - private BitmapDescriptor mCurrentMarker;//定位图标
82   - private static int accuracyCircleFillColor;
83   - private static int accuracyCircleStrokeColor;
84   - private static MyLocationData followMyLocation;
85   - boolean isFirstLoc = true; // 是否首次定位
86   - private MarkerOptions currentMark;
87   - private MarkerOptions endMark;
88   - private MarkerOptions startMark;
89   -
90   - private LatLng firstLatLng;
91   - private Double lastX = 0.0;
92   - private int mCurrentDirection = 0;
93   - // private double mCurrentLat = 0.0;
94   -// private double mCurrentLon = 0.0;
95   - private float mCurrentAccracy;
96   - // 定位相关
97   - private LocationClient mLocClient;
98   - public MyLocationListenner myListener = new MyLocationListenner();
99   - private final int DEFULT_ZOOM = 17;
100   - private RoutePlanSearch routePlanSearch = null; // 路线规划
101   - private final int START_MARK = 0;//起始点
102   - private final int END_MARK = 1;//终止点
103   - private LatLng startLatLng;//起始点
104   - public RunRaceDetailInfo runRaceDetailInfo;
105   - private UserStepEntity userStepEntity;
106   - private boolean isDifferentStreet = false;
107   - private LBSTraceClient mClient = null;
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;//查询到的历史轨迹
114   -
115   - public RunRaceDetailFragmentView(RunRaceDetailFragment fragment) {
116   - this.fragment = fragment;
117   - }
118   -
119   - public Context getContext() {
120   - return fragment == null ? null : fragment.getActivity();
121   - }
122   -
123   -
124   - public void initView(RunRaceDetailInfo runRaceDetailInfo) {
125   - if (fragment.getActivity() == null) {
126   - return;
127   - }
128   - queryResultPoints = new ArrayList<>();
129   - this.runRaceDetailInfo = runRaceDetailInfo;
130   - //轨迹开始时间
131   - long startTime = 0;
132   - //轨迹结束时间
133   - long endTime = 0;
134   - if (!TextUtils.isEmpty(runRaceDetailInfo.getStartTime()) && !TextUtils.isEmpty(runRaceDetailInfo.getEndTime()) && !TextUtils.isEmpty(runRaceDetailInfo.getEntityName())) {
135   - startTime = Long.parseLong(runRaceDetailInfo.getStartTime());
136   - endTime = Long.parseLong(runRaceDetailInfo.getEndTime());
137   - //todo 注意后续查询历史轨迹的时候,必须查数据库中的时间,因为涉及到历史运动恢复,所以不能用这个sp文件中的,这里设置,只是为了在服务启动成功后,
138   -
139   - mClient = new LBSTraceClient(getContext());
140   - //获取轨迹
141   - if (mClient != null) {
142   - MyMapUtil.queryHistoryTrace(getContext(), mClient, runRaceDetailInfo.getEntityName(), startTime, endTime, new MyMapUtil.CallBack() {
143   - @Override
144   - public void success(List<LatLng> resultPoints) {
145   - if (resultPoints != null && resultPoints.size() > 1) {
146   - queryResultPoints.clear();
147   - queryResultPoints.addAll(resultPoints);
148   - startLatLng = resultPoints.get(0);
149   - endLatLng = resultPoints.get(resultPoints.size() - 1);
150   - MyMapUtil.drawServerLineTrack(getContext(), baiduMap, resultPoints, SortType.asc, R.color.green_round, R.drawable.icon_start, R.drawable.icon_end);
151   -// //自动计算地图缩放
152   - //设置地图自动缩放
153   - initZoom = MyMapUtil.setMapAutoZoom(baiduMap, resultPoints, -1.5f);
154   -
155   - }
156   - }
157   - });
158   -
159   - }
160   - //
161   - }
162   -
163   - //显示地图
164   - fragment.binding.mapView.setVisibility(View.VISIBLE);
165   - //显示底部滑动卡片
166   -// fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
167   - //隐藏空视图
168   - fragment.binding.emptyLayout.setVisibility(View.GONE);
169   - //显示立即报名按钮
170   -// fragment.binding.includeStreet.rlStartBtn.setVisibility(View.VISIBLE);
171   - //设置底部卡片第一次可滑动的位置
172   - fragment.binding.slidingLayout.setAnchorPoint(0.6f);
173   - fragment.binding.slidingLayout.addPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {
174   - @Override
175   - public void onPanelSlide(View panel, float slideOffset) {
176   - //设置顶层卡片特效
177   - if (slideOffset > 0.7) {
178   - double alpha = (255 / (1 - 0.6)) * (slideOffset - 0.6);
179   - if (alpha > 60) {
180   - fragment.binding.flTop.getBackground().setAlpha((int) alpha);
181   - fragment.binding.flTop.setVisibility(View.VISIBLE);
182   - QMUIStatusBarHelper.setStatusBarDarkMode(fragment.getActivity());
183   - StatusBarUtil2.setColor(fragment.getActivity(), getContext().getResources().getColor(R.color.run_main_bg), 0);
184   -
185   - }
186   - } else {
187   - if (fragment.binding.flTop.getVisibility() == View.VISIBLE) {
188   - QMUIStatusBarHelper.setStatusBarLightMode(fragment.getActivity());
189   - StatusBarUtil2.setColor(fragment.getActivity(), getContext().getResources().getColor(R.color.white), 0);
190   - fragment.binding.flTop.setVisibility(View.GONE);
191   - }
192   - }
193   - //设置卡片缩放特效
194   - if (slideOffset >= 0 && slideOffset <= 1) {
195   - int leakWidth = (int) (ScreenUtil.dip2px(getContext(), 15) / 0.6);
196   - LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
197   - int current = (int) (leakWidth * slideOffset);
198   -// Log.e(TAG, "current: " + current + ",leakWidth:" + leakWidth + ",ScreenUtil:" + ScreenUtil.dip2px(getContext(), 15));
199   - if (slideOffset == 0) {
200   - layoutParams.setMargins(ScreenUtil.dip2px(getContext(), 15), 0, ScreenUtil.dip2px(getContext(), 15), 0);
201   - fragment.binding.includeStreet.llFirstPanelRoot.setLayoutParams(layoutParams);
202   - fragment.binding.includeStreet.llBottomPanel.setLayoutParams(layoutParams);
203   - }
204   - if (leakWidth - ScreenUtil.dip2px(getContext(), current) <= ScreenUtil.dip2px(getContext(), 15)) {
205   - if (leakWidth - ScreenUtil.dip2px(getContext(), current) >= 0) {
206   - layoutParams.setMargins(leakWidth - ScreenUtil.dip2px(getContext(), current), 0, leakWidth - ScreenUtil.dip2px(getContext(), current), 0);
207   - } else {
208   - layoutParams.setMargins(0, 0, 0, 0);
209   - }
210   -
211   - fragment.binding.includeStreet.llFirstPanelRoot.setLayoutParams(layoutParams);
212   - fragment.binding.includeStreet.llBottomPanel.setLayoutParams(layoutParams);
213   - }
214   -
215   - }
216   -
217   - }
218   -
219   - @Override
220   - public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) {
221   - if (newState == SlidingUpPanelLayout.PanelState.EXPANDED) {
222   - fragment.binding.includeStreet.ivSlideIcon.setVisibility(View.INVISIBLE);
223   - }
224   - if (newState == SlidingUpPanelLayout.PanelState.ANCHORED) {
225   - fragment.binding.includeStreet.ivSlideIcon.setVisibility(View.VISIBLE);
226   - }
227   - if (newState == SlidingUpPanelLayout.PanelState.COLLAPSED) {
228   - fragment.binding.includeStreet.ivSlideIcon.setVisibility(View.VISIBLE);
229   - }
230   - if (previousState == SlidingUpPanelLayout.PanelState.ANCHORED && newState == SlidingUpPanelLayout.PanelState.DRAGGING) {
231   - if (fragment.binding.flTop.getVisibility() != View.VISIBLE) {
232   - QMUIStatusBarHelper.setStatusBarDarkMode(fragment.getActivity());
233   - StatusBarUtil2.setColor(fragment.getActivity(), getContext().getResources().getColor(R.color.run_main_bg), 0);
234   - fragment.binding.flTop.setVisibility(View.VISIBLE);
235   -
236   - }
237   - } else if (previousState == SlidingUpPanelLayout.PanelState.DRAGGING && newState == SlidingUpPanelLayout.PanelState.EXPANDED) {
238   -
239   - if (fragment.binding.flTop.getVisibility() != View.VISIBLE) {
240   - QMUIStatusBarHelper.setStatusBarDarkMode(fragment.getActivity());
241   - StatusBarUtil2.setColor(fragment.getActivity(), getContext().getResources().getColor(R.color.run_main_bg), 0);
242   - fragment.binding.flTop.setVisibility(View.VISIBLE);
243   -
244   - }
245   - } else if (previousState == SlidingUpPanelLayout.PanelState.EXPANDED && newState == SlidingUpPanelLayout.PanelState.DRAGGING) {
246   - QMUIStatusBarHelper.setStatusBarLightMode(fragment.getActivity());
247   - StatusBarUtil2.setColor(fragment.getActivity(), getContext().getResources().getColor(R.color.white), 0);
248   - if (fragment.binding.flTop.getVisibility() != View.GONE) {
249   - fragment.binding.flTop.setVisibility(View.GONE);
250   - }
251   - } else if (previousState == SlidingUpPanelLayout.PanelState.DRAGGING && newState == SlidingUpPanelLayout.PanelState.ANCHORED) {
252   - QMUIStatusBarHelper.setStatusBarLightMode(fragment.getActivity());
253   - StatusBarUtil2.setColor(fragment.getActivity(), getContext().getResources().getColor(R.color.white), 0);
254   - if (fragment.binding.flTop.getVisibility() != View.GONE) {
255   - fragment.binding.flTop.setVisibility(View.GONE);
256   - }
257   - }
258   - //设置地图缩放
259   - if (newState == SlidingUpPanelLayout.PanelState.ANCHORED) {
260   - if (isChangeMapState) {
261   - if (null != baiduMap) {
262   - if (null != baiduMap.getMapStatus()) {
263   - MapStatus mapStatus = new MapStatus
264   - .Builder(baiduMap.getMapStatus())
265   - .overlook(0)
266   - .zoom((float) (baiduMap.getMapStatus().zoom - 1.5)).build();
267   - MapStatusUpdate mapStatusUpdate = MapStatusUpdateFactory.newMapStatus(mapStatus);
268   - baiduMap.animateMapStatus(mapStatusUpdate);
269   - }
270   - }
271   - }
272   - isChangeMapState = false;
273   - } else if (newState == SlidingUpPanelLayout.PanelState.COLLAPSED) {
274   -
275   - if (null != baiduMap) {
276   - if (0 == initZoom) {
277   - initZoom = DEFULT_ZOOM;
278   - }
279   - MapStatus mapStatus = new MapStatus
280   - .Builder(baiduMap.getMapStatus())
281   - .overlook(INIT_MAP_OVERLOOK)
282   - .zoom(initZoom)
283   - .build();
284   - MapStatusUpdate mapStatusUpdate = MapStatusUpdateFactory.newMapStatus(mapStatus);
285   - baiduMap.animateMapStatus(mapStatusUpdate);
286   - isChangeMapState = true;
287   - }
288   - }
289   -
290   - //
291   -
292   - }
293   - });
294   - //卡片滑动上层标题
295   - fragment.binding.llTopBack.setOnClickListener(new View.OnClickListener() {
296   - @Override
297   - public void onClick(View view) {
298   - if (getContext() == null) {
299   - return;
300   - }
301   - fragment.getActivity().finish();
302   - }
303   - });
304   - /*************************设置相关页面数据***************************/
305   - if (runRaceDetailInfo.getFenceId() != null && !TextUtils.isEmpty(runRaceDetailInfo.getFenceId())) {
306   - //设置围栏ID
307   - CommonInfo.setFenceId(getContext(), Integer.parseInt(runRaceDetailInfo.getFenceId()));
308   - }
309   - //设置标题
310   - if (!TextUtils.isEmpty(runRaceDetailInfo.getTitle())) {
311   - fragment.binding.includeStreet.tvRaceTitle.setText(runRaceDetailInfo.getTitle());
312   - fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
313   - @Override
314   - public boolean onPreDraw() {
315   - Log.e(TAG, "initView: " + fragment.binding.includeStreet.tvRaceTitle.getLineCount());
316   - fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().removeOnPreDrawListener(this);
317   - return false;
318   - }
319   - });
320   - fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 181));
321   - //根据标题行数,自动调整卡片大小
322   - fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
323   - @Override
324   - public boolean onPreDraw() {
325   - int line = fragment.binding.includeStreet.tvRaceTitle.getLineCount();
326   - int height = fragment.binding.includeStreet.tvRaceTitle.getHeight();
327   - if (line > 1) {
328   - int avgHeight = height / line;//平局高度
329   - fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 181) + avgHeight * (line - 1));
330   -
331   - }
332   - fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().removeOnPreDrawListener(this);
333   - return false;
334   - }
335   - });
336   - fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
337   - }
338   - //设置活动地点
339   - if (!TextUtils.isEmpty(runRaceDetailInfo.getAddress())) {
340   - fragment.binding.includeStreet.tvAddress.setText(runRaceDetailInfo.getAddress());
341   - //设置活动距离
342   - if (!TextUtils.isEmpty(runRaceDetailInfo.getMileage())) {
343   - fragment.binding.includeStreet.tvAddress.append("\t\t全长" + runRaceDetailInfo.getMileage() + "公里");
344   - }
345   - }
346   -
347   - //设置起点
348   - if (!TextUtils.isEmpty(runRaceDetailInfo.getStartLocation())) {
349   - fragment.binding.includeStreet.tvStartAddr.setText(runRaceDetailInfo.getStartLocation());
350   - }
351   - //设置终点
352   - if (!TextUtils.isEmpty(runRaceDetailInfo.getEndLocation())) {
353   - fragment.binding.includeStreet.tvEndAddr.setText(runRaceDetailInfo.getEndLocation());
354   - }
355   - //设置起始报名时间
356   - if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_start_time(), "yyyy.MM.dd"))) {
357   - fragment.binding.includeStreet.tvSignUpStartTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_start_time(), "yyyy.MM.dd"));
358   -
359   - }
360   - //设置终止报名时间
361   - if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_end_time(), "yyyy.MM.dd"))) {
362   - fragment.binding.includeStreet.tvSignUpEndTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_end_time(), "yyyy.MM.dd"));
363   - }
364   - //设置活动开始时间
365   - if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getStart_time(), "yyyy.MM.dd"))) {
366   - fragment.binding.includeStreet.tvActiveStartTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getStart_time(), "yyyy.MM.dd"));
367   - }
368   - //设置活动结束时间
369   - if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getEnd_time(), "yyyy.MM.dd"))) {
370   - fragment.binding.includeStreet.tvActiveEndTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getEnd_time(), "yyyy.MM.dd"));
371   - }
372   - //设置活动类型
373   - if (!TextUtils.isEmpty(runRaceDetailInfo.getEventType())) {
374   - fragment.binding.includeStreet.tvEventType.setText(runRaceDetailInfo.getEventType());
375   - }
376   - //设置参加人数
377   - fragment.binding.includeStreet.tvSignPerson.setText(runRaceDetailInfo.getSignupNum() + "");
378   - //设置报名完成的头像
379   - List<String> joinFaceIcon = runRaceDetailInfo.getFaceUrl();
380   - if (joinFaceIcon != null && joinFaceIcon.size() > 0) {
381   - fragment.binding.includeStreet.fiveJoinPerson.setVisibility(View.VISIBLE);
382   - //设置头像数据
383   - fragment.binding.includeStreet.fiveJoinPerson.initIconData(joinFaceIcon);
384   - } else {
385   - fragment.binding.includeStreet.fiveJoinPerson.setVisibility(View.INVISIBLE);
386   - }
387   -
388   - //判断是否显示个人排行榜
389   - if (runRaceDetailInfo.isIndividualAchievement()) {
390   - //显示
391   - fragment.binding.includePersonScore.llPersonScoreRoot.setVisibility(View.VISIBLE);
392   - //设置完成人数
393   - if (!TextUtils.isEmpty(runRaceDetailInfo.getFinishNum())) {
394   - fragment.binding.includeRank.tvFinishPerson.setText(runRaceDetailInfo.getFinishNum());
395   - }
396   - //设置个人行走距离
397   - if (!TextUtils.isEmpty(runRaceDetailInfo.getUserMileage())) {
398   - fragment.binding.includePersonScore.tvUserDistance.setText(runRaceDetailInfo.getUserMileage());
399   - }
400   - //设置行走步数
401   - if (!TextUtils.isEmpty(runRaceDetailInfo.getStep())) {
402   - fragment.binding.includePersonScore.tvStep.setText(runRaceDetailInfo.getStep());
403   - }
404   - //设置用时
405   - if (!TextUtils.isEmpty(runRaceDetailInfo.getEmployTime())) {
406   - fragment.binding.includePersonScore.tvEmployTime.setText(TimeUtil.stampToChronometer(Long.parseLong(runRaceDetailInfo.getEmployTime())));
407   - }
408   - //设置配速
409   - if (!TextUtils.isEmpty(runRaceDetailInfo.getPace())) {
410   - fragment.binding.includePersonScore.tvSpeed.setText(runRaceDetailInfo.getPace());
411   - }
412   - } else {
413   - //隐藏
414   - fragment.binding.includePersonScore.llPersonScoreRoot.setVisibility(View.GONE);
415   - }
416   - //设置是否显示排行榜
417   - if (runRaceDetailInfo.isRanking()) {
418   - fragment.binding.includeRank.llRankRoot.setVisibility(View.VISIBLE);
419   - //设置第一名头像
420   - GlideApp.with(getContext()).load(runRaceDetailInfo.getFirstFaceUrl()).into(fragment.binding.includeRank.ivFirstPersonUrl);
421   - //设置排行榜头像
422   - List<String> finishFaceUrl = runRaceDetailInfo.getFinishFaceUrl();
423   - if (finishFaceUrl != null && finishFaceUrl.size() > 0) {
424   - fragment.binding.includeRank.fiveRankPerson.initIconData(finishFaceUrl);
425   - }
426   - //设置第一名昵称
427   - if (!TextUtils.isEmpty(runRaceDetailInfo.getFirstName())) {
428   - fragment.binding.includeRank.tvKingNickName.setText(runRaceDetailInfo.getFirstName());
429   - }
430   - //第一名用时
431   - if (!TextUtils.isEmpty(runRaceDetailInfo.getFirstEmployTime())) {
432   - fragment.binding.includeRank.tvFirstTime.setText(TimeUtil.stampToChronometer(Long.parseLong(runRaceDetailInfo.getFirstEmployTime())));
433   - }
434   - } else {
435   - fragment.binding.includeRank.llRankRoot.setVisibility(View.GONE);
436   -
437   - }
438   - //设置路线描述
439   - if (!TextUtils.isEmpty(runRaceDetailInfo.getDescription())) {
440   - fragment.binding.includeStreetIntroduce.tvStreetIntroduce.setText(runRaceDetailInfo.getDescription());
441   - }
442   - //设置路线介绍的图片
443   - if (!TextUtils.isEmpty(runRaceDetailInfo.getRoadmap())) {
444   - //设置路线图
445   - GlideApp.with(getContext()).load(runRaceDetailInfo.getRoadmap()).into(fragment.binding.includeStreetIntroduce.ivRoadMao);
446   -
447   - }
448   - //判断用户是否报名
449   - if (runRaceDetailInfo.isSignResult()) {
450   - fragment.binding.rlScrollViewStartBtn.setTag("1");
451   - fragment.binding.tvRunNow.setText("现在开始");
452   - fragment.binding.tvGoTip.setVisibility(View.VISIBLE);
453   - checkStartBtnState();
454   - } else {
455   - fragment.binding.rlScrollViewStartBtn.setTag("0");
456   - fragment.binding.tvRunNow.setText("立即报名");
457   - fragment.binding.tvGoTip.setVisibility(View.GONE);
458   - }
459   -
460   -// //开始按钮点击事件(未滑动)
461   -// fragment.binding.includeStreet.rlStartBtn.setOnClickListener(new View.OnClickListener() {
462   -// @Override
463   -// public void onClick(View view) {
464   -// if (fragment.getActivity() == null) {
465   -// return;
466   -// }
467   -// //立即报名
468   -// if ("0".equals(fragment.binding.includeStreet.rlStartBtn.getTag())) {
469   -// fragment.binding.includeStreet.rlStartBtn.setTag("1");
470   -// fragment.binding.includeStreet.tvRunNow.setText(getContext().getResources().getString(R.string.run_race_btn_start_now));
471   -// fragment.binding.includeStreet.tvGoTip.setVisibility(View.VISIBLE);
472   -//
473   -// //设置滑动
474   -// fragment.binding.rlScrollViewStartBtn.setTag("1");
475   -// fragment.binding.tvRunNow.setText(getContext().getResources().getString(R.string.run_race_btn_start_now));
476   -// fragment.binding.tvGoTip.setVisibility(View.VISIBLE);
477   -// RegistrationInfoActivity.newInstance(fragment.getActivity(), 1001);
478   -// } else {
479   -// //计算当前位置与起点坐标距离
480   -// if (firstLatLng != null && trackPoints != null && trackPoints.size() > 0) {
481   -// double distance = DistanceUtil.getDistance(firstLatLng, trackPoints.get(0));
482   -// if (distance < 20) {
483   -// //开始运动
484   -// fragment.binding.includeStreet.rlStartBtn.setTag("0");
485   -// fragment.binding.includeStreet.tvRunNow.setText(getContext().getResources().getString(R.string.run_race_btn_sign_up));
486   -// fragment.binding.includeStreet.tvGoTip.setVisibility(View.GONE);
487   -// fragment.getActivity().startActivity(new Intent(getContext(), PedometerMainActivity.class));
488   -// //设置滑动
489   -// fragment.binding.rlScrollViewStartBtn.setTag("0");
490   -// fragment.binding.tvRunNow.setText(getContext().getResources().getString(R.string.run_race_btn_sign_up));
491   -// fragment.binding.tvGoTip.setVisibility(View.GONE);
492   -// } else {
493   -// TipDialog tipDialog = new TipDialog(getContext(), getContext().getResources().getString(R.string.run_race_far_tip), "我知道了", R.color.green_round, new TipDialog.DialogInterface() {
494   -// @Override
495   -// public void onClick(TipDialog dialog) {
496   -// dialog.dismiss();
497   -// }
498   -// });
499   -// tipDialog.show();
500   -// tipDialog.setCancelable(false);
501   -// tipDialog.setCanceledOnTouchOutside(false);
502   -// }
503   -// }
504   -// }
505   -// }
506   -// });
507   - //开始按钮点击事件(用户进行滑动滑动)
508   - fragment.binding.rlScrollViewStartBtn.setOnClickListener(new View.OnClickListener() {
509   - @Override
510   - public void onClick(View view) {
511   - //立即报名
512   - if ("0".equals(fragment.binding.rlScrollViewStartBtn.getTag())) {
513   - RegistrationInfoActivity.newInstance(fragment.getActivity());
514   - }
515   - //现在开始
516   - else if ("1".equals(fragment.binding.rlScrollViewStartBtn.getTag())) {
517   - //先判断是否从百度查询到赛事轨迹
518   - if (null != endLatLng && null != startLatLng) {
519   - //开始比较距离
520   - if (null != firstLatLng) {
521   - double currentDiatance = DistanceUtil.getDistance(firstLatLng, startLatLng);
522   - if (currentDiatance < Constant.LOCA_START_POINT_ACCURACY) {
523   - //设置终点坐标
524   - runRaceDetailInfo.setEndLatLng(GsonUtil.GsonString(endLatLng));
525   - startStepService(getContext());
526   - } else {
527   - //进行提示
528   - TipDialog tipDialog = new TipDialog(getContext(), getContext().getResources().getString(R.string.run_race_far_tip), "好的", R.color.green_round, new TipDialog.DialogInterface() {
529   - @Override
530   - public void onClick(TipDialog dialog) {
531   - dialog.dismiss();
532   - }
533   - });
534   - tipDialog.setCancelable(false);
535   - tipDialog.setCanceledOnTouchOutside(false);
536   - tipDialog.show();
537   - }
538   - }
539   -
540   - } else {
541   - QMUITipDialogUtil.textDialog(getContext(), "正在获取轨迹请稍后...", 1);
542   - }
543   - }
544   - //继续运动
545   - else if ("2".equals(fragment.binding.rlScrollViewStartBtn.getTag())) {
546   - if (!isDifferentStreet) {
547   - SelectDialog continueTipDialog = new SelectDialog(getContext(), "是否继续运动", "否", new SelectDialog.DialogInterface() {
548   - @Override
549   - public void onClick(SelectDialog dialog) {
550   - //清空上次保存数据
551   - StepUtil.clearRunData(getContext(), CommonInfo.getUserId(getContext()));
552   - //停止服务
553   - stopStepService();
554   - //清除数据
555   - CommonInfo.resetRace(getContext());
556   - dialog.dismiss();
557   - //重置按钮
558   - fragment.binding.tvRunNow.setText("立即开始");
559   - fragment.binding.rlScrollViewStartBtn.setTag("1");
560   - }
561   - }, "是", new SelectDialog.DialogInterface() {
562   - @Override
563   - public void onClick(SelectDialog dialog) {
564   - dialog.dismiss();
565   - checkBaiduServiceState();
566   - }
567   - });
568   - continueTipDialog.setCanceledOnTouchOutside(false);
569   - continueTipDialog.setCancelable(false);
570   - continueTipDialog.show();
571   -
572   - }
573   -
574   - //赛事id不同
575   - else {
576   - SelectDialog selectDialog = new SelectDialog(getContext(), "您正在参与另一赛事\n是否继续?", "否", new SelectDialog.DialogInterface() {
577   - @Override
578   - public void onClick(SelectDialog dialog) {
579   - dialog.dismiss();
580   - //清空上次保存数据
581   - StepUtil.clearRunData(getContext(), CommonInfo.getUserId(getContext()));
582   - //停止服务
583   - stopStepService();
584   - //清除数据
585   - CommonInfo.resetRace(getContext());
586   - //更改当前按钮
587   - fragment.binding.tvRunNow.setText("立即开始");
588   - fragment.binding.rlScrollViewStartBtn.setTag("1");
589   -
590   - }
591   - }, "是", new SelectDialog.DialogInterface() {
592   - @Override
593   - public void onClick(SelectDialog dialog) {
594   - dialog.dismiss();
595   - checkBaiduServiceState();
596   - }
597   - });
598   - selectDialog.setCanceledOnTouchOutside(false);
599   - selectDialog.setCancelable(false);
600   - selectDialog.show();
601   - }
602   - }
603   - }
604   - });
605   - //查看全部成绩点击事件
606   - fragment.binding.includePersonScore.checkAllCord.setOnClickListener(v -> {
607   - RaceRecordActivity.newInstance(fragment.getActivity(), runRaceDetailInfo.getTitle());
608   - });
609   -
610   - fragment.binding.includeStreet.fiveJoinPerson.setOnClickListener(v -> {
611   - TakePartActivity.newInstance(fragment.getActivity());
612   - });
613   - //返回按钮
614   - fragment.binding.ivBack.setOnClickListener(new View.OnClickListener() {
615   - @Override
616   - public void onClick(View view) {
617   - if (fragment.getActivity() == null) {
618   - return;
619   - }
620   - fragment.getActivity().finish();
621   - }
622   - });
623   - //todo 查看排行榜点击
624   - fragment.binding.includeRank.tvCatAllRank.setOnClickListener(new View.OnClickListener() {
625   - @Override
626   - public void onClick(View view) {
627   - ARouter.getInstance().build("/web/WebViewColorActivity")
628   - .withString("url", AppConfig.isDebug() ? "http://wjjh5test.cnlive.com/cnSportList.html" : "http://wjjh5.cnlive.com/cnSportList.html" + "?sid=" + CommonInfo.getUserId(fragment.getActivity()) + "&eventId=" + CommonInfo.getStreetId(fragment.getActivity()))
629   - .withString("title", "排行榜")
630   - .navigation(fragment.getActivity());
631   - }
632   - });
633   - }
634   -
635   - private void checkBaiduServiceState() {
636   - boolean isRunBaidu = CommonInfo.getIsRunBaiduTraceService(getContext());
637   - if (isRunBaidu) {
638   - //判断百度服务是否运行
639   - if (!ServiceUtils.isServiceRunning(getContext(), "com.baidu.trace.LBSTraceService")) {
640   - stopStepService();
641   - startStepService(getContext());
642   - } else {
643   - PedometerMainActivity.startActivity(fragment.getActivity(), runRaceDetailInfo);
644   - }
645   - } else {
646   - PedometerMainActivity.startActivity(fragment.getActivity(), runRaceDetailInfo);
647   - }
648   - }
649   -
650   - private void stopStepService() {
651   - CommonInfo.setTsRunBaiduTraceService(getContext(), false);
652   - CommonInfo.setIsRunKeepAliveService(getContext(), false);
653   - CommonInfo.setIsWriteUserStep(getContext(), false);
654   - CommonInfo.setIsFirstStepSendTraceTip(getContext(), true);
655   - if (StepService.mClient != null) {
656   - StepService.mClient.stopGather(StepService.traceListener);
657   - }
658   - fragment.getActivity().stopService(new Intent(fragment.getActivity(), StepService.class));
659   - }
660   -
661   - public void initMap() {
662   - //隐藏底部滑动卡片
663   - fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);
664   - this.mMapView = fragment.binding.mapView;
665   - if (baiduMap == null) {
666   - baiduMap = mMapView.getMap();
667   - }
668   - //设置指南针位置
669   - android.graphics.Point point = new android.graphics.Point(ScreenUtil.getScreenWidth(getContext()) - 80, 80);
670   - baiduMap.setCompassPosition(point);
671   -// if (routePlanSearch == null) {
672   -// routePlanSearch = RoutePlanSearch.newInstance();
673   -// }
674   - if (mUiSettings == null) {
675   - mUiSettings = baiduMap.getUiSettings();
676   - }
677   - //设置定位模式, 默认为 LocationMode.NORMAL 普通态
678   - mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL;
679   - // 设置定位图标修改为自定义marker
680   - Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.rt_ic_location), 50, 50);
681   - mCurrentMarker = BitmapDescriptorFactory.fromBitmap(pointBitmap);
682   - //设置定位蓝点精度圆圈的填充颜色为透明色
683   - accuracyCircleFillColor = getContext().getResources().getColor(R.color.transparent);
684   - //设置定位蓝点精度圆圈的边框颜色的为透明色
685   - accuracyCircleStrokeColor = getContext().getResources().getColor(R.color.transparent);
686   - MyLocationConfiguration locationConfiguration = new MyLocationConfiguration(mCurrentMode,
687   - true, mCurrentMarker, accuracyCircleFillColor, accuracyCircleStrokeColor);
688   - //设置样式
689   - baiduMap.setMyLocationConfiguration(locationConfiguration);
690   - //启动所有手势
691   - mUiSettings.setAllGesturesEnabled(true);
692   - //通过设置enable为true或false 选择是否显示缩放按钮
693   - mMapView.showZoomControls(false);
694   - mUiSettings.setEnlargeCenterWithDoubleClickEnable(true);
695   - //隐藏自带的指南针,改用自定义指南针 杨帅
696   - baiduMap.getUiSettings().setCompassEnabled(true);
697   - //显示定位图层
698   - baiduMap.setMyLocationEnabled(true);
699   - // 定位初始化
700   - mLocClient = new LocationClient(getContext());
701   - mLocClient.registerLocationListener(myListener);
702   - LocationClientOption option = new LocationClientOption();
703   - option.setOpenGps(true); // 打开gps
704   - option.setCoorType("gcj02"); // 设置坐标类型
705   - //可选,默认false,设置是否开启Gps定位
706   - option.setOpenGps(true);
707   - //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者,该模式下开发者无需再关心定位间隔是多少,定位SDK本身发现位置变化就会及时回调给开发者
708   - option.setOpenAutoNotifyMode();
709   - //可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
710   - option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
711   - //可选,设置是否需要地址信息,默认不需要
712   - option.setIsNeedAddress(true);
713   - //可选,设置是否需要地址描述
714   - option.setIsNeedLocationDescribe(true);
715   - //可选,设置是否需要设备方向结果
716   - option.setNeedDeviceDirect(false);
717   - //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者
718   - option.setOpenAutoNotifyMode(3000, 1, LocationClientOption.LOC_SENSITIVITY_HIGHT);
719   - mLocClient.setLocOption(option);
720   - mLocClient.start();
721   - //设置地图加载完毕监听
722   - baiduMap.setOnMapLoadedCallback(new BaiduMap.OnMapLoadedCallback() {
723   - @Override
724   - public void onMapLoaded() {
725   -//
726   -
727   - }
728   - });
729   - }
730   -
731   -// /**
732   -// * 开始路线规划
733   -// */
734   -// public void searchRouteResult(LatLng StartPoint, LatLng EndPoint, int index, int listSize) {
735   -//// Log.e(TAG, "searchRouteResult: ");
736   -// float currentZoom = baiduMap.getMapStatus().zoom;
737   -// // 设置起终点信息,对于tranist search 来说,城市名无意义
738   -// PlanNode stNode = PlanNode.withLocation(StartPoint);
739   -// PlanNode enNode = PlanNode.withLocation(EndPoint);
740   -// routePlanSearch.setOnGetRoutePlanResultListener(new OnGetRoutePlanResultListener() {
741   -// @Override
742   -// public void onGetWalkingRouteResult(WalkingRouteResult walkingRouteResult) {
743   -// if (fragment.getActivity() == null) {
744   -// return;
745   -// }
746   -// if (walkingRouteResult == null || walkingRouteResult.error != SearchResult.ERRORNO.NO_ERROR) {
747   -// Toast.makeText(fragment.getActivity(), "抱歉,无法获取路线!", Toast.LENGTH_SHORT).show();
748   -// }
749   -// if (walkingRouteResult.error == SearchResult.ERRORNO.AMBIGUOUS_ROURE_ADDR) {
750   -// // 起终点或途经点地址有岐义,通过以下接口获取建议查询信息
751   -// return;
752   -// }
753   -// List<LatLng> points = new ArrayList<LatLng>();
754   -// if (walkingRouteResult.getRouteLines() != null) {
755   -// if (walkingRouteResult.getRouteLines().get(0).getAllStep().get(0).getWayPoints().size() > 0) {
756   -// //添加起点坐标
757   -// if (index == 0) {
758   -// points.add(StartPoint);
759   -// }
760   -// for (int i = 0; i < walkingRouteResult.getRouteLines().get(0).getAllStep().size(); i++) {
761   -// for (int j = 0; j < walkingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().size(); j++) {
762   -// points.add(walkingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().get(j));
763   -// }
764   -// }
765   -// }
766   -// //添加终点坐标
767   -// if (endLatLng != null) {
768   -//// points.add(endLatLng);
769   -// }
770   -//
771   -// ArrayList<Integer> traffics = new ArrayList<Integer>();
772   -// for (int i = 0; i < points.size(); i++) {
773   -// if (i % 2 == 0) {
774   -// traffics.add(i);
775   -// }
776   -// }
777   -//
778   -//
779   -// if (points.size() > 0) {
780   -//// if (baiduMap != null) {
781   -//// baiduMap.clear();
782   -//// if (endLatLng != null) {
783   -//// markPoi(endLatLng.latitude, endLatLng.longitude);
784   -//// }
785   -//// }
786   -//
787   -// //设置折线的属性
788   -//// OverlayOptions mOverlayOptions = new PolylineOptions()
789   -//// .width(10)
790   -//// .color(0xAAFF0000)
791   -//// .points(points);
792   -// //设置折线的属性
793   -// OverlayOptions mOverlayOptions = new PolylineOptions()
794   -// .width(10)
795   -// .dottedLine(true)
796   -// .points(points)
797   -// .customTextureList(getCustomTextureList())
798   -// .textureIndex(traffics);//设置纹理列表
799   -// //在地图上绘制起点
800   -// if (index == 0) {
801   -// //显示当前位置图标
802   -// Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.icon_start), 30, 30);
803   -// startMark = new MarkerOptions()
804   -// .position(StartPoint)
805   -// .icon(BitmapDescriptorFactory.fromBitmap(pointBitmap));
806   -//// startMark.anchor(0.5f, 0.55f);
807   -// baiduMap.addOverlay(startMark);
808   -// } else if (index == listSize - 1) {
809   -// //显示当前位置图标
810   -// Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.icon_end), 30, 30);
811   -// endMark = new MarkerOptions()
812   -// .position(points.get(points.size() - 1))
813   -// .icon(BitmapDescriptorFactory.fromBitmap(pointBitmap))
814   -// .perspective(true)
815   -//// endMark.anchor(0.5f, 0.5f)
816   -// .perspective(true);
817   -// baiduMap.addOverlay(endMark);
818   -// }
819   -// //mPloyline 折线对象
820   -// Overlay mPolyline = baiduMap.addOverlay(mOverlayOptions);
821   -// MapStatus.Builder builder = new MapStatus.Builder();
822   -// builder.zoom(currentZoom);
823   -// baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
824   -//
825   -// }
826   -// }
827   -// }
828   -//
829   -// @Override
830   -// public void onGetTransitRouteResult(TransitRouteResult transitRouteResult) {
831   -//
832   -// }
833   -//
834   -// @Override
835   -// public void onGetMassTransitRouteResult(MassTransitRouteResult massTransitRouteResult) {
836   -//
837   -// }
838   -//
839   -// @Override
840   -// public void onGetDrivingRouteResult(DrivingRouteResult drivingRouteResult) {
841   -// if (fragment.getActivity() == null) {
842   -// return;
843   -// }
844   -//
845   -// if (drivingRouteResult == null || drivingRouteResult.error != SearchResult.ERRORNO.NO_ERROR) {
846   -// Toast.makeText(fragment.getActivity(), "抱歉,无法获取路线!", Toast.LENGTH_SHORT).show();
847   -// }
848   -// if (drivingRouteResult.error == SearchResult.ERRORNO.AMBIGUOUS_ROURE_ADDR) {
849   -// // 起终点或途经点地址有岐义,通过以下接口获取建议查询信息
850   -// return;
851   -// }
852   -// List<LatLng> points = new ArrayList<LatLng>();
853   -// if (drivingRouteResult.getRouteLines() != null) {
854   -// if (drivingRouteResult.getRouteLines().get(0).getAllStep().get(0).getWayPoints().size() > 0) {
855   -// //添加起点坐标
856   -// if (followMyLocation != null) {
857   -// points.add(new LatLng(followMyLocation.latitude, followMyLocation.longitude));
858   -// }
859   -// for (int i = 0; i < drivingRouteResult.getRouteLines().get(0).getAllStep().size(); i++) {
860   -// for (int j = 0; j < drivingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().size(); j++) {
861   -// points.add(drivingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().get(j));
862   -// }
863   -// }
864   -// }
865   -// //添加终点坐标
866   -// if (endLatLng != null) {
867   -// points.add(endLatLng);
868   -// }
869   -// if (points.size() > 0) {
870   -// if (baiduMap != null) {
871   -// baiduMap.clear();
872   -// if (endLatLng != null) {
873   -// markPoi(endLatLng.latitude, endLatLng.longitude);
874   -// }
875   -// }
876   -//
877   -// //设置折线的属性
878   -// OverlayOptions mOverlayOptions = new PolylineOptions()
879   -// .width(10)
880   -// .color(0xAAFF0000)
881   -// .points(points);
882   -// //在地图上绘制折线
883   -// //mPloyline 折线对象
884   -// Overlay mPolyline = baiduMap.addOverlay(mOverlayOptions);
885   -// MapStatus.Builder builder = new MapStatus.Builder();
886   -// builder.zoom(currentZoom);
887   -// baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
888   -//
889   -// }
890   -// }
891   -// }
892   -//
893   -// @Override
894   -// public void onGetIndoorRouteResult(IndoorRouteResult indoorRouteResult) {
895   -//
896   -// }
897   -//
898   -// @Override
899   -// public void onGetBikingRouteResult(BikingRouteResult bikingRouteResult) {
900   -//
901   -// }
902   -// });
903   - //开始检索
904   -// routePlanSearch.drivingSearch((new DrivingRoutePlanOption())
905   -// .from(stNode).to(enNode).policy(DrivingRoutePlanOption.DrivingPolicy.ECAR_DIS_FIRST)
906   -// .trafficPolicy(DrivingRoutePlanOption.DrivingTrafficPolicy.ROUTE_PATH_AND_TRAFFIC));
907   -
908   - //开始步行检索
909   -// routePlanSearch.walkingSearch((new WalkingRoutePlanOption())
910   -// .from(stNode)
911   -// .to(enNode));
912   -// }
913   -// showProgressDialog();
914   -
915   - /**
916   - * 设置终点标记
917   - *
918   - * @param Latitude
919   - * @param Longitude
920   - */
921   - public void markPoi(double Latitude, double Longitude) {
922   - if (fragment.getActivity() == null) {
923   - return;
924   - }
925   - baiduMap.clear();
926   - currentMark = null;
927   - LatLng ll = new LatLng(Latitude, Longitude);
928   - //设置坐标
929   - //显示当前位置图标
930   - Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(fragment.getActivity(), BitmapFactory.decodeResource(fragment.getActivity().getResources(), R.drawable.run_map_icon_end), 22, 32);
931   - currentMark = new MarkerOptions().position(ll).icon(BitmapDescriptorFactory.fromBitmap(pointBitmap));
932   - baiduMap.addOverlay(currentMark);
933   - MapStatus.Builder builder = new MapStatus.Builder();
934   - builder.target(ll).zoom(16.0f);
935   - baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
936   - }
937   -
938   - @Override
939   - public void onSensorChanged(SensorEvent sensorEvent) {
940   - double x = sensorEvent.values[SensorManager.DATA_X];
941   - if (Math.abs(x - lastX) > 1.0) {
942   - mCurrentDirection = (int) x;
943   - if (firstLatLng != null) {
944   - followMyLocation = new MyLocationData.Builder()
945   - .accuracy(mCurrentAccracy)
946   - // 此处设置开发者获取到的方向信息,顺时针0-360
947   - .direction(mCurrentDirection).latitude(firstLatLng.latitude)
948   - .longitude(firstLatLng.longitude).build();
949   - baiduMap.setMyLocationData(followMyLocation);
950   - }
951   - }
952   - lastX = x;
953   - }
954   -
955   - @Override
956   - public void onAccuracyChanged(Sensor sensor, int i) {
957   -
958   - }
959   -
960   - /**
961   - * 纹理图片
962   - *
963   - * @return
964   - */
965   - public List<BitmapDescriptor> getCustomTextureList() {
966   - ArrayList<BitmapDescriptor> list = new ArrayList<BitmapDescriptor>();
967   - list.add(BitmapDescriptorFactory.fromAsset("Icon_road_blue_arrow.png"));
968   -// list.add(BitmapDescriptorFactory.fromAsset("Icon_road_green_arrow.png"));
969   -// list.add(BitmapDescriptorFactory.fromAsset("Icon_road_yellow_arrow.png"));
970   -// list.add(BitmapDescriptorFactory.fromAsset("Icon_road_red_arrow.png"));
971   -// list.add(BitmapDescriptorFactory.fromAsset("Icon_road_nofocus.png"));
972   - return list;
973   - }
974   -
975   - public void onResume() {
976   - if (getContext() == null) {
977   - return;
978   - }
979   - if (mMapView != null) {
980   - mMapView.onResume();
981   - }
982   - //todo 防止停止后,再次开始,无法获取到赛道的轨迹
983   - if (runRaceDetailInfo != null) {
984   - if (runRaceDetailInfo.getFenceId() != null && !TextUtils.isEmpty(runRaceDetailInfo.getFenceId())) {
985   - //设置围栏ID
986   - CommonInfo.setFenceId(getContext(), Integer.parseInt(runRaceDetailInfo.getFenceId()));
987   - }
988   - }
989   -
990   - }
991   -
992   - public void checkStartBtnState() {
993   - //判断是否有进行中的赛事
994   - userStepEntity = StepUtil.getUserStepData(getContext(), CommonInfo.getUserId(getContext()));
995   - Log.e(TAG, "checkStartBtnState: " + userStepEntity);
996   - if (userStepEntity != null) {
997   - //判断赛事id是否一致
998   - String currentStreetId = CommonInfo.getStreetId(getContext());
999   - //数据库保存的id
1000   - String dbStreetId = userStepEntity.getStreetId();
1001   - //获取当前时间戳
1002   - long currnetTime = SystemClock.elapsedRealtime();
1003   - //获取用户暂停的时间戳
1004   - long userPauseTime = userStepEntity.getChronometerBase();
1005   - //判断时间是否小于9小时
1006   - Log.e(TAG, "checkStartBtnState: " + currnetTime + ",userPauseTime:" + userPauseTime);
1007   - if ((currnetTime - userPauseTime) <= (9 * 60 * 60 * 1000)) {
1008   - Log.e(TAG, "小于9小时");
1009   - fragment.binding.tvRunNow.setText("继续运动");
1010   - fragment.binding.rlScrollViewStartBtn.setTag("2");
1011   - } else {
1012   - Log.e(TAG, "大于9小时");
1013   - //重置数据
1014   - CommonInfo.resetRace(getContext());
1015   - //清空数据库
1016   - StepUtil.clearRunData(getContext(), CommonInfo.getUserId(getContext()));
1017   - fragment.binding.tvRunNow.setText("立即开始");
1018   - fragment.binding.rlScrollViewStartBtn.setTag("1");
1019   -
1020   - }
1021   -
1022   - if (currentStreetId.equals(dbStreetId)) {
1023   - isDifferentStreet = false;
1024   - }
1025   - //当前id与赛事id不一样
1026   - else {
1027   - isDifferentStreet = true;
1028   - }
1029   -
1030   - } else {
1031   - fragment.binding.tvRunNow.setText("立即开始");
1032   - fragment.binding.rlScrollViewStartBtn.setTag("1");
1033   - }
1034   - //判断赛事是否已经结束
1035   - checkTheRaceIsEnd();
1036   -
1037   - }
1038   -
1039   - /**
1040   - * 判断赛事是否已经结束
1041   - */
1042   - private void checkTheRaceIsEnd() {
1043   - //判断赛事是否结束
1044   - if (null != userStepEntity) {
1045   - if (null != runRaceDetailInfo) {
1046   - //判断赛事id是否一致
1047   - if (!TextUtils.isEmpty(userStepEntity.getStreetId())) {
1048   - if (userStepEntity.getStreetId().equals(CommonInfo.getStreetId(getContext()))) {
1049   - //判断赛事是否结束
1050   - if (runRaceDetailInfo.isEndState()) {
1051   - //结束清除数据
1052   - //清空上次保存数据
1053   - StepUtil.clearRunData(getContext(), CommonInfo.getUserId(getContext()));
1054   - //停止服务
1055   - stopStepService();
1056   - //清除数据
1057   - CommonInfo.resetRace(getContext());
1058   - //设置按钮状态
1059   - fragment.binding.rlScrollViewStartBtn.setTag("3");
1060   - fragment.binding.rlScrollViewStartBtn.setBackgroundColor(getContext().getResources().getColor(R.color.red_round));
1061   - fragment.binding.tvRunNow.setText("赛事已结束");
1062   - fragment.binding.tvGoTip.setVisibility(View.GONE);
1063   - }
1064   - }
1065   - }
1066   - }
1067   - } else {
1068   - //如果数据库中没有数据,即,用户在当前赛事已经结束
1069   - if (null != runRaceDetailInfo) {
1070   - if (runRaceDetailInfo.isEndState()) {
1071   - //设置按钮状态
1072   - fragment.binding.rlScrollViewStartBtn.setTag("3");
1073   - fragment.binding.rlScrollViewStartBtn.setBackgroundColor(getContext().getResources().getColor(R.color.red_round));
1074   - fragment.binding.tvRunNow.setText("赛事已结束");
1075   - fragment.binding.tvGoTip.setVisibility(View.GONE);
1076   - }
1077   - }
1078   - }
1079   - }
1080   -
1081   - /**
1082   - * 赛事已经结束
1083   - */
1084   - private void raceHasEnd() {
1085   -
1086   - }
1087   -
1088   - public void onPause() {
1089   - if (mMapView != null) {
1090   - mMapView.onPause();
1091   - }
1092   - }
1093   -
1094   - public void onDestroy() {
1095   - if (mMapView != null) {
1096   - mMapView.onDestroy();
1097   - mMapView = null;
1098   - }
1099   - if (mLocClient != null) {
1100   - mLocClient.stop();
1101   - }
1102   - }
1103   -
1104   - /**
1105   - * //设置定位监听器,获取到用户当前位置 杨帅
1106   - * 定位SDK监听函数
1107   - */
1108   - public class MyLocationListenner extends BDAbstractLocationListener {
1109   -
1110   - @Override
1111   - public void onReceiveLocation(BDLocation location) {
1112   - // map view 销毁后不在处理新接收的位置
1113   - if (location == null || mMapView == null) {
1114   - return;
1115   - }
1116   - if (isFirstLoc) {
1117   - isFirstLoc = false;
1118   - if (location.getRadius() > Constant.LOCA_ACCURACY) {
1119   - Toast.makeText(getContext(), "当前定位精度为:" + location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show();
1120   - }
1121   -
1122   - } else {
1123   - //过滤定位精度
1124   - if (location.getRadius() > Constant.LOCA_ACCURACY) {
1125   - return;
1126   - }
1127   - }
1128   - followMyLocation = new MyLocationData.Builder()
1129   - .accuracy(location.getRadius())
1130   - // 此处设置开发者获取到的方向信息,顺时针0-360
1131   - .direction(location.getDirection()).latitude(location.getLatitude())
1132   - .longitude(location.getLongitude()).build();
1133   - if (followMyLocation == null || followMyLocation.latitude == 0 || followMyLocation.longitude == 0) {
1134   - return;
1135   - }
1136   -
1137   - MapStatus.Builder builder = new MapStatus.Builder();
1138   - firstLatLng = new LatLng(location.getLatitude(),
1139   - location.getLongitude());
1140   - baiduMap.setMyLocationData(followMyLocation);
1141   - //没有获取到轨迹
1142   - if ((null == queryResultPoints || queryResultPoints.size() < 1) && null != firstLatLng) {
1143   - builder.target(firstLatLng).zoom(DEFULT_ZOOM);
1144   - baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
1145   - }
1146   -//
1147   -
1148   -// //显示当前位置图标
1149   -// Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.rt_ic_location), 40, 40);
1150   -// currentMark = new MarkerOptions().position(firstLatLng).icon(BitmapDescriptorFactory.fromBitmap(pointBitmap));
1151   -// baiduMap.addOverlay(currentMark);
1152   -
1153   - //根据几个关键点进行步行路径规划
1154   -// if (importLatLngs != null) {
1155   -// if (importLatLngs.size() >= 1) {
1156   -// for (int index = 0; index < importLatLngs.size(); index++) {
1157   -// //开始分段规划路径
1158   -// //第一个点
1159   -// if (index == 0) {
1160   -// searchRouteResult(startLatLng, importLatLngs.get(index), 0, importLatLngs.size());
1161   -// } else {
1162   -// searchRouteResult(importLatLngs.get(index - 1), importLatLngs.get(index), index, importLatLngs.size());
1163   -// }
1164   -// }
1165   -// } else {
1166   -// searchRouteResult(startLatLng, endLatLng, 0, importLatLngs.size());
1167   -// }
1168   -// }
1169   -
1170   -// }
1171   - }
1172   - }
1173   -
1174   - /**
1175   - * 显示loading
1176   - */
1177   - public void showLoadingView() {
1178   - if (fragment.binding.emptyLayout == null) {
1179   - return;
1180   - }
1181   - fragment.binding.emptyLayout.show(true);
1182   - }
1183   -
1184   - /**
1185   - * 隐藏loading
1186   - */
1187   - public void hideLoadingView() {
1188   - if (fragment.binding.emptyLayout == null) {
1189   - return;
1190   - }
1191   - fragment.binding.emptyLayout.hide();
1192   - }
1193   -
1194   - /**
1195   - * 显示重试页面
1196   - *
1197   - * @param errorCode
1198   - * @param listener
1199   - */
1200   - public void showRetryView(int errorCode, View.OnClickListener listener) {
1201   - if (getContext() == null) {
1202   - return;
1203   - }
1204   - //隐藏地图
1205   - fragment.binding.mapView.setVisibility(View.GONE);
1206   - //显示空视图
1207   - fragment.binding.emptyLayout.setVisibility(View.VISIBLE);
1208   - //隐藏底部卡片
1209   - fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);
1210   - if (fragment.binding.emptyLayout == null) return;
1211   - String titleText = "";
1212   - String detailText = "";
1213   - if (errorCode == -3) {
1214   - titleText = getContext().getString(R.string.msg_failed_network_title);
1215   - detailText = getContext().getString(R.string.msg_failed_network_detail);
1216   - } else {
1217   - titleText = getContext().getString(R.string.msg_failed_other_title);
1218   - detailText = getContext().getString(R.string.msg_failed_other_detail);
1219   - }
1220   - fragment.binding.emptyLayout.show(false, titleText, detailText, getContext().getString(R.string.retry), R.drawable.wufalianjie, listener);
1221   - }
1222   -
1223   -
1224   - /**
1225   - * 启动计步服务
1226   - */
1227   - public void startStepService(Context context) {
1228   - CommonInfo.setIsFirstStepSendTraceTip(getContext(), true);
1229   - QMUITipDialogUtil.loadingDialog(getContext(), "请稍后", false);
1230   - CommonInfo.setIsRunKeepAliveService(context, true);
1231   - CommonInfo.setIsRunStepService(context, true);
1232   - CommonInfo.setTsRunBaiduTraceService(context, true);
1233   - CommonInfo.setIsWriteUserStep(context, true);
1234   - Intent intent = new Intent(fragment.getActivity(), KeepLiveService.class);
1235   - ContextCompat.startForegroundService(fragment.getActivity(), intent);
1236   -
1237   - }
1238   -
1239   -
1240   - public void setRegistrationBtn() {
1241   - if (getContext() == null) {
1242   - return;
1243   - }
1244   - fragment.binding.rlScrollViewStartBtn.setTag("1");
1245   - fragment.binding.tvRunNow.setText("现在开始");
1246   - fragment.binding.tvGoTip.setVisibility(View.VISIBLE);
1247   - }
1248   -
1249   -}
  1 +setImportPoints
1250 2 \ No newline at end of file
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunMainFragment.java
... ... @@ -12,6 +12,7 @@ import com.baidu.mapapi.model.LatLng;
12 12 import com.cnlive.libs.base.ui.QMUIFragment;
13 13 import com.cnlive.libs.base.util.StatusBarUtil;
14 14 import com.cnlive.libs.base.util.StatusBarUtil2;
  15 +import com.cnlive.moudle.collectionTrace.model.CollectPoint;
15 16 import com.cnlive.moudle.pedometer.commonInfo.CommonInfo;
16 17 import com.cnlive.moudle.pedometer.frame.presenter.RunMainFragmentPresenter;
17 18 import com.cnlive.moudle.pedometer.frame.view.RunMainFragmentView;
... ... @@ -32,6 +33,7 @@ import org.greenrobot.eventbus.Subscribe;
32 33 import org.greenrobot.eventbus.ThreadMode;
33 34  
34 35 import java.io.Serializable;
  36 +import java.util.ArrayList;
35 37 import java.util.List;
36 38  
37 39 public class RunMainFragment extends QMUIFragment<RunMainFragmentView, RunMainFragmentPresenter, FragmentRunMainBinding> {
... ... @@ -67,9 +69,24 @@ public class RunMainFragment extends QMUIFragment&lt;RunMainFragmentView, RunMainFr
67 69 StepUtil.updateStepData(getActivity(), userStepEntity);
68 70 //获取数据库中的重要点
69 71 String importStr = userStepEntity.getImportPoint();
70   - if (TextUtils.isEmpty(runRaceDetailInfo.getLatLongitude())) {
71   - //设置重要点
72   - StepUtil.setImportPoints(getActivity(), CommonInfo.getUserId(getActivity()), GsonUtil.GsonString(runRaceDetailInfo.getLatLongitude()));
  72 + //如果为空
  73 + if (TextUtils.isEmpty(userStepEntity.getImportPoint())) {
  74 + if (!TextUtils.isEmpty(runRaceDetailInfo.getLatLongitude())) {
  75 + List<CollectPoint> collectPoints = GsonUtil.jsonToList(runRaceDetailInfo.getLatLongitude(), CollectPoint.class);
  76 + List<LatLng> importLatLngs = new ArrayList<>();
  77 + if (null != collectPoints && collectPoints.size() > 0) {
  78 + for (CollectPoint collectPoint : collectPoints) {
  79 + LatLng latLng = new LatLng(collectPoint.getLatitude(), collectPoint.getLongitude());
  80 + if (null != latLng) {
  81 + importLatLngs.add(latLng);
  82 + }
  83 + }
  84 + }
  85 + if (null != importLatLngs && importLatLngs.size() > 0) {
  86 + //设置重要点
  87 + StepUtil.setImportPoints(getActivity(), CommonInfo.getUserId(getActivity()), GsonUtil.GsonString(importLatLngs));
  88 + }
  89 + }
73 90 }
74 91 }
75 92  
... ...