Commit 761995aa3da713ce305f4314d7ccb067d89e06f7

Authored by 杨帅
1 parent f4aa2c68

1.赛事详情

Showing 27 changed files with 1051 additions and 60 deletions
library_baidumap/build.gradle
@@ -43,4 +43,11 @@ dependencies { @@ -43,4 +43,11 @@ dependencies {
43 implementation "com.alibaba:arouter-api:$rootProject.arouterApiVersion" 43 implementation "com.alibaba:arouter-api:$rootProject.arouterApiVersion"
44 annotationProcessor "com.alibaba:arouter-compiler:$rootProject.arouterCompilerVersion" 44 annotationProcessor "com.alibaba:arouter-compiler:$rootProject.arouterCompilerVersion"
45 api files('libs/BaiduLBS_Android.jar') 45 api files('libs/BaiduLBS_Android.jar')
  46 + api files('libs/BaiduTraceSDK_v3_1_0.jar')
  47 + api files('libs/bos-android-sdk-1.0.3.jar')
  48 +// api files('libs/okhttp-3.8.1.jar')
  49 +// api files('libs/okio-1.13.0.jar')
  50 +
46 } 51 }
  52 +
  53 +
library_baidumap/libs/BaiduTraceSDK_v3_1_0.jar 0 → 100644
No preview for this file type
library_baidumap/libs/bos-android-sdk-1.0.3.jar 0 → 100644
No preview for this file type
library_baidumap/libs/okhttp-3.8.1.jar 0 → 100644
No preview for this file type
library_baidumap/libs/okio-1.13.0.jar 0 → 100644
No preview for this file type
library_baidumap/src/main/AndroidManifest.xml
@@ -24,6 +24,12 @@ @@ -24,6 +24,12 @@
24 android:name="com.baidu.location.f" 24 android:name="com.baidu.location.f"
25 android:enabled="true" 25 android:enabled="true"
26 android:process=":remote" /> 26 android:process=":remote" />
  27 +
  28 + <service
  29 + android:name="com.baidu.trace.LBSTraceService"
  30 + android:enabled="true"
  31 + android:process=":remote"></service>
  32 +
27 <activity android:name="com.cnlive.baidumap.BaiduMapMainActivity"></activity> 33 <activity android:name="com.cnlive.baidumap.BaiduMapMainActivity"></activity>
28 </application> 34 </application>
29 35
library_baidumap/src/main/java/com/cnlive/baidumap/InitBaidu.java deleted 100644 → 0
1 -package com.cnlive.baidumap;  
2 -  
3 -import android.content.Context;  
4 -  
5 -import com.baidu.mapapi.CoordType;  
6 -import com.baidu.mapapi.SDKInitializer;  
7 -  
8 -public class InitBaidu {  
9 - public static void init(Context context) {  
10 - //在使用SDK各组件之前初始化context信息,传入ApplicationContext  
11 - SDKInitializer.initialize(context);  
12 - //自4.3.0起,百度地图SDK所有接口均支持百度坐标和国测局坐标,用此方法设置您使用的坐标类型.  
13 - //包括BD09LL和GCJ02两种坐标,默认是BD09LL坐标。  
14 - SDKInitializer.setCoordType(CoordType.GCJ02);  
15 - }  
16 -}  
library_baidumap/src/main/jniLibs/arm64-v8a/libBaiduTraceSDK_v3_1_0.so 0 → 100644
No preview for this file type
library_baidumap/src/main/jniLibs/armeabi-v7a/libBaiduTraceSDK_v3_1_0.so 0 → 100644
No preview for this file type
library_baidumap/src/main/jniLibs/armeabi/libBaiduTraceSDK_v3_1_0.so 0 → 100644
No preview for this file type
library_baidumap/src/main/jniLibs/x86/libBaiduTraceSDK_v3_1_0.so 0 → 100644
No preview for this file type
library_baidumap/src/main/jniLibs/x86_64/libBaiduTraceSDK_v3_1_0.so 0 → 100644
No preview for this file type
moudle_pedometer/build.gradle
@@ -110,3 +110,9 @@ dependencies { @@ -110,3 +110,9 @@ dependencies {
110 implementation project(':library_baidumap') 110 implementation project(':library_baidumap')
111 111
112 } 112 }
  113 +
  114 +configurations {
  115 + all*.exclude group: 'com.squareup.okhttp3', module: 'okhttp'
  116 + all*.exclude group: 'com.squareup.okio'
  117 +
  118 +}
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/presenter/RunningMapFragmentPresenter.java
1 package com.cnlive.moudle.pedometer.frame.presenter; 1 package com.cnlive.moudle.pedometer.frame.presenter;
2 2
  3 +import android.content.Context;
  4 +import android.graphics.Bitmap;
  5 +import android.graphics.BitmapFactory;
  6 +import android.widget.Toast;
  7 +
  8 +import com.baidu.mapapi.map.BitmapDescriptorFactory;
  9 +import com.baidu.mapapi.map.MarkerOptions;
  10 +import com.baidu.mapapi.map.OverlayOptions;
  11 +import com.baidu.mapapi.model.LatLng;
  12 +import com.baidu.trace.api.entity.EntityListResponse;
  13 +import com.baidu.trace.api.entity.OnEntityListener;
  14 +import com.baidu.trace.api.entity.UpdateEntityResponse;
  15 +import com.baidu.trace.api.track.HistoryTrackRequest;
  16 +import com.baidu.trace.api.track.HistoryTrackResponse;
  17 +import com.baidu.trace.api.track.LatestPointResponse;
  18 +import com.baidu.trace.api.track.OnTrackListener;
  19 +import com.baidu.trace.api.track.SupplementMode;
  20 +import com.baidu.trace.api.track.TrackPoint;
  21 +import com.baidu.trace.model.ProcessOption;
  22 +import com.baidu.trace.model.SortType;
  23 +import com.baidu.trace.model.StatusCodes;
  24 +import com.baidu.trace.model.TraceLocation;
  25 +import com.baidu.trace.model.TransportMode;
3 import com.cnlive.moudle.pedometer.frame.view.RunningMapFragmentView; 26 import com.cnlive.moudle.pedometer.frame.view.RunningMapFragmentView;
  27 +import com.cnlive.moudle.pedometer.model.Constant;
  28 +import com.cnlive.moudle.pedometer.service.StepService;
  29 +import com.cnlive.moudle.pedometer.utils.BitmapUtil;
  30 +import com.cnlive.moudle.pedometer.utils.CommonUtil;
  31 +import com.cnlive.moudle.pedometer.utils.MapUtil;
  32 +import com.cnlive.moudle.pedometer.utils.MyMapUtil;
  33 +import com.example.moudle_pedometer.R;
4 import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; 34 import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
5 35
  36 +import java.util.ArrayList;
  37 +import java.util.List;
  38 +
6 public class RunningMapFragmentPresenter extends MvpBasePresenter<RunningMapFragmentView> { 39 public class RunningMapFragmentPresenter extends MvpBasePresenter<RunningMapFragmentView> {
  40 + /******轨迹查询相关******/
  41 + //分页大小
  42 + private int pageSize = 1000;
  43 + //分页索引
  44 + private int pageIndex = 1;
  45 + /**
  46 + * 历史轨迹请求
  47 + */
  48 + private HistoryTrackRequest historyTrackRequest;
  49 + /**
  50 + * 轨迹点集合
  51 + */
  52 + private List<LatLng> trackPoints;
  53 +
  54 + /**
  55 + * 查询历史轨迹
  56 + *
  57 + * @param startTime
  58 + * @param endTime
  59 + */
  60 + public void queryHistoryTrace(Context context, String entityName, long startTime, long endTime) {
  61 + if (historyTrackRequest == null) {
  62 + historyTrackRequest = new HistoryTrackRequest();
  63 + //设置查询设备名称
  64 + historyTrackRequest.setEntityName(entityName);
  65 + //历史轨迹开始时间
  66 + historyTrackRequest.setStartTime(startTime);
  67 + //历史轨迹结束时间
  68 + historyTrackRequest.setEndTime(endTime);
  69 + //分页索引
  70 + historyTrackRequest.setPageIndex(pageIndex);
  71 + //分页大小
  72 + historyTrackRequest.setPageSize(pageSize);
  73 + //设置是否进行纠偏
  74 + historyTrackRequest.setProcessed(true);
  75 + //其他设置
  76 + ProcessOption processOption = new ProcessOption();
  77 + //去噪:可设置是否需要去除角度、速度和方向异常的轨迹点
  78 + processOption.setNeedDenoise(true);
  79 + //绑路:设置是否将轨迹点绑定至路网道路
  80 + processOption.setNeedMapMatch(false);
  81 + //抽稀:设置是否进行抽稀处理,对冗余的轨迹点进行抽稀去除处理,如一条直线上除起终点外的多个轨迹点
  82 + processOption.setNeedVacuate(true);
  83 + //自动判断交通方式
  84 + processOption.setTransportMode(TransportMode.auto);
  85 + // 设置精度过滤值(定位精度大于100米的过滤掉)
  86 + processOption.setRadiusThreshold(100);
  87 + // 设置纠偏选项
  88 + historyTrackRequest.setProcessOption(processOption);
  89 + // 设置里程填充方式为驾车
  90 + historyTrackRequest.setSupplementMode(SupplementMode.walking);
  91 +
  92 + }
  93 + if (trackPoints == null) {
  94 + trackPoints = new ArrayList<>();
  95 + }
  96 + //轨迹查询监听器
  97 + OnTrackListener historyTrackListener = new OnTrackListener() {
  98 + @Override
  99 + public void onHistoryTrackCallback(HistoryTrackResponse response) {
  100 + super.onHistoryTrackCallback(response);
  101 + int total = response.getTotal();
  102 + if (StatusCodes.SUCCESS != response.getStatus()) {
  103 + } else if (0 == total) {
  104 + Toast.makeText(context, "暂未查到您的轨迹,请稍后重试!", Toast.LENGTH_SHORT).show();
  105 + } else {
  106 + //查询到轨迹
  107 + List<TrackPoint> points = response.getTrackPoints();
  108 + if (null != points) {
  109 + for (TrackPoint trackPoint : points) {
  110 + if (!CommonUtil.isZeroPoint(trackPoint.getLocation().getLatitude(),
  111 + trackPoint.getLocation().getLongitude())) {
  112 + //将轨迹点转换为地图坐标点
  113 + trackPoints.add(MyMapUtil.convertTrace2Map(trackPoint.getLocation()));
  114 + }
  115 + }
  116 + }
  117 + }
  118 + if (total > pageSize * pageIndex) {
  119 + historyTrackRequest.setPageIndex(++pageIndex);
  120 + queryHistoryTrace(context, entityName, startTime, endTime);
  121 + } else {
  122 + if (getView() != null) {
  123 + MyMapUtil.drawHistoryTrack(context, getView().baiduMap, trackPoints, SortType.asc, R.color.red, R.drawable.icon_start, R.drawable.run_map_icon_end);
  124 + }
  125 + }
  126 + }
  127 +
  128 + @Override
  129 + public void onLatestPointCallback(LatestPointResponse latestPointResponse) {
  130 + super.onLatestPointCallback(latestPointResponse);
  131 + if (StatusCodes.SUCCESS != latestPointResponse.getStatus()) {
  132 + } else {
  133 + Bitmap startPointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), R.drawable.run_map_icon_start), 40, 40);
  134 + OverlayOptions startOptions = new MarkerOptions()
  135 + .position(MyMapUtil.convertTrace2Map(latestPointResponse.getLatestPoint().getLocation())).icon(BitmapDescriptorFactory.fromBitmap(startPointBitmap));
  136 + if (getView() != null) {
  137 + getView().baiduMap.addOverlay(startOptions);
  138 + }
  139 + }
  140 + }
  141 + };
  142 + //开始查询历史轨迹
  143 + if (StepService.mClient != null) {
  144 + StepService.mClient.queryHistoryTrack(historyTrackRequest, historyTrackListener);
  145 +
  146 + }
  147 +
  148 + }
  149 +
7 } 150 }
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunMainFragmentView.java
@@ -34,6 +34,7 @@ public class RunMainFragmentView implements MvpView { @@ -34,6 +34,7 @@ public class RunMainFragmentView implements MvpView {
34 private int stopIndex = 0;//停止按钮,计数 34 private int stopIndex = 0;//停止按钮,计数
35 private Handler handler; 35 private Handler handler;
36 private Runnable runnable; 36 private Runnable runnable;
  37 + private Runnable animRunnable;
37 38
38 private long mRecordTime;//计时时间 39 private long mRecordTime;//计时时间
39 private boolean firstTimeFlag;//是否是首次计时 40 private boolean firstTimeFlag;//是否是首次计时
@@ -217,31 +218,39 @@ public class RunMainFragmentView implements MvpView { @@ -217,31 +218,39 @@ public class RunMainFragmentView implements MvpView {
217 218
218 ButtonAnimUtil.setViewZoomIn(fragment.binding.flStop); 219 ButtonAnimUtil.setViewZoomIn(fragment.binding.flStop);
219 stopStartFlag = true; 220 stopStartFlag = true;
220 - runnable = new Runnable() { 221 + animRunnable = new Runnable() {
221 @Override 222 @Override
222 public void run() { 223 public void run() {
223 if (stopStartFlag) { 224 if (stopStartFlag) {
224 stopIndex += 5; 225 stopIndex += 5;
225 if (stopIndex <= 100) { 226 if (stopIndex <= 100) {
226 - handler.postDelayed(runnable, 20); 227 + handler.postDelayed(animRunnable, 20);
227 fragment.binding.cpCurrent.setProgress(stopIndex); 228 fragment.binding.cpCurrent.setProgress(stopIndex);
228 fragment.binding.flStopTip.setVisibility(View.VISIBLE); 229 fragment.binding.flStopTip.setVisibility(View.VISIBLE);
229 if (stopIndex == 100) { 230 if (stopIndex == 100) {
230 // 231 //
231 fragment.binding.flStopTip.setVisibility(View.INVISIBLE); 232 fragment.binding.flStopTip.setVisibility(View.INVISIBLE);
232 233
  234 +
233 SelectDialog selectDialog = new SelectDialog(fragment.getActivity(), "确定结束运动吗?", "确定", new SelectDialog.DialogInterface() { 235 SelectDialog selectDialog = new SelectDialog(fragment.getActivity(), "确定结束运动吗?", "确定", new SelectDialog.DialogInterface() {
234 @Override 236 @Override
235 public void onClick(SelectDialog dialog) { 237 public void onClick(SelectDialog dialog) {
  238 + fragment.binding.cpCurrent.setVisibility(View.GONE);
  239 + ButtonAnimUtil.setViewDefault(fragment.binding.flStop);
236 fragment.getActivity().stopService(new Intent(fragment.getActivity(), StepService.class)); 240 fragment.getActivity().stopService(new Intent(fragment.getActivity(), StepService.class));
237 //清空数据 241 //清空数据
238 StepUtil.clearRunData(getContext(), uid); 242 StepUtil.clearRunData(getContext(), uid);
239 dialog.dismiss(); 243 dialog.dismiss();
  244 + if (StepService.mClient != null) {
  245 + StepService.mClient.stopGather(StepService.traceListener);
  246 + }
240 // fragment.getActivity().finish(); 247 // fragment.getActivity().finish();
241 } 248 }
242 }, "取消", new SelectDialog.DialogInterface() { 249 }, "取消", new SelectDialog.DialogInterface() {
243 @Override 250 @Override
244 public void onClick(SelectDialog dialog) { 251 public void onClick(SelectDialog dialog) {
  252 + fragment.binding.cpCurrent.setVisibility(View.GONE);
  253 + ButtonAnimUtil.setViewDefault(fragment.binding.flStop);
245 dialog.cancel(); 254 dialog.cancel();
246 } 255 }
247 }); 256 });
@@ -254,7 +263,7 @@ public class RunMainFragmentView implements MvpView { @@ -254,7 +263,7 @@ public class RunMainFragmentView implements MvpView {
254 } 263 }
255 } 264 }
256 }; 265 };
257 - handler.postDelayed(runnable, 20); 266 + handler.postDelayed(animRunnable, 20);
258 267
259 } 268 }
260 } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { 269 } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
@@ -44,8 +44,6 @@ import com.baidu.mapapi.search.route.WalkingRouteResult; @@ -44,8 +44,6 @@ import com.baidu.mapapi.search.route.WalkingRouteResult;
44 import com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity; 44 import com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity;
45 import com.cnlive.moudle.pedometer.ui.activity.RaceRecordActivity; 45 import com.cnlive.moudle.pedometer.ui.activity.RaceRecordActivity;
46 import com.cnlive.moudle.pedometer.ui.activity.RegistrationInfoActivity; 46 import com.cnlive.moudle.pedometer.ui.activity.RegistrationInfoActivity;
47 -import com.cnlive.moudle.pedometer.ui.activity.RunningMapActivity;  
48 -import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment;  
49 import com.cnlive.moudle.pedometer.ui.fragment.RunRaceDetailFragment; 47 import com.cnlive.moudle.pedometer.ui.fragment.RunRaceDetailFragment;
50 import com.cnlive.moudle.pedometer.utils.BitmapUtil; 48 import com.cnlive.moudle.pedometer.utils.BitmapUtil;
51 import com.cnlive.moudle.pedometer.utils.ScreenUtil; 49 import com.cnlive.moudle.pedometer.utils.ScreenUtil;
@@ -53,8 +51,8 @@ import com.example.moudle_pedometer.R; @@ -53,8 +51,8 @@ import com.example.moudle_pedometer.R;
53 import com.hannesdorfmann.mosby3.mvp.MvpView; 51 import com.hannesdorfmann.mosby3.mvp.MvpView;
54 import com.sothree.slidinguppanel.SlidingUpPanelLayout; 52 import com.sothree.slidinguppanel.SlidingUpPanelLayout;
55 53
56 -import java.io.LineNumberReader;  
57 import java.util.ArrayList; 54 import java.util.ArrayList;
  55 +import java.util.LinkedList;
58 import java.util.List; 56 import java.util.List;
59 57
60 public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { 58 public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
@@ -68,7 +66,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -68,7 +66,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
68 private BitmapDescriptor mCurrentMarker;//定位图标 66 private BitmapDescriptor mCurrentMarker;//定位图标
69 private static int accuracyCircleFillColor; 67 private static int accuracyCircleFillColor;
70 private static int accuracyCircleStrokeColor; 68 private static int accuracyCircleStrokeColor;
71 - private static MyLocationData mylocation; 69 + private static MyLocationData followMyLocation;
72 boolean isFirstLoc = true; // 是否首次定位 70 boolean isFirstLoc = true; // 是否首次定位
73 private MarkerOptions currentMark; 71 private MarkerOptions currentMark;
74 private MarkerOptions endMark; 72 private MarkerOptions endMark;
@@ -77,8 +75,8 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -77,8 +75,8 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
77 private LatLng firstLatLng; 75 private LatLng firstLatLng;
78 private Double lastX = 0.0; 76 private Double lastX = 0.0;
79 private int mCurrentDirection = 0; 77 private int mCurrentDirection = 0;
80 - private double mCurrentLat = 0.0;  
81 - private double mCurrentLon = 0.0; 78 + // private double mCurrentLat = 0.0;
  79 +// private double mCurrentLon = 0.0;
82 private float mCurrentAccracy; 80 private float mCurrentAccracy;
83 // 定位相关 81 // 定位相关
84 private LocationClient mLocClient; 82 private LocationClient mLocClient;
@@ -92,8 +90,8 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -92,8 +90,8 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
92 private String startPoint = "首都师范大学南门"; 90 private String startPoint = "首都师范大学南门";
93 private String endPoint = "首都师范大学篮球场"; 91 private String endPoint = "首都师范大学篮球场";
94 92
95 - private List<LatLng> importLatLngs;//关键点  
96 - private LatLng startLatLng = new LatLng(39.934266, 116.309228);//起始点 93 + private LinkedList<LatLng> importLatLngs;//关键点
  94 + private LatLng startLatLng = new LatLng(39.934733, 116.308646);//起始点
97 95
98 public RunRaceDetailFragmentView(RunRaceDetailFragment fragment) { 96 public RunRaceDetailFragmentView(RunRaceDetailFragment fragment) {
99 this.fragment = fragment; 97 this.fragment = fragment;
@@ -109,17 +107,20 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -109,17 +107,20 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
109 } 107 }
110 initMap(); 108 initMap();
111 //初始化运营人员所选的关键点 109 //初始化运营人员所选的关键点
112 - importLatLngs = new ArrayList<>();  
113 - //北轨山区社区  
114 -// importLatLngs.add(new LatLng(39.933295, 116.308663));  
115 - //中国体育彩票  
116 - importLatLngs.add(new LatLng(39.933065, 116.309838));  
117 - //花园桥招待所  
118 - importLatLngs.add(new LatLng(39.933094, 116.310927));  
119 -// //砂锅时代问题  
120 -// importLatLngs.add(new LatLng(39.933481, 116.311834));  
121 -// //好邻居便利店  
122 - importLatLngs.add(new LatLng(39.933736, 116.312365)); 110 + importLatLngs = new LinkedList<>();
  111 +// importLatLngs.add(new LatLng(39.935861,116.308621));
  112 +// importLatLngs.add(new LatLng( 39.934948,116.308605));
  113 +// importLatLngs.add(new LatLng( 39.934516,116.3086));
  114 +// importLatLngs.add(new LatLng( 39.934121,116.30861));
  115 +// importLatLngs.add(new LatLng( 39.934105,116.308605));
  116 +//
  117 +//
  118 +// importLatLngs.add(new LatLng( 39.933702,116.3086));
  119 + importLatLngs.add(new LatLng(39.933890, 116.308726));
  120 + importLatLngs.add(new LatLng(39.933943, 116.309627));
  121 + importLatLngs.add(new LatLng(39.934733, 116.309515));
  122 + importLatLngs.add(new LatLng(39.934733, 116.308742));
  123 +
123 124
124 // searchRouteResult(new LatLng(39.934266, 116.309228), new LatLng(39.939756, 116.319766), 0); 125 // searchRouteResult(new LatLng(39.934266, 116.309228), new LatLng(39.939756, 116.319766), 0);
125 126
@@ -269,7 +270,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -269,7 +270,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
269 /** 270 /**
270 * 开始路线规划 271 * 开始路线规划
271 */ 272 */
272 - public void searchRouteResult(LatLng StartPoint, LatLng EndPoint, int index) { 273 + public void searchRouteResult(LatLng StartPoint, LatLng EndPoint, int index, int listSize) {
273 Log.e(TAG, "searchRouteResult: "); 274 Log.e(TAG, "searchRouteResult: ");
274 float currentZoom = baiduMap.getMapStatus().zoom; 275 float currentZoom = baiduMap.getMapStatus().zoom;
275 // 设置起终点信息,对于tranist search 来说,城市名无意义 276 // 设置起终点信息,对于tranist search 来说,城市名无意义
@@ -278,7 +279,6 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -278,7 +279,6 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
278 routePlanSearch.setOnGetRoutePlanResultListener(new OnGetRoutePlanResultListener() { 279 routePlanSearch.setOnGetRoutePlanResultListener(new OnGetRoutePlanResultListener() {
279 @Override 280 @Override
280 public void onGetWalkingRouteResult(WalkingRouteResult walkingRouteResult) { 281 public void onGetWalkingRouteResult(WalkingRouteResult walkingRouteResult) {
281 - Log.e(TAG, "onGetWalkingRouteResult: ");  
282 if (fragment.getActivity() == null) { 282 if (fragment.getActivity() == null) {
283 return; 283 return;
284 } 284 }
@@ -293,7 +293,9 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -293,7 +293,9 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
293 if (walkingRouteResult.getRouteLines() != null) { 293 if (walkingRouteResult.getRouteLines() != null) {
294 if (walkingRouteResult.getRouteLines().get(0).getAllStep().get(0).getWayPoints().size() > 0) { 294 if (walkingRouteResult.getRouteLines().get(0).getAllStep().get(0).getWayPoints().size() > 0) {
295 //添加起点坐标 295 //添加起点坐标
296 -// points.add(StartPoint); 296 + if (index == 0) {
  297 + points.add(StartPoint);
  298 + }
297 for (int i = 0; i < walkingRouteResult.getRouteLines().get(0).getAllStep().size(); i++) { 299 for (int i = 0; i < walkingRouteResult.getRouteLines().get(0).getAllStep().size(); i++) {
298 for (int j = 0; j < walkingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().size(); j++) { 300 for (int j = 0; j < walkingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().size(); j++) {
299 points.add(walkingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().get(j)); 301 points.add(walkingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().get(j));
@@ -301,9 +303,9 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -301,9 +303,9 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
301 } 303 }
302 } 304 }
303 //添加终点坐标 305 //添加终点坐标
304 -// if (endLatLng != null) { 306 + if (endLatLng != null) {
305 // points.add(endLatLng); 307 // points.add(endLatLng);
306 -// } 308 + }
307 309
308 ArrayList<Integer> traffics = new ArrayList<Integer>(); 310 ArrayList<Integer> traffics = new ArrayList<Integer>();
309 for (int i = 0; i < points.size(); i++) { 311 for (int i = 0; i < points.size(); i++) {
@@ -333,7 +335,26 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -333,7 +335,26 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
333 .points(points) 335 .points(points)
334 .customTextureList(getCustomTextureList()) 336 .customTextureList(getCustomTextureList())
335 .textureIndex(traffics);//设置纹理列表 337 .textureIndex(traffics);//设置纹理列表
336 - //在地图上绘制折线 338 + //在地图上绘制起点
  339 + if (index == 0) {
  340 + //显示当前位置图标
  341 + Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.icon_start), 30, 30);
  342 + startMark = new MarkerOptions()
  343 + .position(StartPoint)
  344 + .icon(BitmapDescriptorFactory.fromBitmap(pointBitmap));
  345 +// startMark.anchor(0.5f, 0.55f);
  346 + baiduMap.addOverlay(startMark);
  347 + } else if (index == listSize - 1) {
  348 + //显示当前位置图标
  349 + Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.icon_end), 30, 30);
  350 + endMark = new MarkerOptions()
  351 + .position(points.get(points.size()-1))
  352 + .icon(BitmapDescriptorFactory.fromBitmap(pointBitmap))
  353 + .perspective(true)
  354 +// endMark.anchor(0.5f, 0.5f)
  355 + .perspective(true);
  356 + baiduMap.addOverlay(endMark);
  357 + }
337 //mPloyline 折线对象 358 //mPloyline 折线对象
338 Overlay mPolyline = baiduMap.addOverlay(mOverlayOptions); 359 Overlay mPolyline = baiduMap.addOverlay(mOverlayOptions);
339 MapStatus.Builder builder = new MapStatus.Builder(); 360 MapStatus.Builder builder = new MapStatus.Builder();
@@ -371,8 +392,8 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -371,8 +392,8 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
371 if (drivingRouteResult.getRouteLines() != null) { 392 if (drivingRouteResult.getRouteLines() != null) {
372 if (drivingRouteResult.getRouteLines().get(0).getAllStep().get(0).getWayPoints().size() > 0) { 393 if (drivingRouteResult.getRouteLines().get(0).getAllStep().get(0).getWayPoints().size() > 0) {
373 //添加起点坐标 394 //添加起点坐标
374 - if (mylocation != null) {  
375 - points.add(new LatLng(mylocation.latitude, mylocation.longitude)); 395 + if (followMyLocation != null) {
  396 + points.add(new LatLng(followMyLocation.latitude, followMyLocation.longitude));
376 } 397 }
377 for (int i = 0; i < drivingRouteResult.getRouteLines().get(0).getAllStep().size(); i++) { 398 for (int i = 0; i < drivingRouteResult.getRouteLines().get(0).getAllStep().size(); i++) {
378 for (int j = 0; j < drivingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().size(); j++) { 399 for (int j = 0; j < drivingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().size(); j++) {
@@ -459,12 +480,12 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -459,12 +480,12 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
459 if (Math.abs(x - lastX) > 1.0) { 480 if (Math.abs(x - lastX) > 1.0) {
460 mCurrentDirection = (int) x; 481 mCurrentDirection = (int) x;
461 if (firstLatLng != null) { 482 if (firstLatLng != null) {
462 - mylocation = new MyLocationData.Builder() 483 + followMyLocation = new MyLocationData.Builder()
463 .accuracy(mCurrentAccracy) 484 .accuracy(mCurrentAccracy)
464 // 此处设置开发者获取到的方向信息,顺时针0-360 485 // 此处设置开发者获取到的方向信息,顺时针0-360
465 .direction(mCurrentDirection).latitude(firstLatLng.latitude) 486 .direction(mCurrentDirection).latitude(firstLatLng.latitude)
466 .longitude(firstLatLng.longitude).build(); 487 .longitude(firstLatLng.longitude).build();
467 - baiduMap.setMyLocationData(mylocation); 488 + baiduMap.setMyLocationData(followMyLocation);
468 } 489 }
469 } 490 }
470 lastX = x; 491 lastX = x;
@@ -527,12 +548,12 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -527,12 +548,12 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
527 // mCurrentLat = location.getLatitude(); 548 // mCurrentLat = location.getLatitude();
528 // mCurrentLon = location.getLongitude(); 549 // mCurrentLon = location.getLongitude();
529 mCurrentAccracy = location.getRadius(); 550 mCurrentAccracy = location.getRadius();
530 - mylocation = new MyLocationData.Builder() 551 + followMyLocation = new MyLocationData.Builder()
531 .accuracy(location.getRadius()) 552 .accuracy(location.getRadius())
532 // 此处设置开发者获取到的方向信息,顺时针0-360 553 // 此处设置开发者获取到的方向信息,顺时针0-360
533 .direction(location.getDirection()).latitude(location.getLatitude()) 554 .direction(location.getDirection()).latitude(location.getLatitude())
534 .longitude(location.getLongitude()).build(); 555 .longitude(location.getLongitude()).build();
535 - if (mylocation == null) { 556 + if (followMyLocation == null) {
536 return; 557 return;
537 } 558 }
538 559
@@ -542,7 +563,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -542,7 +563,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
542 isFirstLoc = false; 563 isFirstLoc = false;
543 firstLatLng = new LatLng(location.getLatitude(), 564 firstLatLng = new LatLng(location.getLatitude(),
544 location.getLongitude()); 565 location.getLongitude());
545 - baiduMap.setMyLocationData(mylocation); 566 + baiduMap.setMyLocationData(followMyLocation);
546 builder.target(firstLatLng).zoom(DEFULT_ZOOM); 567 builder.target(firstLatLng).zoom(DEFULT_ZOOM);
547 baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); 568 baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
548 569
@@ -558,13 +579,13 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -558,13 +579,13 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
558 //开始分段规划路径 579 //开始分段规划路径
559 //第一个点 580 //第一个点
560 if (index == 0) { 581 if (index == 0) {
561 - searchRouteResult(startLatLng, importLatLngs.get(index), 0); 582 + searchRouteResult(startLatLng, importLatLngs.get(index), 0, importLatLngs.size());
562 } else { 583 } else {
563 - searchRouteResult(importLatLngs.get(index - 1), importLatLngs.get(index), index); 584 + searchRouteResult(importLatLngs.get(index - 1), importLatLngs.get(index), index, importLatLngs.size());
564 } 585 }
565 } 586 }
566 } else { 587 } else {
567 - searchRouteResult(startLatLng, endLatLng, 0); 588 + searchRouteResult(startLatLng, endLatLng, 0, importLatLngs.size());
568 } 589 }
569 } 590 }
570 591
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunningMapFragmentView.java
@@ -42,7 +42,7 @@ import org.greenrobot.eventbus.EventBus; @@ -42,7 +42,7 @@ import org.greenrobot.eventbus.EventBus;
42 public class RunningMapFragmentView implements MvpView, SensorEventListener { 42 public class RunningMapFragmentView implements MvpView, SensorEventListener {
43 private static final String TAG = "RunningMapFragmentView"; 43 private static final String TAG = "RunningMapFragmentView";
44 private RunningMapFragment fragment; 44 private RunningMapFragment fragment;
45 - private BaiduMap baiduMap; 45 + public BaiduMap baiduMap;
46 private MapView mMapView; 46 private MapView mMapView;
47 private UiSettings mUiSettings; 47 private UiSettings mUiSettings;
48 private MyLocationConfiguration.LocationMode mCurrentMode;//定位模式 48 private MyLocationConfiguration.LocationMode mCurrentMode;//定位模式
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/model/Constant.java
@@ -7,5 +7,4 @@ public class Constant { @@ -7,5 +7,4 @@ public class Constant {
7 public static final int SERVICE_STEP_COUNT_RESET_SPEED = 3;//重置速度 7 public static final int SERVICE_STEP_COUNT_RESET_SPEED = 3;//重置速度
8 public static final int FRAGMENT_RUN_CHRONOMETER = 4;//同步计时器 8 public static final int FRAGMENT_RUN_CHRONOMETER = 4;//同步计时器
9 9
10 -  
11 } 10 }
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/StepService.java
@@ -11,6 +11,7 @@ import android.content.ComponentName; @@ -11,6 +11,7 @@ import android.content.ComponentName;
11 import android.content.Context; 11 import android.content.Context;
12 import android.content.Intent; 12 import android.content.Intent;
13 import android.content.IntentFilter; 13 import android.content.IntentFilter;
  14 +import android.content.SharedPreferences;
14 import android.hardware.Sensor; 15 import android.hardware.Sensor;
15 import android.hardware.SensorEvent; 16 import android.hardware.SensorEvent;
16 import android.hardware.SensorEventListener; 17 import android.hardware.SensorEventListener;
@@ -23,7 +24,21 @@ import android.os.IBinder; @@ -23,7 +24,21 @@ import android.os.IBinder;
23 import android.support.v4.app.NotificationCompat; 24 import android.support.v4.app.NotificationCompat;
24 import android.util.Log; 25 import android.util.Log;
25 import android.widget.RemoteViews; 26 import android.widget.RemoteViews;
26 - 27 +import android.widget.Toast;
  28 +
  29 +import com.baidu.mapapi.model.LatLng;
  30 +import com.baidu.trace.LBSTraceClient;
  31 +import com.baidu.trace.Trace;
  32 +import com.baidu.trace.api.entity.OnEntityListener;
  33 +import com.baidu.trace.api.fence.FenceAlarmPushInfo;
  34 +import com.baidu.trace.api.fence.MonitoredAction;
  35 +import com.baidu.trace.api.track.LatestPoint;
  36 +import com.baidu.trace.api.track.LatestPointResponse;
  37 +import com.baidu.trace.api.track.OnTrackListener;
  38 +import com.baidu.trace.model.OnTraceListener;
  39 +import com.baidu.trace.model.PushMessage;
  40 +import com.baidu.trace.model.StatusCodes;
  41 +import com.baidu.trace.model.TraceLocation;
27 import com.cnlive.moudle.pedometer.model.Constant; 42 import com.cnlive.moudle.pedometer.model.Constant;
28 import com.cnlive.moudle.pedometer.model.MessageEvent; 43 import com.cnlive.moudle.pedometer.model.MessageEvent;
29 import com.cnlive.moudle.pedometer.model.step.StepCount; 44 import com.cnlive.moudle.pedometer.model.step.StepCount;
@@ -115,6 +130,33 @@ public class StepService extends Service implements SensorEventListener { @@ -115,6 +130,33 @@ public class StepService extends Service implements SensorEventListener {
115 private static int speedCurrentStep;//用于检测速度步数 130 private static int speedCurrentStep;//用于检测速度步数
116 private boolean updateSpeedStepFlag;//是否是已经更新速度 131 private boolean updateSpeedStepFlag;//是否是已经更新速度
117 132
  133 + /****************************************************鹰眼轨迹相关************************************************/
  134 + /**
  135 + * 轨迹服务监听器
  136 + */
  137 + public static OnTraceListener traceListener = null;
  138 + /**
  139 + * 轨迹监听器(用于接收纠偏后实时位置回调)
  140 + */
  141 + private OnTrackListener realTimeTraceListener = null;
  142 + //位置采集周期
  143 + private int gatherInterval = 5;
  144 + //打包周期
  145 + private int packInterval = 30;
  146 + // 轨迹服务ID
  147 + public static final long serviceId = 213511;
  148 + // 设备标识
  149 + public static String entityName = "";
  150 + /**
  151 + * 轨迹客户端
  152 + */
  153 + public static LBSTraceClient mClient = null;
  154 +
  155 + /**
  156 + * 轨迹服务
  157 + */
  158 + public Trace mTrace = null;
  159 +
118 public StepService() { 160 public StepService() {
119 161
120 } 162 }
@@ -125,12 +167,173 @@ public class StepService extends Service implements SensorEventListener { @@ -125,12 +167,173 @@ public class StepService extends Service implements SensorEventListener {
125 Log.e("执行onCreate", "onCreate"); 167 Log.e("执行onCreate", "onCreate");
126 super.onCreate(); 168 super.onCreate();
127 init(); 169 init();
  170 + if (mClient == null) {
  171 + mClient = new LBSTraceClient(getApplicationContext());
  172 + }
  173 + if (mTrace == null) {
  174 + mTrace = new Trace(serviceId, entityName);
  175 + }
128 showStartForegroundNotification(); 176 showStartForegroundNotification();
129 - userId = "123";  
130 - initTodayData(userId); 177 +
131 initBroadcastReceiver(); 178 initBroadcastReceiver();
132 } 179 }
133 180
  181 + private void initTrace() {
  182 + if (mClient == null) {
  183 + mClient = new LBSTraceClient(getApplicationContext());
  184 + }
  185 + if (mTrace == null) {
  186 + mTrace = new Trace(serviceId, entityName);
  187 + }
  188 + //初始化实时轨迹监听器
  189 + realTimeTraceListener = new OnTrackListener() {
  190 +
  191 + @Override
  192 + public void onLatestPointCallback(LatestPointResponse response) {
  193 + if (StatusCodes.SUCCESS != response.getStatus()) {
  194 + return;
  195 + }
  196 +
  197 + LatestPoint point = response.getLatestPoint();
  198 +
  199 + }
  200 + };
  201 +
  202 + //轨迹监听
  203 + traceListener = new OnTraceListener() {
  204 +
  205 + /**
  206 + * 绑定服务回调接口
  207 + * @param errorNo 状态码
  208 + * @param message 消息
  209 + * <p>
  210 + * <pre>0:成功 </pre>
  211 + * <pre>1:失败</pre>
  212 + */
  213 + @Override
  214 + public void onBindServiceCallback(int errorNo, String message) {
  215 + }
  216 +
  217 + /**
  218 + * 开启服务回调接口
  219 + * @param errorNo 状态码
  220 + * @param message 消息
  221 + * <p>
  222 + * <pre>0:成功 </pre>
  223 + * <pre>10000:请求发送失败</pre>
  224 + * <pre>10001:服务开启失败</pre>
  225 + * <pre>10002:参数错误</pre>
  226 + * <pre>10003:网络连接失败</pre>
  227 + * <pre>10004:网络未开启</pre>
  228 + * <pre>10005:服务正在开启</pre>
  229 + * <pre>10006:服务已开启</pre>
  230 + */
  231 + @Override
  232 + public void onStartTraceCallback(int errorNo, String message) {
  233 + if (StatusCodes.SUCCESS == errorNo || StatusCodes.START_TRACE_NETWORK_CONNECT_FAILED <= errorNo) {
  234 + //开始进行采集
  235 + if (mClient != null) {
  236 + mClient.startGather(traceListener);
  237 + Toast.makeText(getApplicationContext(), "开启轨迹服务", Toast.LENGTH_LONG).show();
  238 +
  239 + }
  240 + }
  241 + }
  242 +
  243 + /**
  244 + * 停止服务回调接口
  245 + * @param errorNo 状态码
  246 + * @param message 消息
  247 + * <p>
  248 + * <pre>0:成功</pre>
  249 + * <pre>11000:请求发送失败</pre>
  250 + * <pre>11001:服务停止失败</pre>
  251 + * <pre>11002:服务未开启</pre>
  252 + * <pre>11003:服务正在停止</pre>
  253 + */
  254 + @Override
  255 + public void onStopTraceCallback(int errorNo, String message) {
  256 + if (StatusCodes.SUCCESS == errorNo || StatusCodes.CACHE_TRACK_NOT_UPLOAD == errorNo) {
  257 + if (mClient != null) {
  258 + mClient.stopTrace(mTrace, traceListener);
  259 + Toast.makeText(getApplicationContext(), "停止轨迹服务", Toast.LENGTH_LONG).show();
  260 +
  261 + }
  262 + }
  263 + }
  264 +
  265 + /**
  266 + * 开启采集回调接口
  267 + * @param errorNo 状态码
  268 + * @param message 消息
  269 + * <p>
  270 + * <pre>0:成功</pre>
  271 + * <pre>12000:请求发送失败</pre>
  272 + * <pre>12001:采集开启失败</pre>
  273 + * <pre>12002:服务未开启</pre>
  274 + */
  275 + @Override
  276 + public void onStartGatherCallback(int errorNo, String message) {
  277 + if (StatusCodes.SUCCESS == errorNo || StatusCodes.GATHER_STARTED == errorNo) {
  278 + Toast.makeText(getApplicationContext(), "开始采集", Toast.LENGTH_LONG).show();
  279 + }
  280 + }
  281 +
  282 + /**
  283 + * 停止采集回调接口
  284 + * @param errorNo 状态码
  285 + * @param message 消息
  286 + * <p>
  287 + * <pre>0:成功</pre>
  288 + * <pre>13000:请求发送失败</pre>
  289 + * <pre>13001:采集停止失败</pre>
  290 + * <pre>13002:服务未开启</pre>
  291 + */
  292 + @Override
  293 + public void onStopGatherCallback(int errorNo, String message) {
  294 + if (StatusCodes.SUCCESS == errorNo || StatusCodes.GATHER_STOPPED == errorNo) {
  295 + Toast.makeText(getApplicationContext(), "停止采集", Toast.LENGTH_LONG).show();
  296 + if (mClient != null) {
  297 + mClient.stopTrace(mTrace, traceListener);
  298 + }
  299 + }
  300 + }
  301 +
  302 + /**
  303 + * 推送消息回调接口
  304 + *
  305 + * @param messageType 状态码
  306 + * @param pushMessage 消息
  307 + * <p>
  308 + * <pre>0x01:配置下发</pre>
  309 + * <pre>0x02:语音消息</pre>
  310 + * <pre>0x03:服务端围栏报警消息</pre>
  311 + * <pre>0x04:本地围栏报警消息</pre>
  312 + * <pre>0x05~0x40:系统预留</pre>
  313 + * <pre>0x41~0xFF:开发者自定义</pre>
  314 + */
  315 + @Override
  316 + public void onPushCallback(byte messageType, PushMessage pushMessage) {
  317 + if (messageType < 0x03 || messageType > 0x04) {
  318 + return;
  319 + }
  320 + FenceAlarmPushInfo alarmPushInfo = pushMessage.getFenceAlarmPushInfo();
  321 + if (null == alarmPushInfo) {
  322 + return;
  323 + }
  324 + }
  325 +
  326 + @Override
  327 + public void onInitBOSCallback(int errorNo, String message) {
  328 + }
  329 + };
  330 +
  331 + //开启轨迹服务
  332 + if (mClient != null) {
  333 + mClient.startTrace(mTrace, traceListener);
  334 + }
  335 +
  336 + }
134 337
135 private long i = 0; 338 private long i = 0;
136 private long index = 0; 339 private long index = 0;
@@ -142,6 +345,9 @@ public class StepService extends Service implements SensorEventListener { @@ -142,6 +345,9 @@ public class StepService extends Service implements SensorEventListener {
142 public int onStartCommand(Intent intent, int flags, int startId) { 345 public int onStartCommand(Intent intent, int flags, int startId) {
143 if (intent.getExtras().getString("userId") != null) { 346 if (intent.getExtras().getString("userId") != null) {
144 userId = intent.getExtras().getString("userId"); 347 userId = intent.getExtras().getString("userId");
  348 + entityName = userId;
  349 + initTodayData(userId);
  350 + initTrace();
145 if (!EventBus.getDefault().isRegistered(this)) { 351 if (!EventBus.getDefault().isRegistered(this)) {
146 EventBus.getDefault().register(this); 352 EventBus.getDefault().register(this);
147 } 353 }
@@ -308,9 +514,14 @@ public class StepService extends Service implements SensorEventListener { @@ -308,9 +514,14 @@ public class StepService extends Service implements SensorEventListener {
308 */ 514 */
309 private void initTodayData(String userId) { 515 private void initTodayData(String userId) {
310 CURRENT_DATE = getTodayDate(); 516 CURRENT_DATE = getTodayDate();
311 - 517 + if (userId == null || CURRENT_DATE == null) {
  518 + return;
  519 + }
312 // //获取当天的数据,用于展示 CURRENT_DATE 520 // //获取当天的数据,用于展示 CURRENT_DATE
313 List<UserStepEntity> list = DbCore.getDaoSession().getUserStepEntityDao().queryBuilder().where(UserStepEntityDao.Properties.UserId.eq(userId), UserStepEntityDao.Properties.Date.eq(CURRENT_DATE)).list(); 521 List<UserStepEntity> list = DbCore.getDaoSession().getUserStepEntityDao().queryBuilder().where(UserStepEntityDao.Properties.UserId.eq(userId), UserStepEntityDao.Properties.Date.eq(CURRENT_DATE)).list();
  522 + if (list == null) {
  523 + return;
  524 + }
314 if (list.size() == 0 || list.isEmpty()) { 525 if (list.size() == 0 || list.isEmpty()) {
315 CURRENT_STEP = 0; 526 CURRENT_STEP = 0;
316 } else if (list.size() == 1) { 527 } else if (list.size() == 1) {
@@ -765,4 +976,6 @@ public class StepService extends Service implements SensorEventListener { @@ -765,4 +976,6 @@ public class StepService extends Service implements SensorEventListener {
765 int h = (int) (time / 3600) % 60;//小时 976 int h = (int) (time / 3600) % 60;//小时
766 return String.format("%02d:%02d:%02d", h, m, s); 977 return String.format("%02d:%02d:%02d", h, m, s);
767 } 978 }
  979 +
  980 +
768 } 981 }
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunningMapFragment.java
@@ -4,6 +4,7 @@ import android.hardware.Sensor; @@ -4,6 +4,7 @@ import android.hardware.Sensor;
4 import android.hardware.SensorManager; 4 import android.hardware.SensorManager;
5 import android.os.Bundle; 5 import android.os.Bundle;
6 import android.support.annotation.Nullable; 6 import android.support.annotation.Nullable;
  7 +import android.text.TextUtils;
7 import android.util.Log; 8 import android.util.Log;
8 import android.view.View; 9 import android.view.View;
9 10
@@ -14,6 +15,8 @@ import com.cnlive.moudle.pedometer.frame.view.RunningMapFragmentView; @@ -14,6 +15,8 @@ import com.cnlive.moudle.pedometer.frame.view.RunningMapFragmentView;
14 import com.cnlive.moudle.pedometer.model.RunningMapBean; 15 import com.cnlive.moudle.pedometer.model.RunningMapBean;
15 import com.cnlive.moudle.pedometer.model.Constant; 16 import com.cnlive.moudle.pedometer.model.Constant;
16 import com.cnlive.moudle.pedometer.model.MessageEvent; 17 import com.cnlive.moudle.pedometer.model.MessageEvent;
  18 +import com.cnlive.moudle.pedometer.service.StepService;
  19 +import com.cnlive.moudle.pedometer.utils.TimeUtil;
17 import com.example.moudle_pedometer.R; 20 import com.example.moudle_pedometer.R;
18 import com.example.moudle_pedometer.databinding.FragmentRunningMapBinding; 21 import com.example.moudle_pedometer.databinding.FragmentRunningMapBinding;
19 22
@@ -78,6 +81,12 @@ public class RunningMapFragment extends QMUIFragment&lt;RunningMapFragmentView, Run @@ -78,6 +81,12 @@ public class RunningMapFragment extends QMUIFragment&lt;RunningMapFragmentView, Run
78 getMvpView().updateChronometer(runningMapBean); 81 getMvpView().updateChronometer(runningMapBean);
79 } 82 }
80 } 83 }
  84 + //开始进行历史轨迹查询
  85 + if (getPresenter() != null && !TextUtils.isEmpty(StepService.entityName)) {
  86 + long startTime = runningMapBean.getTimeBase();
  87 + long endTime = TimeUtil.getCurrentTime();
  88 + getPresenter().queryHistoryTrace(getActivity(), StepService.entityName, startTime, endTime);
  89 + }
81 } 90 }
82 91
83 @Override 92 @Override
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/ButtonAnimUtil.java
@@ -41,6 +41,17 @@ public class ButtonAnimUtil { @@ -41,6 +41,17 @@ public class ButtonAnimUtil {
41 animatorSetsuofang.start(); 41 animatorSetsuofang.start();
42 } 42 }
43 43
  44 + //设置控件缩小动画
  45 + public static void setViewDefault(View view) {
  46 + AnimatorSet animatorSetsuofang = new AnimatorSet();//组合动画
  47 + ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 1f, 1);
  48 + ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 1f, 1);
  49 + animatorSetsuofang.setDuration(DEFAULT_ZOOM_DURATION);
  50 + animatorSetsuofang.setInterpolator(new DecelerateInterpolator());
  51 + animatorSetsuofang.play(scaleX).with(scaleY);//两个动画同时开始
  52 + animatorSetsuofang.start();
  53 + }
  54 +
44 //设置控件显示放大动画 55 //设置控件显示放大动画
45 public static void setViewShowZoomIn(View view) { 56 public static void setViewShowZoomIn(View view) {
46 AnimatorSet animatorSetsuofang = new AnimatorSet();//组合动画 57 AnimatorSet animatorSetsuofang = new AnimatorSet();//组合动画
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/CommonUtil.java 0 → 100644
  1 +package com.cnlive.moudle.pedometer.utils;
  2 +
  3 +import android.app.ActivityManager;
  4 +import android.content.Context;
  5 +import android.content.SharedPreferences;
  6 +import android.telephony.TelephonyManager;
  7 +
  8 +import com.baidu.mapapi.model.LatLng;
  9 +
  10 +import java.sql.Timestamp;
  11 +import java.text.DecimalFormat;
  12 +import java.text.ParseException;
  13 +import java.text.SimpleDateFormat;
  14 +import java.util.Date;
  15 +import java.util.Locale;
  16 +
  17 +/**
  18 + * Created by baidu on 17/1/23.
  19 + */
  20 +
  21 +public class CommonUtil {
  22 +
  23 + private static DecimalFormat df = new DecimalFormat("######0.00");
  24 +
  25 + public static final double DISTANCE = 0.0001;
  26 +
  27 + public static String getCurProcessName(Context context) {
  28 + int pid = android.os.Process.myPid();
  29 + ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
  30 + for (ActivityManager.RunningAppProcessInfo appProcess : activityManager.getRunningAppProcesses()) {
  31 + if (appProcess.pid == pid) {
  32 + return appProcess.processName;
  33 + }
  34 + }
  35 + return "";
  36 + }
  37 +
  38 + /**
  39 + * 获取当前时间戳(单位:秒)
  40 + *
  41 + * @return
  42 + */
  43 + public static long getCurrentTime() {
  44 + return System.currentTimeMillis() / 1000;
  45 + }
  46 +
  47 + /**
  48 + * 校验double数值是否为0
  49 + *
  50 + * @param value
  51 + *
  52 + * @return
  53 + */
  54 + public static boolean isEqualToZero(double value) {
  55 + return Math.abs(value - 0.0) < 0.01 ? true : false;
  56 + }
  57 +
  58 + /**
  59 + * 经纬度是否为(0,0)点
  60 + *
  61 + * @return
  62 + */
  63 + public static boolean isZeroPoint(double latitude, double longitude) {
  64 + return isEqualToZero(latitude) && isEqualToZero(longitude);
  65 + }
  66 +
  67 + /**
  68 + * 将字符串转为时间戳
  69 + */
  70 + public static long toTimeStamp(String time) {
  71 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",
  72 + Locale.CHINA);
  73 + Date date;
  74 + try {
  75 + date = sdf.parse(time);
  76 + } catch (ParseException e) {
  77 + e.printStackTrace();
  78 + return 0;
  79 + }
  80 + return date.getTime() / 1000;
  81 + }
  82 +
  83 + /**
  84 + * 获取时分秒
  85 + *
  86 + * @param timestamp 时间戳(单位:毫秒)
  87 + *
  88 + * @return
  89 + */
  90 + public static String getHMS(long timestamp) {
  91 + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
  92 + try {
  93 + return sdf.format(new Timestamp(timestamp));
  94 + } catch (Exception e) {
  95 + e.printStackTrace();
  96 + }
  97 + return String.valueOf(timestamp);
  98 + }
  99 +
  100 + /**
  101 + * 获取年月日 时分秒
  102 + *
  103 + * @param timestamp 时间戳(单位:毫秒)
  104 + *
  105 + * @return
  106 + */
  107 + public static String formatTime(long timestamp) {
  108 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  109 + try {
  110 + return sdf.format(new Timestamp(timestamp));
  111 + } catch (Exception e) {
  112 + e.printStackTrace();
  113 + }
  114 + return String.valueOf(timestamp);
  115 + }
  116 +
  117 + public static String formatSecond(int second) {
  118 + String format = "%1$,02d:%2$,02d:%3$,02d";
  119 + Integer hours = second / (60 * 60);
  120 + Integer minutes = second / 60 - hours * 60;
  121 + Integer seconds = second - minutes * 60 - hours * 60 * 60;
  122 + Object[] array = new Object[] {hours, minutes, seconds};
  123 + return String.format(format, array);
  124 + }
  125 +
  126 + public static final String formatDouble(double doubleValue) {
  127 + return df.format(doubleValue);
  128 + }
  129 +
  130 + /**
  131 + * 计算x方向每次移动的距离
  132 + */
  133 + public static double getXMoveDistance(double slope) {
  134 + if (slope == Double.MAX_VALUE) {
  135 + return DISTANCE;
  136 + }
  137 + return Math.abs((DISTANCE * slope) / Math.sqrt(1 + slope * slope));
  138 + }
  139 +
  140 + /**
  141 + * 根据点和斜率算取截距
  142 + */
  143 + public static double getInterception(double slope, LatLng point) {
  144 + return point.latitude - slope * point.longitude;
  145 + }
  146 +
  147 + /**
  148 + * 算斜率
  149 + */
  150 + public static double getSlope(LatLng fromPoint, LatLng toPoint) {
  151 + if (toPoint.longitude == fromPoint.longitude) {
  152 + return Double.MAX_VALUE;
  153 + }
  154 + return (toPoint.latitude - fromPoint.latitude) / (toPoint.longitude - fromPoint.longitude);
  155 + }
  156 +
  157 + /**
  158 + * 根据两点算取图标转的角度
  159 + */
  160 + public static double getAngle(LatLng fromPoint, LatLng toPoint) {
  161 + double slope = getSlope(fromPoint, toPoint);
  162 + if (slope == Double.MAX_VALUE) {
  163 + if (toPoint.latitude > fromPoint.latitude) {
  164 + return 0;
  165 + } else {
  166 + return 180;
  167 + }
  168 + }
  169 + float deltAngle = 0;
  170 + if ((toPoint.latitude - fromPoint.latitude) * slope < 0) {
  171 + deltAngle = 180;
  172 + }
  173 + double radio = Math.atan(slope);
  174 + return 180 * (radio / Math.PI) + deltAngle - 90;
  175 + }
  176 +
  177 + /**
  178 + * 保存当前定位点
  179 + */
  180 +// public static void saveCurrentLocation(TrackApplication trackApp) {
  181 +// SharedPreferences.Editor editor = trackApp.trackConf.edit();
  182 +// StringBuffer locationInfo = new StringBuffer();
  183 +// locationInfo.append(CurrentLocation.locTime);
  184 +// locationInfo.append(";");
  185 +// locationInfo.append(CurrentLocation.latitude);
  186 +// locationInfo.append(";");
  187 +// locationInfo.append(CurrentLocation.longitude);
  188 +// editor.putString(Constants.LAST_LOCATION, locationInfo.toString());
  189 +// editor.apply();
  190 +// }
  191 +
  192 + /**
  193 + * 获取设备IMEI码
  194 + *
  195 + * @param context
  196 + *
  197 + * @return
  198 + */
  199 + public static String getImei(Context context) {
  200 + String imei;
  201 + try {
  202 + imei = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
  203 + } catch (Exception e) {
  204 + imei = "myTrace";
  205 + }
  206 + return imei;
  207 + }
  208 +
  209 +}
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/MapUtil.java 0 → 100644
  1 +package com.cnlive.moudle.pedometer.utils;
  2 +
  3 +import android.graphics.Color;
  4 +import android.graphics.Point;
  5 +import android.os.Bundle;
  6 +import android.text.TextUtils;
  7 +
  8 +import com.baidu.mapapi.map.BaiduMap;
  9 +import com.baidu.mapapi.map.BitmapDescriptor;
  10 +import com.baidu.mapapi.map.MapStatus;
  11 +import com.baidu.mapapi.map.MapStatusUpdate;
  12 +import com.baidu.mapapi.map.MapStatusUpdateFactory;
  13 +import com.baidu.mapapi.map.MapView;
  14 +import com.baidu.mapapi.map.Marker;
  15 +import com.baidu.mapapi.map.MarkerOptions;
  16 +import com.baidu.mapapi.map.Overlay;
  17 +import com.baidu.mapapi.map.OverlayOptions;
  18 +import com.baidu.mapapi.map.PolylineOptions;
  19 +import com.baidu.mapapi.model.LatLng;
  20 +import com.baidu.mapapi.model.LatLngBounds;
  21 +import com.baidu.mapapi.utils.CoordinateConverter;
  22 +import com.baidu.trace.model.CoordType;
  23 +import com.baidu.trace.model.SortType;
  24 +import com.baidu.trace.model.TraceLocation;
  25 +
  26 +import java.util.List;
  27 +
  28 +
  29 +/**
  30 + * Created by baidu on 17/2/9.
  31 + */
  32 +
  33 +public class MapUtil {
  34 +
  35 + private static MapUtil INSTANCE = new MapUtil();
  36 +
  37 + private MapStatus mapStatus = null;
  38 +
  39 + private Marker mMoveMarker = null;
  40 +
  41 + public MapView mapView = null;
  42 +
  43 + public BaiduMap baiduMap = null;
  44 +
  45 + public LatLng lastPoint = null;
  46 +
  47 + /**
  48 + * 路线覆盖物
  49 + */
  50 + public Overlay polylineOverlay = null;
  51 +
  52 + private MapUtil() {
  53 + }
  54 +
  55 + public static MapUtil getInstance() {
  56 + return INSTANCE;
  57 + }
  58 +
  59 + public void init(MapView view) {
  60 + mapView = view;
  61 + baiduMap = mapView.getMap();
  62 + mapView.showZoomControls(false);
  63 + }
  64 +
  65 + public void onPause() {
  66 + if (null != mapView) {
  67 + mapView.onPause();
  68 + }
  69 + }
  70 +
  71 + public void onResume() {
  72 + if (null != mapView) {
  73 + mapView.onResume();
  74 + }
  75 + }
  76 +
  77 + public void clear() {
  78 + lastPoint = null;
  79 + if (null != mMoveMarker) {
  80 + mMoveMarker.remove();
  81 + mMoveMarker = null;
  82 + }
  83 + if (null != polylineOverlay) {
  84 + polylineOverlay.remove();
  85 + polylineOverlay = null;
  86 + }
  87 + if (null != baiduMap) {
  88 + baiduMap.clear();
  89 + baiduMap = null;
  90 + }
  91 + mapStatus = null;
  92 + if (null != mapView) {
  93 + mapView.onDestroy();
  94 + mapView = null;
  95 + }
  96 + }
  97 +
  98 + /**
  99 + * 将轨迹实时定位点转换为地图坐标
  100 + *
  101 + * @param location
  102 + *
  103 + * @return
  104 + */
  105 + public static LatLng convertTraceLocation2Map(TraceLocation location) {
  106 + if (null == location) {
  107 + return null;
  108 + }
  109 + double latitude = location.getLatitude();
  110 + double longitude = location.getLongitude();
  111 + if (Math.abs(latitude - 0.0) < 0.000001 && Math.abs(longitude - 0.0) < 0.000001) {
  112 + return null;
  113 + }
  114 + LatLng currentLatLng = new LatLng(latitude, longitude);
  115 + if (CoordType.wgs84 == location.getCoordType()) {
  116 + LatLng sourceLatLng = currentLatLng;
  117 + CoordinateConverter converter = new CoordinateConverter();
  118 + converter.from(CoordinateConverter.CoordType.GPS);
  119 + converter.coord(sourceLatLng);
  120 + currentLatLng = converter.convert();
  121 + }
  122 + return currentLatLng;
  123 + }
  124 +
  125 + /**
  126 + * 将地图坐标转换轨迹坐标
  127 + *
  128 + * @param latLng
  129 + *
  130 + * @return
  131 + */
  132 + public static com.baidu.trace.model.LatLng convertMap2Trace(LatLng latLng) {
  133 + return new com.baidu.trace.model.LatLng(latLng.latitude, latLng.longitude);
  134 + }
  135 +
  136 + /**
  137 + * 将轨迹坐标对象转换为地图坐标对象
  138 + *
  139 + * @param traceLatLng
  140 + *
  141 + * @return
  142 + */
  143 + public static LatLng convertTrace2Map(com.baidu.trace.model.LatLng traceLatLng) {
  144 + return new LatLng(traceLatLng.latitude, traceLatLng.longitude);
  145 + }
  146 +
  147 +// /**
  148 +// * 设置地图中心:使用已有定位信息;
  149 +// *
  150 +// * @param trackApp
  151 +// */
  152 +// public void setCenter(TrackApplication trackApp) {
  153 +// if (!CommonUtil.isZeroPoint(CurrentLocation.latitude, CurrentLocation.longitude)) {
  154 +// LatLng currentLatLng = new LatLng(CurrentLocation.latitude, CurrentLocation.longitude);
  155 +// updateStatus(currentLatLng, false);
  156 +// return;
  157 +// }
  158 +// String lastLocation = trackApp.trackConf.getString(Constants.LAST_LOCATION, null);
  159 +// if (!TextUtils.isEmpty(lastLocation)) {
  160 +// String[] locationInfo = lastLocation.split(";");
  161 +// if (!CommonUtil.isZeroPoint(Double.parseDouble(locationInfo[1]),
  162 +// Double.parseDouble(locationInfo[2]))) {
  163 +// LatLng currentLatLng = new LatLng(Double.parseDouble(locationInfo[1]),
  164 +// Double.parseDouble(locationInfo[2]));
  165 +// updateStatus(currentLatLng, false);
  166 +// return;
  167 +// }
  168 +// }
  169 +// }
  170 +
  171 +// public void updateStatus(LatLng currentPoint, boolean showMarker) {
  172 +// if (null == baiduMap || null == currentPoint) {
  173 +// return;
  174 +// }
  175 +//
  176 +// if (null != baiduMap.getProjection()) {
  177 +// Point screenPoint = baiduMap.getProjection().toScreenLocation(currentPoint);
  178 +// // 点在屏幕上的坐标超过限制范围,则重新聚焦底图
  179 +// if (screenPoint.y < 200 || screenPoint.y > TrackApplication.screenHeight - 500
  180 +// || screenPoint.x < 200 || screenPoint.x > TrackApplication.screenWidth - 200
  181 +// || null == mapStatus) {
  182 +// animateMapStatus(currentPoint, 15.0f);
  183 +// }
  184 +// } else if (null == mapStatus) {
  185 +// // 第一次定位时,聚焦底图
  186 +// setMapStatus(currentPoint, 15.0f);
  187 +// }
  188 +//
  189 +// if (showMarker) {
  190 +// addMarker(currentPoint);
  191 +// }
  192 +//
  193 +// }
  194 +
  195 + public Marker addOverlay(LatLng currentPoint, BitmapDescriptor icon, Bundle bundle) {
  196 + OverlayOptions overlayOptions = new MarkerOptions().position(currentPoint)
  197 + .icon(icon).zIndex(9).draggable(true);
  198 + Marker marker = (Marker) baiduMap.addOverlay(overlayOptions);
  199 + if (null != bundle) {
  200 + marker.setExtraInfo(bundle);
  201 + }
  202 + return marker;
  203 + }
  204 +
  205 + /**
  206 + * 添加地图覆盖物
  207 + */
  208 +// public void addMarker(LatLng currentPoint) {
  209 +// if (null == mMoveMarker) {
  210 +// mMoveMarker = addOverlay(currentPoint, BitmapUtil.bmArrowPoint, null);
  211 +// return;
  212 +// }
  213 +//
  214 +// if (null != lastPoint) {
  215 +// moveLooper(currentPoint);
  216 +// } else {
  217 +// lastPoint = currentPoint;
  218 +// mMoveMarker.setPosition(currentPoint);
  219 +// }
  220 +// }
  221 +
  222 + /**
  223 + * 移动逻辑
  224 + */
  225 + public void moveLooper(LatLng endPoint) {
  226 +
  227 + mMoveMarker.setPosition(lastPoint);
  228 + mMoveMarker.setRotate((float) CommonUtil.getAngle(lastPoint, endPoint));
  229 +
  230 + double slope = CommonUtil.getSlope(lastPoint, endPoint);
  231 + // 是不是正向的标示(向上设为正向)
  232 + boolean isReverse = (lastPoint.latitude > endPoint.latitude);
  233 + double intercept = CommonUtil.getInterception(slope, lastPoint);
  234 + double xMoveDistance = isReverse ? CommonUtil.getXMoveDistance(slope) : -1 * CommonUtil.getXMoveDistance(slope);
  235 +
  236 + for (double latitude = lastPoint.latitude; latitude > endPoint.latitude == isReverse; latitude =
  237 + latitude - xMoveDistance) {
  238 + LatLng latLng;
  239 + if (slope != Double.MAX_VALUE) {
  240 + latLng = new LatLng(latitude, (latitude - intercept) / slope);
  241 + } else {
  242 + latLng = new LatLng(latitude, lastPoint.longitude);
  243 + }
  244 + mMoveMarker.setPosition(latLng);
  245 + }
  246 + }
  247 +
  248 +
  249 + public void animateMapStatus(List<LatLng> points) {
  250 + if (null == points || points.isEmpty()) {
  251 + return;
  252 + }
  253 + LatLngBounds.Builder builder = new LatLngBounds.Builder();
  254 + for (LatLng point : points) {
  255 + builder.include(point);
  256 + }
  257 + MapStatusUpdate msUpdate = MapStatusUpdateFactory.newLatLngBounds(builder.build());
  258 + baiduMap.animateMapStatus(msUpdate);
  259 + }
  260 +
  261 + public void animateMapStatus(LatLng point, float zoom) {
  262 + MapStatus.Builder builder = new MapStatus.Builder();
  263 + mapStatus = builder.target(point).zoom(zoom).build();
  264 + baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(mapStatus));
  265 + }
  266 +
  267 + public void setMapStatus(LatLng point, float zoom) {
  268 + MapStatus.Builder builder = new MapStatus.Builder();
  269 + mapStatus = builder.target(point).zoom(zoom).build();
  270 + baiduMap.setMapStatus(MapStatusUpdateFactory.newMapStatus(mapStatus));
  271 + }
  272 +
  273 + public void refresh() {
  274 + LatLng mapCenter = baiduMap.getMapStatus().target;
  275 + float mapZoom = baiduMap.getMapStatus().zoom - 1.0f;
  276 + setMapStatus(mapCenter, mapZoom);
  277 + }
  278 +
  279 +}
  280 +
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/MyMapUtil.java 0 → 100644
  1 +package com.cnlive.moudle.pedometer.utils;
  2 +
  3 +import android.content.Context;
  4 +import android.graphics.Bitmap;
  5 +import android.graphics.BitmapFactory;
  6 +import android.graphics.Color;
  7 +
  8 +import com.baidu.mapapi.map.BaiduMap;
  9 +import com.baidu.mapapi.map.BitmapDescriptorFactory;
  10 +import com.baidu.mapapi.map.Marker;
  11 +import com.baidu.mapapi.map.MarkerOptions;
  12 +import com.baidu.mapapi.map.Overlay;
  13 +import com.baidu.mapapi.map.OverlayOptions;
  14 +import com.baidu.mapapi.map.PolylineOptions;
  15 +import com.baidu.mapapi.model.LatLng;
  16 +import com.baidu.trace.model.SortType;
  17 +import com.example.moudle_pedometer.R;
  18 +
  19 +import java.util.List;
  20 +
  21 +/**
  22 + * @author ShinnyYang
  23 + */
  24 +public class MyMapUtil {
  25 + /**
  26 + * 将轨迹坐标对象转换为地图坐标对象
  27 + *
  28 + * @param traceLatLng
  29 + * @return
  30 + */
  31 + public static LatLng convertTrace2Map(com.baidu.trace.model.LatLng traceLatLng) {
  32 + return new LatLng(traceLatLng.latitude, traceLatLng.longitude);
  33 + }
  34 +
  35 + /**
  36 + * 绘制历史轨迹
  37 + */
  38 + public static Overlay drawHistoryTrack(Context context, BaiduMap baiduMap, List<LatLng> points, SortType sortType, int lineColor, int startIconRes, int endIconRes) {
  39 + // 绘制新覆盖物前,清空之前的覆盖物
  40 + baiduMap.clear();
  41 + if (points == null || points.size() == 0) {
  42 + return null;
  43 + }
  44 + //只有一个点
  45 + if (points.size() == 1) {
  46 + Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), startIconRes), 40, 40);
  47 + OverlayOptions startOptions = new MarkerOptions().position(points.get(0)).icon(BitmapDescriptorFactory.fromBitmap(pointBitmap));
  48 +// .zIndex(9).draggable(true);
  49 + return baiduMap.addOverlay(startOptions);
  50 + }
  51 +
  52 + LatLng startPoint;
  53 + LatLng endPoint;
  54 + if (sortType == SortType.asc) {
  55 + startPoint = points.get(0);
  56 + endPoint = points.get(points.size() - 1);
  57 + } else {
  58 + startPoint = points.get(points.size() - 1);
  59 + endPoint = points.get(0);
  60 + }
  61 +
  62 + // 添加起点图标
  63 + Bitmap startPointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), startIconRes), 40, 40);
  64 + OverlayOptions startOptions = new MarkerOptions()
  65 + .position(startPoint).icon(BitmapDescriptorFactory.fromBitmap(startPointBitmap));
  66 +// .zIndex(9).draggable(true);
  67 + // 添加终点图标
  68 + Bitmap endPointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), endIconRes), 40, 40);
  69 + OverlayOptions endOptions = new MarkerOptions().position(endPoint)
  70 + .icon(BitmapDescriptorFactory.fromBitmap(endPointBitmap));
  71 +// .zIndex(9).draggable(true);
  72 +
  73 + // 添加路线(轨迹)
  74 + OverlayOptions polylineOptions = new PolylineOptions().width(10)
  75 + .color(context.getResources().getColor(lineColor)).points(points);
  76 +
  77 + baiduMap.addOverlay(startOptions);
  78 +// baiduMap.addOverlay(endOptions);
  79 + return baiduMap.addOverlay(polylineOptions);
  80 + }
  81 +}
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/TimeUtil.java 0 → 100644
  1 +package com.cnlive.moudle.pedometer.utils;
  2 +
  3 +public class TimeUtil {
  4 + /**
  5 + * 获取当前时间戳(单位:秒)
  6 + *
  7 + * @return
  8 + */
  9 + public static long getCurrentTime() {
  10 + return System.currentTimeMillis() / 1000;
  11 + }
  12 +
  13 +}
moudle_pedometer/src/main/res/drawable-hdpi/icon_end.png 0 → 100644

2.2 KB

moudle_pedometer/src/main/res/drawable-hdpi/icon_start.png 0 → 100644

2.02 KB