Commit 0661b519e12c608b87cc4b3c8cff6687cb12ecab

Authored by 杨帅
1 parent b3f8d752

1 实现赛事详情页中赛事结束判断

moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunRaceDetailFragmentView.java
@@ -171,21 +171,21 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen @@ -171,21 +171,21 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen
171 fragment.binding.includeStreet.tvEndAddr.setText(runRaceDetailInfo.getEndLocation()); 171 fragment.binding.includeStreet.tvEndAddr.setText(runRaceDetailInfo.getEndLocation());
172 } 172 }
173 //设置起始报名时间 173 //设置起始报名时间
174 - if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_start_time(), "yyyy-MM-dd"))) {  
175 - fragment.binding.includeStreet.tvSignUpStartTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_start_time(), "yyyy-MM-dd")); 174 + if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_start_time(), "yyyy.MM.dd"))) {
  175 + fragment.binding.includeStreet.tvSignUpStartTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_start_time(), "yyyy.MM.dd"));
176 176
177 } 177 }
178 //设置终止报名时间 178 //设置终止报名时间
179 - if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_end_time(), "yyyy-MM-dd"))) {  
180 - fragment.binding.includeStreet.tvSignUpEndTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_end_time(), "yyyy-MM-dd")); 179 + if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_end_time(), "yyyy.MM.dd"))) {
  180 + fragment.binding.includeStreet.tvSignUpEndTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_end_time(), "yyyy.MM.dd"));
181 } 181 }
182 //设置活动开始时间 182 //设置活动开始时间
183 - if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getStart_time(), "yyyy-MM-dd"))) {  
184 - fragment.binding.includeStreet.tvActiveStartTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getStart_time(), "yyyy-MM-dd")); 183 + if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getStart_time(), "yyyy.MM.dd"))) {
  184 + fragment.binding.includeStreet.tvActiveStartTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getStart_time(), "yyyy.MM.dd"));
185 } 185 }
186 //设置活动结束时间 186 //设置活动结束时间
187 - if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getEnd_time(), "yyyy-MM-dd"))) {  
188 - fragment.binding.includeStreet.tvActiveEndTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getEnd_time(), "yyyy-MM-dd")); 187 + if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getEnd_time(), "yyyy.MM.dd"))) {
  188 + fragment.binding.includeStreet.tvActiveEndTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getEnd_time(), "yyyy.MM.dd"));
189 } 189 }
190 190
191 191
@@ -195,12 +195,6 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen @@ -195,12 +195,6 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen
195 GlideApp.with(getContext()).load(runRaceDetailInfo.getRoadmap()).into(fragment.binding.includeStreetIntroduce.ivRoadMao); 195 GlideApp.with(getContext()).load(runRaceDetailInfo.getRoadmap()).into(fragment.binding.includeStreetIntroduce.ivRoadMao);
196 196
197 } 197 }
198 - //开始按钮点击事件(用户进行滑动滑动)  
199 - fragment.binding.rlScrollViewStartBtn.setOnClickListener(new View.OnClickListener() {  
200 - @Override  
201 - public void onClick(View view) {  
202 - }  
203 - });  
204 //添加轨迹按钮点击事件 198 //添加轨迹按钮点击事件
205 fragment.binding.btnAddTrace.setOnClickListener(new View.OnClickListener() { 199 fragment.binding.btnAddTrace.setOnClickListener(new View.OnClickListener() {
206 @Override 200 @Override
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/OnGoingFragmentView.java
@@ -7,6 +7,7 @@ import android.graphics.BitmapFactory; @@ -7,6 +7,7 @@ import android.graphics.BitmapFactory;
7 import android.text.TextUtils; 7 import android.text.TextUtils;
8 import android.util.Log; 8 import android.util.Log;
9 import android.view.View; 9 import android.view.View;
  10 +import android.view.ViewTreeObserver;
10 import android.widget.LinearLayout; 11 import android.widget.LinearLayout;
11 12
12 import com.alibaba.android.arouter.launcher.ARouter; 13 import com.alibaba.android.arouter.launcher.ARouter;
@@ -210,15 +211,25 @@ public class OnGoingFragmentView implements MvpView { @@ -210,15 +211,25 @@ public class OnGoingFragmentView implements MvpView {
210 //设置围栏ID 211 //设置围栏ID
211 CommonInfo.setFenceId(getContext(), Integer.parseInt(runRaceDetailInfo.getFenceId())); 212 CommonInfo.setFenceId(getContext(), Integer.parseInt(runRaceDetailInfo.getFenceId()));
212 } 213 }
  214 + fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 140));
213 //设置标题 215 //设置标题
214 if (!TextUtils.isEmpty(runRaceDetailInfo.getTitle())) { 216 if (!TextUtils.isEmpty(runRaceDetailInfo.getTitle())) {
215 fragment.binding.includeStreet.tvRaceTitle.setText(runRaceDetailInfo.getTitle()); 217 fragment.binding.includeStreet.tvRaceTitle.setText(runRaceDetailInfo.getTitle());
216 - //根据标题字数动态设置卡片高度  
217 - if (runRaceDetailInfo.getTitle().length() > 19) {  
218 - fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 162));  
219 - } else {  
220 - fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 140));  
221 - } 218 + //根据标题行数,自动调整卡片大小
  219 + fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
  220 + @Override
  221 + public boolean onPreDraw() {
  222 + int line = fragment.binding.includeStreet.tvRaceTitle.getLineCount();
  223 + int height = fragment.binding.includeStreet.tvRaceTitle.getHeight();
  224 + if (line > 1) {
  225 + int avgHeight = height / line;//平局高度
  226 + fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 140) + avgHeight * (line - 1));
  227 +
  228 + }
  229 + fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().removeOnPreDrawListener(this);
  230 + return false;
  231 + }
  232 + });
222 fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); 233 fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
223 } 234 }
224 //设置活动地点 235 //设置活动地点
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
@@ -8,13 +8,11 @@ import android.hardware.Sensor; @@ -8,13 +8,11 @@ import android.hardware.Sensor;
8 import android.hardware.SensorEvent; 8 import android.hardware.SensorEvent;
9 import android.hardware.SensorEventListener; 9 import android.hardware.SensorEventListener;
10 import android.hardware.SensorManager; 10 import android.hardware.SensorManager;
11 -import android.os.Handler;  
12 import android.os.SystemClock; 11 import android.os.SystemClock;
13 import android.support.v4.content.ContextCompat; 12 import android.support.v4.content.ContextCompat;
14 import android.text.TextUtils; 13 import android.text.TextUtils;
15 import android.util.Log; 14 import android.util.Log;
16 import android.view.View; 15 import android.view.View;
17 -import android.view.ViewGroup;  
18 import android.view.ViewTreeObserver; 16 import android.view.ViewTreeObserver;
19 import android.widget.LinearLayout; 17 import android.widget.LinearLayout;
20 import android.widget.Toast; 18 import android.widget.Toast;
@@ -28,39 +26,18 @@ import com.baidu.mapapi.map.BaiduMap; @@ -28,39 +26,18 @@ import com.baidu.mapapi.map.BaiduMap;
28 import com.baidu.mapapi.map.BitmapDescriptor; 26 import com.baidu.mapapi.map.BitmapDescriptor;
29 import com.baidu.mapapi.map.BitmapDescriptorFactory; 27 import com.baidu.mapapi.map.BitmapDescriptorFactory;
30 import com.baidu.mapapi.map.MapStatus; 28 import com.baidu.mapapi.map.MapStatus;
31 -import com.baidu.mapapi.map.MapStatusUpdate;  
32 import com.baidu.mapapi.map.MapStatusUpdateFactory; 29 import com.baidu.mapapi.map.MapStatusUpdateFactory;
33 import com.baidu.mapapi.map.MapView; 30 import com.baidu.mapapi.map.MapView;
34 import com.baidu.mapapi.map.MarkerOptions; 31 import com.baidu.mapapi.map.MarkerOptions;
35 import com.baidu.mapapi.map.MyLocationConfiguration; 32 import com.baidu.mapapi.map.MyLocationConfiguration;
36 import com.baidu.mapapi.map.MyLocationData; 33 import com.baidu.mapapi.map.MyLocationData;
37 -import com.baidu.mapapi.map.Overlay;  
38 -import com.baidu.mapapi.map.OverlayOptions;  
39 -import com.baidu.mapapi.map.PolylineOptions;  
40 import com.baidu.mapapi.map.UiSettings; 34 import com.baidu.mapapi.map.UiSettings;
41 import com.baidu.mapapi.model.LatLng; 35 import com.baidu.mapapi.model.LatLng;
42 -import com.baidu.mapapi.model.LatLngBounds;  
43 -import com.baidu.mapapi.search.core.SearchResult;  
44 -import com.baidu.mapapi.search.route.BikingRouteResult;  
45 -import com.baidu.mapapi.search.route.DrivingRouteResult;  
46 -import com.baidu.mapapi.search.route.IndoorRouteResult;  
47 -import com.baidu.mapapi.search.route.MassTransitRouteResult;  
48 -import com.baidu.mapapi.search.route.OnGetRoutePlanResultListener;  
49 -import com.baidu.mapapi.search.route.PlanNode;  
50 import com.baidu.mapapi.search.route.RoutePlanSearch; 36 import com.baidu.mapapi.search.route.RoutePlanSearch;
51 -import com.baidu.mapapi.search.route.TransitRouteResult;  
52 -import com.baidu.mapapi.search.route.WalkingRoutePlanOption;  
53 -import com.baidu.mapapi.search.route.WalkingRouteResult;  
54 import com.baidu.mapapi.utils.DistanceUtil; 37 import com.baidu.mapapi.utils.DistanceUtil;
55 import com.baidu.trace.LBSTraceClient; 38 import com.baidu.trace.LBSTraceClient;
56 -import com.baidu.trace.Trace;  
57 -import com.baidu.trace.model.LocationMode;  
58 import com.baidu.trace.model.SortType; 39 import com.baidu.trace.model.SortType;
59 -import com.cnlive.libs.base.logic.Event;  
60 -import com.cnlive.libs.base.logic.callback.FailureCallback;  
61 -import com.cnlive.libs.base.logic.callback.SuccessCallback;  
62 import com.cnlive.libs.base.util.StatusBarUtil2; 40 import com.cnlive.libs.base.util.StatusBarUtil2;
63 -import com.cnlive.moudle.pedometer.commonInfo.CollCommonInfo;  
64 import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; 41 import com.cnlive.moudle.pedometer.commonInfo.CommonInfo;
65 import com.cnlive.moudle.pedometer.model.Constant; 42 import com.cnlive.moudle.pedometer.model.Constant;
66 import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo; 43 import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo;
@@ -74,7 +51,6 @@ import com.cnlive.moudle.pedometer.ui.activity.TakePartActivity; @@ -74,7 +51,6 @@ import com.cnlive.moudle.pedometer.ui.activity.TakePartActivity;
74 import com.cnlive.moudle.pedometer.ui.fragment.RunRaceDetailFragment; 51 import com.cnlive.moudle.pedometer.ui.fragment.RunRaceDetailFragment;
75 import com.cnlive.moudle.pedometer.ui.widget.SelectDialog; 52 import com.cnlive.moudle.pedometer.ui.widget.SelectDialog;
76 import com.cnlive.moudle.pedometer.ui.widget.TipDialog; 53 import com.cnlive.moudle.pedometer.ui.widget.TipDialog;
77 -import com.cnlive.moudle.pedometer.upload.UploadLogic;  
78 import com.cnlive.moudle.pedometer.utils.BitmapUtil; 54 import com.cnlive.moudle.pedometer.utils.BitmapUtil;
79 import com.cnlive.moudle.pedometer.utils.GsonUtil; 55 import com.cnlive.moudle.pedometer.utils.GsonUtil;
80 import com.cnlive.moudle.pedometer.utils.MyMapUtil; 56 import com.cnlive.moudle.pedometer.utils.MyMapUtil;
@@ -89,13 +65,7 @@ import com.hannesdorfmann.mosby3.mvp.MvpView; @@ -89,13 +65,7 @@ import com.hannesdorfmann.mosby3.mvp.MvpView;
89 import com.qmuiteam.qmui.util.QMUIStatusBarHelper; 65 import com.qmuiteam.qmui.util.QMUIStatusBarHelper;
90 import com.sothree.slidinguppanel.SlidingUpPanelLayout; 66 import com.sothree.slidinguppanel.SlidingUpPanelLayout;
91 67
92 -import java.io.File;  
93 -import java.io.FileOutputStream;  
94 -import java.io.LineNumberReader;  
95 -import java.text.SimpleDateFormat;  
96 import java.util.ArrayList; 68 import java.util.ArrayList;
97 -import java.util.Date;  
98 -import java.util.LinkedList;  
99 import java.util.List; 69 import java.util.List;
100 70
101 public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { 71 public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
@@ -353,20 +323,30 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -353,20 +323,30 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
353 //设置标题 323 //设置标题
354 if (!TextUtils.isEmpty(runRaceDetailInfo.getTitle())) { 324 if (!TextUtils.isEmpty(runRaceDetailInfo.getTitle())) {
355 fragment.binding.includeStreet.tvRaceTitle.setText(runRaceDetailInfo.getTitle()); 325 fragment.binding.includeStreet.tvRaceTitle.setText(runRaceDetailInfo.getTitle());
356 - fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {  
357 - @Override  
358 - public boolean onPreDraw() {  
359 - Log.e(TAG, "initView: "+ fragment.binding.includeStreet.tvRaceTitle.getLineCount() );  
360 - fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().removeOnPreDrawListener(this);  
361 - return false;  
362 - }  
363 - });  
364 - //根据标题字数动态设置卡片高度  
365 - if (runRaceDetailInfo.getTitle().length() > 19) {  
366 - fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 200));  
367 - } else {  
368 - fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 181));  
369 - } 326 + fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
  327 + @Override
  328 + public boolean onPreDraw() {
  329 + Log.e(TAG, "initView: " + fragment.binding.includeStreet.tvRaceTitle.getLineCount());
  330 + fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().removeOnPreDrawListener(this);
  331 + return false;
  332 + }
  333 + });
  334 + fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 181) );
  335 + //根据标题行数,自动调整卡片大小
  336 + fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
  337 + @Override
  338 + public boolean onPreDraw() {
  339 + int line = fragment.binding.includeStreet.tvRaceTitle.getLineCount();
  340 + int height = fragment.binding.includeStreet.tvRaceTitle.getHeight();
  341 + if (line > 1) {
  342 + int avgHeight = height / line;//平局高度
  343 + fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 181) + avgHeight * (line - 1));
  344 +
  345 + }
  346 + fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().removeOnPreDrawListener(this);
  347 + return false;
  348 + }
  349 + });
370 fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); 350 fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
371 } 351 }
372 //设置活动地点 352 //设置活动地点
@@ -1056,6 +1036,57 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -1056,6 +1036,57 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
1056 fragment.binding.tvRunNow.setText("立即开始"); 1036 fragment.binding.tvRunNow.setText("立即开始");
1057 fragment.binding.rlScrollViewStartBtn.setTag("1"); 1037 fragment.binding.rlScrollViewStartBtn.setTag("1");
1058 } 1038 }
  1039 + //判断赛事是否已经结束
  1040 + checkTheRaceIsEnd();
  1041 +
  1042 + }
  1043 +
  1044 + /**
  1045 + * 判断赛事是否已经结束
  1046 + */
  1047 + private void checkTheRaceIsEnd() {
  1048 + //判断赛事是否结束
  1049 + if (null != userStepEntity) {
  1050 + if (null != runRaceDetailInfo) {
  1051 + //判断赛事id是否一致
  1052 + if (!TextUtils.isEmpty(userStepEntity.getStreetId())) {
  1053 + if (userStepEntity.getStreetId().equals(CommonInfo.getStreetId(getContext()))) {
  1054 + //判断赛事是否结束
  1055 + if (runRaceDetailInfo.isEndState()) {
  1056 + //结束清除数据
  1057 + //清空上次保存数据
  1058 + StepUtil.clearRunData(getContext(), CommonInfo.getUserId(getContext()));
  1059 + //停止服务
  1060 + stopStepService();
  1061 + //清除数据
  1062 + CommonInfo.resetRace(getContext());
  1063 + //设置按钮状态
  1064 + fragment.binding.rlScrollViewStartBtn.setTag("3");
  1065 + fragment.binding.rlScrollViewStartBtn.setBackgroundColor(getContext().getResources().getColor(R.color.red_round));
  1066 + fragment.binding.tvRunNow.setText("赛事已结束");
  1067 + fragment.binding.tvGoTip.setVisibility(View.GONE);
  1068 + }
  1069 + }
  1070 + }
  1071 + }
  1072 + } else {
  1073 + //如果数据库中没有数据,即,用户在当前赛事已经结束
  1074 + if (null != runRaceDetailInfo) {
  1075 + if (runRaceDetailInfo.isEndState()) {
  1076 + //设置按钮状态
  1077 + fragment.binding.rlScrollViewStartBtn.setTag("3");
  1078 + fragment.binding.rlScrollViewStartBtn.setBackgroundColor(getContext().getResources().getColor(R.color.red_round));
  1079 + fragment.binding.tvRunNow.setText("赛事已结束");
  1080 + fragment.binding.tvGoTip.setVisibility(View.GONE);
  1081 + }
  1082 + }
  1083 + }
  1084 + }
  1085 +
  1086 + /**
  1087 + * 赛事已经结束
  1088 + */
  1089 + private void raceHasEnd() {
1059 1090
1060 } 1091 }
1061 1092
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/net/bean/RunRaceDetailInfo.java
@@ -87,6 +87,15 @@ public class RunRaceDetailInfo implements Serializable { @@ -87,6 +87,15 @@ public class RunRaceDetailInfo implements Serializable {
87 private List<String> faceUrl; 87 private List<String> faceUrl;
88 private List<String> finishFaceUrl; 88 private List<String> finishFaceUrl;
89 private String endLatLng;//终点坐标,后加的,不是后台返回,这是从百度历史轨迹查出来的 89 private String endLatLng;//终点坐标,后加的,不是后台返回,这是从百度历史轨迹查出来的
  90 + private boolean endState;//活动是否结束(true 结束 false 未结束 )
  91 +
  92 + public boolean isEndState() {
  93 + return endState;
  94 + }
  95 +
  96 + public void setEndState(boolean endState) {
  97 + this.endState = endState;
  98 + }
90 99
91 public String getEndLatLng() { 100 public String getEndLatLng() {
92 return endLatLng; 101 return endLatLng;
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/MyMapUtil.java
@@ -331,7 +331,7 @@ public class MyMapUtil { @@ -331,7 +331,7 @@ public class MyMapUtil {
331 */ 331 */
332 public static Overlay drawRealTimeTrack(Context context, BaiduMap baiduMap, List<LatLng> points, SortType sortType, int lineColor, int startIconRes) { 332 public static Overlay drawRealTimeTrack(Context context, BaiduMap baiduMap, List<LatLng> points, SortType sortType, int lineColor, int startIconRes) {
333 // 绘制新覆盖物前,清空之前的覆盖物 333 // 绘制新覆盖物前,清空之前的覆盖物
334 - if (points == null || points.size() == 0 || lineColor == 0 ) { 334 + if (points == null || points.size() == 0 || lineColor == 0) {
335 return null; 335 return null;
336 } 336 }
337 //只有一个点 337 //只有一个点
@@ -378,114 +378,120 @@ public class MyMapUtil { @@ -378,114 +378,120 @@ public class MyMapUtil {
378 * 绘制服务器传过来的轨迹 378 * 绘制服务器传过来的轨迹
379 */ 379 */
380 public static List<Overlay> drawServerLineTrack(Context context, BaiduMap baiduMap, List<LatLng> points, SortType sortType, int lineColor, int startIconRes, int endIconRes) { 380 public static List<Overlay> drawServerLineTrack(Context context, BaiduMap baiduMap, List<LatLng> points, SortType sortType, int lineColor, int startIconRes, int endIconRes) {
381 - // 绘制新覆盖物前,清空之前的覆盖物  
382 - if (points == null || points.size() == 0) {  
383 - return null;  
384 - }  
385 - List<Overlay> resultOverlays = new ArrayList<>();  
386 - //只有一个点  
387 - if (points.size() == 1) {  
388 - Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), startIconRes), 24, 30);  
389 - OverlayOptions startOptions = null;  
390 - if (pointBitmap != null) {  
391 - startOptions = new MarkerOptions().position(points.get(0)).icon(BitmapDescriptorFactory.fromBitmap(pointBitmap));  
392 - if (startOptions != null) {  
393 - resultOverlays.add(baiduMap.addOverlay(startOptions)); 381 + try {
  382 + // 绘制新覆盖物前,清空之前的覆盖物
  383 + if (points == null || points.size() == 0) {
  384 + return null;
  385 + }
  386 + List<Overlay> resultOverlays = new ArrayList<>();
  387 + //只有一个点
  388 + if (points.size() == 1) {
  389 + Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), startIconRes), 24, 30);
  390 + OverlayOptions startOptions = null;
  391 + if (pointBitmap != null) {
  392 + startOptions = new MarkerOptions().position(points.get(0)).icon(BitmapDescriptorFactory.fromBitmap(pointBitmap));
  393 + if (startOptions != null) {
  394 + resultOverlays.add(baiduMap.addOverlay(startOptions));
  395 + }
  396 + return resultOverlays;
394 } 397 }
395 - return resultOverlays;  
396 } 398 }
397 - }  
398 399
399 - LatLng startPoint;  
400 - LatLng endPoint;  
401 - if (sortType == SortType.asc) {  
402 - startPoint = points.get(0);  
403 - endPoint = points.get(points.size() - 1);  
404 - } else {  
405 - startPoint = points.get(points.size() - 1);  
406 - endPoint = points.get(0);  
407 - }  
408 - // 添加起点图标  
409 - Bitmap startPointBitmap = null;  
410 - if (null != context.getResources()) {  
411 - startPointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), startIconRes), 24, 30);  
412 - }  
413 - OverlayOptions startOptions = null;  
414 - if (startPointBitmap != null) {  
415 - startOptions = new MarkerOptions()  
416 - .position(startPoint)  
417 - .icon(BitmapDescriptorFactory.fromBitmap(startPointBitmap))  
418 - .perspective(false)  
419 - .animateType(MarkerOptions.MarkerAnimateType.grow);  
420 - }  
421 - // 添加终点图标  
422 - Bitmap endPointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), endIconRes), 24, 30);  
423 - OverlayOptions endOptions = null;  
424 - if (endPointBitmap != null) {  
425 - endOptions = new MarkerOptions()  
426 - .position(endPoint)  
427 - .icon(BitmapDescriptorFactory.fromBitmap(endPointBitmap))  
428 - .perspective(false)  
429 - .anchor(0.6f, 0.96f)  
430 - .animateType(MarkerOptions.MarkerAnimateType.grow);  
431 - }  
432 - // 添加圆形范围  
433 - Bitmap startCircleBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), R.drawable.circle_point_raduis), 60, 60);  
434 - OverlayOptions startCircleOptions = null;  
435 - OverlayOptions endCircleOptions = null;  
436 - if (startCircleBitmap != null) {  
437 - startCircleOptions = new MarkerOptions()  
438 - .position(startPoint)  
439 - .icon(BitmapDescriptorFactory.fromBitmap(startCircleBitmap))  
440 - .perspective(false)  
441 - .anchor(0.5f, 0.6f)  
442 - .animateType(MarkerOptions.MarkerAnimateType.grow);  
443 -  
444 - endCircleOptions = new MarkerOptions()  
445 - .position(endPoint)  
446 - .icon(BitmapDescriptorFactory.fromBitmap(startCircleBitmap))  
447 - .perspective(false)  
448 - .anchor(0.5f, 0.6f)  
449 - .animateType(MarkerOptions.MarkerAnimateType.grow);  
450 - }  
451 - // 添加路线(轨迹)  
452 - OverlayOptions polylineOptions = null;  
453 - if (points != null && points.size() > 1) {  
454 - polylineOptions = new PolylineOptions().width(10)  
455 - .color(context.getResources().getColor(lineColor)).points(points);  
456 - }  
457 - if (endCircleOptions != null) {  
458 - resultOverlays.add(baiduMap.addOverlay(endCircleOptions));  
459 - }  
460 - if (startCircleOptions != null) {  
461 - resultOverlays.add(baiduMap.addOverlay(startCircleOptions));  
462 - }  
463 - if (startOptions != null) {  
464 - resultOverlays.add(baiduMap.addOverlay(startOptions)); 400 + LatLng startPoint;
  401 + LatLng endPoint;
  402 + if (sortType == SortType.asc) {
  403 + startPoint = points.get(0);
  404 + endPoint = points.get(points.size() - 1);
  405 + } else {
  406 + startPoint = points.get(points.size() - 1);
  407 + endPoint = points.get(0);
  408 + }
  409 + // 添加起点图标
  410 + Bitmap startPointBitmap = null;
  411 + if (null != context.getResources()) {
  412 + startPointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), startIconRes), 24, 30);
  413 + }
  414 + OverlayOptions startOptions = null;
  415 + if (startPointBitmap != null) {
  416 + startOptions = new MarkerOptions()
  417 + .position(startPoint)
  418 + .icon(BitmapDescriptorFactory.fromBitmap(startPointBitmap))
  419 + .perspective(false)
  420 + .animateType(MarkerOptions.MarkerAnimateType.grow);
  421 + }
  422 + // 添加终点图标
  423 + Bitmap endPointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), endIconRes), 24, 30);
  424 + OverlayOptions endOptions = null;
  425 + if (endPointBitmap != null) {
  426 + endOptions = new MarkerOptions()
  427 + .position(endPoint)
  428 + .icon(BitmapDescriptorFactory.fromBitmap(endPointBitmap))
  429 + .perspective(false)
  430 + .anchor(0.6f, 0.96f)
  431 + .animateType(MarkerOptions.MarkerAnimateType.grow);
  432 + }
  433 + // 添加圆形范围
  434 + Bitmap startCircleBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), R.drawable.circle_point_raduis), 60, 60);
  435 + OverlayOptions startCircleOptions = null;
  436 + OverlayOptions endCircleOptions = null;
  437 + if (startCircleBitmap != null) {
  438 + startCircleOptions = new MarkerOptions()
  439 + .position(startPoint)
  440 + .icon(BitmapDescriptorFactory.fromBitmap(startCircleBitmap))
  441 + .perspective(false)
  442 + .anchor(0.5f, 0.6f)
  443 + .animateType(MarkerOptions.MarkerAnimateType.grow);
  444 +
  445 + endCircleOptions = new MarkerOptions()
  446 + .position(endPoint)
  447 + .icon(BitmapDescriptorFactory.fromBitmap(startCircleBitmap))
  448 + .perspective(false)
  449 + .anchor(0.5f, 0.6f)
  450 + .animateType(MarkerOptions.MarkerAnimateType.grow);
  451 + }
  452 + // 添加路线(轨迹)
  453 + OverlayOptions polylineOptions = null;
  454 + if (points != null && points.size() > 1) {
  455 + polylineOptions = new PolylineOptions().width(10)
  456 + .color(context.getResources().getColor(lineColor)).points(points);
  457 + }
  458 + if (endCircleOptions != null) {
  459 + resultOverlays.add(baiduMap.addOverlay(endCircleOptions));
  460 + }
  461 + if (startCircleOptions != null) {
  462 + resultOverlays.add(baiduMap.addOverlay(startCircleOptions));
  463 + }
  464 + if (startOptions != null) {
  465 + resultOverlays.add(baiduMap.addOverlay(startOptions));
465 466
466 - }  
467 - if (endOptions != null) {  
468 - resultOverlays.add(baiduMap.addOverlay(endOptions));  
469 - }  
470 - if (polylineOptions != null) {  
471 - resultOverlays.add(baiduMap.addOverlay(polylineOptions)); 467 + }
  468 + if (endOptions != null) {
  469 + resultOverlays.add(baiduMap.addOverlay(endOptions));
  470 + }
  471 + if (polylineOptions != null) {
  472 + resultOverlays.add(baiduMap.addOverlay(polylineOptions));
472 473
473 - }  
474 - if (resultOverlays != null) {  
475 - return resultOverlays;  
476 - } else { 474 + }
  475 + if (resultOverlays != null) {
  476 + return resultOverlays;
  477 + } else {
  478 + return null;
  479 + }
  480 + } catch (Exception e) {
477 return null; 481 return null;
478 } 482 }
479 } 483 }
480 484
481 485
482 - public static Overlay drawMapLine(Context context, BaiduMap baiduMap, List<LatLng> points, int lineColor) { 486 + public static Overlay drawMapLine(Context context, BaiduMap
  487 + baiduMap, List<LatLng> points, int lineColor) {
483 OverlayOptions polylineOptions = new PolylineOptions().width(10) 488 OverlayOptions polylineOptions = new PolylineOptions().width(10)
484 .color(context.getResources().getColor(lineColor)).points(points); 489 .color(context.getResources().getColor(lineColor)).points(points);
485 return baiduMap.addOverlay(polylineOptions); 490 return baiduMap.addOverlay(polylineOptions);
486 } 491 }
487 492
488 - public static Overlay drawMapLineRoutePoint(Context context, BaiduMap baiduMap, List<RoutePoint> points, int lineColor) { 493 + public static Overlay drawMapLineRoutePoint(Context context, BaiduMap
  494 + baiduMap, List<RoutePoint> points, int lineColor) {
489 List<LatLng> latLngs = new ArrayList<>(); 495 List<LatLng> latLngs = new ArrayList<>();
490 for (RoutePoint routePoint : points) { 496 for (RoutePoint routePoint : points) {
491 if (routePoint != null && routePoint.getLat() != 0 && routePoint.getLng() != 0) { 497 if (routePoint != null && routePoint.getLat() != 0 && routePoint.getLng() != 0) {
moudle_pedometer/src/main/res/drawable/shape_circle_30_btn_black_green.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<shape xmlns:android="http://schemas.android.com/apk/res/android">
  3 + <corners android:radius="100dp" />
  4 + <stroke
  5 + android:width="1dp"
  6 + android:color="@color/green_round" />
  7 + <solid android:color="@color/black_20" />
  8 +</shape>
0 \ No newline at end of file 9 \ No newline at end of file
moudle_pedometer/src/main/res/layout/fragment_collect_run_race_detail.xml
@@ -48,12 +48,15 @@ @@ -48,12 +48,15 @@
48 48
49 <Button 49 <Button
50 android:id="@+id/btn_add_trace" 50 android:id="@+id/btn_add_trace"
51 - android:layout_width="wrap_content"  
52 - android:layout_height="wrap_content" 51 + android:layout_width="90dp"
  52 + android:layout_height="35dp"
53 android:layout_gravity="center" 53 android:layout_gravity="center"
54 android:layout_marginBottom="100dp" 54 android:layout_marginBottom="100dp"
  55 + android:background="@drawable/shape_circle_30_btn_black_green"
55 android:text="@string/layout_collect_bind_trace" 56 android:text="@string/layout_collect_bind_trace"
56 - android:textSize="15sp" /> 57 + android:textColor="@color/green_round"
  58 + android:textSize="15sp"
  59 + android:textStyle="bold" />
57 <!----> 60 <!---->
58 <com.cnlive.strike.ui.widget.UIEmptyView 61 <com.cnlive.strike.ui.widget.UIEmptyView
59 android:id="@+id/empty_layout" 62 android:id="@+id/empty_layout"
@@ -71,6 +74,7 @@ @@ -71,6 +74,7 @@
71 android:id="@+id/dragView" 74 android:id="@+id/dragView"
72 android:layout_width="match_parent" 75 android:layout_width="match_parent"
73 android:layout_height="match_parent" 76 android:layout_height="match_parent"
  77 + android:background="@drawable/shape_left_right_10dp_white_raduis_bg"
74 android:clickable="false" 78 android:clickable="false"
75 android:focusable="false"> 79 android:focusable="false">
76 80
@@ -92,7 +96,7 @@ @@ -92,7 +96,7 @@
92 <!----> 96 <!---->
93 <View 97 <View
94 android:layout_width="match_parent" 98 android:layout_width="match_parent"
95 - android:layout_height="20dp" 99 + android:layout_height="10dp"
96 android:background="#F4F4F4" /> 100 android:background="#F4F4F4" />
97 <!--路线介绍--> 101 <!--路线介绍-->
98 <include 102 <include
@@ -101,27 +105,6 @@ @@ -101,27 +105,6 @@
101 </LinearLayout> 105 </LinearLayout>
102 106
103 </ScrollView> 107 </ScrollView>
104 - <!--按钮-->  
105 - <RelativeLayout  
106 - android:id="@+id/rl_scrollView_startBtn"  
107 - android:layout_width="match_parent"  
108 - android:layout_height="40sp"  
109 - android:layout_gravity="bottom"  
110 - android:background="@color/green_round"  
111 - android:tag="0">  
112 -  
113 - <TextView  
114 - android:id="@+id/tv_run_now"  
115 - android:layout_width="wrap_content"  
116 - android:layout_height="wrap_content"  
117 - android:layout_centerInParent="true"  
118 - android:tag="0"  
119 - android:text="@string/layout_collect_bind_trace"  
120 - android:textColor="@color/white"  
121 - android:textSize="18sp" />  
122 -  
123 -  
124 - </RelativeLayout>  
125 </FrameLayout> 108 </FrameLayout>
126 </com.sothree.slidinguppanel.SlidingUpPanelLayout> 109 </com.sothree.slidinguppanel.SlidingUpPanelLayout>
127 110
moudle_pedometer/src/main/res/layout/layout_collect_run_detail_street.xml
@@ -22,7 +22,6 @@ @@ -22,7 +22,6 @@
22 android:id="@+id/ll_first_panel_root" 22 android:id="@+id/ll_first_panel_root"
23 android:layout_width="match_parent" 23 android:layout_width="match_parent"
24 android:layout_height="wrap_content" 24 android:layout_height="wrap_content"
25 - android:background="@drawable/shape_left_right_10dp_white_raduis_bg"  
26 android:orientation="vertical"> 25 android:orientation="vertical">
27 <!--活动标题--> 26 <!--活动标题-->
28 <TextView 27 <TextView
@@ -76,6 +75,15 @@ @@ -76,6 +75,15 @@
76 75
77 </LinearLayout> 76 </LinearLayout>
78 </LinearLayout> 77 </LinearLayout>
  78 +
  79 + <View
  80 + android:layout_width="match_parent"
  81 + android:layout_height="1dp"
  82 + android:layout_marginLeft="35dp"
  83 + android:layout_marginTop="-5dp"
  84 + android:layout_marginRight="35dp"
  85 + android:layout_marginBottom="5dp"
  86 + android:background="@color/line" />
79 </LinearLayout> 87 </LinearLayout>
80 <!----> 88 <!---->
81 <LinearLayout 89 <LinearLayout
@@ -92,8 +100,8 @@ @@ -92,8 +100,8 @@
92 android:gravity="center_vertical"> 100 android:gravity="center_vertical">
93 101
94 <View 102 <View
95 - android:layout_width="10dp"  
96 - android:layout_height="10dp" 103 + android:layout_width="6dp"
  104 + android:layout_height="6dp"
97 android:layout_marginLeft="25dp" 105 android:layout_marginLeft="25dp"
98 android:background="@drawable/shape_circle_green" /> 106 android:background="@drawable/shape_circle_green" />
99 107
@@ -114,6 +122,14 @@ @@ -114,6 +122,14 @@
114 android:textColor="@color/text_black" 122 android:textColor="@color/text_black"
115 android:textSize="15sp" /> 123 android:textSize="15sp" />
116 </LinearLayout> 124 </LinearLayout>
  125 + <!--竖线-->
  126 + <View
  127 + android:layout_width="1dp"
  128 + android:layout_height="20dp"
  129 + android:layout_marginLeft="37dp"
  130 + android:layout_marginTop="-3dp"
  131 + android:layout_marginBottom="-13dp"
  132 + android:background="@color/vertical_line" />
117 <!--终点--> 133 <!--终点-->
118 <LinearLayout 134 <LinearLayout
119 android:id="@+id/ll_end_point" 135 android:id="@+id/ll_end_point"
@@ -124,8 +140,8 @@ @@ -124,8 +140,8 @@
124 android:gravity="center_vertical"> 140 android:gravity="center_vertical">
125 141
126 <View 142 <View
127 - android:layout_width="10dp"  
128 - android:layout_height="10dp" 143 + android:layout_width="6dp"
  144 + android:layout_height="6dp"
129 android:layout_marginLeft="25dp" 145 android:layout_marginLeft="25dp"
130 android:background="@drawable/shape_circle_red" /> 146 android:background="@drawable/shape_circle_red" />
131 147
@@ -189,7 +205,7 @@ @@ -189,7 +205,7 @@
189 android:layout_width="wrap_content" 205 android:layout_width="wrap_content"
190 android:layout_height="match_parent" 206 android:layout_height="match_parent"
191 android:layout_marginLeft="5dp" 207 android:layout_marginLeft="5dp"
192 - android:text="——" 208 + android:text=""
193 android:textColor="@color/text_black" 209 android:textColor="@color/text_black"
194 android:textSize="15sp" /> 210 android:textSize="15sp" />
195 211
@@ -206,9 +222,9 @@ @@ -206,9 +222,9 @@
206 <View 222 <View
207 android:layout_width="match_parent" 223 android:layout_width="match_parent"
208 android:layout_height="1dp" 224 android:layout_height="1dp"
209 - android:layout_marginLeft="10dp" 225 + android:layout_marginLeft="35dp"
210 android:layout_marginTop="5dp" 226 android:layout_marginTop="5dp"
211 - android:layout_marginRight="10dp" 227 + android:layout_marginRight="35dp"
212 android:background="@color/line" /> 228 android:background="@color/line" />
213 <!--活动时间--> 229 <!--活动时间-->
214 <LinearLayout 230 <LinearLayout
@@ -251,7 +267,7 @@ @@ -251,7 +267,7 @@
251 android:layout_width="wrap_content" 267 android:layout_width="wrap_content"
252 android:layout_height="match_parent" 268 android:layout_height="match_parent"
253 android:layout_marginLeft="5dp" 269 android:layout_marginLeft="5dp"
254 - android:text="——" 270 + android:text=""
255 android:textColor="@color/text_black" 271 android:textColor="@color/text_black"
256 android:textSize="15sp" /> 272 android:textSize="15sp" />
257 273
@@ -268,9 +284,9 @@ @@ -268,9 +284,9 @@
268 <View 284 <View
269 android:layout_width="match_parent" 285 android:layout_width="match_parent"
270 android:layout_height="1dp" 286 android:layout_height="1dp"
271 - android:layout_marginLeft="10dp" 287 + android:layout_marginLeft="35dp"
272 android:layout_marginTop="5dp" 288 android:layout_marginTop="5dp"
273 - android:layout_marginRight="10dp" 289 + android:layout_marginRight="35dp"
274 android:background="@color/line" /> 290 android:background="@color/line" />
275 <!--活动类型--> 291 <!--活动类型-->
276 <LinearLayout 292 <LinearLayout
@@ -311,6 +327,15 @@ @@ -311,6 +327,15 @@
311 android:textStyle="bold" /> 327 android:textStyle="bold" />
312 328
313 </LinearLayout> 329 </LinearLayout>
  330 +
  331 + <View
  332 + android:layout_width="match_parent"
  333 + android:layout_height="1dp"
  334 + android:layout_marginLeft="35dp"
  335 + android:layout_marginTop="5dp"
  336 + android:layout_marginRight="35dp"
  337 + android:layout_marginBottom="15dp"
  338 + android:background="@color/line" />
314 </LinearLayout> 339 </LinearLayout>
315 <!----> 340 <!---->
316 </LinearLayout> 341 </LinearLayout>
moudle_pedometer/src/main/res/values/colors.xml
@@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
20 <color name="black_50">#80000000</color> 20 <color name="black_50">#80000000</color>
21 <color name="black_20">#33000000</color> 21 <color name="black_20">#33000000</color>
22 22
  23 +
23 <color name="white_50">#80FFFFFF</color> 24 <color name="white_50">#80FFFFFF</color>
24 25
25 <color name="green">#23D026</color> 26 <color name="green">#23D026</color>