Commit 2a122520a229f07452eaaa82c34151586b8a358e

Authored by 韩亚云
2 parents 077c6696 47b15bb5

Merge branch 'master' of bj.gitlab.cnlive.com:cnlive-team/ModulePedometer

# Conflicts:
#	moudle_pedometer/src/main/AndroidManifest.xml
Showing 38 changed files with 2532 additions and 973 deletions

Too many changes to show.

To preserve performance only 38 of 44 files are displayed.

moudle_pedometer/src/main/AndroidManifest.xml
... ... @@ -57,7 +57,7 @@
57 57 <activity android:name="com.cnlive.moudle.pedometer.ui.activity.LineUpAgainActivity" />
58 58 <activity android:name="com.cnlive.moudle.pedometer.ui.activity.SelfRecordActivity" />
59 59 <activity android:name="com.cnlive.moudle.pedometer.ui.activity.TakePartActivity" />
60   - <activity android:name="com.cnlive.moudle.pedometer.ui.activity.RunLineActivity"/>
  60 + <activity android:name="com.cnlive.moudle.pedometer.ui.activity.RunLineActivity" />
61 61 <activity android:name="com.cnlive.moudle.pedometer.ui.activity.MyRecordActivity" />
62 62 <activity android:name="com.cnlive.moudle.pedometer.ui.activity.ShareRecordActivity" />
63 63 <activity android:name="com.cnlive.moudle.pedometer.ui.activity.RaceRecordActivity" />
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/commonInfo/CollCommonInfo.java renamed to moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/commonInfo/CollCommonInfo.java
1   -package com.cnlive.moudle.pedometer.commonInfo;
  1 +package com.cnlive.moudle.collectionTrace.commonInfo;
2 2  
3 3 import android.content.Context;
4 4  
... ... @@ -132,7 +132,7 @@ public class CollCommonInfo {
132 132 * @param context
133 133 */
134 134 public static boolean getIsRunBaiduTraceService(Context context) {
135   - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("CollRunBaiduTraceService", false);
  135 + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("CollRunBaiduTraceService", true);
136 136 }
137 137  
138 138 /**
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunMainFragmentView.java
... ... @@ -4,9 +4,7 @@ import android.content.Context;
4 4 import android.content.Intent;
5 5 import android.os.Handler;
6 6 import android.os.SystemClock;
7   -import android.support.v4.content.ContextCompat;
8 7 import android.text.TextUtils;
9   -import android.util.Log;
10 8 import android.view.MotionEvent;
11 9 import android.view.View;
12 10 import android.widget.Chronometer;
... ... @@ -15,26 +13,24 @@ import com.baidu.location.BDAbstractLocationListener;
15 13 import com.baidu.location.BDLocation;
16 14 import com.baidu.location.LocationClient;
17 15 import com.baidu.location.LocationClientOption;
18   -import com.cnlive.moudle.collectionTrace.service.CollKeepLiveService;
  16 +import com.baidu.mapapi.model.LatLng;
19 17 import com.cnlive.moudle.collectionTrace.service.CollStepService;
20   -import com.cnlive.moudle.collectionTrace.ui.activity.CollRunningMapActivity;
21 18 import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunMainFragment;
22   -import com.cnlive.moudle.pedometer.commonInfo.CollCommonInfo;
  19 +import com.cnlive.moudle.collectionTrace.commonInfo.CollCommonInfo;
23 20 import com.cnlive.moudle.pedometer.model.Constant;
24   -import com.cnlive.moudle.pedometer.model.MessageEvent;
25 21 import com.cnlive.moudle.pedometer.model.RunningFinishBean;
26 22 import com.cnlive.moudle.pedometer.model.RunningMapBean;
  23 +import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo;
  24 +import com.cnlive.moudle.pedometer.sql.entity.CollFailedEntity;
27 25 import com.cnlive.moudle.pedometer.sql.entity.CollUserStepEntity;
28   -import com.cnlive.moudle.pedometer.ui.activity.RunningMapActivity;
29 26 import com.cnlive.moudle.pedometer.ui.widget.SelectDialog;
  27 +import com.cnlive.moudle.pedometer.ui.widget.TipDialog;
30 28 import com.cnlive.moudle.pedometer.utils.ButtonAnimUtil;
31   -import com.cnlive.moudle.pedometer.utils.CollStepUtil;
32   -import com.cnlive.moudle.pedometer.utils.GsonUtil;
  29 +import com.cnlive.moudle.collectionTrace.utils.CollStepUtil;
33 30 import com.cnlive.moudle.pedometer.utils.TimeUtil;
34 31 import com.example.moudle_pedometer.R;
35 32 import com.hannesdorfmann.mosby3.mvp.MvpView;
36 33  
37   -import org.greenrobot.eventbus.EventBus;
38 34  
39 35 public class CollRunMainFragmentView implements MvpView {
40 36 private final String TAG = "CollRunMainFragmentView";
... ... @@ -51,9 +47,13 @@ public class CollRunMainFragmentView implements MvpView {
51 47 private int timeCountDown;//时间倒计时
52 48 private String uid;
53 49 private boolean needWriteDataFlag = true;//是否需要将计时器基值写入到数据库
  50 + private CollUserStepEntity userStepEntity;
54 51 // 定位相关
55 52 private LocationClient mLocClient;
56   - public MyLocationListenner myListener = new MyLocationListenner();
  53 + public CollRunMainFragmentView.MyLocationListenner myListener = new CollRunMainFragmentView.MyLocationListenner();
  54 + private String employTime = "";
  55 + private LatLng endLatLng;//终点坐标
  56 + private TipDialog tipDialog;
57 57  
58 58 public CollRunMainFragmentView(CollRunMainFragment fragment) {
59 59 this.fragment = fragment;
... ... @@ -106,51 +106,67 @@ public class CollRunMainFragmentView implements MvpView {
106 106 /**
107 107 * 初始化相关视图
108 108 */
109   - public void initView() {
110   - uid = "yangshuai";
  109 + public void initView(RunRaceDetailInfo runRaceDetailInfo) {
111 110 initLocationClient();
112   - CollUserStepEntity userStepEntity = CollStepUtil.getCollUserStepData(getContext(), uid);
  111 + uid = CollCommonInfo.getUserId(getContext());
  112 + userStepEntity = CollStepUtil.getCollUserStepData(getContext(), uid);
  113 + //设置数据
113 114 if (userStepEntity != null) {
114   - CollStepUtil.clearRunData(getContext(), CollCommonInfo.getUserId(getContext()));
  115 + //设置赛事标题
  116 + if (TextUtils.isEmpty(userStepEntity.getStreetTitle())) {
  117 + CollStepUtil.setCollStreetTitle(getContext(), CollCommonInfo.getUserId(getContext()), runRaceDetailInfo.getTitle());
  118 + }
  119 + //设置开始时间和赛事id
  120 + if (TextUtils.isEmpty(userStepEntity.getStreetId())) {
  121 + CollStepUtil.setCollStepStartData(getContext(), uid, TimeUtil.getNowTimeStamp(), CollCommonInfo.getStreetId(getContext()));
  122 + }
  123 + //设置步数
  124 + if (!TextUtils.isEmpty(userStepEntity.getStepCount())) {
  125 + //设置行走步数
  126 + fragment.binding.tvStepCount.setText(userStepEntity.getStepCount());
  127 + //设置行走公里
  128 + fragment.binding.tvRunDistance.setText(CollStepUtil.getWalkDistanceKM(Long.parseLong(userStepEntity.getStepCount())) + "");
  129 + }
  130 +
  131 +
115 132 }
  133 +
116 134 fragment.binding.llRunMainRoot.setVisibility(View.GONE);
117   - ButtonAnimUtil.startAnimation(fragment.binding.llStartTimeTip, false);
118 135 firstTimeFlag = true;
119 136 handler = new Handler();
120 137 timeCountDown = 4;
121 138 //开始时间倒计时
122   - runnable = new Runnable() {
  139 + fragment.binding.llRunMainRoot.setVisibility(View.VISIBLE);
  140 + fragment.binding.llRunMainRoot.setBackgroundColor(getContext().getResources().getColor(R.color.run_main_bg));
  141 + new Handler().postDelayed(new Runnable() {
123 142 @Override
124 143 public void run() {
125   - if (fragment.getActivity() == null) {
126   - return;
  144 + if (userStepEntity != null) {
  145 + //没有暂停,从初始时间开始
  146 + if (userStepEntity.getChronometerBase() != 0) {
  147 + fragment.binding.chronometer.setBase(userStepEntity.getChronometerBase());
  148 + } else {
  149 + fragment.binding.chronometer.setFormat("00:00:01");
  150 + fragment.binding.chronometer.setBase(SystemClock.elapsedRealtime());
  151 + //设置计步开始时间
  152 + CollStepUtil.setCollChronometerBase(getContext(), uid, fragment.binding.chronometer.getBase());
  153 + }
  154 + fragment.binding.chronometer.start();
  155 + //设置步数
  156 + if (!TextUtils.isEmpty(userStepEntity.getStepCount())) {
  157 + fragment.binding.tvStepCount.setText(userStepEntity.getStepCount());
  158 + }
127 159 }
128   - if (timeCountDown > 1) {
129   - timeCountDown--;
130   - fragment.binding.tvTimeCountDown.setVisibility(View.VISIBLE);
131   - fragment.binding.tvTimeCountDown.setText(timeCountDown + "");
132   - ButtonAnimUtil.setTimeShowZoomIn(fragment.binding.tvTimeCountDown);
133   - //依次倒计时
134   - handler.postDelayed(runnable, 1000);
135   - } else {
136   - ButtonAnimUtil.startAnimation(fragment.binding.llStartTimeTip, true);
137   - fragment.binding.llRunMainRoot.setVisibility(View.VISIBLE);
138   - new Handler().postDelayed(new Runnable() {
139   - @Override
140   - public void run() {
141   - //开始计时
142   - if (firstTimeFlag) {
143   - firstTimeFlag = false;
144   - fragment.binding.chronometer.setFormat("00:00:01");
145   - fragment.binding.chronometer.setBase(SystemClock.elapsedRealtime());
146   - fragment.binding.chronometer.start();
147   - }
148   - }
149   - }, 10);
150   -
  160 + //没有数据
  161 + else {
  162 + fragment.binding.chronometer.setFormat("00:00:01");
  163 + fragment.binding.chronometer.setBase(SystemClock.elapsedRealtime());
  164 + //设置计步开始时间
  165 + CollStepUtil.setCollChronometerBase(getContext(), uid, fragment.binding.chronometer.getBase());
  166 + fragment.binding.chronometer.start();
151 167 }
152 168 }
153   - };
  169 + }, 10);
154 170 //设置计时监听
155 171 fragment.binding.chronometer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
156 172 @Override
... ... @@ -158,135 +174,50 @@ public class CollRunMainFragmentView implements MvpView {
158 174 int hour = (int) ((SystemClock.elapsedRealtime() - chronometer.getBase()) / 1000 / 60 / 60);
159 175 int minute = (int) ((SystemClock.elapsedRealtime() - chronometer.getBase()) / 1000 / 60) % 60;
160 176 int second = (int) ((SystemClock.elapsedRealtime() - chronometer.getBase()) / 1000) % 60;
161   -// if (hour < 1) {
162   -// if (minute == 59 && second == 59) {
163   -// chronometer.setFormat("0" + "%s");
164   -// } else {
165   -// chronometer.setFormat("0" + String.valueOf(hour) + ":%s");
166   -// }
167   -// } else if (hour < 10) {
168   -// chronometer.setFormat("0" + "%s");
169   -// } else {
170   -// chronometer.setFormat("%s");
171   -// }
172   - String result = "";
  177 + employTime = (hour * 3600 + minute * 60 + second) + "";
173 178 if (hour < 1) {
174   - result += "0" + hour + ":";
175   - } else {
176   - result += hour + ":";
177   - }
178   - if (minute < 10) {
179   - result += "0" + minute + ":";
180   - } else {
181   - result += minute + ":";
182   - }
183   - if (second < 10) {
184   - result += "0" + second;
  179 + if (minute == 59 && second == 59) {
  180 + chronometer.setFormat("0" + "%s");
  181 + } else {
  182 + chronometer.setFormat("0" + String.valueOf(hour) + ":%s");
  183 + }
  184 + } else if (hour < 10) {
  185 + chronometer.setFormat("0" + "%s");
185 186 } else {
186   - result += second;
187   - }
188   - if (!TextUtils.isEmpty(result)) {
189   - chronometer.setFormat(result);
  187 + chronometer.setFormat("");
190 188 }
  189 +
191 190 }
192 191 });
193 192  
194   - boolean isRunStep = CollCommonInfo.getIsRunStepService(getContext());
195   - //当前用户已经在运动
196   -// if (!isRunStep) {
197   - //依次倒计时
198   - handler.postDelayed(runnable, 1000);
199   -// }
200   -// else {
201   -// //隐藏计时界面
202   -// fragment.binding.llStartTimeTip.setVisibility(View.GONE);
203   -// fragment.binding.llRunMainRoot.setVisibility(View.VISIBLE);
204   -// new Handler().postDelayed(new Runnable() {
205   -// @Override
206   -// public void run() {
207   -// //开始计时
208   -// if (firstTimeFlag) {
209   -// firstTimeFlag = false;
210   -// if (userStepEntity != null) {
211   -// Log.e(TAG, "run: "+ GsonUtil.GsonString(userStepEntity));
212   -// if ((userStepEntity.getPauseTimeStamp() != 0) && (userStepEntity.getRecordTime() != 0)) {
213   -// fragment.binding.chronometer.setBase(userStepEntity.getPauseTimeStamp() + (SystemClock.elapsedRealtime() - userStepEntity.getRecordTime()));
214   -// } else {
215   -// fragment.binding.chronometer.setFormat("00:00:01");
216   -// fragment.binding.chronometer.setBase(SystemClock.elapsedRealtime());
217   -// }
218   -// //设置步数
219   -// if (!TextUtils.isEmpty(userStepEntity.getStepCount())) {
220   -// fragment.binding.tvStepCount.setText(userStepEntity.getStepCount());
221   -// }
222   -// }
223   -// fragment.binding.chronometer.start();
224   -// }
225   -// }
226   -// }, 100);
227   -// //开启计步服务
228   -// startStepService(getContext(), uid);
229   -// }
230   -
231   - //设置继续按钮,缩放效果
232   - fragment.binding.flContinue.setOnTouchListener(new View.OnTouchListener() {
  193 + //隐藏计时界面
  194 + fragment.binding.llRunMainRoot.setVisibility(View.VISIBLE);
  195 + new Handler().postDelayed(new Runnable() {
233 196 @Override
234   - public boolean onTouch(View view, MotionEvent motionEvent) {
235   - //避免两个按钮事件同时响应
236   - if (stopStartFlag) {
237   - return false;
238   - }
239   - if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
240   - if (!continueStartFlag) {
241   - ButtonAnimUtil.setViewZoomIn(fragment.binding.flContinue);
242   - continueStartFlag = true;
243   -
  197 + public void run() {
  198 + //开始计时
  199 + if (firstTimeFlag) {
  200 + firstTimeFlag = false;
  201 + if (userStepEntity != null) {
  202 + //判断显示时间
  203 + //没有暂停,从初始时间开始
  204 + if (userStepEntity.getChronometerBase() != 0) {
  205 + fragment.binding.chronometer.setBase(userStepEntity.getChronometerBase());
  206 + } else {
  207 + fragment.binding.chronometer.setFormat("00:00:01");
  208 + fragment.binding.chronometer.setBase(SystemClock.elapsedRealtime());
  209 + }
  210 + //设置步数
  211 + if (!TextUtils.isEmpty(userStepEntity.getStepCount())) {
  212 + fragment.binding.tvStepCount.setText(userStepEntity.getStepCount());
  213 + }
244 214 }
245   - } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
246   - ButtonAnimUtil.setViewZoomOut(fragment.binding.flContinue);
247   - continueStartFlag = false;
  215 + fragment.binding.chronometer.start();
248 216 }
249   - return false;
250 217 }
251   - });
252   - //设置继续按钮点击事件
253   - fragment.binding.flContinue.setOnClickListener(new View.OnClickListener() {
254   - @Override
255   - public void onClick(View view) {
256   - //继续记录轨迹
257   - if (CollStepService.mClient != null && CollStepService.traceListener != null) {
258   - CollCommonInfo.setTsRunBaiduTraceService(getContext(), true);
259   - CollStepService.mClient.startTrace(CollStepService.mTrace, CollStepService.traceListener);
260   - }
261   - needWriteDataFlag = true;
262   - //将当前计时器时间戳写入数据库
263   - setSQLPauseTime(uid);
264   - //为了点击时可以显示缩放动画,这里延迟一个动画时间进行(包括放大和缩小)
265   - handler.postDelayed(new Runnable() {
266   - @Override
267   - public void run() {
268   - //
269   - //隐藏两个按钮
270   - fragment.binding.flStopTip.setVisibility(View.INVISIBLE);
271   - fragment.binding.llTwoBottomButton.setVisibility(View.GONE);
272   -// ButtonAnimUtil.setViewShowZoomIn(fragment.binding.llPause);
273   - //显示暂停按钮
274   - fragment.binding.flPause.setVisibility(View.VISIBLE);
275   - //
276   - }
277   - }, ButtonAnimUtil.DEFAULT_ZOOM_DURATION * 2);
278   - //继续计步
279   - EventBus.getDefault().post(new MessageEvent(Constant.SERVICE_STEP_COUNT_CONTINUE, ""));
280   - //开始计时
281   - if (!firstTimeFlag) {
282   - fragment.binding.chronometer.setBase(fragment.binding.chronometer.getBase() + (SystemClock.elapsedRealtime() - mRecordTime));
283   - }
284   - fragment.binding.chronometer.start();
285   -
  218 + }, 10);
286 219  
287   - }
288   - });
289   - //设置停止按钮缩放特效
  220 +//设置停止按钮缩放特效
290 221 fragment.binding.flStop.setOnTouchListener(new View.OnTouchListener() {
291 222 @Override
292 223 public boolean onTouch(View view, MotionEvent motionEvent) {
... ... @@ -321,27 +252,46 @@ public class CollRunMainFragmentView implements MvpView {
321 252 SelectDialog selectDialog = new SelectDialog(fragment.getActivity(), "确定结束运动吗?", "确定", new SelectDialog.DialogInterface() {
322 253 @Override
323 254 public void onClick(SelectDialog dialog) {
324   - CollCommonInfo.setIsRunKeepAliveService(getContext(), false);
325   - CollCommonInfo.setIsWriteUserStep(getContext(), false);
  255 + //停止计时
  256 + fragment.binding.chronometer.stop();
  257 + //设置状态标志位
  258 + setStopStartFlag();
  259 + //设置运动结束时间戳
  260 +// CollStepUtil.setUserFinishTimeStamp(getContext(), uid);
326 261 fragment.binding.cpCurrent.setVisibility(View.GONE);
327 262 ButtonAnimUtil.setViewDefault(fragment.binding.flStop);
328   - //清空数据
329   - CollCommonInfo.reset(getContext());
330 263 dialog.dismiss();
331   - if (CollStepService.mClient != null) {
332   - CollStepService.mClient.stopGather(CollStepService.traceListener);
333   - }
334   - fragment.getActivity().stopService(new Intent(fragment.getActivity(), CollStepService.class));
335 264 RunningFinishBean runningFinishBean = new RunningFinishBean();
336   - runningFinishBean.setStartPoint("开始地点");
337   - runningFinishBean.setEndPoint("结束地点");
  265 +// runningFinishBean.setStartPoint(userStepEntity.getStartPoint());
  266 +// runningFinishBean.setEndPoint(userStepEntity.getEndPoint());
338 267 runningFinishBean.setRunDistance(fragment.binding.tvRunDistance.getText().toString());
339   - runningFinishBean.setSpeed(fragment.binding.tvSpeed.getText().toString());
340   - runningFinishBean.setStep(fragment.binding.tvStepCount.getText().toString());
  268 + //必须先设置步数,然后设置配速
  269 + if ("--".equals(fragment.binding.tvStepCount.getText().toString())) {
  270 + runningFinishBean.setStep("0");
  271 + } else {
  272 + runningFinishBean.setStep(fragment.binding.tvStepCount.getText().toString());
  273 + }
  274 + if ("--".equals(fragment.binding.tvSpeed.getText().toString())) {
  275 + String speed = CollStepUtil.getPaceSpeed(Double.parseDouble(employTime), Double.parseDouble(fragment.binding.tvRunDistance.getText().toString()));
  276 + runningFinishBean.setSpeed(speed);
  277 + } else {
  278 + runningFinishBean.setSpeed(fragment.binding.tvSpeed.getText().toString());
  279 + }
341 280 runningFinishBean.setTime(fragment.binding.chronometer.getText().toString());
342   - runningFinishBean.setDate(TimeUtil.getFormatNowTime());
343   -// RunningFinishActivity.startActivity(fragment.getActivity(), runningFinishBean);
344   - fragment.getActivity().finish();
  281 + runningFinishBean.setDate(TimeUtil.getStampToTime(userStepEntity.getFinishTimeStamp() * 1000, "yyyy/MM/dd HH:mm"));
  282 + runningFinishBean.setStreetTitle(userStepEntity.getStreetTitle());
  283 + //设置用时
  284 + runningFinishBean.setEmployTime(employTime);
  285 +
  286 + //先将失败数据保存起来
  287 + if (runningFinishBean != null && userStepEntity != null) {
  288 + setFailData(getContext(), userStepEntity, runningFinishBean);
  289 + }
  290 +// FailedEntity failedEntity = CollStepUtil.getTempSaveFailData(getContext(), CollCommonInfo.getUserId(getContext()), userStepEntity.getStartTimeStamp());
  291 +// if (failedEntity != null) {
  292 +// CollRunningFinishActivity.startActivity(fragment.getActivity(), runningFinishBean);
  293 +// fragment.getActivity().finish();
  294 +// }
345 295 }
346 296 }, "取消", new SelectDialog.DialogInterface() {
347 297 @Override
... ... @@ -372,56 +322,6 @@ public class CollRunMainFragmentView implements MvpView {
372 322 return true;
373 323 }
374 324 });
375   - //设置暂停按钮,缩放效果
376   - fragment.binding.flPause.setOnTouchListener(new View.OnTouchListener() {
377   - @Override
378   - public boolean onTouch(View view, MotionEvent motionEvent) {
379   - if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
380   - if (!pauseStartFlag) {
381   - ButtonAnimUtil.setViewZoomIn(fragment.binding.flPause);
382   - pauseStartFlag = true;
383   -
384   - }
385   - } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
386   - ButtonAnimUtil.setViewZoomOut(fragment.binding.flPause);
387   - pauseStartFlag = false;
388   - }
389   - return false;
390   - }
391   - });
392   - //设置暂停按钮点击事件
393   - fragment.binding.flPause.setOnClickListener(new View.OnClickListener() {
394   - @Override
395   - public void onClick(View view) {
396   - //暂停轨迹记录
397   - if (CollStepService.mClient != null && CollStepService.traceListener != null) {
398   - CollCommonInfo.setTsRunBaiduTraceService(getContext(), false);
399   - CollStepService.mClient.stopGather(CollStepService.traceListener);
400   - }
401   - //将当前计时器时间戳写入数据库
402   - setSQLPauseTime(uid);
403   - needWriteDataFlag = false;
404   -// ButtonAnimUtil.setViewHideZoomOut(fragment.binding.llPause);
405   - handler.postDelayed(new Runnable() {
406   - @Override
407   - public void run() {
408   - //隐藏本身
409   - fragment.binding.flPause.setVisibility(View.GONE);
410   - }
411   - }, ButtonAnimUtil.HIDE_VIEW_ZOOM_DURATION);
412   - //显示继续按钮
413   - fragment.binding.llTwoBottomButton.setVisibility(View.VISIBLE);
414   - ButtonAnimUtil.setViewShowZoomIn(fragment.binding.flContinue);
415   - ButtonAnimUtil.setViewShowZoomIn(fragment.binding.flStop);
416   - //停止计时
417   - fragment.binding.chronometer.stop();
418   - mRecordTime = SystemClock.elapsedRealtime();
419   - //暂停计步
420   - EventBus.getDefault().post(new MessageEvent(Constant.SERVICE_STEP_COUNT_PAUSE, ""));
421   - //重置速度
422   -// resetSpeed();
423   - }
424   - });
425 325 //gps点击事件
426 326 fragment.binding.rlGps.setOnClickListener(new View.OnClickListener() {
427 327 @Override
... ... @@ -441,7 +341,19 @@ public class CollRunMainFragmentView implements MvpView {
441 341 }
442 342 runningMapBean.setDistance(fragment.binding.tvRunDistance.getText().toString());
443 343 runningMapBean.setCurrentSpeed(fragment.binding.tvSpeed.getText().toString());
444   - CollRunningMapActivity.startActivity(fragment.getActivity(), runningMapBean);
  344 +// CollRunningMapActivity.startActivity(fragment.getActivity(), runningMapBean);
  345 + }
  346 + });
  347 + //返回按钮点击事件
  348 + fragment.binding.llBack.setOnClickListener(new View.OnClickListener() {
  349 + @Override
  350 + public void onClick(View view) {
  351 +
  352 + if (getContext() == null) {
  353 + return;
  354 + }
  355 +// setSQLPauseTime(CollCommonInfo.getUserId(getContext()));
  356 + fragment.getActivity().finish();
445 357 }
446 358 });
447 359  
... ... @@ -453,22 +365,41 @@ public class CollRunMainFragmentView implements MvpView {
453 365 });
454 366 }
455 367  
456   - public void setSQLPauseTime(String id) {
457   - if (needWriteDataFlag) {
458   - //将当前计时器时间戳写入数据库
459   -// String id = MySpHelper.getInstance(getContext(), Context.MODE_MULTI_PROCESS).getString("userId", "");
460   - if (!TextUtils.isEmpty(id)) {
461   - CollUserStepEntity userStepEntity = CollStepUtil.getCollUserStepData(fragment.getActivity(), uid);
462   - if (userStepEntity != null) {
463   - userStepEntity.setPauseTimeStamp(fragment.binding.chronometer.getBase());
464   - //设置当前暂停的时间戳
465   - userStepEntity.setRecordTime(SystemClock.elapsedRealtime());
466   - //更新数据
467   - CollStepUtil.updateStepData(fragment.getActivity(), userStepEntity);
468   - }
469   - }
470   - }
471   - }
  368 +
  369 +// public void setSQLPauseTime(String id) {
  370 +// Log.e(TAG, "setSQLPauseTime: ");
  371 +//// if (needWriteDataFlag) {
  372 +// //将当前计时器时间戳写入数据库
  373 +// if (!TextUtils.isEmpty(id)) {
  374 +// CollUserStepEntity userStepEntity = StepUtil.getCollUserStepData(fragment.getActivity(), uid);
  375 +// if (userStepEntity != null) {
  376 +//// userStepEntity.setChronometerBase(fragment.binding.chronometer.getBase());
  377 +// //设置当前暂停的时间戳
  378 +// userStepEntity.setRecordTime(SystemClock.elapsedRealtime());
  379 +// //设置当前用户暂停的时间戳
  380 +// userStepEntity.setUserPauseTimeStamp(TimeUtil.getNowTimeStamp());
  381 +// //设置暂停次数
  382 +// userStepEntity.setPauseCount(userStepEntity.getPauseCount() + 1);
  383 +// //更新数据
  384 +// StepUtil.updateCollStepData(fragment.getActivity(), userStepEntity);
  385 +// }
  386 +// }
  387 +//// }
  388 +// }
  389 +
  390 +// public void setFragmentPauseTime(String id) {
  391 +// if (!TextUtils.isEmpty(id)) {
  392 +// UserStepEntity userStepEntity = StepUtil.getUserStepData(fragment.getActivity(), uid);
  393 +// if (userStepEntity != null) {
  394 +// userStepEntity.setPauseTimeStamp(fragment.binding.chronometer.getBase());
  395 +// userStepEntity.setRecordTime(SystemClock.elapsedRealtime());
  396 +// //设置当前暂停的时间戳
  397 +// userStepEntity.setUserPauseTimeStamp(TimeUtil.getNowTimeStamp());
  398 +// //更新数据
  399 +// StepUtil.updateStepData(fragment.getActivity(), userStepEntity);
  400 +// }
  401 +// }
  402 +// }
472 403  
473 404  
474 405 /**
... ... @@ -505,7 +436,8 @@ public class CollRunMainFragmentView implements MvpView {
505 436  
506 437 @Override
507 438 public void onReceiveLocation(BDLocation location) {
508   - if (location == null) {
  439 + // map view 销毁后不在处理新接收的位置
  440 + if (location == null || getContext() == null) {
509 441 return;
510 442 }
511 443 //正在搜索GPS信号
... ... @@ -562,7 +494,27 @@ public class CollRunMainFragmentView implements MvpView {
562 494 fragment.binding.ivGps.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_3));
563 495 }
564 496 }
  497 +
  498 + //进行精度过滤
  499 + if (location.getRadius() > Constant.LOCA_ACCURACY) {
  500 + return;
  501 + }
  502 + //开始比较
565 503 }
  504 +
  505 + }
  506 +
  507 + /**
  508 + * 设置停止状态标志位
  509 + */
  510 + private void setStopStartFlag() {
  511 + CollCommonInfo.setTsRunBaiduTraceService(getContext(), false);
  512 + CollCommonInfo.setIsRunKeepAliveService(getContext(), false);
  513 + CollCommonInfo.setIsWriteUserStep(getContext(), false);
  514 + if (CollStepService.mClient != null) {
  515 + CollStepService.mClient.stopGather(CollStepService.traceListener);
  516 + }
  517 + fragment.getActivity().stopService(new Intent(fragment.getActivity(), CollStepService.class));
566 518 }
567 519  
568 520 public void onDestroy() {
... ... @@ -570,6 +522,82 @@ public class CollRunMainFragmentView implements MvpView {
570 522 mLocClient.stop();
571 523 }
572 524 }
  525 +
  526 + /**
  527 + * 暂存失败数据
  528 + *
  529 + * @param context
  530 + * @param userStepEntity
  531 + * @param runningFinishBean
  532 + */
  533 + public void setFailData(Context context, CollUserStepEntity userStepEntity, RunningFinishBean runningFinishBean) {
  534 + if (userStepEntity == null || runningFinishBean == null || context == null) {
  535 + return;
  536 + }
  537 + //设置数据
  538 + CollFailedEntity failedEntity = new CollFailedEntity();
  539 + //设置主键
  540 + failedEntity.setUuid(CollStepUtil.getUUID());
  541 + //设置用户id
  542 + failedEntity.setUid(userStepEntity.getUserId());
  543 + //设置当前数据创建时间戳
  544 + failedEntity.setCreatTimeStamp(TimeUtil.getNowTimeStamp());
  545 + //设置是否暂停
  546 + if (userStepEntity.getPauseCount() != 0) {
  547 + failedEntity.setIsPause(true);
  548 + //设置暂停时间
  549 + failedEntity.setUserPauseTime(userStepEntity.getUserPauseTimeStamp());
  550 + //设置继续时间戳
  551 + failedEntity.setUsrContinueTime(userStepEntity.getContinueTime());
  552 + } else {
  553 + failedEntity.setIsPause(false);
  554 + }
  555 + //设置用时
  556 + failedEntity.setTime(runningFinishBean.getEmployTime());
  557 + //设置配速
  558 + if ("--".equals(runningFinishBean.getSpeed())) {
  559 + failedEntity.setSpeed("0");
  560 + } else {
  561 + failedEntity.setSpeed(runningFinishBean.getSpeed());
  562 + }
  563 + //设置步数
  564 + if ("--".equals(runningFinishBean.getStep())) {
  565 + failedEntity.setStep("0");
  566 + } else {
  567 + failedEntity.setStep(runningFinishBean.getStep());
  568 + }
  569 + //设置距离
  570 + if ("--".equals(runningFinishBean.getRunDistance())) {
  571 + failedEntity.setDistance("0");
  572 + } else {
  573 + failedEntity.setDistance(runningFinishBean.getRunDistance());
  574 + }
  575 +// //设置开始地点
  576 +// failedEntity.setStartPoint(userStepEntity.getStartPoint());
  577 +// //设置结束地点
  578 +// failedEntity.setEndPoint(userStepEntity.getEndPoint());
  579 + //设置赛道开始时间
  580 + failedEntity.setStreetTraceStartTime(userStepEntity.getQueryTraceStartTime());
  581 + //设置赛道结束时间
  582 + failedEntity.setStreetTraceEndTime(userStepEntity.getQueryTraceEndTime());
  583 + //设置赛道查询实体
  584 + failedEntity.setEntityName(userStepEntity.getQueryEntityName());
  585 + //设置用户开始时间
  586 + failedEntity.setUserStartTime(userStepEntity.getStartTimeStamp());
  587 + //设置用户完成时间
  588 + failedEntity.setUserEndTime(userStepEntity.getFinishTimeStamp());
  589 + //设置关键点
  590 + failedEntity.setImportPoint(userStepEntity.getImportPoint());
  591 + //设置赛事id
  592 + failedEntity.setStreetId(userStepEntity.getStreetId());
  593 + //设置赛事标题
  594 + failedEntity.setStreetTitle(userStepEntity.getStreetTitle());
  595 + //设置是否完成
  596 + failedEntity.setIsArriveEndPoint(userStepEntity.getIsArriveEndPoint());
  597 + //设置数据
  598 +// CollStepUtil.setCollFailData(context, failedEntity);
  599 +
  600 + }
573 601 }
574 602  
575 603  
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunRaceDetailFragmentView.java
1 1 package com.cnlive.moudle.collectionTrace.frame.view;
2 2  
3 3 import android.content.Context;
4   -import android.content.Intent;
5 4 import android.graphics.Bitmap;
6 5 import android.graphics.BitmapFactory;
7 6 import android.hardware.Sensor;
8 7 import android.hardware.SensorEvent;
9 8 import android.hardware.SensorEventListener;
10 9 import android.hardware.SensorManager;
11   -import android.support.v4.content.ContextCompat;
12 10 import android.text.TextUtils;
13   -import android.util.Log;
14 11 import android.view.View;
  12 +import android.view.ViewTreeObserver;
15 13 import android.widget.Toast;
16 14  
17 15 import com.baidu.location.BDAbstractLocationListener;
... ... @@ -43,16 +41,13 @@ import com.baidu.mapapi.search.route.RoutePlanSearch;
43 41 import com.baidu.mapapi.search.route.TransitRouteResult;
44 42 import com.baidu.mapapi.search.route.WalkingRoutePlanOption;
45 43 import com.baidu.mapapi.search.route.WalkingRouteResult;
46   -import com.cnlive.moudle.collectionTrace.service.CollKeepLiveService;
47 44 import com.cnlive.moudle.collectionTrace.ui.activity.StartCollectTraceActivity;
48 45 import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunRaceDetailFragment;
49   -import com.cnlive.moudle.pedometer.commonInfo.CollCommonInfo;
  46 +import com.cnlive.moudle.collectionTrace.commonInfo.CollCommonInfo;
50 47 import com.cnlive.moudle.pedometer.model.Constant;
51 48 import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo;
52 49 import com.cnlive.moudle.pedometer.utils.BitmapUtil;
53   -import com.cnlive.moudle.pedometer.utils.GsonUtil;
54   -import com.cnlive.moudle.pedometer.utils.MyMapUtil;
55   -import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil;
  50 +import com.cnlive.moudle.pedometer.utils.ScreenUtil;
56 51 import com.cnlive.moudle.pedometer.utils.TimeUtil;
57 52 import com.cnlive.strike.application.GlideApp;
58 53 import com.example.moudle_pedometer.R;
... ... @@ -118,19 +113,6 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen
118 113 }
119 114 CollCommonInfo.setUserId(getContext(), uid);
120 115 this.runRaceDetailInfo = runRaceDetailInfo;
121   - //初始化地图点位
122   - if (runRaceDetailInfo.getLatLongitude() != null) {
123   -// Log.e(TAG, "initView: 长度:" + runRaceDetailInfo.getLatLongitude().length());
124   - trackPoints = GsonUtil.jsonToList(runRaceDetailInfo.getLatLongitude(), LatLng.class);
125   -// Log.e(TAG, "initView: trackPoints" + trackPoints.size());
126   -// MyMapUtil.drawServerLineTrack(getContext(), baiduMap, trackPoints, SortType.asc, R.color.green_round, R.drawable.icon_start, R.drawable.icon_end);
127   -// //自动计算地图缩放
128   - MapStatus.Builder builder = new MapStatus.Builder();
129   - builder.target(MyMapUtil.getCenterZoomPosition(trackPoints));
130   - builder.zoom(MyMapUtil.getZoom(trackPoints));
131   - baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
132   - }
133   -
134 116 //显示地图
135 117 fragment.binding.mapView.setVisibility(View.VISIBLE);
136 118 //隐藏底部滑动卡片
... ... @@ -153,6 +135,22 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen
153 135 if (!TextUtils.isEmpty(runRaceDetailInfo.getTitle())) {
154 136 fragment.binding.includeStreet.tvRaceTitle.setText(runRaceDetailInfo.getTitle());
155 137 }
  138 + fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 140));
  139 +// //根据标题行数,自动调整卡片大小
  140 + fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
  141 + @Override
  142 + public boolean onPreDraw() {
  143 + int line = fragment.binding.includeStreet.tvRaceTitle.getLineCount();
  144 + int height = fragment.binding.includeStreet.tvRaceTitle.getHeight();
  145 + if (line > 1) {
  146 + int avgHeight = height / line;//平局高度
  147 + fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 140) + avgHeight * (line - 1));
  148 +
  149 + }
  150 + fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().removeOnPreDrawListener(this);
  151 + return false;
  152 + }
  153 + });
156 154 //设置活动地点
157 155 if (!TextUtils.isEmpty(runRaceDetailInfo.getAddress())) {
158 156 fragment.binding.includeStreet.tvAddress.setText(runRaceDetailInfo.getAddress());
... ... @@ -171,21 +169,21 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen
171 169 fragment.binding.includeStreet.tvEndAddr.setText(runRaceDetailInfo.getEndLocation());
172 170 }
173 171 //设置起始报名时间
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"));
  172 + if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_start_time(), "yyyy.MM.dd"))) {
  173 + fragment.binding.includeStreet.tvSignUpStartTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_start_time(), "yyyy.MM.dd"));
176 174  
177 175 }
178 176 //设置终止报名时间
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"));
  177 + if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_end_time(), "yyyy.MM.dd"))) {
  178 + fragment.binding.includeStreet.tvSignUpEndTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_end_time(), "yyyy.MM.dd"));
181 179 }
182 180 //设置活动开始时间
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"));
  181 + if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getStart_time(), "yyyy.MM.dd"))) {
  182 + fragment.binding.includeStreet.tvActiveStartTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getStart_time(), "yyyy.MM.dd"));
185 183 }
186 184 //设置活动结束时间
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"));
  185 + if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getEnd_time(), "yyyy.MM.dd"))) {
  186 + fragment.binding.includeStreet.tvActiveEndTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getEnd_time(), "yyyy.MM.dd"));
189 187 }
190 188  
191 189  
... ... @@ -195,17 +193,13 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen
195 193 GlideApp.with(getContext()).load(runRaceDetailInfo.getRoadmap()).into(fragment.binding.includeStreetIntroduce.ivRoadMao);
196 194  
197 195 }
198   - //开始按钮点击事件(用户进行滑动滑动)
199   - fragment.binding.rlScrollViewStartBtn.setOnClickListener(new View.OnClickListener() {
200   - @Override
201   - public void onClick(View view) {
202   - }
203   - });
204 196 //添加轨迹按钮点击事件
205   - fragment.binding.btnAddTrace.setOnClickListener(new View.OnClickListener() {
  197 + fragment.binding.rlScrollViewAddTrace.setOnClickListener(new View.OnClickListener() {
206 198 @Override
207 199 public void onClick(View view) {
208   - StartCollectTraceActivity.startActivity(fragment.getActivity());
  200 + if (null != runRaceDetailInfo) {
  201 + StartCollectTraceActivity.startActivity(fragment.getActivity(), runRaceDetailInfo);
  202 + }
209 203 }
210 204 });
211 205  
... ... @@ -215,7 +209,7 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen
215 209  
216 210 public void initMap() {
217 211 //隐藏底部滑动卡片
218   - fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);
  212 +// fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);
219 213 this.mMapView = fragment.binding.mapView;
220 214 if (baiduMap == null) {
221 215 baiduMap = mMapView.getMap();
... ... @@ -649,7 +643,7 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen
649 643 //显示空视图
650 644 fragment.binding.emptyLayout.setVisibility(View.VISIBLE);
651 645 //隐藏底部卡片
652   - fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);
  646 +// fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);
653 647 if (fragment.binding.emptyLayout == null) return;
654 648 String titleText = "";
655 649 String detailText = "";
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunningMapFragmentView.java
... ... @@ -7,8 +7,8 @@ import android.hardware.Sensor;
7 7 import android.hardware.SensorEvent;
8 8 import android.hardware.SensorEventListener;
9 9 import android.hardware.SensorManager;
10   -import android.os.Handler;
11 10 import android.os.SystemClock;
  11 +import android.text.TextUtils;
12 12 import android.util.Log;
13 13 import android.view.MotionEvent;
14 14 import android.view.View;
... ... @@ -32,15 +32,18 @@ import com.baidu.mapapi.map.Overlay;
32 32 import com.baidu.mapapi.map.UiSettings;
33 33 import com.baidu.mapapi.model.LatLng;
34 34 import com.baidu.mapapi.utils.DistanceUtil;
35   -import com.baidu.trace.model.SortType;
36 35 import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunningMapFragment;
  36 +import com.cnlive.moudle.collectionTrace.commonInfo.CollCommonInfo;
37 37 import com.cnlive.moudle.pedometer.model.Constant;
38   -import com.cnlive.moudle.pedometer.model.RunningMapBean;
39   -import com.cnlive.moudle.pedometer.ui.fragment.RunningMapFragment;
  38 +import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo;
  39 +import com.cnlive.moudle.pedometer.sql.entity.CollUserStepEntity;
40 40 import com.cnlive.moudle.pedometer.utils.BitmapUtil;
41 41 import com.cnlive.moudle.pedometer.utils.ButtonAnimUtil;
42   -import com.cnlive.moudle.pedometer.utils.CollStepUtil;
  42 +import com.cnlive.moudle.collectionTrace.utils.CollStepUtil;
  43 +import com.cnlive.moudle.pedometer.utils.GsonUtil;
43 44 import com.cnlive.moudle.pedometer.utils.MyMapUtil;
  45 +import com.cnlive.moudle.pedometer.utils.StepUtil;
  46 +import com.cnlive.moudle.pedometer.utils.TimeUtil;
44 47 import com.example.moudle_pedometer.R;
45 48 import com.hannesdorfmann.mosby3.mvp.MvpView;
46 49  
... ... @@ -71,9 +74,12 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
71 74 public MyLocationListenner myListener = new MyLocationListenner();
72 75 private final int DEFULT_ZOOM = 17;
73 76 private boolean isFirstLoadMap = true;
74   - private List<LatLng> trackPoints;
75 77 private Overlay currentLine;
76 78 private List<LatLng> currentPoints;
  79 + private CollUserStepEntity userStepEntity;
  80 + private String uid;
  81 + private RunRaceDetailInfo runRaceDetailInfo;
  82 + private List<Overlay> overlays;
77 83  
78 84 public CollRunningMapFragmentView(CollRunningMapFragment fragment) {
79 85 this.fragment = fragment;
... ... @@ -83,9 +89,139 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
83 89 return fragment == null ? null : fragment.getActivity();
84 90 }
85 91  
86   - public void initView(List<LatLng> trackPoints) {
  92 + public void initView(RunRaceDetailInfo runRaceDetailInfo) {
87 93 currentPoints = new ArrayList<>();
88   - this.trackPoints = trackPoints;
  94 + this.runRaceDetailInfo = runRaceDetailInfo;
  95 + uid = CollCommonInfo.getUserId(getContext());
  96 + userStepEntity = CollStepUtil.getCollUserStepData(getContext(), uid);
  97 + //在地图上显示起点
  98 + //设置数据
  99 + if (userStepEntity != null) {
  100 + //设置赛事标题
  101 + if (TextUtils.isEmpty(userStepEntity.getStreetTitle())) {
  102 + CollStepUtil.setCollStreetTitle(getContext(), CollCommonInfo.getUserId(getContext()), runRaceDetailInfo.getTitle());
  103 + }
  104 + //设置开始时间和赛事id
  105 + if (TextUtils.isEmpty(userStepEntity.getStreetId())) {
  106 + CollStepUtil.setCollStepStartData(getContext(), uid, TimeUtil.getNowTimeStamp(), CollCommonInfo.getStreetId(getContext()));
  107 + }
  108 + //设置步数
  109 + if (!TextUtils.isEmpty(userStepEntity.getStepCount())) {
  110 + //设置行走公里
  111 + fragment.binding.tvCurrentDiatance.setText(CollStepUtil.getWalkDistanceKM(Long.parseLong(userStepEntity.getStepCount())) + "");
  112 + }
  113 + //设置是否需要设置起点信息
  114 + if (TextUtils.isEmpty(userStepEntity.getCollStartLatLng())||TextUtils.isEmpty(userStepEntity.getCollStartLatLngName())) {
  115 + //开始设置
  116 + if (!TextUtils.isEmpty(runRaceDetailInfo.getCollStartLatLng()) && !TextUtils.isEmpty(runRaceDetailInfo.getCollStartLntLngName())) {
  117 + CollStepUtil.setCollStartPointData(getContext(), uid, runRaceDetailInfo.getCollStartLntLngName(), runRaceDetailInfo.getCollStartLatLng());
  118 + }
  119 + }
  120 + initChrom();
  121 + //初始化起点
  122 + overlays = new ArrayList<>();
  123 + //打起点(重新获取数据)
  124 + userStepEntity = CollStepUtil.getCollUserStepData(getContext(), uid);
  125 + if (!TextUtils.isEmpty(userStepEntity.getCollStartLatLng())) {
  126 + LatLng startLatLng = GsonUtil.GsonToBean(userStepEntity.getCollStartLatLng(), LatLng.class);
  127 + if (null != startLatLng) {
  128 + List<Overlay> resultOverlays = MyMapUtil.setStartMarker(getContext(), baiduMap, startLatLng, R.drawable.icon_start);
  129 + if (null != resultOverlays) {
  130 + this.overlays.addAll(resultOverlays);
  131 + }
  132 + }
  133 + }
  134 + }
  135 + //返回键
  136 + fragment.binding.flBack.setOnTouchListener(new View.OnTouchListener() {
  137 + @Override
  138 + public boolean onTouch(View view, MotionEvent motionEvent) {
  139 + Log.e(TAG, "onTouch: " + motionEvent.getAction());
  140 + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
  141 + ButtonAnimUtil.setViewZoomIn(fragment.binding.flBack);
  142 + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
  143 + ButtonAnimUtil.setViewZoomOut(fragment.binding.flBack);
  144 + }
  145 + return false;
  146 + }
  147 + });
  148 + //返回键点击事件
  149 + fragment.binding.flBack.setOnClickListener(new View.OnClickListener() {
  150 + @Override
  151 + public void onClick(View view) {
  152 + fragment.getActivity().finish();
  153 + }
  154 + });
  155 + //重新定位
  156 + fragment.binding.flLocation.setOnTouchListener(new View.OnTouchListener() {
  157 + @Override
  158 + public boolean onTouch(View view, MotionEvent motionEvent) {
  159 + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
  160 + ButtonAnimUtil.setViewZoomIn(fragment.binding.flLocation);
  161 + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
  162 + ButtonAnimUtil.setViewZoomOut(fragment.binding.flLocation);
  163 + }
  164 + return false;
  165 + }
  166 + });
  167 + //重新定位功能
  168 + fragment.binding.flLocation.setOnClickListener(new View.OnClickListener() {
  169 + @Override
  170 + public void onClick(View view) {
  171 + mLocClient.restart();
  172 + isFirstLoc = true;
  173 + }
  174 + });
  175 +
  176 + }
  177 +
  178 + private void initChrom() {
  179 + //设置计时监听
  180 + fragment.binding.chronometer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
  181 + @Override
  182 + public void onChronometerTick(Chronometer chronometer) {
  183 + int hour = (int) ((SystemClock.elapsedRealtime() - chronometer.getBase()) / 1000 / 60 / 60);
  184 + int minute = (int) ((SystemClock.elapsedRealtime() - chronometer.getBase()) / 1000 / 60) % 60;
  185 + int second = (int) ((SystemClock.elapsedRealtime() - chronometer.getBase()) / 1000) % 60;
  186 + if (hour < 1) {
  187 + if (minute == 59 && second == 59) {
  188 + chronometer.setFormat("0" + "%s");
  189 + } else {
  190 + chronometer.setFormat("0" + String.valueOf(hour) + ":%s");
  191 + }
  192 + } else if (hour < 10) {
  193 + chronometer.setFormat("0" + "%s");
  194 + } else {
  195 + chronometer.setFormat("%s");
  196 + }
  197 +
  198 + }
  199 + });
  200 +
  201 + if (userStepEntity != null) {
  202 + //没有暂停,从初始时间开始
  203 + if (userStepEntity.getChronometerBase() != 0) {
  204 + fragment.binding.chronometer.setBase(userStepEntity.getChronometerBase());
  205 + } else {
  206 + fragment.binding.chronometer.setFormat("00:00:01");
  207 + fragment.binding.chronometer.setBase(SystemClock.elapsedRealtime());
  208 + //设置计步开始时间
  209 + CollStepUtil.setCollChronometerBase(getContext(), uid, fragment.binding.chronometer.getBase());
  210 + }
  211 + fragment.binding.chronometer.start();
  212 +
  213 + }
  214 + //没有数据
  215 + else {
  216 + fragment.binding.chronometer.setFormat("00:00:01");
  217 + fragment.binding.chronometer.setBase(SystemClock.elapsedRealtime());
  218 + //设置计步开始时间
  219 + CollStepUtil.setCollChronometerBase(getContext(), uid, fragment.binding.chronometer.getBase());
  220 + fragment.binding.chronometer.start();
  221 + }
  222 + }
  223 +
  224 + public void initMap() {
89 225 this.mMapView = fragment.binding.mapView;
90 226 if (baiduMap == null) {
91 227 baiduMap = mMapView.getMap();
... ... @@ -156,67 +292,8 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
156 292 baiduMap.setOnMapLoadedCallback(new BaiduMap.OnMapLoadedCallback() {
157 293 @Override
158 294 public void onMapLoaded() {
159   - //自动计算地图缩放
160   - MapStatus.Builder builder = new MapStatus.Builder();
161   - builder.target(MyMapUtil.getCenterZoomPosition(trackPoints));
162   - builder.zoom(MyMapUtil.getZoom(trackPoints));
163   - baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
164   - if (isFirstLoadMap) {
165   - isFirstLoadMap = false;
166   - new Handler().postDelayed(new Runnable() {
167   - @Override
168   - public void run() {
169   - //绘制赛道轨迹
170   - if (getContext() == null) {
171   - return;
172   - }
173   - MyMapUtil.drawServerLineTrack(getContext(), baiduMap, trackPoints, SortType.asc, R.color.green_50, R.drawable.icon_start, R.drawable.icon_end);
174   - }
175   - }, 1500);
176   - }
177   - }
178   - });
179   - //返回键
180   - fragment.binding.flBack.setOnTouchListener(new View.OnTouchListener() {
181   - @Override
182   - public boolean onTouch(View view, MotionEvent motionEvent) {
183   - Log.e(TAG, "onTouch: " + motionEvent.getAction());
184   - if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
185   - ButtonAnimUtil.setViewZoomIn(fragment.binding.flBack);
186   - } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
187   - ButtonAnimUtil.setViewZoomOut(fragment.binding.flBack);
188   - }
189   - return false;
190   - }
191   - });
192   - //返回键点击事件
193   - fragment.binding.flBack.setOnClickListener(new View.OnClickListener() {
194   - @Override
195   - public void onClick(View view) {
196   - fragment.getActivity().finish();
197   - }
198   - });
199   - //重新定位
200   - fragment.binding.flLocation.setOnTouchListener(new View.OnTouchListener() {
201   - @Override
202   - public boolean onTouch(View view, MotionEvent motionEvent) {
203   - if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
204   - ButtonAnimUtil.setViewZoomIn(fragment.binding.flLocation);
205   - } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
206   - ButtonAnimUtil.setViewZoomOut(fragment.binding.flLocation);
207   - }
208   - return false;
209 295 }
210 296 });
211   - //重新定位功能
212   - fragment.binding.flLocation.setOnClickListener(new View.OnClickListener() {
213   - @Override
214   - public void onClick(View view) {
215   - mLocClient.restart();
216   - isFirstLoc = true;
217   - }
218   - });
219   -
220 297 }
221 298  
222 299  
... ... @@ -322,6 +399,9 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
322 399 MapStatus.Builder builder = new MapStatus.Builder();
323 400 //不是第一次定位状态
324 401 if (!isFirstLoc) {
  402 + baiduMap.setMyLocationData(mylocation);
  403 + builder.target(new LatLng(mylocation.latitude, mylocation.longitude)).zoom(DEFULT_ZOOM);
  404 + baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
325 405 if (currentPoints.size() > 0) {
326 406 //进行判断
327 407 LatLng lastLatLng = currentPoints.get(currentPoints.size() - 1);
... ... @@ -356,44 +436,24 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
356 436 }
357 437  
358 438  
359   - /**
360   - * 同步计时器
361   - */
362   - public void updateChronometer(RunningMapBean runningMapBean) {
363   - //设置计时监听
364   - fragment.binding.chronometer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
365   - @Override
366   - public void onChronometerTick(Chronometer chronometer) {
367   - int hour = (int) ((SystemClock.elapsedRealtime() - chronometer.getBase()) / 1000 / 60 / 60);
368   - int minute = (int) ((SystemClock.elapsedRealtime() - chronometer.getBase()) / 1000 / 60) % 60;
369   - int second = (int) ((SystemClock.elapsedRealtime() - chronometer.getBase()) / 1000) % 60;
370   - if (hour < 1) {
371   - if (minute == 59 && second == 59) {
372   - chronometer.setFormat("0" + "%s");
373   - } else {
374   - chronometer.setFormat("0" + String.valueOf(hour) + ":%s");
375   - }
376   - } else if (hour < 10) {
377   - chronometer.setFormat("0" + "%s");
378   - } else {
379   - chronometer.setFormat("%s");
380   - }
381   -
382   - }
383   - });
384   - fragment.binding.chronometer.setBase(runningMapBean.getTimeBase() + (SystemClock.elapsedRealtime() - runningMapBean.getRecordTime()));
385   - //判断是否点击暂停按钮
386   - if (runningMapBean.isPause()) {
387   - //点击暂停按钮,那么就只显示文本
388   - fragment.binding.chronometer.setText(runningMapBean.getPauseShowTime());
389   - } else {
390   - fragment.binding.chronometer.start();
391   - }
392   - //设置速度
393   - fragment.binding.tvCurrentSpeed.setText(runningMapBean.getCurrentSpeed());
394   - //设置距离
395   - fragment.binding.tvCurrentDiatance.setText(runningMapBean.getDistance());
396   - }
  439 +// /**
  440 +// * 同步计时器
  441 +// */
  442 +// public void updateChronometer(RunningMapBean runningMapBean) {
  443 +//
  444 +// fragment.binding.chronometer.setBase(runningMapBean.getTimeBase() + (SystemClock.elapsedRealtime() - runningMapBean.getRecordTime()));
  445 +// //判断是否点击暂停按钮
  446 +// if (runningMapBean.isPause()) {
  447 +// //点击暂停按钮,那么就只显示文本
  448 +// fragment.binding.chronometer.setText(runningMapBean.getPauseShowTime());
  449 +// } else {
  450 +// fragment.binding.chronometer.start();
  451 +// }
  452 +// //设置速度
  453 +// fragment.binding.tvCurrentSpeed.setText(runningMapBean.getCurrentSpeed());
  454 +// //设置距离
  455 +// fragment.binding.tvCurrentDiatance.setText(runningMapBean.getDistance());
  456 +// }
397 457  
398 458 /**
399 459 * 更新行走距离
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/StartTraceFragmentView.java
... ... @@ -27,18 +27,18 @@ import com.baidu.mapapi.map.MyLocationConfiguration;
27 27 import com.baidu.mapapi.map.MyLocationData;
28 28 import com.baidu.mapapi.map.UiSettings;
29 29 import com.baidu.mapapi.model.LatLng;
30   -import com.baidu.mapapi.search.route.RoutePlanSearch;
31 30 import com.cnlive.moudle.collectionTrace.service.CollKeepLiveService;
32   -import com.cnlive.moudle.collectionTrace.ui.activity.CollPedometerMainActivity;
33   -import com.cnlive.moudle.collectionTrace.ui.activity.CollRunRaceDetailActivity;
34   -import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunRaceDetailFragment;
  31 +import com.cnlive.moudle.collectionTrace.service.CollStepService;
  32 +import com.cnlive.moudle.collectionTrace.ui.activity.CollRunningMapActivity;
35 33 import com.cnlive.moudle.collectionTrace.ui.fragment.StartTraceFragment;
36   -import com.cnlive.moudle.pedometer.commonInfo.CollCommonInfo;
  34 +import com.cnlive.moudle.collectionTrace.commonInfo.CollCommonInfo;
37 35 import com.cnlive.moudle.pedometer.model.Constant;
  36 +import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo;
38 37 import com.cnlive.moudle.pedometer.ui.widget.SelectDialog;
39   -import com.cnlive.moudle.pedometer.ui.widget.TipDialog;
40 38 import com.cnlive.moudle.pedometer.utils.BitmapUtil;
  39 +import com.cnlive.moudle.pedometer.utils.GsonUtil;
41 40 import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil;
  41 +import com.cnlive.moudle.pedometer.utils.ServiceUtils;
42 42 import com.cnlive.moudle.pedometer.utils.TimeUtil;
43 43 import com.example.moudle_pedometer.R;
44 44 import com.hannesdorfmann.mosby3.mvp.MvpView;
... ... @@ -53,7 +53,7 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener {
53 53 private static int accuracyCircleFillColor;
54 54 private static int accuracyCircleStrokeColor;
55 55 private static MyLocationData followMyLocation;
56   - private LatLng firstLatLng;
  56 + private LatLng currentLatLng;
57 57 private Double lastX = 0.0;
58 58 private int mCurrentDirection = 0;
59 59 private float mCurrentAccracy;
... ... @@ -65,6 +65,7 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener {
65 65 private String currentAddress;
66 66 private SelectDialog selectDialog;
67 67 private boolean isShowFollowAddress = false;//是否显示跟随地址
  68 + public RunRaceDetailInfo runRaceDetailInfo;
68 69  
69 70 public StartTraceFragmentView(StartTraceFragment fragment) {
70 71 this.fragment = fragment;
... ... @@ -74,7 +75,8 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener {
74 75 return fragment == null ? null : fragment.getActivity();
75 76 }
76 77  
77   - public void initView() {
  78 + public void initView(RunRaceDetailInfo runRaceDetailInfo) {
  79 + this.runRaceDetailInfo = runRaceDetailInfo;
78 80 if (getContext() == null) {
79 81 return;
80 82 }
... ... @@ -90,9 +92,13 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener {
90 92 public void onClick(SelectDialog dialog) {
91 93 dialog.dismiss();
92 94 isShowFollowAddress = false;
  95 + //设置运营起点
  96 + runRaceDetailInfo.setCollStartLatLng(GsonUtil.GsonString(currentLatLng));
  97 + //设置起点名称
  98 + runRaceDetailInfo.setCollStartLntLngName(currentAddress);
93 99 //开启计步服务
94   - startStepService(getContext());
95   -
  100 +// startStepService(getContext());
  101 + checkBaiduServiceState();
96 102 }
97 103 });
98 104 selectDialog.setCancelable(false);
... ... @@ -112,13 +118,14 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener {
112 118 }
113 119 }
114 120 });
  121 +
115 122 }
116 123  
117 124 /**
118 125 * 启动计步服务
119 126 */
120 127 public void startStepService(Context context) {
121   - CollCommonInfo.setIsFirstStepSendTraceTip(getContext(),true);
  128 + CollCommonInfo.setIsFirstStepSendTraceTip(getContext(), true);
122 129 QMUITipDialogUtil.loadingDialog(getContext(), "请稍后", false);
123 130 if (CollCommonInfo.getStepStartTime(context) == 0) {
124 131 CollCommonInfo.setStepStartTime(context, TimeUtil.getNowTimeStamp());
... ... @@ -132,6 +139,33 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener {
132 139  
133 140 }
134 141  
  142 + private void checkBaiduServiceState() {
  143 + boolean isRunBaidu = CollCommonInfo.getIsRunBaiduTraceService(getContext());
  144 + //要运行百度
  145 + if (isRunBaidu) {
  146 + //判断百度服务是否运行
  147 + if (!ServiceUtils.isServiceRunning(getContext(), "com.baidu.trace.LBSTraceService")) {
  148 + stopStepService();
  149 + startStepService(getContext());
  150 + } else {
  151 + CollRunningMapActivity.startActivity(fragment.getActivity(), runRaceDetailInfo);
  152 + }
  153 + } else {
  154 + CollRunningMapActivity.startActivity(fragment.getActivity(), runRaceDetailInfo);
  155 + }
  156 + }
  157 +
  158 + private void stopStepService() {
  159 + CollCommonInfo.setTsRunBaiduTraceService(getContext(), false);
  160 + CollCommonInfo.setIsRunKeepAliveService(getContext(), false);
  161 + CollCommonInfo.setIsWriteUserStep(getContext(), false);
  162 + CollCommonInfo.setIsFirstStepSendTraceTip(getContext(), true);
  163 + if (CollStepService.mClient != null) {
  164 + CollStepService.mClient.stopGather(CollStepService.traceListener);
  165 + }
  166 + fragment.getActivity().stopService(new Intent(fragment.getActivity(), CollStepService.class));
  167 + }
  168 +
135 169 /**
136 170 * 初始化地图
137 171 */
... ... @@ -224,12 +258,12 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener {
224 258 double x = sensorEvent.values[SensorManager.DATA_X];
225 259 if (Math.abs(x - lastX) > 1.0) {
226 260 mCurrentDirection = (int) x;
227   - if (firstLatLng != null) {
  261 + if (currentLatLng != null) {
228 262 followMyLocation = new MyLocationData.Builder()
229 263 .accuracy(mCurrentAccracy)
230 264 // 此处设置开发者获取到的方向信息,顺时针0-360
231   - .direction(mCurrentDirection).latitude(firstLatLng.latitude)
232   - .longitude(firstLatLng.longitude).build();
  265 + .direction(mCurrentDirection).latitude(currentLatLng.latitude)
  266 + .longitude(currentLatLng.longitude).build();
233 267 baiduMap.setMyLocationData(followMyLocation);
234 268 }
235 269 }
... ... @@ -269,6 +303,7 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener {
269 303 // 此处设置开发者获取到的方向信息,顺时针0-360
270 304 .direction(location.getDirection()).latitude(location.getLatitude())
271 305 .longitude(location.getLongitude()).build();
  306 +// currentAddress = location.getAddrStr();
272 307 currentAddress = location.getLocationDescribe();
273 308 if (selectDialog != null && selectDialog.isShowing()) {
274 309 selectDialog.setTipMessage(currentAddress);
... ... @@ -287,10 +322,10 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener {
287 322  
288 323 // if (isFirstLoc) {
289 324 // isFirstLoc = false;
290   - firstLatLng = new LatLng(location.getLatitude(),
  325 + currentLatLng = new LatLng(location.getLatitude(),
291 326 location.getLongitude());
292 327 baiduMap.setMyLocationData(followMyLocation);
293   - builder.target(firstLatLng).zoom(DEFULT_ZOOM);
  328 + builder.target(currentLatLng).zoom(DEFULT_ZOOM);
294 329 baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
295 330  
296 331 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/model/CollectPoint.java 0 → 100644
  1 +package com.cnlive.moudle.collectionTrace.model;
  2 +
  3 +import com.baidu.mapapi.model.LatLng;
  4 +
  5 +public class CollectPoint {
  6 + private double lat;
  7 + private double lng;
  8 + private String pointName;
  9 +
  10 + public double getLat() {
  11 + return lat;
  12 + }
  13 +
  14 + public void setLat(double lat) {
  15 + this.lat = lat;
  16 + }
  17 +
  18 + public double getLng() {
  19 + return lng;
  20 + }
  21 +
  22 + public void setLng(double lng) {
  23 + this.lng = lng;
  24 + }
  25 +
  26 + public String getPointName() {
  27 + return pointName;
  28 + }
  29 +
  30 + public void setPointName(String pointName) {
  31 + this.pointName = pointName;
  32 + }
  33 +}
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/receivers/CollServiceReceiver.java
... ... @@ -10,7 +10,7 @@ import android.util.Log;
10 10  
11 11 import com.cnlive.moudle.collectionTrace.service.CollKeepLiveService;
12 12 import com.cnlive.moudle.collectionTrace.service.CollStepService;
13   -import com.cnlive.moudle.pedometer.commonInfo.CollCommonInfo;
  13 +import com.cnlive.moudle.collectionTrace.commonInfo.CollCommonInfo;
14 14 import com.cnlive.moudle.pedometer.utils.ServiceUtils;
15 15  
16 16  
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/service/CollKeepLiveService.java
... ... @@ -18,7 +18,7 @@ import android.support.v4.app.NotificationCompat;
18 18 import android.util.Log;
19 19  
20 20 import com.cnlive.moudle.collectionTrace.receivers.CollServiceReceiver;
21   -import com.cnlive.moudle.pedometer.commonInfo.CollCommonInfo;
  21 +import com.cnlive.moudle.collectionTrace.commonInfo.CollCommonInfo;
22 22 import com.cnlive.moudle.pedometer.utils.ServiceUtils;
23 23 import com.example.moudle_pedometer.R;
24 24  
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/service/CollStepService.java
... ... @@ -28,8 +28,6 @@ import android.widget.Toast;
28 28  
29 29 import com.baidu.trace.LBSTraceClient;
30 30 import com.baidu.trace.Trace;
31   -import com.baidu.trace.api.fence.FenceAlarmPushInfo;
32   -import com.baidu.trace.api.fence.MonitoredAction;
33 31 import com.baidu.trace.api.track.LatestPoint;
34 32 import com.baidu.trace.api.track.LatestPointResponse;
35 33 import com.baidu.trace.api.track.OnTrackListener;
... ... @@ -37,18 +35,16 @@ import com.baidu.trace.model.LocationMode;
37 35 import com.baidu.trace.model.OnTraceListener;
38 36 import com.baidu.trace.model.PushMessage;
39 37 import com.baidu.trace.model.StatusCodes;
40   -import com.cnlive.moudle.pedometer.commonInfo.CollCommonInfo;
41   -import com.cnlive.moudle.pedometer.commonInfo.CommonInfo;
  38 +import com.cnlive.moudle.collectionTrace.commonInfo.CollCommonInfo;
42 39 import com.cnlive.moudle.pedometer.model.Constant;
43 40 import com.cnlive.moudle.pedometer.model.MessageEvent;
44 41 import com.cnlive.moudle.pedometer.model.step.StepCount;
45 42 import com.cnlive.moudle.pedometer.model.step.StepValuePassListener;
46   -import com.cnlive.moudle.pedometer.sql.dao.CollUserStepEntityDao;
47 43 import com.cnlive.moudle.pedometer.sql.db.DbCore;
48 44 import com.cnlive.moudle.pedometer.sql.entity.CollUserStepEntity;
49 45 import com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity;
  46 +import com.cnlive.moudle.collectionTrace.utils.CollStepUtil;
50 47 import com.cnlive.moudle.pedometer.utils.ServiceUtils;
51   -import com.cnlive.moudle.pedometer.utils.TimeUtil;
52 48 import com.example.moudle_pedometer.R;
53 49  
54 50 import org.greenrobot.eventbus.EventBus;
... ... @@ -57,14 +53,10 @@ import org.greenrobot.eventbus.ThreadMode;
57 53  
58 54 import java.text.SimpleDateFormat;
59 55 import java.util.Date;
60   -import java.util.List;
61   -import java.util.UUID;
62   -
63 56  
64 57 public class CollStepService extends Service implements SensorEventListener {
65 58  
66   - private String TAG = "CollStepService";
67   -
  59 + private String TAG = "StepService";
68 60 /**
69 61 * 通知栏相关
70 62 */
... ... @@ -92,11 +84,11 @@ public class CollStepService extends Service implements SensorEventListener {
92 84 /**
93 85 * 保存记步计时器
94 86 */
95   - private TimeCount time;
  87 + private static TimeCount time;
96 88 /**
97 89 * 当前所走的步数
98 90 */
99   - private int CURRENT_STEP;
  91 + private int CURRENT_STEP = 0;
100 92 /**
101 93 * 计步传感器类型 Sensor.TYPE_STEP_COUNTER或者Sensor.TYPE_STEP_DETECTOR
102 94 */
... ... @@ -120,12 +112,12 @@ public class CollStepService extends Service implements SensorEventListener {
120 112 /**
121 113 * IBinder对象,向Activity传递数据的桥梁
122 114 */
123   - private StepBinder stepBinder = new StepBinder();
  115 + private CollStepService.StepBinder stepBinder = new CollStepService.StepBinder();
124 116 private String userId;
125 117 private Handler handler;
126 118 private Runnable speedRunnable;
127 119 private final int NOTIFICATION_ID = 100;
128   - private static int tempStep;//计步器临时保存步数
  120 + // private static int tempStep;//计步器临时保存步数
129 121 private static boolean pauseFlag;//是否暂停
130 122 private static int speedCurrentStep;//用于检测速度步数
131 123 private boolean updateSpeedStepFlag;//是否是已经更新速度
... ... @@ -139,7 +131,6 @@ public class CollStepService extends Service implements SensorEventListener {
139 131 * 轨迹监听器(用于接收纠偏后实时位置回调)
140 132 */
141 133 private OnTrackListener realTimeTraceListener = null;
142   -// public static final long serviceId = 213553;//杨帅
143 134  
144 135 // 设备标识
145 136 public static String entityName = "";
... ... @@ -153,8 +144,6 @@ public class CollStepService extends Service implements SensorEventListener {
153 144 */
154 145 public static Trace mTrace = null;
155 146  
156   - private boolean isFirstSendNotification = true;
157   -
158 147 public CollStepService() {
159 148  
160 149 }
... ... @@ -165,11 +154,19 @@ public class CollStepService extends Service implements SensorEventListener {
165 154 super.onCreate();
166 155 init();
167 156 initBroadcastReceiver();
  157 + if (!ServiceUtils.isServiceRunning(getApplicationContext(), "com.cnlive.moudle.pedometer.service.CollKeepLiveService")) {
  158 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  159 + startForegroundService(new Intent(getApplicationContext(), CollKeepLiveService.class));
  160 + } else {
  161 + startService(new Intent(getApplicationContext(), CollKeepLiveService.class));
  162 + }
  163 + }
168 164 showStartForegroundNotification();
169 165 }
170 166  
171   - private void initTrace() {
  167 + private static int retryIndex = 0;
172 168  
  169 + private void initTrace() {
173 170 if (mClient == null) {
174 171 mClient = new LBSTraceClient(getApplicationContext());
175 172 // 设置定位和打包周期
... ... @@ -228,9 +225,33 @@ public class CollStepService extends Service implements SensorEventListener {
228 225 if (StatusCodes.SUCCESS == errorNo || StatusCodes.START_TRACE_NETWORK_CONNECT_FAILED <= errorNo) {
229 226 //开始进行采集
230 227 if (mClient != null) {
  228 + retryIndex = 0;
231 229 mClient.startGather(traceListener);
232 230 Toast.makeText(getApplicationContext(), "开启轨迹服务", Toast.LENGTH_LONG).show();
  231 + boolean isFirstSendNotification = CollCommonInfo.getIsFirstStepSendTraceTip(getApplicationContext());
  232 + if (isFirstSendNotification) {
  233 + CollCommonInfo.setIsFirstStepSendTraceTip(getApplicationContext(), false);
  234 + EventBus.getDefault().post(new MessageEvent(Constant.COLL_START_TRACE_GATHER_SUCCESS, ""));
  235 + }
  236 +
  237 +
  238 + }
  239 + } else {
  240 +
  241 + if (retryIndex < 4) {
  242 + //重新开启服务
  243 + if (mClient != null) {
  244 + mClient.startTrace(mTrace, traceListener);
  245 + retryIndex++;
  246 + }
  247 + } else {
  248 + boolean isFirstSendNotification = CollCommonInfo.getIsFirstStepSendTraceTip(getApplicationContext());
  249 + if (isFirstSendNotification) {
  250 + CollCommonInfo.setIsFirstStepSendTraceTip(getApplicationContext(), false);
  251 + EventBus.getDefault().post(new MessageEvent(Constant.COLL_START_TRACE_GATHER_FAIL, ""));
  252 + }
233 253 }
  254 +
234 255 }
235 256 }
236 257  
... ... @@ -269,17 +290,15 @@ public class CollStepService extends Service implements SensorEventListener {
269 290 @Override
270 291 public void onStartGatherCallback(int errorNo, String message) {
271 292 if (StatusCodes.SUCCESS == errorNo || StatusCodes.GATHER_STARTED == errorNo) {
  293 + retryIndex = 0;
272 294 Toast.makeText(getApplicationContext(), "开始采集", Toast.LENGTH_LONG).show();
273   - boolean isFirstSendNotification = CollCommonInfo.getIsFirstStepSendTraceTip(getApplicationContext());
274   - if (isFirstSendNotification) {
275   - CollCommonInfo.setIsFirstStepSendTraceTip(getApplicationContext(), false);
276   - EventBus.getDefault().post(new MessageEvent(Constant.COLL_START_TRACE_GATHER_SUCCESS, ""));
277   - }
278 295 } else {
279   - boolean isFirstSendNotification = CollCommonInfo.getIsFirstStepSendTraceTip(getApplicationContext());
280   - if (isFirstSendNotification) {
281   - CollCommonInfo.setIsFirstStepSendTraceTip(getApplicationContext(), false);
282   - EventBus.getDefault().post(new MessageEvent(Constant.COLL_START_TRACE_GATHER_FAIL, ""));
  296 + //重新开启采集
  297 + if (retryIndex < 4) {
  298 + if (null != mClient) {
  299 + mClient.startGather(traceListener);
  300 + }
  301 + retryIndex++;
283 302 }
284 303 }
285 304 }
... ... @@ -320,24 +339,6 @@ public class CollStepService extends Service implements SensorEventListener {
320 339 @Override
321 340 public void onPushCallback(byte messageType, PushMessage pushMessage) {
322 341 Log.e(TAG, "onPushCallback: ");
323   -
324   - if (messageType < 0x03 || messageType > 0x04) {
325   - return;
326   - }
327   - FenceAlarmPushInfo alarmPushInfo = pushMessage.getFenceAlarmPushInfo();
328   - if (null == alarmPushInfo) {
329   - return;
330   - }
331   - //超出范围
332   - if (alarmPushInfo.getMonitoredAction() == MonitoredAction.exit) {
333   - EventBus.getDefault().post(new MessageEvent(Constant.EXIT_RANGE, ""));
334   - }
335   - //进入范围
336   - else if (alarmPushInfo.getMonitoredAction() == MonitoredAction.enter) {
337   - EventBus.getDefault().post(new MessageEvent(Constant.ENTER_RANGE, ""));
338   - }
339   - Toast.makeText(getApplicationContext(), "onPushCallback:" + alarmPushInfo.getMonitoredAction(), Toast.LENGTH_SHORT).show();
340   -
341 342 }
342 343  
343 344 @Override
... ... @@ -348,14 +349,11 @@ public class CollStepService extends Service implements SensorEventListener {
348 349 //开启轨迹服务
349 350 if (mClient != null) {
350 351 mClient.startTrace(mTrace, traceListener);
351   - long stepStartTime = CollCommonInfo.getStepStartTime(getApplicationContext());
352   - if (stepStartTime == 0) {
353   - CollCommonInfo.setStepStartTime(getApplicationContext(), TimeUtil.getNowTimeStamp());
354   - }
355 352 }
356 353  
357 354 }
358 355  
  356 +
359 357 private long i = 0;
360 358 private long index = 0;
361 359 private int mJobId;
... ... @@ -366,10 +364,11 @@ public class CollStepService extends Service implements SensorEventListener {
366 364 public int onStartCommand(Intent intent, int flags, int startId) {
367 365 userId = CollCommonInfo.getUserId(getApplicationContext());
368 366 if (userId != null && !TextUtils.isEmpty(userId)) {
  367 + //初始化数据库
  368 + CollStepUtil.initCollDataBase(getApplicationContext(), userId);
369 369 if (!EventBus.getDefault().isRegistered(this)) {
370 370 EventBus.getDefault().register(this);
371 371 }
372   -
373 372 entityName = userId;
374 373 initTodayData(userId);
375 374 initTrace();
... ... @@ -383,8 +382,7 @@ public class CollStepService extends Service implements SensorEventListener {
383 382 }).start();
384 383 startTimeCount();
385 384 } else {
386   - EventBus.getDefault().post(new MessageEvent(Constant.COLL_START_TRACE_GATHER_FAIL, ""));
387   -
  385 + EventBus.getDefault().post(new MessageEvent(Constant.START_TRACE_GATHER_FAIL, ""));
388 386 }
389 387 // if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
390 388 // //开始配置JobInfo
... ... @@ -406,7 +404,7 @@ public class CollStepService extends Service implements SensorEventListener {
406 404 }
407 405  
408 406 private void init() {
409   - CommonInfo.setIsRunStepService(getApplicationContext(), true);
  407 + CollCommonInfo.setIsRunStepService(getApplicationContext(), true);
410 408 if (null == mNM) {
411 409 mNM = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
412 410 }
... ... @@ -417,7 +415,7 @@ public class CollStepService extends Service implements SensorEventListener {
417 415 //说明用户没有动
418 416 if (!updateSpeedStepFlag) {
419 417 //重置速度
420   - EventBus.getDefault().post(new MessageEvent(Constant.SERVICE_STEP_COUNT_RESET_SPEED, CURRENT_STEP));
  418 + EventBus.getDefault().post(new MessageEvent(Constant.COLL_SERVICE_STEP_COUNT_RESET_SPEED, CURRENT_STEP));
421 419 }
422 420 }
423 421 };
... ... @@ -431,7 +429,7 @@ public class CollStepService extends Service implements SensorEventListener {
431 429 private void showStartForegroundNotification() {
432 430 remoteViews = new RemoteViews(getPackageName(), R.layout.custom_step_notification);
433 431 NotificationChannel channel = null;
434   - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  432 + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
435 433 channel = new NotificationChannel(CHANNEL_ONE_ID, CHANNEL_ONE_NAME,
436 434 NotificationManager.IMPORTANCE_HIGH);
437 435 channel.enableLights(false);
... ... @@ -481,20 +479,31 @@ public class CollStepService extends Service implements SensorEventListener {
481 479 if (speedRunnable != null) {
482 480 handler.removeCallbacks(speedRunnable);
483 481 }
484   - Log.e("杀死", "MyTestService");
  482 +// Log.e("杀死", "MyTestService");
  483 + lastStep = 0;
  484 + hasStepCount = 0;
  485 + hasRecord = false;
  486 + CURRENT_STEP = 0;
  487 + previousStepCount = 0;
  488 + if (sensorManager != null) {
  489 + sensorManager.unregisterListener(CollStepService.this);
  490 + sensorManager = null;
  491 + }
  492 + stepSensorType = -1;
  493 + time = null;
485 494 }
486 495  
487 496 //接收事件
488 497 @Subscribe(threadMode = ThreadMode.BACKGROUND)
489 498 public void Event(MessageEvent messageEvent) {
490   - //暂停计步
491   - if (messageEvent.getMessageType() == Constant.SERVICE_STEP_COUNT_PAUSE) {
492   - pauseFlag = true;
493   - }
494   - //继续计步
495   - else if (messageEvent.getMessageType() == Constant.SERVICE_STEP_COUNT_CONTINUE) {
496   - pauseFlag = false;
497   - }
  499 +// //暂停计步
  500 +// if (messageEvent.getMessageType() == Constant.SERVICE_STEP_COUNT_PAUSE) {
  501 +// pauseFlag = true;
  502 +// }
  503 +// //继续计步
  504 +// else if (messageEvent.getMessageType() == Constant.SERVICE_STEP_COUNT_CONTINUE) {
  505 +// pauseFlag = false;
  506 +// }
498 507 }
499 508  
500 509 /**
... ... @@ -544,17 +553,15 @@ public class CollStepService extends Service implements SensorEventListener {
544 553 return;
545 554 }
546 555 //获取当天的数据,用于展示 CURRENT_DATE
547   - List<CollUserStepEntity> list = DbCore.getDaoSession().getCollUserStepEntityDao().queryBuilder().where(CollUserStepEntityDao.Properties.UserId.eq(userId), CollUserStepEntityDao.Properties.Date.eq(CURRENT_DATE)).list();
548   - if (list == null) {
549   - return;
550   - }
551   - if (list.size() == 0 || list.isEmpty()) {
  556 + CollUserStepEntity userStepEntity = CollStepUtil.getCollUserStepData(getApplicationContext(), CollCommonInfo.getUserId(getApplicationContext()));
  557 + if (userStepEntity == null) {
552 558 CURRENT_STEP = 0;
553   - } else if (list.size() == 1) {
554   - CURRENT_STEP = Integer.parseInt(list.get(0).getStepCount());
555 559 } else {
556   - Log.e(TAG, "出错了!");
  560 + if (userStepEntity.getStepCount() != null) {
  561 + CURRENT_STEP = Integer.parseInt(userStepEntity.getStepCount());
  562 + }
557 563 }
  564 +// Log.e(TAG, "initTodayData: 初始化当前步数" + CURRENT_STEP);
558 565 if (mStepCount != null) {
559 566 mStepCount.setSteps(CURRENT_STEP);
560 567 }
... ... @@ -562,7 +569,8 @@ public class CollStepService extends Service implements SensorEventListener {
562 569 }
563 570  
564 571 private void updateNotification() {
565   - EventBus.getDefault().post(new MessageEvent(Constant.SERVICE_STEP_COUNT_UPDATE, CURRENT_STEP));
  572 +// Log.e(TAG, "updateNotification: 当前步数:" + CURRENT_STEP);
  573 + EventBus.getDefault().post(new MessageEvent(Constant.COLL_SERVICE_STEP_COUNT_UPDATE, CURRENT_STEP));
566 574 updateSpeedStepFlag = false;
567 575 // remoteViews = new RemoteViews(getPackageName(), R.layout.custom_step_notification);
568 576 // NotificationChannel channel = null;
... ... @@ -857,29 +865,45 @@ public class CollStepService extends Service implements SensorEventListener {
857 865 *
858 866 * @param event
859 867 */
  868 + private static int lastStep = 0;//有时候获取的是一样的
  869 +
860 870 @Override
861 871 public void onSensorChanged(SensorEvent event) {
862 872 //没有暂停
863 873 if (stepSensorType == Sensor.TYPE_STEP_COUNTER) {
864 874 //获取当前传感器返回的临时步数
865   - tempStep = (int) event.values[0];
  875 + int tempStep = (int) event.values[0];
  876 +// Log.e(TAG, "onSensorChanged: 第一次,tempStep:" + tempStep + "lastStep:" + lastStep + ",previousStepCount" + previousStepCount + ",CURRENT_STEP" + CURRENT_STEP);
866 877 //首次如果没有获取手机系统中已有的步数则获取一次系统中APP还未开始记步的步数
867 878 if (!hasRecord) {
868 879 hasRecord = true;
869 880 hasStepCount = tempStep;
  881 + previousStepCount = 0;
870 882 } else {
871   - //获取APP打开到现在的总步数=本次系统回调的总步数-APP打开之前已有的步数
872   - int thisStepCount = tempStep - hasStepCount;
873   - //本次有效步数=(APP打开后所记录的总步数-上一次APP打开后所记录的总步数)
874   - int thisStep = thisStepCount - previousStepCount;
875   - //当用户点击暂停了
876   - if (pauseFlag) {
877   - thisStep = 0;
  883 + if (tempStep > lastStep) {
  884 + //获取APP打开到现在的总步数=本次系统回调的总步数-APP打开之前已有的步数
  885 +// Log.e(TAG, "tempStep: " + tempStep + ",hasStepCount:" + hasStepCount);
  886 + int thisStepCount = tempStep - hasStepCount;
  887 +// Log.e(TAG, "onSensorChanged: thisStepCount" + thisStepCount);
  888 + //本次有效步数=(APP打开后所记录的总步数-上一次APP打开后所记录的总步数)
  889 + int thisStep = thisStepCount - previousStepCount;
  890 + //记录最后一次APP打开到现在的总步数
  891 + previousStepCount = thisStepCount;
  892 +// Log.e(TAG, "本次有效步数: thisStep" + thisStep + ",previousStepCount:" + previousStepCount);
  893 + //当用户点击暂停了
  894 + if (pauseFlag) {
  895 + thisStep = 0;
  896 +// Log.e(TAG, "修改: thisStepCount" + thisStep);
  897 + }
  898 +// Log.e(TAG, "onSensorChanged: CURRENT_STEP" + CURRENT_STEP);
  899 + if (CURRENT_STEP < 0) {
  900 + CURRENT_STEP = -CURRENT_STEP;
  901 + }
  902 + //总步数=现有的步数+本次有效步数
  903 + CURRENT_STEP += (thisStep);
  904 +// Log.e(TAG, "onSensorChanged: 加了以后" + CURRENT_STEP);
  905 + lastStep = tempStep;
878 906 }
879   - //总步数=现有的步数+本次有效步数
880   - CURRENT_STEP += (thisStep);
881   - //记录最后一次APP打开到现在的总步数
882   - previousStepCount = thisStepCount;
883 907 }
884 908 } else if (stepSensorType == Sensor.TYPE_STEP_DETECTOR) {
885 909 if (event.values[0] == 1.0) {
... ... @@ -905,27 +929,21 @@ public class CollStepService extends Service implements SensorEventListener {
905 929 * 保存记步数据
906 930 */
907 931 private void save() {
908   - boolean isWriteUserStep = CommonInfo.getIsWriteUserStep(getApplicationContext());
909   - if (!isWriteUserStep) {
910   - return;
911   - }
912 932 int tempStep = CURRENT_STEP;
913   - List<CollUserStepEntity> list = DbCore.getDaoSession().getCollUserStepEntityDao().queryBuilder().where(CollUserStepEntityDao.Properties.UserId.eq(userId), CollUserStepEntityDao.Properties.Date.eq(CURRENT_DATE)).list();
914   - if (list.size() == 0 || list.isEmpty()) {
  933 + CollUserStepEntity userStepEntity = CollStepUtil.getCollUserStepData(getApplicationContext(), CollCommonInfo.getUserId(getApplicationContext()));
  934 + if (userStepEntity == null) {
915 935 CollUserStepEntity data = new CollUserStepEntity();
916   - data.setUuid(UUID.randomUUID().toString());
917 936 data.setUserId(userId);
918 937 data.setDate(CURRENT_DATE);
919 938 data.setStepCount(tempStep + "");
920   - DbCore.getDaoSession().getCollUserStepEntityDao().insert(data);
921   - } else if (list.size() == 1) {
922   - CollUserStepEntity data = list.get(0);
923   - data.setStepCount(tempStep + "");
924   - DbCore.getDaoSession().getCollUserStepEntityDao().update(data);
  939 + CollStepUtil.insertCollStepData(getApplicationContext(), data);
925 940 } else {
  941 + userStepEntity.setStepCount(tempStep + "");
  942 + CollStepUtil.updateCollStepData(getApplicationContext(), userStepEntity);
926 943 }
927 944 }
928 945  
  946 +
929 947 /**
930 948 * 保存记步数据
931 949 */
... ... @@ -937,9 +955,11 @@ public class CollStepService extends Service implements SensorEventListener {
937 955 @Override
938 956 public void onFinish() {
939 957 // 如果计时器正常结束,则开始计步
940   - time.cancel();
941   - save();
942   - startTimeCount();
  958 + if (null != time) {
  959 + time.cancel();
  960 + save();
  961 + startTimeCount();
  962 + }
943 963 }
944 964  
945 965 @Override
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/activity/CollPedometerMainActivity.java
... ... @@ -18,6 +18,7 @@ import com.alibaba.android.arouter.facade.annotation.Route;
18 18 import com.cnlive.libs.base.ui.QMUIFragmentActivity;
19 19 import com.cnlive.libs.base.util.StatusBarUtil2;
20 20 import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunMainFragment;
  21 +import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo;
21 22 import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment;
22 23 import com.cnlive.moudle.pedometer.utils.MyMapUtil;
23 24 import com.cnlive.moudle.pedometer.utils.lib_permisshelper.PermissionsListener;
... ... @@ -38,6 +39,7 @@ public class CollPedometerMainActivity extends QMUIFragmentActivity {
38 39 private boolean isOpen;
39 40 private PermissionsUtils mPermissionsUtils = new PermissionsUtils();//权限申请
40 41 private CollRunMainFragment fragment;
  42 + private RunRaceDetailInfo runRaceDetailInfo;
41 43  
42 44 @Override
43 45 protected int getContextViewId() {
... ... @@ -49,6 +51,7 @@ public class CollPedometerMainActivity extends QMUIFragmentActivity {
49 51 super.onCreate(savedInstanceState);
50 52 StatusBarUtil2.setColor(this, getResources().getColor(R.color.run_main_bg), 0);
51 53 // setContentView(R.layout.activity_pedometer_main);
  54 + runRaceDetailInfo = (RunRaceDetailInfo) getIntent().getExtras().getSerializable("runRaceDetailInfo");
52 55  
53 56 }
54 57  
... ... @@ -118,8 +121,8 @@ public class CollPedometerMainActivity extends QMUIFragmentActivity {
118 121 getPermissionsWithTip();
119 122 }
120 123  
121   - private void addFragment() {
122   - fragment = new CollRunMainFragment();
  124 + private void addFragment(RunRaceDetailInfo runRaceDetailInfo) {
  125 + fragment = CollRunMainFragment.newInstance(runRaceDetailInfo);
123 126 getSupportFragmentManager().beginTransaction()
124 127 .add(getContextViewId(), fragment, fragment.getClass().getSimpleName())
125 128 .addToBackStack(fragment.getClass().getSimpleName())
... ... @@ -150,7 +153,9 @@ public class CollPedometerMainActivity extends QMUIFragmentActivity {
150 153 Toast.makeText(getApplicationContext(), getString(R.string.open_gps_tip), Toast.LENGTH_LONG).show();
151 154 } else {
152 155 if (getCurrentFragment() == null) {
153   - addFragment();
  156 + if (null != runRaceDetailInfo) {
  157 + addFragment(runRaceDetailInfo);
  158 + }
154 159 }
155 160 }
156 161 }
... ... @@ -196,8 +201,9 @@ public class CollPedometerMainActivity extends QMUIFragmentActivity {
196 201 return;
197 202 }
198 203  
199   - public static void startActivity(Activity activity) {
  204 + public static void startActivity(Activity activity, RunRaceDetailInfo runRaceDetailInfo) {
200 205 Intent intent = new Intent(activity, CollPedometerMainActivity.class);
  206 + intent.putExtra("runRaceDetailInfo", runRaceDetailInfo);
201 207 activity.startActivity(intent);
202 208 }
203 209  
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/activity/CollRunningMapActivity.java
... ... @@ -9,6 +9,7 @@ import com.cnlive.libs.base.ui.QMUIFragmentActivity;
9 9 import com.cnlive.libs.base.util.StatusBarUtil2;
10 10 import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunningMapFragment;
11 11 import com.cnlive.moudle.pedometer.model.RunningMapBean;
  12 +import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo;
12 13 import com.cnlive.moudle.pedometer.ui.fragment.RunningMapFragment;
13 14 import com.example.moudle_pedometer.R;
14 15  
... ... @@ -20,9 +21,9 @@ public class CollRunningMapActivity extends QMUIFragmentActivity {
20 21 super.onCreate(savedInstanceState);
21 22  
22 23 StatusBarUtil2.setColor(this, getResources().getColor(R.color.run_main_bg), 0);
23   - RunningMapBean chronometerBean = (RunningMapBean) getIntent().getExtras().getSerializable("runningMapBean");
24   - if (chronometerBean != null) {
25   - addFragment(chronometerBean);
  24 + RunRaceDetailInfo runRaceDetailInfo = (RunRaceDetailInfo) getIntent().getExtras().getSerializable("runRaceDetailInfo");
  25 + if (runRaceDetailInfo != null) {
  26 + addFragment(runRaceDetailInfo);
26 27 }
27 28 }
28 29  
... ... @@ -32,17 +33,17 @@ public class CollRunningMapActivity extends QMUIFragmentActivity {
32 33 return R.id.fragment_running_map;
33 34 }
34 35  
35   - private void addFragment(RunningMapBean chronometerBean) {
36   - QMUIFragment fragment = CollRunningMapFragment.getInstance(chronometerBean);
  36 + private void addFragment(RunRaceDetailInfo runRaceDetailInfo) {
  37 + QMUIFragment fragment = CollRunningMapFragment.getInstance(runRaceDetailInfo);
37 38 getSupportFragmentManager().beginTransaction()
38 39 .add(getContextViewId(), fragment, fragment.getClass().getSimpleName())
39 40 .addToBackStack(fragment.getClass().getSimpleName())
40 41 .commit();
41 42 }
42 43  
43   - public static void startActivity(Activity activity, RunningMapBean runningMapBean) {
  44 + public static void startActivity(Activity activity, RunRaceDetailInfo runRaceDetailInfo) {
44 45 Intent intent = new Intent(activity, CollRunningMapActivity.class);
45   - intent.putExtra("runningMapBean", runningMapBean);
  46 + intent.putExtra("runRaceDetailInfo", runRaceDetailInfo);
46 47 activity.startActivity(intent);
47 48 }
48 49 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/activity/StartCollectTraceActivity.java
... ... @@ -10,14 +10,15 @@ import com.cnlive.libs.base.ui.QMUIFragmentActivity;
10 10 import com.cnlive.libs.base.util.StatusBarUtil;
11 11 import com.cnlive.libs.base.util.StatusBarUtil2;
12 12 import com.cnlive.moudle.collectionTrace.ui.fragment.StartTraceFragment;
  13 +import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo;
13 14 import com.example.moudle_pedometer.R;
14 15  
15 16 public class StartCollectTraceActivity extends QMUIFragmentActivity {
16 17  
17 18  
18   - public static void newInstance(Context context,String eventId){
19   - Intent intent = new Intent(context,StartCollectTraceActivity.class);
20   - intent.putExtra("eventId",eventId);
  19 + public static void newInstance(Context context, String eventId) {
  20 + Intent intent = new Intent(context, StartCollectTraceActivity.class);
  21 + intent.putExtra("eventId", eventId);
21 22 context.startActivity(intent);
22 23 }
23 24  
... ... @@ -31,7 +32,11 @@ public class StartCollectTraceActivity extends QMUIFragmentActivity {
31 32 super.onCreate(savedInstanceState);
32 33 StatusBarUtil.setStatusBarWrite(this);
33 34 StatusBarUtil2.setColor(this, getResources().getColor(R.color.white), 0);
34   - addFragment(new StartTraceFragment());
  35 + RunRaceDetailInfo runRaceDetailInfo = (RunRaceDetailInfo) getIntent().getExtras().getSerializable("runRaceDetailInfo");
  36 + if (null != runRaceDetailInfo) {
  37 + addFragment(StartTraceFragment.newInstance(runRaceDetailInfo));
  38 + }
  39 +
35 40 }
36 41  
37 42 private void addFragment(QMUIFragment fragment) {
... ... @@ -41,8 +46,9 @@ public class StartCollectTraceActivity extends QMUIFragmentActivity {
41 46 .commit();
42 47 }
43 48  
44   - public static void startActivity(Activity activity) {
  49 + public static void startActivity(Activity activity, RunRaceDetailInfo runRaceDetailInfo) {
45 50 Intent intent = new Intent(activity, StartCollectTraceActivity.class);
  51 + intent.putExtra("runRaceDetailInfo", runRaceDetailInfo);
46 52 activity.startActivity(intent);
47 53 }
48 54 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/fragment/CollRunMainFragment.java
... ... @@ -14,19 +14,36 @@ import com.cnlive.libs.base.ui.QMUIFragment;
14 14 import com.cnlive.libs.base.util.StatusBarUtil2;
15 15 import com.cnlive.moudle.collectionTrace.frame.presenter.CollRunMainFragmentPresenter;
16 16 import com.cnlive.moudle.collectionTrace.frame.view.CollRunMainFragmentView;
  17 +import com.cnlive.moudle.pedometer.commonInfo.CommonInfo;
17 18 import com.cnlive.moudle.pedometer.model.Constant;
18 19 import com.cnlive.moudle.pedometer.model.MessageEvent;
  20 +import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo;
  21 +import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity;
  22 +import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment;
  23 +import com.cnlive.moudle.pedometer.utils.GsonUtil;
  24 +import com.cnlive.moudle.pedometer.utils.StepUtil;
19 25 import com.cnlive.moudle.pedometer.utils.TimeUtil;
20 26 import com.example.moudle_pedometer.R;
  27 +import com.example.moudle_pedometer.databinding.FragmentCollRunMainBinding;
21 28 import com.example.moudle_pedometer.databinding.FragmentRunMainBinding;
22 29  
23 30 import org.greenrobot.eventbus.EventBus;
24 31 import org.greenrobot.eventbus.Subscribe;
25 32 import org.greenrobot.eventbus.ThreadMode;
26 33  
27   -public class CollRunMainFragment extends QMUIFragment<CollRunMainFragmentView, CollRunMainFragmentPresenter, FragmentRunMainBinding> {
  34 +import java.io.Serializable;
  35 +
  36 +public class CollRunMainFragment extends QMUIFragment<CollRunMainFragmentView, CollRunMainFragmentPresenter, FragmentCollRunMainBinding> {
28 37 private final String TAG = "CollRunMainFragment";
29   - private String userId = "yangshuai";
  38 + private RunRaceDetailInfo runRaceDetailInfo;
  39 +
  40 + public static CollRunMainFragment newInstance(RunRaceDetailInfo runRaceDetailInfo) {
  41 + Bundle bundle = new Bundle();
  42 + bundle.putSerializable("runRaceDetailInfo", (Serializable) runRaceDetailInfo);
  43 + CollRunMainFragment fragment = new CollRunMainFragment();
  44 + fragment.setArguments(bundle);
  45 + return fragment;
  46 + }
30 47  
31 48 @NonNull
32 49 @Override
... ... @@ -39,16 +56,17 @@ public class CollRunMainFragment extends QMUIFragment&lt;CollRunMainFragmentView, C
39 56 super.onViewCreated(view, savedInstanceState);
40 57 StatusBarUtil2.setColor(getActivity(), getResources().getColor(R.color.run_main_bg), 0);
41 58 EventBus.getDefault().register(this);
42   - if (getMvpView() != null) {
43   - new Handler().postDelayed(new Runnable() {
44   - @Override
45   - public void run() {
  59 + if (getArguments() != null) {
  60 + runRaceDetailInfo = (RunRaceDetailInfo) getArguments().getSerializable("runRaceDetailInfo");
  61 + if (runRaceDetailInfo != null) {
  62 + if (getMvpView() != null) {
  63 + getMvpView().initView(runRaceDetailInfo);
46 64  
47   - getMvpView().initView();
48 65 }
49   - }, 5);
  66 + }
50 67 }
51 68  
  69 +
52 70 //
53 71  
54 72  
... ... @@ -63,12 +81,6 @@ public class CollRunMainFragment extends QMUIFragment&lt;CollRunMainFragmentView, C
63 81 @Override
64 82 public void onPause() {
65 83 super.onPause();
66   - //记录当前计时器相关数据
67   - if (getMvpView() != null) {
68   - if (!TextUtils.isEmpty(userId)) {
69   - getMvpView().setSQLPauseTime(userId);
70   - }
71   - }
72 84 }
73 85  
74 86 @Override
... ... @@ -95,19 +107,19 @@ public class CollRunMainFragment extends QMUIFragment&lt;CollRunMainFragmentView, C
95 107  
96 108 @Override
97 109 protected int getLayoutId() {
98   - return R.layout.fragment_run_main;
  110 + return R.layout.fragment_coll_run_main;
99 111 }
100 112  
101 113 @Subscribe(threadMode = ThreadMode.MAIN)
102 114 public void Event(MessageEvent messageEvent) {
103 115 //更新步数
104   - if (messageEvent.getMessageType() == Constant.SERVICE_STEP_COUNT_UPDATE) {
  116 + if (messageEvent.getMessageType() == Constant.COLL_SERVICE_STEP_COUNT_UPDATE) {
105 117 if (getMvpView() != null) {
106 118 getMvpView().updateRunDistance((Integer) messageEvent.getMessageContent());
107 119 }
108 120 }
109 121 //重置速度
110   - else if (messageEvent.getMessageType() == Constant.SERVICE_STEP_COUNT_RESET_SPEED) {
  122 + else if (messageEvent.getMessageType() == Constant.COLL_SERVICE_STEP_COUNT_RESET_SPEED) {
111 123 if (getMvpView() != null) {
112 124 getMvpView().resetSpeed();
113 125 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/fragment/CollRunningMapFragment.java
... ... @@ -6,25 +6,17 @@ import android.hardware.SensorManager;
6 6 import android.os.Bundle;
7 7 import android.os.Vibrator;
8 8 import android.support.annotation.Nullable;
9   -import android.text.TextUtils;
10   -import android.util.Log;
11 9 import android.view.View;
12 10  
13   -import com.baidu.mapapi.model.LatLng;
14 11 import com.cnlive.libs.base.ui.QMUIFragment;
15 12 import com.cnlive.libs.base.util.StatusBarUtil2;
16 13 import com.cnlive.moudle.collectionTrace.frame.presenter.CollRunningMapFragmentPresenter;
17 14 import com.cnlive.moudle.collectionTrace.frame.view.CollRunningMapFragmentView;
18   -import com.cnlive.moudle.pedometer.commonInfo.CollCommonInfo;
19   -import com.cnlive.moudle.pedometer.commonInfo.CommonInfo;
20 15 import com.cnlive.moudle.pedometer.model.Constant;
21 16 import com.cnlive.moudle.pedometer.model.MessageEvent;
22   -import com.cnlive.moudle.pedometer.model.RunningMapBean;
23   -import com.cnlive.moudle.pedometer.service.StepService;
  17 +import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo;
24 18 import com.cnlive.moudle.pedometer.ui.widget.TipDialog;
25 19 import com.cnlive.moudle.pedometer.utils.ChineseToSpeechUtil;
26   -import com.cnlive.moudle.pedometer.utils.GsonUtil;
27   -import com.cnlive.moudle.pedometer.utils.TimeUtil;
28 20 import com.example.moudle_pedometer.R;
29 21 import com.example.moudle_pedometer.databinding.FragmentCollectRunningMapBinding;
30 22  
... ... @@ -32,9 +24,6 @@ import org.greenrobot.eventbus.EventBus;
32 24 import org.greenrobot.eventbus.Subscribe;
33 25 import org.greenrobot.eventbus.ThreadMode;
34 26  
35   -import java.util.ArrayList;
36   -import java.util.List;
37   -
38 27 import static android.content.Context.SENSOR_SERVICE;
39 28  
40 29 /**
... ... @@ -44,7 +33,6 @@ import static android.content.Context.SENSOR_SERVICE;
44 33 */
45 34 public class CollRunningMapFragment extends QMUIFragment<CollRunningMapFragmentView, CollRunningMapFragmentPresenter, FragmentCollectRunningMapBinding> {
46 35 private static final String TAG = "CollRunningMapFragment";
47   - private RunningMapBean runningMapBean;
48 36 private SensorManager mSensorManager;
49 37 private String test = "[{\"latitude\":39.933889208848,\"latitudeE6\":3.9933889208848E7,\"longitude\":116.30900265517,\"longitudeE6\":1.1630900265517001E8},{\"latitude\":39.933868507347,\"latitudeE6\":3.9933868507347E7,\"longitude\":116.30865416508,\"longitudeE6\":1.1630865416508E8},{\"latitude\":39.934756505077,\"latitudeE6\":3.9934756505077E7,\"longitude\":116.30860516469,\"longitudeE6\":1.1630860516468999E8},{\"latitude\":39.934781620502,\"latitudeE6\":3.9934781620502E7,\"longitude\":116.30961013007,\"longitudeE6\":1.1630961013007E8},{\"latitude\":39.934881620374,\"latitudeE6\":3.9934881620374E7,\"longitude\":116.30960513008,\"longitudeE6\":1.1630960513008E8},{\"latitude\":39.934077623132,\"latitudeE6\":3.9934077623132E7,\"longitude\":116.30965812942,\"longitudeE6\":1.1630965812942E8},{\"latitude\":39.933972618463,\"latitudeE6\":3.9933972618463E7,\"longitude\":116.30962113087,\"longitudeE6\":1.1630962113087E8},{\"latitude\":39.933932608856,\"latitudeE6\":3.9933932608856E7,\"longitude\":116.30953913383,\"longitudeE6\":1.1630953913383E8}]";
50 38 //创建震动服务对象
... ... @@ -66,16 +54,26 @@ public class CollRunningMapFragment extends QMUIFragment&lt;CollRunningMapFragmentV
66 54 return R.layout.fragment_collect_running_map;
67 55 }
68 56  
69   - public static CollRunningMapFragment getInstance(RunningMapBean runningMapBean) {
  57 + // public static CollRunningMapFragment getInstance(RunningMapBean runningMapBean) {
  58 +// CollRunningMapFragment fragment = new CollRunningMapFragment();
  59 +// Bundle bundle = new Bundle();
  60 +// if (runningMapBean != null) {
  61 +// bundle.putSerializable("runningMapBean", runningMapBean);
  62 +// }
  63 +// fragment.setArguments(bundle);
  64 +// return fragment;
  65 +// }
  66 + public static CollRunningMapFragment getInstance(RunRaceDetailInfo runRaceDetailInfo) {
70 67 CollRunningMapFragment fragment = new CollRunningMapFragment();
71 68 Bundle bundle = new Bundle();
72   - if (runningMapBean != null) {
73   - bundle.putSerializable("runningMapBean", runningMapBean);
  69 + if (runRaceDetailInfo != null) {
  70 + bundle.putSerializable("runRaceDetailInfo", runRaceDetailInfo);
74 71 }
75 72 fragment.setArguments(bundle);
76 73 return fragment;
77 74 }
78 75  
  76 +
79 77 @Override
80 78 public void onActivityCreated(@Nullable Bundle savedInstanceState) {
81 79 super.onActivityCreated(savedInstanceState);
... ... @@ -92,41 +90,35 @@ public class CollRunningMapFragment extends QMUIFragment&lt;CollRunningMapFragmentV
92 90 mVibrator = (Vibrator) getActivity().getSystemService(Service.VIBRATOR_SERVICE);
93 91 //初始化提示框
94 92 initTipDialog();
95   - List<LatLng> trackPoints = GsonUtil.jsonToList(test, LatLng.class);
96   -
97 93 if (getArguments() != null) {
98   - runningMapBean = (RunningMapBean) getArguments().getSerializable("runningMapBean");
99   - }
100   - if (getMvpView() != null) {
101   - getMvpView().initView(trackPoints);
102   - if (runningMapBean != null) {
103   - getMvpView().updateChronometer(runningMapBean);
  94 + RunRaceDetailInfo runRaceDetailInfo = (RunRaceDetailInfo) getArguments().getSerializable("runRaceDetailInfo");
  95 + if (null!=runRaceDetailInfo){
  96 + if (getMvpView() != null) {
  97 + getMvpView().initMap();
  98 + getMvpView().initView(runRaceDetailInfo);
  99 + }
104 100 }
105 101 }
106   - //开始进行历史轨迹查询
107   - if (getPresenter() != null && !TextUtils.isEmpty(StepService.entityName)) {
108   - long stepStartTime = CollCommonInfo.getStepStartTime(getActivity());
109   - Log.e(TAG, "onViewCreated: 时间"+stepStartTime );
110   - long startTime = 0;
111   - if (stepStartTime != 0) {
112   - startTime = stepStartTime;
113   - } else {
114   - startTime = (int) (System.currentTimeMillis() / 1000 -12 * 60 * 60);
115   - }
116   - long current = TimeUtil.getNowTimeStamp();
117   -// long startTime = current - hour * 3600 * 1000 - minute * 60 * 1000 - second * 1000;
118   - long endTime = current;
119   -// Log.e(TAG, "onViewCreated: " + "hour:" + hour + ",minute" + minute + ",second:" + second);
120   - getPresenter().queryHistoryTrace(getActivity(), StepService.entityName, startTime, endTime);
121 102  
122   - }
  103 + //开始进行历史轨迹查询
  104 +// if (getPresenter() != null && !TextUtils.isEmpty(StepService.entityName)) {
  105 +// long stepStartTime = CollCommonInfo.getStepStartTime(getActivity());
  106 +// Log.e(TAG, "onViewCreated: 时间" + stepStartTime);
  107 +// long startTime = 0;
  108 +// if (stepStartTime != 0) {
  109 +// startTime = stepStartTime;
  110 +// } else {
  111 +// startTime = (int) (System.currentTimeMillis() / 1000 - 12 * 60 * 60);
  112 +// }
  113 +// long current = TimeUtil.getNowTimeStamp();
  114 +//// long startTime = current - hour * 3600 * 1000 - minute * 60 * 1000 - second * 1000;
  115 +// long endTime = current;
  116 +//// Log.e(TAG, "onViewCreated: " + "hour:" + hour + ",minute" + minute + ",second:" + second);
  117 +// getPresenter().queryHistoryTrace(getActivity(), CollStepService.entityName, startTime, endTime);
  118 +//
  119 +// }
123 120  
124 121  
125   - List<com.baidu.trace.model.LatLng> fenceLatLngs = new ArrayList<>();
126   - for (LatLng latLng : trackPoints) {
127   - com.baidu.trace.model.LatLng tempLatLng = new com.baidu.trace.model.LatLng(latLng.latitude, latLng.longitude);
128   - fenceLatLngs.add(tempLatLng);
129   - }
130 122 }
131 123  
132 124 @Override
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/fragment/StartTraceFragment.java
... ... @@ -10,9 +10,11 @@ import com.cnlive.libs.base.ui.QMUIFragment;
10 10 import com.cnlive.moudle.collectionTrace.frame.presenter.StartTraceFragmentPresenter;
11 11 import com.cnlive.moudle.collectionTrace.frame.view.StartTraceFragmentView;
12 12 import com.cnlive.moudle.collectionTrace.ui.activity.CollPedometerMainActivity;
  13 +import com.cnlive.moudle.collectionTrace.ui.activity.CollRunningMapActivity;
13 14 import com.cnlive.moudle.collectionTrace.ui.activity.StartCollectTraceActivity;
14 15 import com.cnlive.moudle.pedometer.model.Constant;
15 16 import com.cnlive.moudle.pedometer.model.MessageEvent;
  17 +import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo;
16 18 import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil;
17 19 import com.example.moudle_pedometer.R;
18 20 import com.example.moudle_pedometer.databinding.FragmentStartCollectTraceBinding;
... ... @@ -27,6 +29,14 @@ public class StartTraceFragment extends QMUIFragment&lt;StartTraceFragmentView, Sta
27 29 private static final String TAG = "StartTraceFragment";
28 30 private SensorManager mSensorManager;
29 31  
  32 + public static StartTraceFragment newInstance(RunRaceDetailInfo runRaceDetailInfo) {
  33 + StartTraceFragment fragment = new StartTraceFragment();
  34 + Bundle bundle = new Bundle();
  35 + bundle.putSerializable("runRaceDetailInfo", runRaceDetailInfo);
  36 + fragment.setArguments(bundle);
  37 + return fragment;
  38 + }
  39 +
30 40 @Override
31 41 protected int getToolbarId() {
32 42 return R.id.topbar;
... ... @@ -47,11 +57,16 @@ public class StartTraceFragment extends QMUIFragment&lt;StartTraceFragmentView, Sta
47 57 super.onViewCreated(view, savedInstanceState);
48 58 EventBus.getDefault().register(this);
49 59 mSensorManager = (SensorManager) getActivity().getSystemService(SENSOR_SERVICE);//获取传感器管理服务
50   -
51   - if (getMvpView() != null) {
52   - getMvpView().initMap();
53   - getMvpView().initView();
  60 + if (null != getArguments()) {
  61 + RunRaceDetailInfo runRaceDetailInfo = (RunRaceDetailInfo) getArguments().getSerializable("runRaceDetailInfo");
  62 + if (null != runRaceDetailInfo) {
  63 + if (getMvpView() != null) {
  64 + getMvpView().initMap();
  65 + getMvpView().initView(runRaceDetailInfo);
  66 + }
  67 + }
54 68 }
  69 +
55 70 }
56 71  
57 72 @Override
... ... @@ -102,7 +117,9 @@ public class StartTraceFragment extends QMUIFragment&lt;StartTraceFragmentView, Sta
102 117 if (messageEvent.getMessageType() == Constant.COLL_START_TRACE_GATHER_SUCCESS) {
103 118 if (getMvpView() != null) {
104 119 QMUITipDialogUtil.dismessDialog();
105   - CollPedometerMainActivity.startActivity(getActivity());
  120 + if (null != getMvpView()) {
  121 + CollRunningMapActivity.startActivity(getActivity(),getMvpView().runRaceDetailInfo);
  122 + }
106 123 }
107 124 }
108 125 //启动鹰眼失败
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/utils/CollStepUtil.java 0 → 100644
  1 +package com.cnlive.moudle.collectionTrace.utils;
  2 +
  3 +import android.content.Context;
  4 +import android.text.TextUtils;
  5 +import android.util.Log;
  6 +
  7 +import com.baidu.mapapi.model.LatLng;
  8 +import com.cnlive.moudle.collectionTrace.model.CollectPoint;
  9 +import com.cnlive.moudle.pedometer.sql.dao.CollUserStepEntityDao;
  10 +import com.cnlive.moudle.pedometer.sql.dao.UserStepEntityDao;
  11 +import com.cnlive.moudle.pedometer.sql.db.DbCore;
  12 +import com.cnlive.moudle.pedometer.sql.entity.CollUserStepEntity;
  13 +import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity;
  14 +import com.cnlive.moudle.pedometer.utils.GsonUtil;
  15 +
  16 +import java.text.SimpleDateFormat;
  17 +import java.util.ArrayList;
  18 +import java.util.Date;
  19 +import java.util.List;
  20 +import java.util.UUID;
  21 +
  22 +/**
  23 + * 步数工具
  24 + *
  25 + * @author ShinnyYang
  26 + */
  27 +public class CollStepUtil {
  28 + private static final String TAG = "CollStepUtil";
  29 + private static final String dbName = "CollStep.db";
  30 +
  31 + public static String getUUID() {
  32 + return UUID.randomUUID().toString().replace("-", "");
  33 + }
  34 +
  35 + /**
  36 + * 初始化数据库
  37 + *
  38 + * @param context
  39 + * @param uid
  40 + */
  41 + public static void initCollDataBase(Context context, String uid) {
  42 + if (null == getCollUserStepData(context, uid)) {
  43 + CollUserStepEntity entity = new CollUserStepEntity();
  44 + entity.setUserId(uid);
  45 + insertCollStepData(context, entity);
  46 + }
  47 +
  48 + }
  49 +
  50 +
  51 + /**
  52 + * 设置开始起点坐标
  53 + *
  54 + * @param context
  55 + * @param uid
  56 + * @param startPointName
  57 + * @param startPointLatLng
  58 + */
  59 + public static void setCollStartPointData(Context context, String uid, String startPointName, String startPointLatLng) {
  60 + //先获取有没有
  61 + if (getCollUserStepData(context, uid) != null) {
  62 + CollUserStepEntity entity = getCollUserStepData(context, uid);
  63 + if (null != entity) {
  64 + entity.setCollStartLatLngName(startPointName);
  65 + entity.setCollStartLatLng(startPointLatLng);
  66 + //更新数据
  67 + updateCollStepData(context, entity);
  68 + }
  69 + }
  70 + }
  71 +
  72 + /**
  73 + * 设置打的重要点
  74 + *
  75 + * @param context
  76 + * @param uid
  77 + * @param latLng
  78 + */
  79 + public static void setImportPoints(Context context, String uid, LatLng latLng) {
  80 + //先获取有没有
  81 + if (getCollUserStepData(context, uid) != null) {
  82 + CollUserStepEntity entity = getCollUserStepData(context, uid);
  83 + if (null != entity) {
  84 + //判断有没有打过点
  85 + if (!TextUtils.isEmpty(entity.getImportPoint())) {
  86 + //已经打过点,先把打的点取出来
  87 + List<LatLng> lngs = GsonUtil.jsonToList(entity.getImportPoint(), LatLng.class);
  88 + if (null != lngs) {
  89 + //加入新打的点
  90 + if (!lngs.contains(latLng)) {
  91 + lngs.add(latLng);
  92 + //重新设置打的点
  93 + entity.setImportPoint(GsonUtil.GsonString(lngs));
  94 + //更新数据
  95 + updateCollStepData(context, entity);
  96 + }
  97 +
  98 + }
  99 + }
  100 + //没有打过点
  101 + else {
  102 + //则设置一个
  103 + List<LatLng> lngs = new ArrayList<>();
  104 + lngs.add(latLng);
  105 + //重新设置打的点
  106 + entity.setImportPoint(GsonUtil.GsonString(lngs));
  107 + //更新数据
  108 + updateCollStepData(context, entity);
  109 + }
  110 + }
  111 + }
  112 + }
  113 +
  114 + /**
  115 + * 设置运营赛事标题
  116 + *
  117 + * @param context
  118 + * @param uid
  119 + * @param streetTitle
  120 + */
  121 + public static void setCollStreetTitle(Context context, String uid, String streetTitle) {
  122 + if (getCollUserStepData(context, uid) != null) {
  123 + CollUserStepEntity entity = getCollUserStepData(context, uid);
  124 + entity.setStreetTitle(streetTitle);
  125 + //更新数据
  126 + updateCollStepData(context, entity);
  127 + }
  128 + }
  129 +
  130 + /**
  131 + * 更新运营数据
  132 + *
  133 + * @param context
  134 + * @param userStepEntity
  135 + */
  136 + public static void updateCollStepData(Context context, CollUserStepEntity userStepEntity) {
  137 + if (userStepEntity != null) {
  138 + DbCore.init(context, dbName);
  139 + DbCore.getDaoSession().getCollUserStepEntityDao().update(userStepEntity);
  140 + }
  141 +
  142 + }
  143 +
  144 + /**
  145 + * 插入计步数据
  146 + *
  147 + * @param context
  148 + * @param userStepEntity
  149 + */
  150 + public static void insertCollStepData(Context context, CollUserStepEntity userStepEntity) {
  151 + DbCore.init(context, dbName);
  152 + DbCore.getDaoSession().getCollUserStepEntityDao().insert(userStepEntity);
  153 + }
  154 +
  155 + /**
  156 + * 设置计步开始时间
  157 + *
  158 + * @param context
  159 + * @param uid
  160 + * @param time
  161 + */
  162 + public static void setCollChronometerBase(Context context, String uid, long time) {
  163 + if (getCollUserStepData(context, uid) != null) {
  164 + CollUserStepEntity entity = getCollUserStepData(context, uid);
  165 + entity.setChronometerBase(time);
  166 + //更新数据
  167 + updateCollStepData(context, entity);
  168 + } else {
  169 + //创建数据
  170 + CollUserStepEntity userStepEntity = new CollUserStepEntity();
  171 + userStepEntity.setUserId(uid);
  172 + userStepEntity.setChronometerBase(time);
  173 + insertCollStepData(context, userStepEntity);
  174 + }
  175 + }
  176 +
  177 + /**
  178 + * 初始化运营计步相关数据
  179 + *
  180 + * @param context
  181 + * @param uid
  182 + * @param startStamp
  183 + * @param streetId
  184 + */
  185 + public static void setCollStepStartData(Context context, String uid, long startStamp, String streetId) {
  186 + if (getCollUserStepData(context, uid) != null) {
  187 + CollUserStepEntity entity = getCollUserStepData(context, uid);
  188 + entity.setStartTimeStamp(startStamp);
  189 + entity.setStreetId(streetId);
  190 + //更新数据
  191 + updateCollStepData(context, entity);
  192 + } else {
  193 + //创建数据
  194 + CollUserStepEntity userStepEntity = new CollUserStepEntity();
  195 + userStepEntity.setUserId(uid);
  196 + userStepEntity.setStartTimeStamp(startStamp);
  197 + userStepEntity.setStreetId(streetId);
  198 + insertCollStepData(context, userStepEntity);
  199 + }
  200 + }
  201 +
  202 + /**
  203 + * 计算配速
  204 + */
  205 + public static String getPaceSpeed(double second, double distance) {
  206 + if (distance != 0) {
  207 + //计算分
  208 + int minute = (int) (second / distance / 60);
  209 + //获取秒
  210 + double miaoMin = ((double) (second / distance / 60)) - ((int) (second / distance / 60));
  211 + int miao = (int) (miaoMin * 60);
  212 + return minute + "'" + miao + "''";
  213 + } else {
  214 + return "--";
  215 + }
  216 + }
  217 +
  218 +
  219 + /**
  220 + * 得到当前速度
  221 + *
  222 + * @param time
  223 + * @param distance
  224 + * @return
  225 + */
  226 + public static double getCurrentSpeed(double time, double distance) {
  227 + double result = distance / time;
  228 + result = Double.parseDouble(String.format("%1.2f", result));
  229 + return result;
  230 + }
  231 +
  232 + /**
  233 + * 根据行走步数,计算大概行走具体
  234 + * 单位:公里
  235 + * 1步的距离大概是60厘米。
  236 + * 1万多步,距离大概就是600000厘米,即6000米(6公里)
  237 + *
  238 + * @param step
  239 + * @return
  240 + */
  241 + public static double getWalkDistanceKM(long step) {
  242 + double result = step * 60.0 / 100.0 / 1000.0;
  243 + result = Double.parseDouble(String.format("%1.2f", result));
  244 + return result;
  245 + }
  246 +
  247 + /**
  248 + * 清除保存数据库中的数据
  249 + *
  250 + * @param uid
  251 + */
  252 + public static void clearRunData(Context context, String uid) {
  253 + DbCore.init(context, dbName);
  254 + String CURRENT_DATE = getTodayDate();
  255 + List<CollUserStepEntity> list = DbCore.getDaoSession().getCollUserStepEntityDao().queryBuilder().where(CollUserStepEntityDao.Properties.UserId.eq(uid), CollUserStepEntityDao.Properties.Date.eq(CURRENT_DATE)).list();
  256 + if (list != null && list.size() > 0) {
  257 + Log.e(TAG, "clearRunData: " + list.size());
  258 + DbCore.getDaoSession().getCollUserStepEntityDao().deleteByKey(list.get(0).getUserId());
  259 + DbCore.getDaoSession().getCollUserStepEntityDao().detachAll();
  260 + }
  261 + }
  262 +
  263 + /**
  264 + * 获取用户数据
  265 + *
  266 + * @param context
  267 + * @param uid
  268 + * @return
  269 + */
  270 + public static CollUserStepEntity getCollUserStepData(Context context, String uid) {
  271 + if (!TextUtils.isEmpty(uid)) {
  272 + DbCore.init(context, dbName);
  273 + DbCore.getDaoSession().getCollUserStepEntityDao().detachAll();
  274 + DbCore.getDaoSession().clear();
  275 + List<CollUserStepEntity> list = DbCore.getDaoSession().getCollUserStepEntityDao().queryBuilder().where(CollUserStepEntityDao.Properties.UserId.eq(uid)).list();
  276 + if (list != null && list.size() > 0) {
  277 + return list.get(0);
  278 + } else {
  279 + return null;
  280 + }
  281 + } else {
  282 + return null;
  283 + }
  284 + }
  285 +
  286 + /**
  287 + * 获取用户数据
  288 + *
  289 + * @param context
  290 + * @param uid
  291 + * @return
  292 + */
  293 + public static void setServerTraceData(Context context, String uid, CollUserStepEntity userStepEntity) {
  294 + if (getCollUserStepData(context, uid) != null) {
  295 + CollUserStepEntity entity = getCollUserStepData(context, uid);
  296 + } else {
  297 +
  298 + }
  299 + }
  300 +
  301 + /**
  302 + * 获取当天日期
  303 + *
  304 + * @return
  305 + */
  306 + private static String getTodayDate() {
  307 + Date date = new Date(System.currentTimeMillis());
  308 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  309 + return sdf.format(date);
  310 + }
  311 +
  312 +
  313 +}
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/commonInfo/CommonInfo.java
... ... @@ -134,7 +134,7 @@ public class CommonInfo {
134 134 * @param context
135 135 */
136 136 public static boolean getIsRunBaiduTraceService(Context context) {
137   - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("RunBaiduTraceService", false);
  137 + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("RunBaiduTraceService", true);
138 138 }
139 139  
140 140 /**
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/presenter/RunningFinishFragmetPresenter.java
... ... @@ -211,6 +211,8 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter&lt;RunningFinis
211 211 //判断用户是否点击暂停按钮
212 212 if (userStepEntity.getPauseCount() == 0) {
213 213 MyMapUtil.drawHistoryTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, R.drawable.icon_start, R.drawable.icon_end);
  214 + MyMapUtil.setMapAutoZoom(getView().baiduMap, resultPoints, -2f);
  215 +
214 216 //没有点击暂停
215 217 //先判断是否到达终点
216 218 checkUserIsFinish(resultPoints, userStepEntity, runningFinishBean, context);
... ... @@ -231,6 +233,8 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter&lt;RunningFinis
231 233 allResults.addAll(resultPoints);
232 234 //判断用户是否完成
233 235 if (importPoints != null) {
  236 + MyMapUtil.drawHistoryTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, 0, R.drawable.icon_end);
  237 + MyMapUtil.setMapAutoZoom(getView().baiduMap, allResults, -2f);
234 238 //先判断是否到达终点
235 239 checkUserIsFinish(resultPoints, userStepEntity, runningFinishBean, context);
236 240 saveRouteData(context, userStepEntity, runningFinishBean);
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/presenter/RunningMapFragmentPresenter.java
... ... @@ -382,7 +382,7 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter&lt;RunningMapFrag
382 382 if (isPause) {
383 383 MyMapUtil.drawRealTimeTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, R.drawable.icon_start);
384 384 } else {
385   - MyMapUtil.drawHistoryTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, R.drawable.icon_start, R.drawable.icon_end);
  385 + MyMapUtil.drawHistoryTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, R.drawable.icon_start, 0);
386 386 }
387 387 }
388 388 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/OnGoingFragmentView.java
... ... @@ -7,6 +7,7 @@ import android.graphics.BitmapFactory;
7 7 import android.text.TextUtils;
8 8 import android.util.Log;
9 9 import android.view.View;
  10 +import android.view.ViewTreeObserver;
10 11 import android.widget.LinearLayout;
11 12  
12 13 import com.alibaba.android.arouter.launcher.ARouter;
... ... @@ -210,15 +211,25 @@ public class OnGoingFragmentView implements MvpView {
210 211 //设置围栏ID
211 212 CommonInfo.setFenceId(getContext(), Integer.parseInt(runRaceDetailInfo.getFenceId()));
212 213 }
  214 + fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 140));
213 215 //设置标题
214 216 if (!TextUtils.isEmpty(runRaceDetailInfo.getTitle())) {
215 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 233 fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
223 234 }
224 235 //设置活动地点
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunMainFragmentView.java
... ... @@ -193,6 +193,7 @@ public class RunMainFragmentView implements MvpView {
193 193 } else {
194 194 ButtonAnimUtil.startAnimation(fragment.binding.llStartTimeTip, true);
195 195 fragment.binding.llRunMainRoot.setVisibility(View.VISIBLE);
  196 + fragment.binding.llRunMainRoot.setBackgroundColor(getContext().getResources().getColor(R.color.run_main_bg));
196 197 new Handler().postDelayed(new Runnable() {
197 198 @Override
198 199 public void run() {
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
... ... @@ -8,13 +8,11 @@ import android.hardware.Sensor;
8 8 import android.hardware.SensorEvent;
9 9 import android.hardware.SensorEventListener;
10 10 import android.hardware.SensorManager;
11   -import android.os.Handler;
12 11 import android.os.SystemClock;
13 12 import android.support.v4.content.ContextCompat;
14 13 import android.text.TextUtils;
15 14 import android.util.Log;
16 15 import android.view.View;
17   -import android.view.ViewGroup;
18 16 import android.view.ViewTreeObserver;
19 17 import android.widget.LinearLayout;
20 18 import android.widget.Toast;
... ... @@ -28,39 +26,18 @@ import com.baidu.mapapi.map.BaiduMap;
28 26 import com.baidu.mapapi.map.BitmapDescriptor;
29 27 import com.baidu.mapapi.map.BitmapDescriptorFactory;
30 28 import com.baidu.mapapi.map.MapStatus;
31   -import com.baidu.mapapi.map.MapStatusUpdate;
32 29 import com.baidu.mapapi.map.MapStatusUpdateFactory;
33 30 import com.baidu.mapapi.map.MapView;
34 31 import com.baidu.mapapi.map.MarkerOptions;
35 32 import com.baidu.mapapi.map.MyLocationConfiguration;
36 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 34 import com.baidu.mapapi.map.UiSettings;
41 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 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 37 import com.baidu.mapapi.utils.DistanceUtil;
55 38 import com.baidu.trace.LBSTraceClient;
56   -import com.baidu.trace.Trace;
57   -import com.baidu.trace.model.LocationMode;
58 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 40 import com.cnlive.libs.base.util.StatusBarUtil2;
63   -import com.cnlive.moudle.pedometer.commonInfo.CollCommonInfo;
64 41 import com.cnlive.moudle.pedometer.commonInfo.CommonInfo;
65 42 import com.cnlive.moudle.pedometer.model.Constant;
66 43 import com.cnlive.moudle.pedometer.net.SubscriptionRequest;
... ... @@ -75,7 +52,6 @@ import com.cnlive.moudle.pedometer.ui.activity.TakePartActivity;
75 52 import com.cnlive.moudle.pedometer.ui.fragment.RunRaceDetailFragment;
76 53 import com.cnlive.moudle.pedometer.ui.widget.SelectDialog;
77 54 import com.cnlive.moudle.pedometer.ui.widget.TipDialog;
78   -import com.cnlive.moudle.pedometer.upload.UploadLogic;
79 55 import com.cnlive.moudle.pedometer.utils.BitmapUtil;
80 56 import com.cnlive.moudle.pedometer.utils.GsonUtil;
81 57 import com.cnlive.moudle.pedometer.utils.MyMapUtil;
... ... @@ -90,13 +66,7 @@ import com.hannesdorfmann.mosby3.mvp.MvpView;
90 66 import com.qmuiteam.qmui.util.QMUIStatusBarHelper;
91 67 import com.sothree.slidinguppanel.SlidingUpPanelLayout;
92 68  
93   -import java.io.File;
94   -import java.io.FileOutputStream;
95   -import java.io.LineNumberReader;
96   -import java.text.SimpleDateFormat;
97 69 import java.util.ArrayList;
98   -import java.util.Date;
99   -import java.util.LinkedList;
100 70 import java.util.List;
101 71  
102 72 public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
... ... @@ -354,20 +324,30 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
354 324 //设置标题
355 325 if (!TextUtils.isEmpty(runRaceDetailInfo.getTitle())) {
356 326 fragment.binding.includeStreet.tvRaceTitle.setText(runRaceDetailInfo.getTitle());
357   - fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
358   - @Override
359   - public boolean onPreDraw() {
360   - Log.e(TAG, "initView: "+ fragment.binding.includeStreet.tvRaceTitle.getLineCount() );
361   - fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().removeOnPreDrawListener(this);
362   - return false;
363   - }
364   - });
365   - //根据标题字数动态设置卡片高度
366   - if (runRaceDetailInfo.getTitle().length() > 19) {
367   - fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 200));
368   - } else {
369   - fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 181));
370   - }
  327 + fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
  328 + @Override
  329 + public boolean onPreDraw() {
  330 + Log.e(TAG, "initView: " + fragment.binding.includeStreet.tvRaceTitle.getLineCount());
  331 + fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().removeOnPreDrawListener(this);
  332 + return false;
  333 + }
  334 + });
  335 + fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 181));
  336 + //根据标题行数,自动调整卡片大小
  337 + fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
  338 + @Override
  339 + public boolean onPreDraw() {
  340 + int line = fragment.binding.includeStreet.tvRaceTitle.getLineCount();
  341 + int height = fragment.binding.includeStreet.tvRaceTitle.getHeight();
  342 + if (line > 1) {
  343 + int avgHeight = height / line;//平局高度
  344 + fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 181) + avgHeight * (line - 1));
  345 +
  346 + }
  347 + fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().removeOnPreDrawListener(this);
  348 + return false;
  349 + }
  350 + });
371 351 fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
372 352 }
373 353 //设置活动地点
... ... @@ -585,6 +565,9 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
585 565 //清除数据
586 566 CommonInfo.resetRace(getContext());
587 567 dialog.dismiss();
  568 + //重置按钮
  569 + fragment.binding.tvRunNow.setText("立即开始");
  570 + fragment.binding.rlScrollViewStartBtn.setTag("1");
588 571 }
589 572 }, "是", new SelectDialog.DialogInterface() {
590 573 @Override
... ... @@ -653,7 +636,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
653 636 @Override
654 637 public void onClick(View view) {
655 638 ARouter.getInstance().build("/web/WebViewColorActivity")
656   - .withString("url", SubscriptionRequest.baseEndpoint()+"cnSportList.html" + "?sid=" + CommonInfo.getUserId(fragment.getActivity()) + "&eventId=" + CommonInfo.getStreetId(fragment.getActivity()))
  639 + .withString("url", SubscriptionRequest.baseEndpoint() + "cnSportList.html" + "?sid=" + CommonInfo.getUserId(fragment.getActivity()) + "&eventId=" + CommonInfo.getStreetId(fragment.getActivity()))
657 640 .withString("title", "排行榜")
658 641 .navigation(fragment.getActivity());
659 642 }
... ... @@ -1057,6 +1040,57 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
1057 1040 fragment.binding.tvRunNow.setText("立即开始");
1058 1041 fragment.binding.rlScrollViewStartBtn.setTag("1");
1059 1042 }
  1043 + //判断赛事是否已经结束
  1044 + checkTheRaceIsEnd();
  1045 +
  1046 + }
  1047 +
  1048 + /**
  1049 + * 判断赛事是否已经结束
  1050 + */
  1051 + private void checkTheRaceIsEnd() {
  1052 + //判断赛事是否结束
  1053 + if (null != userStepEntity) {
  1054 + if (null != runRaceDetailInfo) {
  1055 + //判断赛事id是否一致
  1056 + if (!TextUtils.isEmpty(userStepEntity.getStreetId())) {
  1057 + if (userStepEntity.getStreetId().equals(CommonInfo.getStreetId(getContext()))) {
  1058 + //判断赛事是否结束
  1059 + if (runRaceDetailInfo.isEndState()) {
  1060 + //结束清除数据
  1061 + //清空上次保存数据
  1062 + StepUtil.clearRunData(getContext(), CommonInfo.getUserId(getContext()));
  1063 + //停止服务
  1064 + stopStepService();
  1065 + //清除数据
  1066 + CommonInfo.resetRace(getContext());
  1067 + //设置按钮状态
  1068 + fragment.binding.rlScrollViewStartBtn.setTag("3");
  1069 + fragment.binding.rlScrollViewStartBtn.setBackgroundColor(getContext().getResources().getColor(R.color.red_round));
  1070 + fragment.binding.tvRunNow.setText("赛事已结束");
  1071 + fragment.binding.tvGoTip.setVisibility(View.GONE);
  1072 + }
  1073 + }
  1074 + }
  1075 + }
  1076 + } else {
  1077 + //如果数据库中没有数据,即,用户在当前赛事已经结束
  1078 + if (null != runRaceDetailInfo) {
  1079 + if (runRaceDetailInfo.isEndState()) {
  1080 + //设置按钮状态
  1081 + fragment.binding.rlScrollViewStartBtn.setTag("3");
  1082 + fragment.binding.rlScrollViewStartBtn.setBackgroundColor(getContext().getResources().getColor(R.color.red_round));
  1083 + fragment.binding.tvRunNow.setText("赛事已结束");
  1084 + fragment.binding.tvGoTip.setVisibility(View.GONE);
  1085 + }
  1086 + }
  1087 + }
  1088 + }
  1089 +
  1090 + /**
  1091 + * 赛事已经结束
  1092 + */
  1093 + private void raceHasEnd() {
1060 1094  
1061 1095 }
1062 1096  
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/model/Constant.java
1 1 package com.cnlive.moudle.pedometer.model;
2 2  
3 3 public class Constant {
4   - public static final long SERVICE_ID = 213511;
  4 +// public static final long SERVICE_ID = 213511;//公司账号
  5 + public static final long SERVICE_ID = 213553;
  6 +
5 7 public static final int TAG = 1;
6 8 public static final int GATHER_INTERVAL = 2;//位置采集周期
7 9 public static final int PACK_INTERVAL = 10;//位置采集周期
... ... @@ -13,6 +15,8 @@ public class Constant {
13 15 public static final int FRAGMENT_RUN_CHRONOMETER = 4;//同步计时器
14 16 public static final int EXIT_RANGE = 5;//超出范围
15 17 public static final int ENTER_RANGE = 6;//进入范围
  18 + public static final int COLL_SERVICE_STEP_COUNT_RESET_SPEED = 3;//重置速度
  19 + public static final int COLL_SERVICE_STEP_COUNT_UPDATE = 0;//步数更新
16 20 public static final int COLL_START_TRACE_GATHER_SUCCESS = 7;//启动轨迹服务成功(运营)
17 21 public static final int COLL_START_TRACE_GATHER_FAIL = 8;//启动轨迹服务失败(运营)
18 22 public static final int START_TRACE_GATHER_SUCCESS = 9;//启动轨迹服务成功(用户)
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/net/bean/RunRaceDetailInfo.java
... ... @@ -65,7 +65,7 @@ public class RunRaceDetailInfo implements Serializable {
65 65 private boolean ranking;
66 66 private boolean individualAchievement;
67 67 private boolean signResult;
68   - private boolean trackButton;
  68 + private boolean trackButton;//轨迹按钮,true展示,false不展示
69 69 private String state;
70 70 private String finishNum;
71 71 private String firstEmployTime;
... ... @@ -86,7 +86,35 @@ public class RunRaceDetailInfo implements Serializable {
86 86 private String userMileage;
87 87 private List<String> faceUrl;
88 88 private List<String> finishFaceUrl;
  89 + /*********************************后加的,非接口返回,用于*******************************************/
89 90 private String endLatLng;//终点坐标,后加的,不是后台返回,这是从百度历史轨迹查出来的
  91 + private boolean endState;//活动是否结束(true 结束 false 未结束 )
  92 + private String collStartLatLng;//运营打的点
  93 + private String collStartLntLngName;//运营打点名称
  94 +
  95 + public String getCollStartLatLng() {
  96 + return collStartLatLng;
  97 + }
  98 +
  99 + public void setCollStartLatLng(String collStartLatLng) {
  100 + this.collStartLatLng = collStartLatLng;
  101 + }
  102 +
  103 + public String getCollStartLntLngName() {
  104 + return collStartLntLngName;
  105 + }
  106 +
  107 + public void setCollStartLntLngName(String collStartLntLngName) {
  108 + this.collStartLntLngName = collStartLntLngName;
  109 + }
  110 +
  111 + public boolean isEndState() {
  112 + return endState;
  113 + }
  114 +
  115 + public void setEndState(boolean endState) {
  116 + this.endState = endState;
  117 + }
90 118  
91 119 public String getEndLatLng() {
92 120 return endLatLng;
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/CollUserStepEntityDao.java
... ... @@ -24,14 +24,29 @@ public class CollUserStepEntityDao extends AbstractDao&lt;CollUserStepEntity, Strin
24 24 * Can be used for QueryBuilder and for referencing column names.
25 25 */
26 26 public static class Properties {
27   - public final static Property Uuid = new Property(0, String.class, "uuid", true, "UUID");
28   - public final static Property UserId = new Property(1, String.class, "userId", false, "USER_ID");
29   - public final static Property Date = new Property(2, String.class, "date", false, "DATE");
30   - public final static Property StepCount = new Property(3, String.class, "stepCount", false, "STEP_COUNT");
31   - public final static Property PauseTimeStamp = new Property(4, long.class, "pauseTimeStamp", false, "PAUSE_TIME_STAMP");
32   - public final static Property RecordTime = new Property(5, long.class, "recordTime", false, "RECORD_TIME");
33   - public final static Property CaloriesCount = new Property(6, double.class, "caloriesCount", false, "CALORIES_COUNT");
34   - public final static Property ServerTraceData = new Property(7, String.class, "serverTraceData", false, "SERVER_TRACE_DATA");
  27 + public final static Property UserId = new Property(0, String.class, "userId", true, "USER_ID");
  28 + public final static Property Date = new Property(1, String.class, "date", false, "DATE");
  29 + public final static Property StepCount = new Property(2, String.class, "stepCount", false, "STEP_COUNT");
  30 + public final static Property RecordTime = new Property(3, long.class, "recordTime", false, "RECORD_TIME");
  31 + public final static Property CaloriesCount = new Property(4, double.class, "caloriesCount", false, "CALORIES_COUNT");
  32 + public final static Property ServerTraceData = new Property(5, String.class, "serverTraceData", false, "SERVER_TRACE_DATA");
  33 + public final static Property StartTimeStamp = new Property(6, long.class, "startTimeStamp", false, "START_TIME_STAMP");
  34 + public final static Property FinishTimeStamp = new Property(7, long.class, "finishTimeStamp", false, "FINISH_TIME_STAMP");
  35 + public final static Property StreetId = new Property(8, String.class, "streetId", false, "STREET_ID");
  36 + public final static Property PauseCount = new Property(9, int.class, "pauseCount", false, "PAUSE_COUNT");
  37 + public final static Property UserPauseTimeStamp = new Property(10, long.class, "userPauseTimeStamp", false, "USER_PAUSE_TIME_STAMP");
  38 + public final static Property ChronometerBase = new Property(11, long.class, "chronometerBase", false, "CHRONOMETER_BASE");
  39 + public final static Property QueryTraceStartTime = new Property(12, long.class, "queryTraceStartTime", false, "QUERY_TRACE_START_TIME");
  40 + public final static Property QueryTraceEndTime = new Property(13, long.class, "queryTraceEndTime", false, "QUERY_TRACE_END_TIME");
  41 + public final static Property QueryEntityName = new Property(14, String.class, "queryEntityName", false, "QUERY_ENTITY_NAME");
  42 + public final static Property ContinueTime = new Property(15, long.class, "continueTime", false, "CONTINUE_TIME");
  43 + public final static Property FenceId = new Property(16, long.class, "fenceId", false, "FENCE_ID");
  44 + public final static Property ImportPoint = new Property(17, String.class, "importPoint", false, "IMPORT_POINT");
  45 + public final static Property StreetTitle = new Property(18, String.class, "streetTitle", false, "STREET_TITLE");
  46 + public final static Property EndLatLng = new Property(19, String.class, "endLatLng", false, "END_LAT_LNG");
  47 + public final static Property IsArriveEndPoint = new Property(20, boolean.class, "isArriveEndPoint", false, "IS_ARRIVE_END_POINT");
  48 + public final static Property CollStartLatLngName = new Property(21, String.class, "collStartLatLngName", false, "COLL_START_LAT_LNG_NAME");
  49 + public final static Property CollStartLatLng = new Property(22, String.class, "collStartLatLng", false, "COLL_START_LAT_LNG");
35 50 }
36 51  
37 52  
... ... @@ -47,14 +62,29 @@ public class CollUserStepEntityDao extends AbstractDao&lt;CollUserStepEntity, Strin
47 62 public static void createTable(Database db, boolean ifNotExists) {
48 63 String constraint = ifNotExists? "IF NOT EXISTS ": "";
49 64 db.execSQL("CREATE TABLE " + constraint + "\"COLL_USER_STEP_ENTITY\" (" + //
50   - "\"UUID\" TEXT PRIMARY KEY NOT NULL ," + // 0: uuid
51   - "\"USER_ID\" TEXT," + // 1: userId
52   - "\"DATE\" TEXT," + // 2: date
53   - "\"STEP_COUNT\" TEXT," + // 3: stepCount
54   - "\"PAUSE_TIME_STAMP\" INTEGER NOT NULL ," + // 4: pauseTimeStamp
55   - "\"RECORD_TIME\" INTEGER NOT NULL ," + // 5: recordTime
56   - "\"CALORIES_COUNT\" REAL NOT NULL ," + // 6: caloriesCount
57   - "\"SERVER_TRACE_DATA\" TEXT);"); // 7: serverTraceData
  65 + "\"USER_ID\" TEXT PRIMARY KEY NOT NULL ," + // 0: userId
  66 + "\"DATE\" TEXT," + // 1: date
  67 + "\"STEP_COUNT\" TEXT," + // 2: stepCount
  68 + "\"RECORD_TIME\" INTEGER NOT NULL ," + // 3: recordTime
  69 + "\"CALORIES_COUNT\" REAL NOT NULL ," + // 4: caloriesCount
  70 + "\"SERVER_TRACE_DATA\" TEXT," + // 5: serverTraceData
  71 + "\"START_TIME_STAMP\" INTEGER NOT NULL ," + // 6: startTimeStamp
  72 + "\"FINISH_TIME_STAMP\" INTEGER NOT NULL ," + // 7: finishTimeStamp
  73 + "\"STREET_ID\" TEXT," + // 8: streetId
  74 + "\"PAUSE_COUNT\" INTEGER NOT NULL ," + // 9: pauseCount
  75 + "\"USER_PAUSE_TIME_STAMP\" INTEGER NOT NULL ," + // 10: userPauseTimeStamp
  76 + "\"CHRONOMETER_BASE\" INTEGER NOT NULL ," + // 11: chronometerBase
  77 + "\"QUERY_TRACE_START_TIME\" INTEGER NOT NULL ," + // 12: queryTraceStartTime
  78 + "\"QUERY_TRACE_END_TIME\" INTEGER NOT NULL ," + // 13: queryTraceEndTime
  79 + "\"QUERY_ENTITY_NAME\" TEXT," + // 14: queryEntityName
  80 + "\"CONTINUE_TIME\" INTEGER NOT NULL ," + // 15: continueTime
  81 + "\"FENCE_ID\" INTEGER NOT NULL ," + // 16: fenceId
  82 + "\"IMPORT_POINT\" TEXT," + // 17: importPoint
  83 + "\"STREET_TITLE\" TEXT," + // 18: streetTitle
  84 + "\"END_LAT_LNG\" TEXT," + // 19: endLatLng
  85 + "\"IS_ARRIVE_END_POINT\" INTEGER NOT NULL ," + // 20: isArriveEndPoint
  86 + "\"COLL_START_LAT_LNG_NAME\" TEXT," + // 21: collStartLatLngName
  87 + "\"COLL_START_LAT_LNG\" TEXT);"); // 22: collStartLatLng
58 88 }
59 89  
60 90 /** Drops the underlying database table. */
... ... @@ -67,32 +97,71 @@ public class CollUserStepEntityDao extends AbstractDao&lt;CollUserStepEntity, Strin
67 97 protected final void bindValues(DatabaseStatement stmt, CollUserStepEntity entity) {
68 98 stmt.clearBindings();
69 99  
70   - String uuid = entity.getUuid();
71   - if (uuid != null) {
72   - stmt.bindString(1, uuid);
73   - }
74   -
75 100 String userId = entity.getUserId();
76 101 if (userId != null) {
77   - stmt.bindString(2, userId);
  102 + stmt.bindString(1, userId);
78 103 }
79 104  
80 105 String date = entity.getDate();
81 106 if (date != null) {
82   - stmt.bindString(3, date);
  107 + stmt.bindString(2, date);
83 108 }
84 109  
85 110 String stepCount = entity.getStepCount();
86 111 if (stepCount != null) {
87   - stmt.bindString(4, stepCount);
  112 + stmt.bindString(3, stepCount);
88 113 }
89   - stmt.bindLong(5, entity.getPauseTimeStamp());
90   - stmt.bindLong(6, entity.getRecordTime());
91   - stmt.bindDouble(7, entity.getCaloriesCount());
  114 + stmt.bindLong(4, entity.getRecordTime());
  115 + stmt.bindDouble(5, entity.getCaloriesCount());
92 116  
93 117 String serverTraceData = entity.getServerTraceData();
94 118 if (serverTraceData != null) {
95   - stmt.bindString(8, serverTraceData);
  119 + stmt.bindString(6, serverTraceData);
  120 + }
  121 + stmt.bindLong(7, entity.getStartTimeStamp());
  122 + stmt.bindLong(8, entity.getFinishTimeStamp());
  123 +
  124 + String streetId = entity.getStreetId();
  125 + if (streetId != null) {
  126 + stmt.bindString(9, streetId);
  127 + }
  128 + stmt.bindLong(10, entity.getPauseCount());
  129 + stmt.bindLong(11, entity.getUserPauseTimeStamp());
  130 + stmt.bindLong(12, entity.getChronometerBase());
  131 + stmt.bindLong(13, entity.getQueryTraceStartTime());
  132 + stmt.bindLong(14, entity.getQueryTraceEndTime());
  133 +
  134 + String queryEntityName = entity.getQueryEntityName();
  135 + if (queryEntityName != null) {
  136 + stmt.bindString(15, queryEntityName);
  137 + }
  138 + stmt.bindLong(16, entity.getContinueTime());
  139 + stmt.bindLong(17, entity.getFenceId());
  140 +
  141 + String importPoint = entity.getImportPoint();
  142 + if (importPoint != null) {
  143 + stmt.bindString(18, importPoint);
  144 + }
  145 +
  146 + String streetTitle = entity.getStreetTitle();
  147 + if (streetTitle != null) {
  148 + stmt.bindString(19, streetTitle);
  149 + }
  150 +
  151 + String endLatLng = entity.getEndLatLng();
  152 + if (endLatLng != null) {
  153 + stmt.bindString(20, endLatLng);
  154 + }
  155 + stmt.bindLong(21, entity.getIsArriveEndPoint() ? 1L: 0L);
  156 +
  157 + String collStartLatLngName = entity.getCollStartLatLngName();
  158 + if (collStartLatLngName != null) {
  159 + stmt.bindString(22, collStartLatLngName);
  160 + }
  161 +
  162 + String collStartLatLng = entity.getCollStartLatLng();
  163 + if (collStartLatLng != null) {
  164 + stmt.bindString(23, collStartLatLng);
96 165 }
97 166 }
98 167  
... ... @@ -100,32 +169,71 @@ public class CollUserStepEntityDao extends AbstractDao&lt;CollUserStepEntity, Strin
100 169 protected final void bindValues(SQLiteStatement stmt, CollUserStepEntity entity) {
101 170 stmt.clearBindings();
102 171  
103   - String uuid = entity.getUuid();
104   - if (uuid != null) {
105   - stmt.bindString(1, uuid);
106   - }
107   -
108 172 String userId = entity.getUserId();
109 173 if (userId != null) {
110   - stmt.bindString(2, userId);
  174 + stmt.bindString(1, userId);
111 175 }
112 176  
113 177 String date = entity.getDate();
114 178 if (date != null) {
115   - stmt.bindString(3, date);
  179 + stmt.bindString(2, date);
116 180 }
117 181  
118 182 String stepCount = entity.getStepCount();
119 183 if (stepCount != null) {
120   - stmt.bindString(4, stepCount);
  184 + stmt.bindString(3, stepCount);
121 185 }
122   - stmt.bindLong(5, entity.getPauseTimeStamp());
123   - stmt.bindLong(6, entity.getRecordTime());
124   - stmt.bindDouble(7, entity.getCaloriesCount());
  186 + stmt.bindLong(4, entity.getRecordTime());
  187 + stmt.bindDouble(5, entity.getCaloriesCount());
125 188  
126 189 String serverTraceData = entity.getServerTraceData();
127 190 if (serverTraceData != null) {
128   - stmt.bindString(8, serverTraceData);
  191 + stmt.bindString(6, serverTraceData);
  192 + }
  193 + stmt.bindLong(7, entity.getStartTimeStamp());
  194 + stmt.bindLong(8, entity.getFinishTimeStamp());
  195 +
  196 + String streetId = entity.getStreetId();
  197 + if (streetId != null) {
  198 + stmt.bindString(9, streetId);
  199 + }
  200 + stmt.bindLong(10, entity.getPauseCount());
  201 + stmt.bindLong(11, entity.getUserPauseTimeStamp());
  202 + stmt.bindLong(12, entity.getChronometerBase());
  203 + stmt.bindLong(13, entity.getQueryTraceStartTime());
  204 + stmt.bindLong(14, entity.getQueryTraceEndTime());
  205 +
  206 + String queryEntityName = entity.getQueryEntityName();
  207 + if (queryEntityName != null) {
  208 + stmt.bindString(15, queryEntityName);
  209 + }
  210 + stmt.bindLong(16, entity.getContinueTime());
  211 + stmt.bindLong(17, entity.getFenceId());
  212 +
  213 + String importPoint = entity.getImportPoint();
  214 + if (importPoint != null) {
  215 + stmt.bindString(18, importPoint);
  216 + }
  217 +
  218 + String streetTitle = entity.getStreetTitle();
  219 + if (streetTitle != null) {
  220 + stmt.bindString(19, streetTitle);
  221 + }
  222 +
  223 + String endLatLng = entity.getEndLatLng();
  224 + if (endLatLng != null) {
  225 + stmt.bindString(20, endLatLng);
  226 + }
  227 + stmt.bindLong(21, entity.getIsArriveEndPoint() ? 1L: 0L);
  228 +
  229 + String collStartLatLngName = entity.getCollStartLatLngName();
  230 + if (collStartLatLngName != null) {
  231 + stmt.bindString(22, collStartLatLngName);
  232 + }
  233 +
  234 + String collStartLatLng = entity.getCollStartLatLng();
  235 + if (collStartLatLng != null) {
  236 + stmt.bindString(23, collStartLatLng);
129 237 }
130 238 }
131 239  
... ... @@ -137,39 +245,69 @@ public class CollUserStepEntityDao extends AbstractDao&lt;CollUserStepEntity, Strin
137 245 @Override
138 246 public CollUserStepEntity readEntity(Cursor cursor, int offset) {
139 247 CollUserStepEntity entity = new CollUserStepEntity( //
140   - cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // uuid
141   - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userId
142   - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // date
143   - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // stepCount
144   - cursor.getLong(offset + 4), // pauseTimeStamp
145   - cursor.getLong(offset + 5), // recordTime
146   - cursor.getDouble(offset + 6), // caloriesCount
147   - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // serverTraceData
  248 + cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // userId
  249 + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // date
  250 + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // stepCount
  251 + cursor.getLong(offset + 3), // recordTime
  252 + cursor.getDouble(offset + 4), // caloriesCount
  253 + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // serverTraceData
  254 + cursor.getLong(offset + 6), // startTimeStamp
  255 + cursor.getLong(offset + 7), // finishTimeStamp
  256 + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // streetId
  257 + cursor.getInt(offset + 9), // pauseCount
  258 + cursor.getLong(offset + 10), // userPauseTimeStamp
  259 + cursor.getLong(offset + 11), // chronometerBase
  260 + cursor.getLong(offset + 12), // queryTraceStartTime
  261 + cursor.getLong(offset + 13), // queryTraceEndTime
  262 + cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // queryEntityName
  263 + cursor.getLong(offset + 15), // continueTime
  264 + cursor.getLong(offset + 16), // fenceId
  265 + cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // importPoint
  266 + cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // streetTitle
  267 + cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // endLatLng
  268 + cursor.getShort(offset + 20) != 0, // isArriveEndPoint
  269 + cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // collStartLatLngName
  270 + cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22) // collStartLatLng
148 271 );
149 272 return entity;
150 273 }
151 274  
152 275 @Override
153 276 public void readEntity(Cursor cursor, CollUserStepEntity entity, int offset) {
154   - entity.setUuid(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
155   - entity.setUserId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
156   - entity.setDate(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
157   - entity.setStepCount(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
158   - entity.setPauseTimeStamp(cursor.getLong(offset + 4));
159   - entity.setRecordTime(cursor.getLong(offset + 5));
160   - entity.setCaloriesCount(cursor.getDouble(offset + 6));
161   - entity.setServerTraceData(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
  277 + entity.setUserId(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
  278 + entity.setDate(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
  279 + entity.setStepCount(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
  280 + entity.setRecordTime(cursor.getLong(offset + 3));
  281 + entity.setCaloriesCount(cursor.getDouble(offset + 4));
  282 + entity.setServerTraceData(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
  283 + entity.setStartTimeStamp(cursor.getLong(offset + 6));
  284 + entity.setFinishTimeStamp(cursor.getLong(offset + 7));
  285 + entity.setStreetId(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
  286 + entity.setPauseCount(cursor.getInt(offset + 9));
  287 + entity.setUserPauseTimeStamp(cursor.getLong(offset + 10));
  288 + entity.setChronometerBase(cursor.getLong(offset + 11));
  289 + entity.setQueryTraceStartTime(cursor.getLong(offset + 12));
  290 + entity.setQueryTraceEndTime(cursor.getLong(offset + 13));
  291 + entity.setQueryEntityName(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14));
  292 + entity.setContinueTime(cursor.getLong(offset + 15));
  293 + entity.setFenceId(cursor.getLong(offset + 16));
  294 + entity.setImportPoint(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17));
  295 + entity.setStreetTitle(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18));
  296 + entity.setEndLatLng(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19));
  297 + entity.setIsArriveEndPoint(cursor.getShort(offset + 20) != 0);
  298 + entity.setCollStartLatLngName(cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21));
  299 + entity.setCollStartLatLng(cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22));
162 300 }
163 301  
164 302 @Override
165 303 protected final String updateKeyAfterInsert(CollUserStepEntity entity, long rowId) {
166   - return entity.getUuid();
  304 + return entity.getUserId();
167 305 }
168 306  
169 307 @Override
170 308 public String getKey(CollUserStepEntity entity) {
171 309 if(entity != null) {
172   - return entity.getUuid();
  310 + return entity.getUserId();
173 311 } else {
174 312 return null;
175 313 }
... ... @@ -177,7 +315,7 @@ public class CollUserStepEntityDao extends AbstractDao&lt;CollUserStepEntity, Strin
177 315  
178 316 @Override
179 317 public boolean hasKey(CollUserStepEntity entity) {
180   - return entity.getUuid() != null;
  318 + return entity.getUserId() != null;
181 319 }
182 320  
183 321 @Override
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/DaoMaster.java
... ... @@ -24,6 +24,7 @@ public class DaoMaster extends AbstractDaoMaster {
24 24 CollUserStepEntityDao.createTable(db, ifNotExists);
25 25 FailedEntityDao.createTable(db, ifNotExists);
26 26 UserStepEntityDao.createTable(db, ifNotExists);
  27 + CollFailedEntityDao.createTable(db, ifNotExists);
27 28 }
28 29  
29 30 /** Drops underlying database table using DAOs. */
... ... @@ -31,6 +32,7 @@ public class DaoMaster extends AbstractDaoMaster {
31 32 CollUserStepEntityDao.dropTable(db, ifExists);
32 33 FailedEntityDao.dropTable(db, ifExists);
33 34 UserStepEntityDao.dropTable(db, ifExists);
  35 + CollFailedEntityDao.dropTable(db, ifExists);
34 36 }
35 37  
36 38 /**
... ... @@ -52,6 +54,7 @@ public class DaoMaster extends AbstractDaoMaster {
52 54 registerDaoClass(CollUserStepEntityDao.class);
53 55 registerDaoClass(FailedEntityDao.class);
54 56 registerDaoClass(UserStepEntityDao.class);
  57 + registerDaoClass(CollFailedEntityDao.class);
55 58 }
56 59  
57 60 public DaoSession newSession() {
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/DaoSession.java
... ... @@ -11,10 +11,12 @@ import org.greenrobot.greendao.internal.DaoConfig;
11 11 import com.cnlive.moudle.pedometer.sql.entity.CollUserStepEntity;
12 12 import com.cnlive.moudle.pedometer.sql.entity.FailedEntity;
13 13 import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity;
  14 +import com.cnlive.moudle.pedometer.sql.entity.CollFailedEntity;
14 15  
15 16 import com.cnlive.moudle.pedometer.sql.dao.CollUserStepEntityDao;
16 17 import com.cnlive.moudle.pedometer.sql.dao.FailedEntityDao;
17 18 import com.cnlive.moudle.pedometer.sql.dao.UserStepEntityDao;
  19 +import com.cnlive.moudle.pedometer.sql.dao.CollFailedEntityDao;
18 20  
19 21 // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
20 22  
... ... @@ -28,10 +30,12 @@ public class DaoSession extends AbstractDaoSession {
28 30 private final DaoConfig collUserStepEntityDaoConfig;
29 31 private final DaoConfig failedEntityDaoConfig;
30 32 private final DaoConfig userStepEntityDaoConfig;
  33 + private final DaoConfig collFailedEntityDaoConfig;
31 34  
32 35 private final CollUserStepEntityDao collUserStepEntityDao;
33 36 private final FailedEntityDao failedEntityDao;
34 37 private final UserStepEntityDao userStepEntityDao;
  38 + private final CollFailedEntityDao collFailedEntityDao;
35 39  
36 40 public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
37 41 daoConfigMap) {
... ... @@ -46,19 +50,25 @@ public class DaoSession extends AbstractDaoSession {
46 50 userStepEntityDaoConfig = daoConfigMap.get(UserStepEntityDao.class).clone();
47 51 userStepEntityDaoConfig.initIdentityScope(type);
48 52  
  53 + collFailedEntityDaoConfig = daoConfigMap.get(CollFailedEntityDao.class).clone();
  54 + collFailedEntityDaoConfig.initIdentityScope(type);
  55 +
49 56 collUserStepEntityDao = new CollUserStepEntityDao(collUserStepEntityDaoConfig, this);
50 57 failedEntityDao = new FailedEntityDao(failedEntityDaoConfig, this);
51 58 userStepEntityDao = new UserStepEntityDao(userStepEntityDaoConfig, this);
  59 + collFailedEntityDao = new CollFailedEntityDao(collFailedEntityDaoConfig, this);
52 60  
53 61 registerDao(CollUserStepEntity.class, collUserStepEntityDao);
54 62 registerDao(FailedEntity.class, failedEntityDao);
55 63 registerDao(UserStepEntity.class, userStepEntityDao);
  64 + registerDao(CollFailedEntity.class, collFailedEntityDao);
56 65 }
57 66  
58 67 public void clear() {
59 68 collUserStepEntityDaoConfig.clearIdentityScope();
60 69 failedEntityDaoConfig.clearIdentityScope();
61 70 userStepEntityDaoConfig.clearIdentityScope();
  71 + collFailedEntityDaoConfig.clearIdentityScope();
62 72 }
63 73  
64 74 public CollUserStepEntityDao getCollUserStepEntityDao() {
... ... @@ -73,4 +83,8 @@ public class DaoSession extends AbstractDaoSession {
73 83 return userStepEntityDao;
74 84 }
75 85  
  86 + public CollFailedEntityDao getCollFailedEntityDao() {
  87 + return collFailedEntityDao;
  88 + }
  89 +
76 90 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/entity/CollFailedEntity.java 0 → 100644
  1 +package com.cnlive.moudle.pedometer.sql.entity;
  2 +
  3 +import org.greenrobot.greendao.annotation.Entity;
  4 +import org.greenrobot.greendao.annotation.Generated;
  5 +import org.greenrobot.greendao.annotation.Id;
  6 +
  7 +import java.io.Serializable;
  8 +
  9 +/**
  10 + * 上传失败列表
  11 + *
  12 + * @author ShinnyYang
  13 + */
  14 +@Entity
  15 +public class CollFailedEntity implements Serializable {
  16 + static final long serialVersionUID = 02L;
  17 + @Id
  18 + private String uuid;//主键
  19 + private String uid;//用户id
  20 + private boolean isPause;//是否暂停
  21 + private long userPauseTime;//用户暂停时间
  22 + private long usrContinueTime;//用户继续时间
  23 + private String isFinish;//是否完成
  24 + private String time;//用时
  25 + private String speed;//配速
  26 + private String step;//步数
  27 + private String distance;//距离
  28 + private String startPoint;//开始地点
  29 + private String endPoint;//结束地点
  30 + private long streetTraceStartTime;//赛道开始时间
  31 + private long streetTraceEndTime;//赛道结束时间
  32 + private String entityName;//实体名称
  33 + private long userStartTime;//用户开始时间
  34 + private long userEndTime;//用户结束时间
  35 + private String importPoint;//关键点
  36 + private String streetId;//赛事id
  37 + private String streetTitle;//赛道标题
  38 + private long creatTimeStamp;//数据创建的时间
  39 + private boolean isArriveEndPoint;//是否到达终点
  40 + @Generated(hash = 1512309823)
  41 + public CollFailedEntity(String uuid, String uid, boolean isPause,
  42 + long userPauseTime, long usrContinueTime, String isFinish, String time,
  43 + String speed, String step, String distance, String startPoint,
  44 + String endPoint, long streetTraceStartTime, long streetTraceEndTime,
  45 + String entityName, long userStartTime, long userEndTime,
  46 + String importPoint, String streetId, String streetTitle,
  47 + long creatTimeStamp, boolean isArriveEndPoint) {
  48 + this.uuid = uuid;
  49 + this.uid = uid;
  50 + this.isPause = isPause;
  51 + this.userPauseTime = userPauseTime;
  52 + this.usrContinueTime = usrContinueTime;
  53 + this.isFinish = isFinish;
  54 + this.time = time;
  55 + this.speed = speed;
  56 + this.step = step;
  57 + this.distance = distance;
  58 + this.startPoint = startPoint;
  59 + this.endPoint = endPoint;
  60 + this.streetTraceStartTime = streetTraceStartTime;
  61 + this.streetTraceEndTime = streetTraceEndTime;
  62 + this.entityName = entityName;
  63 + this.userStartTime = userStartTime;
  64 + this.userEndTime = userEndTime;
  65 + this.importPoint = importPoint;
  66 + this.streetId = streetId;
  67 + this.streetTitle = streetTitle;
  68 + this.creatTimeStamp = creatTimeStamp;
  69 + this.isArriveEndPoint = isArriveEndPoint;
  70 + }
  71 + @Generated(hash = 1910302097)
  72 + public CollFailedEntity() {
  73 + }
  74 + public String getUuid() {
  75 + return this.uuid;
  76 + }
  77 + public void setUuid(String uuid) {
  78 + this.uuid = uuid;
  79 + }
  80 + public String getUid() {
  81 + return this.uid;
  82 + }
  83 + public void setUid(String uid) {
  84 + this.uid = uid;
  85 + }
  86 + public boolean getIsPause() {
  87 + return this.isPause;
  88 + }
  89 + public void setIsPause(boolean isPause) {
  90 + this.isPause = isPause;
  91 + }
  92 + public long getUserPauseTime() {
  93 + return this.userPauseTime;
  94 + }
  95 + public void setUserPauseTime(long userPauseTime) {
  96 + this.userPauseTime = userPauseTime;
  97 + }
  98 + public long getUsrContinueTime() {
  99 + return this.usrContinueTime;
  100 + }
  101 + public void setUsrContinueTime(long usrContinueTime) {
  102 + this.usrContinueTime = usrContinueTime;
  103 + }
  104 + public String getIsFinish() {
  105 + return this.isFinish;
  106 + }
  107 + public void setIsFinish(String isFinish) {
  108 + this.isFinish = isFinish;
  109 + }
  110 + public String getTime() {
  111 + return this.time;
  112 + }
  113 + public void setTime(String time) {
  114 + this.time = time;
  115 + }
  116 + public String getSpeed() {
  117 + return this.speed;
  118 + }
  119 + public void setSpeed(String speed) {
  120 + this.speed = speed;
  121 + }
  122 + public String getStep() {
  123 + return this.step;
  124 + }
  125 + public void setStep(String step) {
  126 + this.step = step;
  127 + }
  128 + public String getDistance() {
  129 + return this.distance;
  130 + }
  131 + public void setDistance(String distance) {
  132 + this.distance = distance;
  133 + }
  134 + public String getStartPoint() {
  135 + return this.startPoint;
  136 + }
  137 + public void setStartPoint(String startPoint) {
  138 + this.startPoint = startPoint;
  139 + }
  140 + public String getEndPoint() {
  141 + return this.endPoint;
  142 + }
  143 + public void setEndPoint(String endPoint) {
  144 + this.endPoint = endPoint;
  145 + }
  146 + public long getStreetTraceStartTime() {
  147 + return this.streetTraceStartTime;
  148 + }
  149 + public void setStreetTraceStartTime(long streetTraceStartTime) {
  150 + this.streetTraceStartTime = streetTraceStartTime;
  151 + }
  152 + public long getStreetTraceEndTime() {
  153 + return this.streetTraceEndTime;
  154 + }
  155 + public void setStreetTraceEndTime(long streetTraceEndTime) {
  156 + this.streetTraceEndTime = streetTraceEndTime;
  157 + }
  158 + public String getEntityName() {
  159 + return this.entityName;
  160 + }
  161 + public void setEntityName(String entityName) {
  162 + this.entityName = entityName;
  163 + }
  164 + public long getUserStartTime() {
  165 + return this.userStartTime;
  166 + }
  167 + public void setUserStartTime(long userStartTime) {
  168 + this.userStartTime = userStartTime;
  169 + }
  170 + public long getUserEndTime() {
  171 + return this.userEndTime;
  172 + }
  173 + public void setUserEndTime(long userEndTime) {
  174 + this.userEndTime = userEndTime;
  175 + }
  176 + public String getImportPoint() {
  177 + return this.importPoint;
  178 + }
  179 + public void setImportPoint(String importPoint) {
  180 + this.importPoint = importPoint;
  181 + }
  182 + public String getStreetId() {
  183 + return this.streetId;
  184 + }
  185 + public void setStreetId(String streetId) {
  186 + this.streetId = streetId;
  187 + }
  188 + public String getStreetTitle() {
  189 + return this.streetTitle;
  190 + }
  191 + public void setStreetTitle(String streetTitle) {
  192 + this.streetTitle = streetTitle;
  193 + }
  194 + public long getCreatTimeStamp() {
  195 + return this.creatTimeStamp;
  196 + }
  197 + public void setCreatTimeStamp(long creatTimeStamp) {
  198 + this.creatTimeStamp = creatTimeStamp;
  199 + }
  200 + public boolean getIsArriveEndPoint() {
  201 + return this.isArriveEndPoint;
  202 + }
  203 + public void setIsArriveEndPoint(boolean isArriveEndPoint) {
  204 + this.isArriveEndPoint = isArriveEndPoint;
  205 + }
  206 +
  207 +
  208 +
  209 +}
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/entity/CollUserStepEntity.java
... ... @@ -7,79 +7,252 @@ import org.greenrobot.greendao.annotation.Id;
7 7 @Entity
8 8 public class CollUserStepEntity {
9 9 @Id
10   - private String uuid;
11 10 private String userId;
12 11 private String date;
13 12 private String stepCount;
14   - private long pauseTimeStamp;//暂停时间戳
15 13 private long recordTime;//暂停时间
16 14 private double caloriesCount;//卡路里
17 15 private String serverTraceData;//服务端赛道数据
18   - @Generated(hash = 1080314982)
19   - public CollUserStepEntity(String uuid, String userId, String date,
20   - String stepCount, long pauseTimeStamp, long recordTime,
21   - double caloriesCount, String serverTraceData) {
22   - this.uuid = uuid;
  16 + private long startTimeStamp;
  17 + private long finishTimeStamp;
  18 + private String streetId;//赛事ID
  19 + private int pauseCount;//暂停次数
  20 + private long userPauseTimeStamp;//暂停时间戳
  21 + private long chronometerBase;//计时器设置基础时间
  22 + private long queryTraceStartTime;//从服务器获取的开始时间呢
  23 + private long queryTraceEndTime;//从服务器获取的结束时间呢
  24 + private String queryEntityName;//从服务器获取的运营人员的实体名称
  25 + private long continueTime;//继续运动时间
  26 + private long fenceId;//围栏id
  27 + private String importPoint;//关键点
  28 + private String streetTitle;//赛事标题
  29 + private String endLatLng;//终点坐标
  30 + private boolean isArriveEndPoint;//是否到达终点
  31 + private String collStartLatLngName;//运营打点名称
  32 + private String collStartLatLng;//运营打点名称
  33 +
  34 + @Generated(hash = 1127995406)
  35 + public CollUserStepEntity(String userId, String date, String stepCount, long recordTime, double caloriesCount,
  36 + String serverTraceData, long startTimeStamp, long finishTimeStamp, String streetId, int pauseCount,
  37 + long userPauseTimeStamp, long chronometerBase, long queryTraceStartTime, long queryTraceEndTime,
  38 + String queryEntityName, long continueTime, long fenceId, String importPoint, String streetTitle,
  39 + String endLatLng, boolean isArriveEndPoint, String collStartLatLngName, String collStartLatLng) {
23 40 this.userId = userId;
24 41 this.date = date;
25 42 this.stepCount = stepCount;
26   - this.pauseTimeStamp = pauseTimeStamp;
27 43 this.recordTime = recordTime;
28 44 this.caloriesCount = caloriesCount;
29 45 this.serverTraceData = serverTraceData;
  46 + this.startTimeStamp = startTimeStamp;
  47 + this.finishTimeStamp = finishTimeStamp;
  48 + this.streetId = streetId;
  49 + this.pauseCount = pauseCount;
  50 + this.userPauseTimeStamp = userPauseTimeStamp;
  51 + this.chronometerBase = chronometerBase;
  52 + this.queryTraceStartTime = queryTraceStartTime;
  53 + this.queryTraceEndTime = queryTraceEndTime;
  54 + this.queryEntityName = queryEntityName;
  55 + this.continueTime = continueTime;
  56 + this.fenceId = fenceId;
  57 + this.importPoint = importPoint;
  58 + this.streetTitle = streetTitle;
  59 + this.endLatLng = endLatLng;
  60 + this.isArriveEndPoint = isArriveEndPoint;
  61 + this.collStartLatLngName = collStartLatLngName;
  62 + this.collStartLatLng = collStartLatLng;
30 63 }
  64 +
31 65 @Generated(hash = 681143087)
32 66 public CollUserStepEntity() {
33 67 }
34   - public String getUuid() {
35   - return this.uuid;
36   - }
37   - public void setUuid(String uuid) {
38   - this.uuid = uuid;
39   - }
  68 +
40 69 public String getUserId() {
41 70 return this.userId;
42 71 }
  72 +
43 73 public void setUserId(String userId) {
44 74 this.userId = userId;
45 75 }
  76 +
46 77 public String getDate() {
47 78 return this.date;
48 79 }
  80 +
49 81 public void setDate(String date) {
50 82 this.date = date;
51 83 }
  84 +
52 85 public String getStepCount() {
53 86 return this.stepCount;
54 87 }
  88 +
55 89 public void setStepCount(String stepCount) {
56 90 this.stepCount = stepCount;
57 91 }
58   - public long getPauseTimeStamp() {
59   - return this.pauseTimeStamp;
60   - }
61   - public void setPauseTimeStamp(long pauseTimeStamp) {
62   - this.pauseTimeStamp = pauseTimeStamp;
63   - }
  92 +
64 93 public long getRecordTime() {
65 94 return this.recordTime;
66 95 }
  96 +
67 97 public void setRecordTime(long recordTime) {
68 98 this.recordTime = recordTime;
69 99 }
  100 +
70 101 public double getCaloriesCount() {
71 102 return this.caloriesCount;
72 103 }
  104 +
73 105 public void setCaloriesCount(double caloriesCount) {
74 106 this.caloriesCount = caloriesCount;
75 107 }
  108 +
76 109 public String getServerTraceData() {
77 110 return this.serverTraceData;
78 111 }
  112 +
79 113 public void setServerTraceData(String serverTraceData) {
80 114 this.serverTraceData = serverTraceData;
81 115 }
82 116  
83 117  
  118 + public long getStartTimeStamp() {
  119 + return this.startTimeStamp;
  120 + }
  121 +
  122 + public void setStartTimeStamp(long startTimeStamp) {
  123 + this.startTimeStamp = startTimeStamp;
  124 + }
  125 +
  126 + public long getFinishTimeStamp() {
  127 + return this.finishTimeStamp;
  128 + }
  129 +
  130 + public void setFinishTimeStamp(long finishTimeStamp) {
  131 + this.finishTimeStamp = finishTimeStamp;
  132 + }
  133 +
  134 + public String getStreetId() {
  135 + return this.streetId;
  136 + }
  137 +
  138 + public void setStreetId(String streetId) {
  139 + this.streetId = streetId;
  140 + }
  141 +
  142 + public int getPauseCount() {
  143 + return this.pauseCount;
  144 + }
  145 +
  146 + public void setPauseCount(int pauseCount) {
  147 + this.pauseCount = pauseCount;
  148 + }
  149 +
  150 + public long getUserPauseTimeStamp() {
  151 + return this.userPauseTimeStamp;
  152 + }
  153 +
  154 + public void setUserPauseTimeStamp(long userPauseTimeStamp) {
  155 + this.userPauseTimeStamp = userPauseTimeStamp;
  156 + }
  157 +
  158 + public long getChronometerBase() {
  159 + return this.chronometerBase;
  160 + }
  161 +
  162 + public void setChronometerBase(long chronometerBase) {
  163 + this.chronometerBase = chronometerBase;
  164 + }
  165 +
  166 + public long getQueryTraceStartTime() {
  167 + return this.queryTraceStartTime;
  168 + }
  169 +
  170 + public void setQueryTraceStartTime(long queryTraceStartTime) {
  171 + this.queryTraceStartTime = queryTraceStartTime;
  172 + }
  173 +
  174 + public long getQueryTraceEndTime() {
  175 + return this.queryTraceEndTime;
  176 + }
  177 +
  178 + public void setQueryTraceEndTime(long queryTraceEndTime) {
  179 + this.queryTraceEndTime = queryTraceEndTime;
  180 + }
  181 +
  182 + public String getQueryEntityName() {
  183 + return this.queryEntityName;
  184 + }
  185 +
  186 + public void setQueryEntityName(String queryEntityName) {
  187 + this.queryEntityName = queryEntityName;
  188 + }
  189 +
  190 + public long getContinueTime() {
  191 + return this.continueTime;
  192 + }
  193 +
  194 + public void setContinueTime(long continueTime) {
  195 + this.continueTime = continueTime;
  196 + }
  197 +
  198 + public long getFenceId() {
  199 + return this.fenceId;
  200 + }
  201 +
  202 + public void setFenceId(long fenceId) {
  203 + this.fenceId = fenceId;
  204 + }
  205 +
  206 + public String getImportPoint() {
  207 + return this.importPoint;
  208 + }
  209 +
  210 + public void setImportPoint(String importPoint) {
  211 + this.importPoint = importPoint;
  212 + }
  213 +
  214 + public String getStreetTitle() {
  215 + return this.streetTitle;
  216 + }
  217 +
  218 + public void setStreetTitle(String streetTitle) {
  219 + this.streetTitle = streetTitle;
  220 + }
  221 +
  222 + public String getEndLatLng() {
  223 + return this.endLatLng;
  224 + }
  225 +
  226 + public void setEndLatLng(String endLatLng) {
  227 + this.endLatLng = endLatLng;
  228 + }
  229 +
  230 + public boolean getIsArriveEndPoint() {
  231 + return this.isArriveEndPoint;
  232 + }
  233 +
  234 + public void setIsArriveEndPoint(boolean isArriveEndPoint) {
  235 + this.isArriveEndPoint = isArriveEndPoint;
  236 + }
  237 +
  238 + public String getCollStartLatLngName() {
  239 + return this.collStartLatLngName;
  240 + }
  241 +
  242 + public void setCollStartLatLngName(String collStartLatLngName) {
  243 + this.collStartLatLngName = collStartLatLngName;
  244 + }
  245 +
  246 + public String getCollStartLatLng() {
  247 + return this.collStartLatLng;
  248 + }
  249 +
  250 + public void setCollStartLatLng(String collStartLatLng) {
  251 + this.collStartLatLng = collStartLatLng;
  252 + }
  253 +
  254 +
  255 +
  256 +
84 257  
85 258 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/CollStepUtil.java deleted 100644 → 0
1   -package com.cnlive.moudle.pedometer.utils;
2   -
3   -import android.content.Context;
4   -import android.text.TextUtils;
5   -import android.util.Log;
6   -
7   -import com.cnlive.moudle.pedometer.sql.dao.CollUserStepEntityDao;
8   -import com.cnlive.moudle.pedometer.sql.dao.UserStepEntityDao;
9   -import com.cnlive.moudle.pedometer.sql.db.DbCore;
10   -import com.cnlive.moudle.pedometer.sql.entity.CollUserStepEntity;
11   -import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity;
12   -
13   -import java.text.SimpleDateFormat;
14   -import java.util.Date;
15   -import java.util.List;
16   -
17   -/**
18   - * 步数工具
19   - *
20   - * @author ShinnyYang
21   - */
22   -public class CollStepUtil {
23   - private static final String TAG = "CollStepUtil";
24   - private static final String dbName = "CollStep.db";
25   -
26   -
27   - /**
28   - * 计算配速
29   - */
30   - public static String getPaceSpeed(double second, double distance) {
31   - if (distance != 0) {
32   - //计算分
33   - int minute = (int) (second / distance / 60);
34   - //获取秒
35   - double miaoMin = ((double) (second / distance / 60)) - ((int) (second / distance / 60));
36   - int miao = (int) (miaoMin * 60);
37   - return minute + "'" + miao + "''";
38   - } else {
39   - return "--";
40   - }
41   - }
42   -
43   - /**
44   - * 更新数据
45   - *
46   - * @param context
47   - * @param userStepEntity
48   - */
49   - public static void updateStepData(Context context, CollUserStepEntity userStepEntity) {
50   - if (userStepEntity != null) {
51   - DbCore.init(context, dbName);
52   - DbCore.getDaoSession().getCollUserStepEntityDao().update(userStepEntity);
53   - }
54   -
55   - }
56   -
57   - /**
58   - * 得到当前速度
59   - *
60   - * @param time
61   - * @param distance
62   - * @return
63   - */
64   - public static double getCurrentSpeed(double time, double distance) {
65   - double result = distance / time;
66   - result = Double.parseDouble(String.format("%1.2f", result));
67   - return result;
68   - }
69   -
70   - /**
71   - * 根据行走步数,计算大概行走具体
72   - * 单位:公里
73   - * 1步的距离大概是60厘米。
74   - * 1万多步,距离大概就是600000厘米,即6000米(6公里)
75   - *
76   - * @param step
77   - * @return
78   - */
79   - public static double getWalkDistanceKM(long step) {
80   - double result = step * 60.0 / 100.0 / 1000.0;
81   - result = Double.parseDouble(String.format("%1.2f", result));
82   - return result;
83   - }
84   -
85   - /**
86   - * 清除保存数据库中的数据
87   - *
88   - * @param uid
89   - */
90   - public static void clearRunData(Context context, String uid) {
91   - DbCore.init(context, dbName);
92   - String CURRENT_DATE = getTodayDate();
93   - List<CollUserStepEntity> list = DbCore.getDaoSession().getCollUserStepEntityDao().queryBuilder().where(CollUserStepEntityDao.Properties.UserId.eq(uid), CollUserStepEntityDao.Properties.Date.eq(CURRENT_DATE)).list();
94   - if (list != null && list.size() > 0) {
95   - Log.e(TAG, "clearRunData: " + list.size());
96   - DbCore.getDaoSession().getCollUserStepEntityDao().deleteByKey(list.get(0).getUuid());
97   - DbCore.getDaoSession().getCollUserStepEntityDao().detachAll();
98   - }
99   - }
100   -
101   - /**
102   - * 获取用户数据
103   - *
104   - * @param context
105   - * @param uid
106   - * @return
107   - */
108   - public static CollUserStepEntity getCollUserStepData(Context context, String uid) {
109   - if (!TextUtils.isEmpty(uid)) {
110   - DbCore.init(context, dbName);
111   - DbCore.getDaoSession().getCollUserStepEntityDao().detachAll();
112   - DbCore.getDaoSession().clear();
113   - String CURRENT_DATE = getTodayDate();
114   - List<CollUserStepEntity> list = DbCore.getDaoSession().getCollUserStepEntityDao().queryBuilder().where(CollUserStepEntityDao.Properties.UserId.eq(uid), CollUserStepEntityDao.Properties.Date.eq(CURRENT_DATE)).list();
115   - if (list != null && list.size() > 0) {
116   - return list.get(0);
117   - } else {
118   - return null;
119   - }
120   - } else {
121   - return null;
122   - }
123   - }
124   -
125   - /**
126   - * 获取用户数据
127   - *
128   - * @param context
129   - * @param uid
130   - * @return
131   - */
132   - public static void setServerTraceData(Context context, String uid, CollUserStepEntity userStepEntity) {
133   - if (getCollUserStepData(context, uid) != null) {
134   - CollUserStepEntity entity = getCollUserStepData(context, uid);
135   - } else {
136   -
137   - }
138   - }
139   -
140   - /**
141   - * 获取当天日期
142   - *
143   - * @return
144   - */
145   - private static String getTodayDate() {
146   - Date date = new Date(System.currentTimeMillis());
147   - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
148   - return sdf.format(date);
149   - }
150   -
151   -
152   -}
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/MyMapUtil.java
... ... @@ -52,6 +52,55 @@ public class MyMapUtil {
52 52 private static int pageIndex = 1;
53 53 private static List<LatLng> trackPoints;
54 54  
  55 + public static List<Overlay> setStartMarker(Context context, BaiduMap baiduMap, LatLng startLatLng, int startIconRes) {
  56 + if (0 == startIconRes || null == startLatLng || null == context || null == baiduMap) {
  57 + return null;
  58 + }
  59 + List<Overlay> resultOverlays = new ArrayList<>();
  60 + try {
  61 + Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), startIconRes), 24, 30);
  62 + OverlayOptions startOptions = null;
  63 + if (pointBitmap != null) {
  64 + startOptions = new MarkerOptions().position(startLatLng).icon(BitmapDescriptorFactory.fromBitmap(pointBitmap));
  65 + }
  66 +
  67 + // 添加圆形范围
  68 + Bitmap startCircleBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), R.drawable.circle_point_raduis), 60, 60);
  69 + OverlayOptions startCircleOptions = null;
  70 + if (startCircleBitmap != null) {
  71 + startCircleOptions = new MarkerOptions()
  72 + .position(startLatLng)
  73 + .icon(BitmapDescriptorFactory.fromBitmap(startCircleBitmap))
  74 + .perspective(false)
  75 + .anchor(0.5f, 0.6f)
  76 + .animateType(MarkerOptions.MarkerAnimateType.grow);
  77 +
  78 + }
  79 + if (startCircleOptions != null) {
  80 + resultOverlays.add(baiduMap.addOverlay(startCircleOptions));
  81 + }
  82 + if (startOptions != null) {
  83 + resultOverlays.add(baiduMap.addOverlay(startOptions));
  84 +
  85 + }
  86 + if (resultOverlays != null) {
  87 + return resultOverlays;
  88 + } else {
  89 + return null;
  90 + }
  91 + } catch (
  92 + Exception e) {
  93 + return null;
  94 + }
  95 + }
  96 +
  97 + /**
  98 + * 根据点位信息,自动缩放地图
  99 + *
  100 + * @param baiduMap
  101 + * @param trackPoints
  102 + * @param zoomBy
  103 + */
55 104 public static void setMapAutoZoom(BaiduMap baiduMap, List<LatLng> trackPoints, float zoomBy) {
56 105 LatLngBounds.Builder builder = new LatLngBounds.Builder();
57 106 for (LatLng latLng : trackPoints) {
... ... @@ -331,7 +380,7 @@ public class MyMapUtil {
331 380 */
332 381 public static Overlay drawRealTimeTrack(Context context, BaiduMap baiduMap, List<LatLng> points, SortType sortType, int lineColor, int startIconRes) {
333 382 // 绘制新覆盖物前,清空之前的覆盖物
334   - if (points == null || points.size() == 0 || lineColor == 0 ) {
  383 + if (points == null || points.size() == 0 || lineColor == 0) {
335 384 return null;
336 385 }
337 386 //只有一个点
... ... @@ -378,114 +427,120 @@ public class MyMapUtil {
378 427 * 绘制服务器传过来的轨迹
379 428 */
380 429 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));
  430 + try {
  431 + // 绘制新覆盖物前,清空之前的覆盖物
  432 + if (points == null || points.size() == 0) {
  433 + return null;
  434 + }
  435 + List<Overlay> resultOverlays = new ArrayList<>();
  436 + //只有一个点
  437 + if (points.size() == 1) {
  438 + Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), startIconRes), 24, 30);
  439 + OverlayOptions startOptions = null;
  440 + if (pointBitmap != null) {
  441 + startOptions = new MarkerOptions().position(points.get(0)).icon(BitmapDescriptorFactory.fromBitmap(pointBitmap));
  442 + if (startOptions != null) {
  443 + resultOverlays.add(baiduMap.addOverlay(startOptions));
  444 + }
  445 + return resultOverlays;
394 446 }
395   - return resultOverlays;
396 447 }
397   - }
398 448  
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));
  449 + LatLng startPoint;
  450 + LatLng endPoint;
  451 + if (sortType == SortType.asc) {
  452 + startPoint = points.get(0);
  453 + endPoint = points.get(points.size() - 1);
  454 + } else {
  455 + startPoint = points.get(points.size() - 1);
  456 + endPoint = points.get(0);
  457 + }
  458 + // 添加起点图标
  459 + Bitmap startPointBitmap = null;
  460 + if (null != context.getResources()) {
  461 + startPointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), startIconRes), 24, 30);
  462 + }
  463 + OverlayOptions startOptions = null;
  464 + if (startPointBitmap != null) {
  465 + startOptions = new MarkerOptions()
  466 + .position(startPoint)
  467 + .icon(BitmapDescriptorFactory.fromBitmap(startPointBitmap))
  468 + .perspective(false)
  469 + .animateType(MarkerOptions.MarkerAnimateType.grow);
  470 + }
  471 + // 添加终点图标
  472 + Bitmap endPointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), endIconRes), 24, 30);
  473 + OverlayOptions endOptions = null;
  474 + if (endPointBitmap != null) {
  475 + endOptions = new MarkerOptions()
  476 + .position(endPoint)
  477 + .icon(BitmapDescriptorFactory.fromBitmap(endPointBitmap))
  478 + .perspective(false)
  479 + .anchor(0.6f, 0.96f)
  480 + .animateType(MarkerOptions.MarkerAnimateType.grow);
  481 + }
  482 + // 添加圆形范围
  483 + Bitmap startCircleBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), R.drawable.circle_point_raduis), 60, 60);
  484 + OverlayOptions startCircleOptions = null;
  485 + OverlayOptions endCircleOptions = null;
  486 + if (startCircleBitmap != null) {
  487 + startCircleOptions = new MarkerOptions()
  488 + .position(startPoint)
  489 + .icon(BitmapDescriptorFactory.fromBitmap(startCircleBitmap))
  490 + .perspective(false)
  491 + .anchor(0.5f, 0.6f)
  492 + .animateType(MarkerOptions.MarkerAnimateType.grow);
  493 +
  494 + endCircleOptions = new MarkerOptions()
  495 + .position(endPoint)
  496 + .icon(BitmapDescriptorFactory.fromBitmap(startCircleBitmap))
  497 + .perspective(false)
  498 + .anchor(0.5f, 0.6f)
  499 + .animateType(MarkerOptions.MarkerAnimateType.grow);
  500 + }
  501 + // 添加路线(轨迹)
  502 + OverlayOptions polylineOptions = null;
  503 + if (points != null && points.size() > 1) {
  504 + polylineOptions = new PolylineOptions().width(10)
  505 + .color(context.getResources().getColor(lineColor)).points(points);
  506 + }
  507 + if (endCircleOptions != null) {
  508 + resultOverlays.add(baiduMap.addOverlay(endCircleOptions));
  509 + }
  510 + if (startCircleOptions != null) {
  511 + resultOverlays.add(baiduMap.addOverlay(startCircleOptions));
  512 + }
  513 + if (startOptions != null) {
  514 + resultOverlays.add(baiduMap.addOverlay(startOptions));
465 515  
466   - }
467   - if (endOptions != null) {
468   - resultOverlays.add(baiduMap.addOverlay(endOptions));
469   - }
470   - if (polylineOptions != null) {
471   - resultOverlays.add(baiduMap.addOverlay(polylineOptions));
  516 + }
  517 + if (endOptions != null) {
  518 + resultOverlays.add(baiduMap.addOverlay(endOptions));
  519 + }
  520 + if (polylineOptions != null) {
  521 + resultOverlays.add(baiduMap.addOverlay(polylineOptions));
472 522  
473   - }
474   - if (resultOverlays != null) {
475   - return resultOverlays;
476   - } else {
  523 + }
  524 + if (resultOverlays != null) {
  525 + return resultOverlays;
  526 + } else {
  527 + return null;
  528 + }
  529 + } catch (Exception e) {
477 530 return null;
478 531 }
479 532 }
480 533  
481 534  
482   - public static Overlay drawMapLine(Context context, BaiduMap baiduMap, List<LatLng> points, int lineColor) {
  535 + public static Overlay drawMapLine(Context context, BaiduMap
  536 + baiduMap, List<LatLng> points, int lineColor) {
483 537 OverlayOptions polylineOptions = new PolylineOptions().width(10)
484 538 .color(context.getResources().getColor(lineColor)).points(points);
485 539 return baiduMap.addOverlay(polylineOptions);
486 540 }
487 541  
488   - public static Overlay drawMapLineRoutePoint(Context context, BaiduMap baiduMap, List<RoutePoint> points, int lineColor) {
  542 + public static Overlay drawMapLineRoutePoint(Context context, BaiduMap
  543 + baiduMap, List<RoutePoint> points, int lineColor) {
489 544 List<LatLng> latLngs = new ArrayList<>();
490 545 for (RoutePoint routePoint : points) {
491 546 if (routePoint != null && routePoint.getLat() != 0 && routePoint.getLng() != 0) {
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/StepUtil.java
... ... @@ -6,9 +6,12 @@ import android.util.Log;
6 6  
7 7 import com.cnlive.moudle.pedometer.commonInfo.CommonInfo;
8 8 import com.cnlive.moudle.pedometer.model.Constant;
  9 +import com.cnlive.moudle.pedometer.sql.dao.CollUserStepEntityDao;
9 10 import com.cnlive.moudle.pedometer.sql.dao.FailedEntityDao;
10 11 import com.cnlive.moudle.pedometer.sql.dao.UserStepEntityDao;
11 12 import com.cnlive.moudle.pedometer.sql.db.DbCore;
  13 +import com.cnlive.moudle.pedometer.sql.entity.CollFailedEntity;
  14 +import com.cnlive.moudle.pedometer.sql.entity.CollUserStepEntity;
12 15 import com.cnlive.moudle.pedometer.sql.entity.FailedEntity;
13 16 import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity;
14 17  
... ... @@ -81,6 +84,12 @@ public class StepUtil {
81 84 DbCore.getDaoSession().getFailedEntityDao().insert(failedEntity);
82 85 }
83 86  
  87 + //设置运营失败数据
  88 + public static void setCollFailData(Context context, CollFailedEntity failedEntity) {
  89 + DbCore.init(context, dbName);
  90 + DbCore.getDaoSession().getCollFailedEntityDao().insert(failedEntity);
  91 + }
  92 +
84 93 /**
85 94 * 设置赛事标题
86 95 *
... ... @@ -97,6 +106,8 @@ public class StepUtil {
97 106 }
98 107 }
99 108  
  109 +
  110 +
100 111 /**
101 112 * 设置重要点
102 113 *
... ... @@ -199,6 +210,8 @@ public class StepUtil {
199 210  
200 211 }
201 212  
  213 +
  214 +
202 215 /**
203 216 * 得到当前速度
204 217 *
... ... @@ -264,6 +277,27 @@ public class StepUtil {
264 277 }
265 278  
266 279 /**
  280 + * 获取运营用户数据
  281 + *
  282 + * @param context
  283 + * @param uid
  284 + * @return
  285 + */
  286 + public static CollUserStepEntity getCollUserStepData(Context context, String uid) {
  287 + if (!TextUtils.isEmpty(uid)) {
  288 + DbCore.init(context, dbName);
  289 + List<CollUserStepEntity> list = DbCore.getDaoSession().getCollUserStepEntityDao().queryBuilder().where(CollUserStepEntityDao.Properties.UserId.eq(uid)).list();
  290 + if (list != null && list.size() > 0) {
  291 + return list.get(0);
  292 + } else {
  293 + return null;
  294 + }
  295 + } else {
  296 + return null;
  297 + }
  298 + }
  299 +
  300 + /**
267 301 * 设置用户数据
268 302 *
269 303 * @param context
... ... @@ -303,6 +337,8 @@ public class StepUtil {
303 337 }
304 338 }
305 339  
  340 +
  341 +
306 342 /**
307 343 * 设置计步开始时间
308 344 *
... ... @@ -337,6 +373,8 @@ public class StepUtil {
337 373 }
338 374  
339 375  
  376 +
  377 +
340 378 /**
341 379 * 获取用户暂停次数
342 380 *
... ...
moudle_pedometer/src/main/res/drawable-hdpi/icon_slide_up.png 0 → 100644

469 Bytes

moudle_pedometer/src/main/res/drawable-xhdpi/icon_slide_up.png 0 → 100644

517 Bytes

moudle_pedometer/src/main/res/drawable-xxhdpi/icon_slide_up.png 0 → 100644

1002 Bytes

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 9 \ No newline at end of file
... ...
moudle_pedometer/src/main/res/layout/fragment_coll_run_main.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<layout xmlns:android="http://schemas.android.com/apk/res/android">
  3 +
  4 + <LinearLayout
  5 + android:layout_width="match_parent"
  6 + android:layout_height="match_parent"
  7 + android:orientation="vertical">
  8 +
  9 + <FrameLayout
  10 + android:layout_width="match_parent"
  11 + android:layout_height="match_parent">
  12 +
  13 + <LinearLayout
  14 + android:id="@+id/ll_run_main_root"
  15 + android:layout_width="match_parent"
  16 + android:layout_height="match_parent"
  17 + android:background="@color/run_main_bg"
  18 + android:orientation="vertical">
  19 +
  20 + <RelativeLayout
  21 + android:id="@+id/rl_close"
  22 + android:layout_width="match_parent"
  23 + android:layout_height="wrap_content"
  24 + android:visibility="gone">
  25 +
  26 + <ImageView
  27 + android:layout_width="25dp"
  28 + android:layout_height="25dp"
  29 + android:layout_alignParentRight="true"
  30 + android:layout_margin="10dp"
  31 + android:src="@drawable/icon_right_close" />
  32 + </RelativeLayout>
  33 + <!--公里数显示-->
  34 + <FrameLayout
  35 + android:layout_width="match_parent"
  36 + android:layout_height="0dp"
  37 + android:layout_weight="1.2">
  38 +
  39 + <LinearLayout
  40 + android:layout_width="match_parent"
  41 + android:layout_height="match_parent"
  42 + android:gravity="center"
  43 + android:paddingLeft="50dp">
  44 +
  45 + <TextView
  46 + android:id="@+id/tv_run_distance"
  47 + android:layout_width="wrap_content"
  48 + android:layout_height="wrap_content"
  49 + android:text="0.00"
  50 + android:textColor="@color/white"
  51 + android:textSize="70sp"
  52 + android:textStyle="bold" />
  53 +
  54 + <TextView
  55 + android:layout_width="wrap_content"
  56 + android:layout_height="wrap_content"
  57 + android:layout_marginLeft="10dp"
  58 + android:layout_marginTop="20dp"
  59 + android:text="公里"
  60 + android:textColor="@color/white"
  61 + android:textSize="15sp" />
  62 + </LinearLayout>
  63 +
  64 + <LinearLayout
  65 + android:id="@+id/ll_back"
  66 + android:layout_width="wrap_content"
  67 + android:layout_height="wrap_content"
  68 + android:padding="10dp">
  69 +
  70 + <ImageView
  71 + android:layout_width="12dp"
  72 + android:layout_height="20dp"
  73 + android:layout_margin="10dp"
  74 + android:background="@drawable/icon_white_back" />
  75 + </LinearLayout>
  76 + </FrameLayout>
  77 + <!--GPS信息-->
  78 + <LinearLayout
  79 + android:layout_width="match_parent"
  80 + android:layout_height="0dp"
  81 + android:layout_weight="2.2"
  82 + android:orientation="vertical">
  83 +
  84 + <RelativeLayout
  85 + android:id="@+id/rl_gps"
  86 + android:layout_width="match_parent"
  87 + android:layout_height="wrap_content">
  88 +
  89 + <TextView
  90 + android:id="@+id/tv_gps"
  91 + android:layout_width="wrap_content"
  92 + android:layout_height="wrap_content"
  93 + android:layout_centerVertical="true"
  94 + android:layout_marginLeft="20dp"
  95 + android:text="GPS"
  96 + android:textColor="@color/white"
  97 + android:textSize="18sp"
  98 + android:textStyle="bold" />
  99 +
  100 + <ImageView
  101 + android:id="@+id/iv_gps"
  102 + android:layout_width="18dp"
  103 + android:layout_height="5dp"
  104 + android:layout_centerVertical="true"
  105 + android:layout_marginLeft="5dp"
  106 + android:layout_toRightOf="@id/tv_gps" />
  107 +
  108 + <TextView
  109 + android:id="@+id/tv_look_trace"
  110 + android:layout_width="wrap_content"
  111 + android:layout_height="wrap_content"
  112 + android:layout_centerVertical="true"
  113 + android:layout_marginLeft="5dp"
  114 + android:layout_toRightOf="@id/iv_gps"
  115 + android:textColor="@color/text_gray99"
  116 + android:textSize="12sp"
  117 + android:textStyle="bold" />
  118 +
  119 + <LinearLayout
  120 + android:layout_width="wrap_content"
  121 + android:layout_height="wrap_content"
  122 + android:layout_alignParentRight="true"
  123 + android:layout_marginRight="15dp"
  124 + android:gravity="center"
  125 + android:orientation="vertical">
  126 +
  127 + <ImageView
  128 + android:layout_width="55dp"
  129 + android:layout_height="55dp"
  130 + android:src="@drawable/rt_ic_home_map" />
  131 +
  132 + <TextView
  133 + android:layout_width="wrap_content"
  134 + android:layout_height="wrap_content"
  135 + android:layout_marginTop="5dp"
  136 + android:text="点击查看轨迹"
  137 + android:textColor="@color/text_gray99"
  138 + android:textSize="10sp" />
  139 + </LinearLayout>
  140 + </RelativeLayout>
  141 + <!--计时-->
  142 + <LinearLayout
  143 + android:layout_width="match_parent"
  144 + android:layout_height="wrap_content"
  145 + android:layout_marginTop="35dp">
  146 +
  147 + <LinearLayout
  148 + android:layout_width="0dp"
  149 + android:layout_height="wrap_content"
  150 + android:layout_weight="1"
  151 + android:gravity="center"
  152 + android:orientation="vertical">
  153 +
  154 + <ImageView
  155 + android:layout_width="26dp"
  156 + android:layout_height="23dp"
  157 + android:layout_marginBottom="5dp"
  158 + android:src="@drawable/sport_speed" />
  159 +
  160 + <LinearLayout
  161 + android:layout_width="match_parent"
  162 + android:layout_height="wrap_content"
  163 + android:gravity="center">
  164 +
  165 + <TextView
  166 + android:id="@+id/tv_speed"
  167 + android:layout_width="wrap_content"
  168 + android:layout_height="wrap_content"
  169 + android:text="--"
  170 + android:textColor="@color/white"
  171 + android:textSize="20sp"
  172 + android:textStyle="bold" />
  173 +
  174 + </LinearLayout>
  175 +
  176 + <TextView
  177 + android:layout_width="wrap_content"
  178 + android:layout_height="wrap_content"
  179 + android:layout_marginTop="5dp"
  180 + android:gravity="center"
  181 + android:text="配速"
  182 + android:textColor="@color/text_gray99"
  183 + android:textSize="15sp" />
  184 + </LinearLayout>
  185 + <!--用时-->
  186 + <LinearLayout
  187 + android:layout_width="0dp"
  188 + android:layout_height="wrap_content"
  189 + android:layout_weight="1"
  190 + android:gravity="center"
  191 + android:orientation="vertical">
  192 +
  193 + <ImageView
  194 + android:layout_width="23dp"
  195 + android:layout_height="25dp"
  196 + android:layout_marginBottom="5dp"
  197 + android:src="@drawable/sport_time_cost" />
  198 +
  199 + <Chronometer
  200 + android:id="@+id/chronometer"
  201 + android:layout_width="wrap_content"
  202 + android:layout_height="wrap_content"
  203 + android:format="00:00:00"
  204 + android:textColor="@color/white"
  205 + android:textSize="20sp"
  206 + android:textStyle="bold" />
  207 +
  208 + <TextView
  209 + android:layout_width="wrap_content"
  210 + android:layout_height="wrap_content"
  211 + android:layout_marginTop="5dp"
  212 + android:gravity="center"
  213 + android:text="用时"
  214 + android:textColor="@color/text_gray99"
  215 + android:textSize="15sp" />
  216 + </LinearLayout>
  217 + <!--热量-->
  218 + <LinearLayout
  219 + android:layout_width="0dp"
  220 + android:layout_height="wrap_content"
  221 + android:layout_weight="1"
  222 + android:gravity="center"
  223 + android:orientation="vertical">
  224 +
  225 + <ImageView
  226 + android:layout_width="26dp"
  227 + android:layout_height="24dp"
  228 + android:layout_marginBottom="5dp"
  229 + android:src="@drawable/sport_step" />
  230 +
  231 + <TextView
  232 + android:id="@+id/tv_step_count"
  233 + android:layout_width="match_parent"
  234 + android:layout_height="wrap_content"
  235 + android:gravity="center"
  236 + android:text="--"
  237 + android:textColor="@color/white"
  238 + android:textSize="20sp"
  239 + android:textStyle="bold" />
  240 +
  241 + <TextView
  242 + android:layout_width="wrap_content"
  243 + android:layout_height="wrap_content"
  244 + android:layout_marginTop="5dp"
  245 + android:gravity="center"
  246 + android:text="步"
  247 + android:textColor="@color/text_gray99"
  248 + android:textSize="15sp" />
  249 + </LinearLayout>
  250 + </LinearLayout>
  251 +
  252 + <RelativeLayout
  253 + android:layout_width="match_parent"
  254 + android:layout_height="wrap_content">
  255 + <!--限制速度-->
  256 + <TextView
  257 + android:layout_width="wrap_content"
  258 + android:layout_height="wrap_content"
  259 + android:layout_marginLeft="15dp"
  260 + android:layout_marginTop="10dp"
  261 + android:text="限速10m/s"
  262 + android:textColor="@color/white"
  263 + android:textSize="15sp"
  264 + android:visibility="gone" />
  265 +
  266 +
  267 + </RelativeLayout>
  268 + <!--按钮-->
  269 + <FrameLayout
  270 + android:layout_width="match_parent"
  271 + android:layout_height="match_parent">
  272 + <!--底部;两个按钮-->
  273 + <LinearLayout
  274 + android:id="@+id/ll_two_bottom_button"
  275 + android:layout_width="match_parent"
  276 + android:layout_height="wrap_content"
  277 + android:layout_gravity="center"
  278 + android:layout_marginBottom="25dp"
  279 + android:gravity="center_horizontal"
  280 + android:visibility="visible">
  281 +
  282 + <LinearLayout
  283 + android:layout_width="wrap_content"
  284 + android:layout_height="match_parent"
  285 + android:layout_marginRight="50dp"
  286 + android:orientation="vertical"
  287 + android:visibility="gone">
  288 +
  289 + <FrameLayout
  290 + android:layout_width="match_parent"
  291 + android:layout_height="wrap_content"
  292 + android:layout_marginTop="10dp"
  293 + android:visibility="invisible">
  294 +
  295 + <ImageView
  296 + android:layout_width="72dp"
  297 + android:layout_height="33dp"
  298 + android:layout_gravity="center" />
  299 +
  300 + <TextView
  301 + android:layout_width="wrap_content"
  302 + android:layout_height="wrap_content"
  303 + android:layout_gravity="center"
  304 + android:layout_marginBottom="5dp"
  305 + android:gravity="center"
  306 + android:src="@drawable/bg_tips_bottom_center"
  307 + android:textSize="12sp" />
  308 + </FrameLayout>
  309 + <!--暂停-->
  310 + <FrameLayout
  311 + android:layout_width="wrap_content"
  312 + android:layout_height="wrap_content">
  313 +
  314 + <FrameLayout
  315 + android:id="@+id/fl_continue"
  316 + android:layout_width="85dp"
  317 + android:layout_height="85dp"
  318 + android:layout_margin="10dp"
  319 + android:background="@drawable/shape_green_round"
  320 + android:focusable="true">
  321 +
  322 + <ImageView
  323 + android:layout_width="17dp"
  324 + android:layout_height="20dp"
  325 + android:layout_gravity="center"
  326 + android:layout_marginBottom="10dp"
  327 + android:background="@drawable/rt_training_button_resume"
  328 + android:focusable="false" />
  329 +
  330 + <TextView
  331 + android:layout_width="wrap_content"
  332 + android:layout_height="wrap_content"
  333 + android:layout_gravity="center"
  334 + android:layout_marginTop="15dp"
  335 + android:focusable="false"
  336 + android:text="继续"
  337 + android:textColor="@color/white"
  338 + android:textSize="14sp" />
  339 + </FrameLayout>
  340 + <!--暂停-->
  341 + <FrameLayout
  342 + android:id="@+id/fl_pause"
  343 + android:layout_width="85dp"
  344 + android:layout_height="85dp"
  345 + android:layout_margin="10dp"
  346 + android:background="@drawable/shape_white_round"
  347 + android:focusable="true">
  348 +
  349 + <ImageView
  350 + android:layout_width="wrap_content"
  351 + android:layout_height="18dp"
  352 + android:layout_gravity="center"
  353 + android:layout_marginBottom="10dp"
  354 + android:background="@drawable/rt_training_button_pause"
  355 + android:focusable="false" />
  356 +
  357 + <TextView
  358 + android:layout_width="wrap_content"
  359 + android:layout_height="wrap_content"
  360 + android:layout_gravity="center"
  361 + android:layout_marginTop="15dp"
  362 + android:focusable="false"
  363 + android:text="暂停"
  364 + android:textColor="@color/blacktext"
  365 + android:textSize="14sp" />
  366 + </FrameLayout>
  367 + <!---->
  368 + </FrameLayout>
  369 + </LinearLayout>
  370 +
  371 + <LinearLayout
  372 + android:layout_width="wrap_content"
  373 + android:layout_height="match_parent"
  374 + android:orientation="vertical">
  375 +
  376 + <FrameLayout
  377 + android:id="@+id/fl_stop_tip"
  378 + android:layout_width="match_parent"
  379 + android:layout_height="wrap_content"
  380 + android:layout_marginTop="10dp"
  381 + android:visibility="invisible">
  382 +
  383 + <ImageView
  384 + android:layout_width="72dp"
  385 + android:layout_height="33dp"
  386 + android:layout_gravity="center"
  387 + android:background="@drawable/bg_tips_bottom_center" />
  388 +
  389 + <TextView
  390 + android:layout_width="wrap_content"
  391 + android:layout_height="wrap_content"
  392 + android:layout_gravity="center"
  393 + android:layout_marginBottom="3dp"
  394 + android:gravity="center"
  395 + android:src="@drawable/bg_tips_bottom_center"
  396 + android:text="长按结束"
  397 + android:textSize="12sp" />
  398 + </FrameLayout>
  399 +
  400 + <FrameLayout
  401 + android:id="@+id/fl_stop"
  402 + android:layout_width="85dp"
  403 + android:layout_height="85dp"
  404 + android:layout_margin="10dp"
  405 + android:background="@drawable/shape_red_round">
  406 +
  407 + <com.cnlive.moudle.pedometer.ui.widget.CircularProgressBar
  408 + android:id="@+id/cp_current"
  409 + android:layout_width="match_parent"
  410 + android:layout_height="match_parent"
  411 + android:layout_margin="7dp"
  412 + android:visibility="gone" />
  413 +
  414 + <ImageView
  415 + android:layout_width="17dp"
  416 + android:layout_height="17dp"
  417 + android:layout_gravity="center"
  418 + android:layout_marginBottom="10dp"
  419 + android:background="@drawable/rt_training_button_stop"
  420 + android:focusable="false" />
  421 +
  422 + <TextView
  423 + android:layout_width="wrap_content"
  424 + android:layout_height="wrap_content"
  425 + android:layout_gravity="center"
  426 + android:layout_marginTop="15dp"
  427 + android:focusable="false"
  428 + android:text="结束"
  429 + android:textColor="@color/white"
  430 + android:textSize="14sp" />
  431 + </FrameLayout>
  432 + </LinearLayout>
  433 + </LinearLayout>
  434 + <!--暂停按钮-->
  435 + <!--<LinearLayout-->
  436 + <!--android:id="@+id/ll_pause"-->
  437 + <!--android:layout_width="match_parent"-->
  438 + <!--android:layout_height="match_parent"-->
  439 + <!--android:gravity="center">-->
  440 +
  441 + <!--<FrameLayout-->
  442 + <!--android:id="@+id/fl_pause"-->
  443 + <!--android:layout_width="85dp"-->
  444 + <!--android:layout_height="85dp"-->
  445 + <!--android:layout_marginBottom="12dp"-->
  446 + <!--android:background="@drawable/shape_white_round"-->
  447 + <!--android:focusable="true">-->
  448 +
  449 + <!--<ImageView-->
  450 + <!--android:layout_width="15dp"-->
  451 + <!--android:layout_height="18dp"-->
  452 + <!--android:layout_gravity="center"-->
  453 + <!--android:layout_marginBottom="10dp"-->
  454 + <!--android:background="@drawable/rt_training_button_pause"-->
  455 + <!--android:focusable="false" />-->
  456 +
  457 + <!--<TextView-->
  458 + <!--android:layout_width="wrap_content"-->
  459 + <!--android:layout_height="wrap_content"-->
  460 + <!--android:layout_gravity="center"-->
  461 + <!--android:layout_marginTop="15dp"-->
  462 + <!--android:focusable="false"-->
  463 + <!--android:text="暂停"-->
  464 + <!--android:textColor="@color/blacktext"-->
  465 + <!--android:textSize="14sp" />-->
  466 + <!--</FrameLayout>-->
  467 + <!--</LinearLayout>-->
  468 + </FrameLayout>
  469 + </LinearLayout>
  470 + </LinearLayout>
  471 + <!---->
  472 + </FrameLayout>
  473 + </LinearLayout>
  474 +</layout>
0 475 \ No newline at end of file
... ...