Commit 61a896b276c3b6bbb864a200d1b9223768fe5161

Authored by 杨帅
1 parent 801f67e2

1 修复BUG

Showing 22 changed files with 455 additions and 148 deletions
config.gradle
@@ -21,7 +21,7 @@ ext { @@ -21,7 +21,7 @@ ext {
21 //编译方式 21 //编译方式
22 debug : false, 22 debug : false,
23 //版本号 23 //版本号
24 - version: "0.7.8", 24 + version: "0.7.10",
25 //Lib库前缀 25 //Lib库前缀
26 packeg : "com.cnlive.module", 26 packeg : "com.cnlive.module",
27 //Lib库名称 27 //Lib库名称
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/presenter/CollRunningFinishFragmetPresenter.java
@@ -43,10 +43,13 @@ import io.reactivex.disposables.Disposable; @@ -43,10 +43,13 @@ import io.reactivex.disposables.Disposable;
43 public class CollRunningFinishFragmetPresenter extends MvpBasePresenter<CollRunningFinishFragmentView> { 43 public class CollRunningFinishFragmetPresenter extends MvpBasePresenter<CollRunningFinishFragmentView> {
44 44
45 public void uploadTraceDateToServer(Activity context, CollUserStepEntity userStepEntity, String roadmap) { 45 public void uploadTraceDateToServer(Activity context, CollUserStepEntity userStepEntity, String roadmap) {
  46 + if (null == getView()) {
  47 + return;
  48 + }
46 if (null != getView()) { 49 if (null != getView()) {
47 getView().limitUploadBtnTouch(); 50 getView().limitUploadBtnTouch();
48 } 51 }
49 - QMUITipDialogUtil.loadingDialog(context, "正在上传数据", false); 52 + getView().showLoading("正在上传数据");
50 Map<String, String> paramsMap = new HashMap<>(); 53 Map<String, String> paramsMap = new HashMap<>();
51 //赛事id 54 //赛事id
52 if (!TextUtils.isEmpty(userStepEntity.getStreetId())) { 55 if (!TextUtils.isEmpty(userStepEntity.getStreetId())) {
@@ -120,6 +123,7 @@ public class CollRunningFinishFragmetPresenter extends MvpBasePresenter&lt;CollRunn @@ -120,6 +123,7 @@ public class CollRunningFinishFragmetPresenter extends MvpBasePresenter&lt;CollRunn
120 if (getView() == null) { 123 if (getView() == null) {
121 return; 124 return;
122 } 125 }
  126 + getView().hideLoading();
123 if (null != getView()) { 127 if (null != getView()) {
124 getView().allowUploadBtnTouch(); 128 getView().allowUploadBtnTouch();
125 } 129 }
@@ -132,7 +136,7 @@ public class CollRunningFinishFragmetPresenter extends MvpBasePresenter&lt;CollRunn @@ -132,7 +136,7 @@ public class CollRunningFinishFragmetPresenter extends MvpBasePresenter&lt;CollRunn
132 }, "重试", new SelectDialog.DialogInterface() { 136 }, "重试", new SelectDialog.DialogInterface() {
133 @Override 137 @Override
134 public void onClick(SelectDialog dialog) { 138 public void onClick(SelectDialog dialog) {
135 - dialog.dismiss(); 139 + getView().hideLoading();
136 uploadTraceDateToServer(context, userStepEntity, roadmap); 140 uploadTraceDateToServer(context, userStepEntity, roadmap);
137 } 141 }
138 }); 142 });
@@ -149,7 +153,7 @@ public class CollRunningFinishFragmetPresenter extends MvpBasePresenter&lt;CollRunn @@ -149,7 +153,7 @@ public class CollRunningFinishFragmetPresenter extends MvpBasePresenter&lt;CollRunn
149 return; 153 return;
150 } 154 }
151 EventBus.getDefault().post(new MessageEvent(Constant.UPDATA_COLL_TRACE_LIST, "")); 155 EventBus.getDefault().post(new MessageEvent(Constant.UPDATA_COLL_TRACE_LIST, ""));
152 - QMUITipDialogUtil.dismessDialog(); 156 + getView().hideLoading();
153 QMUITipDialogUtil.successDialog(context, "数据上传成功", 1); 157 QMUITipDialogUtil.successDialog(context, "数据上传成功", 1);
154 //清空数据 158 //清空数据
155 CollStepUtil.clearRunData(context, CollCommonInfo.getUserId(context)); 159 CollStepUtil.clearRunData(context, CollCommonInfo.getUserId(context));
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunningFinishFragmentView.java
@@ -8,6 +8,7 @@ import android.text.TextUtils; @@ -8,6 +8,7 @@ import android.text.TextUtils;
8 import android.util.Log; 8 import android.util.Log;
9 import android.view.MotionEvent; 9 import android.view.MotionEvent;
10 import android.view.View; 10 import android.view.View;
  11 +import android.widget.TextView;
11 12
12 import com.baidu.mapapi.map.BaiduMap; 13 import com.baidu.mapapi.map.BaiduMap;
13 import com.baidu.mapapi.map.MapView; 14 import com.baidu.mapapi.map.MapView;
@@ -122,7 +123,7 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener { @@ -122,7 +123,7 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener {
122 String faceUrl = CommonInfo.getUserIcon(getContext()); 123 String faceUrl = CommonInfo.getUserIcon(getContext());
123 if (!TextUtils.isEmpty(faceUrl)) { 124 if (!TextUtils.isEmpty(faceUrl)) {
124 GlideApp.with(getContext()).load(faceUrl).into(fragment.binding.includeFinishUserInfo.qmIvIcon); 125 GlideApp.with(getContext()).load(faceUrl).into(fragment.binding.includeFinishUserInfo.qmIvIcon);
125 - }else { 126 + } else {
126 GlideApp.with(getContext()).load(getContext().getResources().getString(R.string.default_face_url)).into(fragment.binding.includeFinishUserInfo.qmIvIcon); 127 GlideApp.with(getContext()).load(getContext().getResources().getString(R.string.default_face_url)).into(fragment.binding.includeFinishUserInfo.qmIvIcon);
127 } 128 }
128 //设置标题 129 //设置标题
@@ -207,7 +208,7 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener { @@ -207,7 +208,7 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener {
207 } 208 }
208 } 209 }
209 dialog.dismiss(); 210 dialog.dismiss();
210 - QMUITipDialogUtil.loadingDialog(getContext(), "正在截取赛事图片,请稍后", false); 211 + showLoading("正在截取赛事图片,请稍后");
211 //延迟一秒进行截图,以免把打的点都截取到 212 //延迟一秒进行截图,以免把打的点都截取到
212 new Handler().postDelayed(new Runnable() { 213 new Handler().postDelayed(new Runnable() {
213 @Override 214 @Override
@@ -358,8 +359,8 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener { @@ -358,8 +359,8 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener {
358 baiduMap.snapshot(new BaiduMap.SnapshotReadyCallback() { 359 baiduMap.snapshot(new BaiduMap.SnapshotReadyCallback() {
359 @Override 360 @Override
360 public void onSnapshotReady(Bitmap bitmap) { 361 public void onSnapshotReady(Bitmap bitmap) {
361 - QMUITipDialogUtil.dismessDialog();  
362 if (null == bitmap) { 362 if (null == bitmap) {
  363 + hideLoading();
363 QMUITipDialogUtil.failedDialog(getContext(), "赛事图片截取失败,请重试", 2); 364 QMUITipDialogUtil.failedDialog(getContext(), "赛事图片截取失败,请重试", 2);
364 return; 365 return;
365 } 366 }
@@ -376,7 +377,7 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener { @@ -376,7 +377,7 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener {
376 //开始上传 377 //开始上传
377 uploadRoadMapPic(roadMapPath); 378 uploadRoadMapPic(roadMapPath);
378 } catch (Exception e) { 379 } catch (Exception e) {
379 - QMUITipDialogUtil.dismessDialog(); 380 + hideLoading();
380 QMUITipDialogUtil.failedDialog(getContext(), "赛事图片截取失败,请重试", 2); 381 QMUITipDialogUtil.failedDialog(getContext(), "赛事图片截取失败,请重试", 2);
381 //允许点击 382 //允许点击
382 allowUploadBtnTouch(); 383 allowUploadBtnTouch();
@@ -395,14 +396,14 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener { @@ -395,14 +396,14 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener {
395 //禁止点击 396 //禁止点击
396 limitUploadBtnTouch(); 397 limitUploadBtnTouch();
397 if (!TextUtils.isEmpty(roadMapPath)) { 398 if (!TextUtils.isEmpty(roadMapPath)) {
398 - QMUITipDialogUtil.loadingDialog(getContext(), "正在上传赛事图片,请稍后", false); 399 + showLoading("正在上传赛事图片,请稍后");
399 List<String> imagePaths = new ArrayList<>(); 400 List<String> imagePaths = new ArrayList<>();
400 imagePaths.add(roadMapPath); 401 imagePaths.add(roadMapPath);
401 UploadLogic.uploadAddressPicInfo(getContext(), imagePaths, new Event<String>() 402 UploadLogic.uploadAddressPicInfo(getContext(), imagePaths, new Event<String>()
402 .setFailureCallback(new FailureCallback() { 403 .setFailureCallback(new FailureCallback() {
403 @Override 404 @Override
404 public void onFailure(int i, String s) { 405 public void onFailure(int i, String s) {
405 - QMUITipDialogUtil.dismessDialog(); 406 + hideLoading();
406 SelectDialog selectDialog = new SelectDialog(getContext(), "赛事图片上传失败,是否重试?", "取消", new SelectDialog.DialogInterface() { 407 SelectDialog selectDialog = new SelectDialog(getContext(), "赛事图片上传失败,是否重试?", "取消", new SelectDialog.DialogInterface() {
407 @Override 408 @Override
408 public void onClick(SelectDialog dialog) { 409 public void onClick(SelectDialog dialog) {
@@ -428,7 +429,7 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener { @@ -428,7 +429,7 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener {
428 .setSuccessCallback(new SuccessCallback<String>() { 429 .setSuccessCallback(new SuccessCallback<String>() {
429 @Override 430 @Override
430 public void onSuccess(String data) { 431 public void onSuccess(String data) {
431 - QMUITipDialogUtil.dismessDialog(); 432 + hideLoading();
432 //开始把数据传到服务端 433 //开始把数据传到服务端
433 collUserStepEntity = CollStepUtil.getCollUserStepData(getContext(), CollCommonInfo.getUserId(getContext())); 434 collUserStepEntity = CollStepUtil.getCollUserStepData(getContext(), CollCommonInfo.getUserId(getContext()));
434 if (null != fragment.getPresenter() || null == fragment.getActivity() || null == collUserStepEntity || TextUtils.isEmpty(data)) { 435 if (null != fragment.getPresenter() || null == fragment.getActivity() || null == collUserStepEntity || TextUtils.isEmpty(data)) {
@@ -441,6 +442,26 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener { @@ -441,6 +442,26 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener {
441 } 442 }
442 } 443 }
443 444
  445 + public void showLoading(String tip) {
  446 + if (null == getContext() || null == fragment.binding.llLoading || null == fragment.binding.tvLoadingTip) {
  447 + return;
  448 + }
  449 + if (fragment.binding.llLoading.getVisibility() == View.GONE) {
  450 + fragment.binding.llLoading.setVisibility(View.VISIBLE);
  451 + }
  452 + if (!TextUtils.isEmpty(tip)) {
  453 + fragment.binding.tvLoadingTip.setText(tip);
  454 + }
  455 +
  456 + }
  457 + public void hideLoading() {
  458 + if (null == getContext() || null == fragment.binding.llLoading || null == fragment.binding.tvLoadingTip) {
  459 + return;
  460 + }
  461 + if (fragment.binding.llLoading.getVisibility() == View.VISIBLE) {
  462 + fragment.binding.llLoading.setVisibility(View.GONE);
  463 + }
  464 + }
444 465
445 public void initMap() { 466 public void initMap() {
446 this.mMapView = fragment.binding.mapView; 467 this.mMapView = fragment.binding.mapView;
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunningMapFragmentView.java
@@ -36,6 +36,7 @@ import com.baidu.mapapi.utils.DistanceUtil; @@ -36,6 +36,7 @@ import com.baidu.mapapi.utils.DistanceUtil;
36 import com.baidu.trace.model.SortType; 36 import com.baidu.trace.model.SortType;
37 import com.cnlive.libs.base.util.AlertUtil; 37 import com.cnlive.libs.base.util.AlertUtil;
38 import com.cnlive.moudle.collectionTrace.model.CollectPoint; 38 import com.cnlive.moudle.collectionTrace.model.CollectPoint;
  39 +import com.cnlive.moudle.collectionTrace.service.CollKeepLiveService;
39 import com.cnlive.moudle.collectionTrace.service.CollStepService; 40 import com.cnlive.moudle.collectionTrace.service.CollStepService;
40 import com.cnlive.moudle.collectionTrace.ui.activity.CollRunningFinishActivity; 41 import com.cnlive.moudle.collectionTrace.ui.activity.CollRunningFinishActivity;
41 import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunningMapFragment; 42 import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunningMapFragment;
@@ -303,7 +304,7 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener @@ -303,7 +304,7 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
303 public void onClick(View view) { 304 public void onClick(View view) {
304 //先获取打点数量 305 //先获取打点数量
305 int canTakePointCount = CollStepUtil.getCollImportPointSize(getContext(), CollCommonInfo.getUserId(getContext())); 306 int canTakePointCount = CollStepUtil.getCollImportPointSize(getContext(), CollCommonInfo.getUserId(getContext()));
306 - if (canTakePointCount<2) { 307 + if (canTakePointCount < 2) {
307 AlertUtil.showDeftToast(getContext(), "请至少打两个点后结束"); 308 AlertUtil.showDeftToast(getContext(), "请至少打两个点后结束");
308 } else { 309 } else {
309 if (null != followMyLocation) { 310 if (null != followMyLocation) {
@@ -444,12 +445,15 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener @@ -444,12 +445,15 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener
444 private void stopStepService() { 445 private void stopStepService() {
445 CollCommonInfo.setTsRunBaiduTraceService(getContext(), false); 446 CollCommonInfo.setTsRunBaiduTraceService(getContext(), false);
446 CollCommonInfo.setIsRunKeepAliveService(getContext(), false); 447 CollCommonInfo.setIsRunKeepAliveService(getContext(), false);
  448 + CollCommonInfo.setIsRunStepService(getContext(), false);
447 CollCommonInfo.setIsWriteUserStep(getContext(), false); 449 CollCommonInfo.setIsWriteUserStep(getContext(), false);
448 CollCommonInfo.setIsFirstStepSendTraceTip(getContext(), true); 450 CollCommonInfo.setIsFirstStepSendTraceTip(getContext(), true);
449 if (CollStepService.mClient != null) { 451 if (CollStepService.mClient != null) {
450 CollStepService.mClient.stopGather(StepService.traceListener); 452 CollStepService.mClient.stopGather(StepService.traceListener);
451 } 453 }
  454 + fragment.getActivity().stopService(new Intent(fragment.getActivity(), CollKeepLiveService.class));
452 fragment.getActivity().stopService(new Intent(fragment.getActivity(), CollStepService.class)); 455 fragment.getActivity().stopService(new Intent(fragment.getActivity(), CollStepService.class));
  456 +
453 } 457 }
454 458
455 private void initChrom() { 459 private void initChrom() {
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/StartTraceFragmentView.java
@@ -133,6 +133,9 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { @@ -133,6 +133,9 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener {
133 MyMapUtil.getGeoCoderResult(new LatLng(followMyLocation.latitude, followMyLocation.longitude), new MyMapUtil.GeoCodeResult() { 133 MyMapUtil.getGeoCoderResult(new LatLng(followMyLocation.latitude, followMyLocation.longitude), new MyMapUtil.GeoCodeResult() {
134 @Override 134 @Override
135 public void success(String address) { 135 public void success(String address) {
  136 + if (null==getContext()){
  137 + return;
  138 + }
136 QMUITipDialogUtil.dismessDialog(); 139 QMUITipDialogUtil.dismessDialog();
137 if (null != address && !TextUtils.isEmpty(address)) { 140 if (null != address && !TextUtils.isEmpty(address)) {
138 currentAddress = address; 141 currentAddress = address;
@@ -301,9 +304,8 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { @@ -301,9 +304,8 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener {
301 if (CollStepService.mClient != null) { 304 if (CollStepService.mClient != null) {
302 CollStepService.mClient.stopGather(CollStepService.traceListener); 305 CollStepService.mClient.stopGather(CollStepService.traceListener);
303 } 306 }
304 - fragment.getActivity().stopService(new Intent(fragment.getActivity(), CollStepService.class));  
305 fragment.getActivity().stopService(new Intent(fragment.getActivity(), CollKeepLiveService.class)); 307 fragment.getActivity().stopService(new Intent(fragment.getActivity(), CollKeepLiveService.class));
306 - 308 + fragment.getActivity().stopService(new Intent(fragment.getActivity(), CollStepService.class));
307 } 309 }
308 310
309 /** 311 /**
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/service/CollKeepLiveService.java
@@ -44,7 +44,7 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple @@ -44,7 +44,7 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple
44 private NotificationManager mNM; 44 private NotificationManager mNM;
45 private Notification notification = null; 45 private Notification notification = null;
46 //是否在后台运行 46 //是否在后台运行
47 - public static boolean isKeepService = true; 47 + public static boolean isKeepService = false;
48 public static CollKeepLiveService instance; 48 public static CollKeepLiveService instance;
49 private final String TAG = "CollKeepLiveService"; 49 private final String TAG = "CollKeepLiveService";
50 private Handler handler; 50 private Handler handler;
@@ -152,8 +152,20 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple @@ -152,8 +152,20 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple
152 if (isRun) { 152 if (isRun) {
153 showHideForegroundNotification(); 153 showHideForegroundNotification();
154 startPlaySong(); 154 startPlaySong();
155 - if (runnable != null) {  
156 - handler.postDelayed(runnable, 5000); 155 +// if (runnable != null) {
  156 +// handler.postDelayed(runnable, 5000);
  157 +// }
  158 + } else {
  159 + try {
  160 + if (myReceiver != null && isRegisterReceiver) {
  161 + unregisterReceiver(myReceiver);
  162 + }
  163 + } catch (Exception e) {
  164 + Log.e(TAG, "run: ");
  165 + }
  166 + stopPlaySong();
  167 + if (isStartForegroundService) {
  168 + stopForeground(true);
157 } 169 }
158 } 170 }
159 return START_STICKY; 171 return START_STICKY;
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/presenter/RunningFinishFragmetPresenter.java
@@ -58,10 +58,10 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter&lt;RunningFinis @@ -58,10 +58,10 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter&lt;RunningFinis
58 String employTime = runningFinishBean.getEmployTime(); 58 String employTime = runningFinishBean.getEmployTime();
59 //路线全程里数 59 //路线全程里数
60 String mileage = ""; 60 String mileage = "";
61 - if ("--".equals(runningFinishBean.getRunDistance())) { 61 + if (null == userStepEntity.getStepCount() || TextUtils.isEmpty(userStepEntity.getStepCount())) {
62 mileage = "0"; 62 mileage = "0";
63 } else { 63 } else {
64 - mileage = runningFinishBean.getRunDistance(); 64 + mileage = StepUtil.getWalkDistanceKM(Long.parseLong(userStepEntity.getStepCount())) + "";
65 } 65 }
66 //配速 66 //配速
67 String pace = ""; 67 String pace = "";
@@ -352,7 +352,7 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter&lt;RunningFinis @@ -352,7 +352,7 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter&lt;RunningFinis
352 StepUtil.clearRunData(context, CommonInfo.getUserId(context)); 352 StepUtil.clearRunData(context, CommonInfo.getUserId(context));
353 CommonInfo.reset(context); 353 CommonInfo.reset(context);
354 //用户跑完了,更新一下按钮 354 //用户跑完了,更新一下按钮
355 - EventBus.getDefault().post(new MessageEvent(Constant.UPDATE_RACE_STATE_BTN,"")); 355 + EventBus.getDefault().post(new MessageEvent(Constant.UPDATE_RACE_STATE_BTN, ""));
356 //跳转到上传失败列表 356 //跳转到上传失败列表
357 LineUpAgainActivity.newInstance(context); 357 LineUpAgainActivity.newInstance(context);
358 //关闭当前窗口 358 //关闭当前窗口
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunMainFragmentView.java
@@ -74,7 +74,7 @@ public class RunMainFragmentView implements MvpView { @@ -74,7 +74,7 @@ public class RunMainFragmentView implements MvpView {
74 public MyLocationListenner myListener = new MyLocationListenner(); 74 public MyLocationListenner myListener = new MyLocationListenner();
75 private String employTime = ""; 75 private String employTime = "";
76 private LatLng endLatLng;//终点坐标 76 private LatLng endLatLng;//终点坐标
77 - private TipDialog tipDialog; 77 + private TipDialog endTipDialog;
78 //创建震动服务对象 78 //创建震动服务对象
79 private Vibrator mVibrator; 79 private Vibrator mVibrator;
80 private boolean isfirstEndTip = true; 80 private boolean isfirstEndTip = true;
@@ -131,6 +131,10 @@ public class RunMainFragmentView implements MvpView { @@ -131,6 +131,10 @@ public class RunMainFragmentView implements MvpView {
131 * 初始化相关视图 131 * 初始化相关视图
132 */ 132 */
133 public void initView(RunRaceDetailInfo runRaceDetailInfo) { 133 public void initView(RunRaceDetailInfo runRaceDetailInfo) {
  134 + if (getContext() == null) {
  135 + return;
  136 + }
  137 + initEndTipDialog();
134 //获取手机震动服务 138 //获取手机震动服务
135 mVibrator = (Vibrator) getContext().getSystemService(Service.VIBRATOR_SERVICE); 139 mVibrator = (Vibrator) getContext().getSystemService(Service.VIBRATOR_SERVICE);
136 uid = CommonInfo.getUserId(getContext()); 140 uid = CommonInfo.getUserId(getContext());
@@ -342,6 +346,9 @@ public class RunMainFragmentView implements MvpView { @@ -342,6 +346,9 @@ public class RunMainFragmentView implements MvpView {
342 //继续记录轨迹 346 //继续记录轨迹
343 if (StepService.mClient != null && StepService.traceListener != null) { 347 if (StepService.mClient != null && StepService.traceListener != null) {
344 CommonInfo.setTsRunBaiduTraceService(getContext(), true); 348 CommonInfo.setTsRunBaiduTraceService(getContext(), true);
  349 + CommonInfo.setIsRunKeepAliveService(getContext(), true);
  350 + CommonInfo.setIsRunStepService(getContext(), true);
  351 + CommonInfo.setIsWriteUserStep(getContext(), true);
345 StepService.mClient.startTrace(StepService.mTrace, StepService.traceListener); 352 StepService.mClient.startTrace(StepService.mTrace, StepService.traceListener);
346 } 353 }
347 needWriteDataFlag = true; 354 needWriteDataFlag = true;
@@ -405,8 +412,8 @@ public class RunMainFragmentView implements MvpView { @@ -405,8 +412,8 @@ public class RunMainFragmentView implements MvpView {
405 public void onClick(SelectDialog dialog) { 412 public void onClick(SelectDialog dialog) {
406 //停止计时 413 //停止计时
407 fragment.binding.chronometer.stop(); 414 fragment.binding.chronometer.stop();
408 - //设置状态标志位  
409 - setStopStartFlag(); 415 + //停止服务
  416 + stopRunService();
410 //设置运动结束时间戳 417 //设置运动结束时间戳
411 StepUtil.setUserFinishTimeStamp(getContext(), uid); 418 StepUtil.setUserFinishTimeStamp(getContext(), uid);
412 fragment.binding.cpCurrent.setVisibility(View.GONE); 419 fragment.binding.cpCurrent.setVisibility(View.GONE);
@@ -576,6 +583,17 @@ public class RunMainFragmentView implements MvpView { @@ -576,6 +583,17 @@ public class RunMainFragmentView implements MvpView {
576 }); 583 });
577 } 584 }
578 585
  586 + private void initEndTipDialog() {
  587 + endTipDialog = new TipDialog(getContext(), getContext().getResources().getString(R.string.run_race_arrive_end_tip), "好的", R.color.green_round, new TipDialog.DialogInterface() {
  588 + @Override
  589 + public void onClick(TipDialog dialog) {
  590 + dialog.dismiss();
  591 + }
  592 + });
  593 + endTipDialog.setCancelable(false);
  594 + endTipDialog.setCanceledOnTouchOutside(false);
  595 + }
  596 +
579 /** 597 /**
580 * 暂停按钮 598 * 暂停按钮
581 */ 599 */
@@ -641,18 +659,18 @@ public class RunMainFragmentView implements MvpView { @@ -641,18 +659,18 @@ public class RunMainFragmentView implements MvpView {
641 Log.e(TAG, "setSQLPauseTime: "); 659 Log.e(TAG, "setSQLPauseTime: ");
642 // if (needWriteDataFlag) { 660 // if (needWriteDataFlag) {
643 //将当前计时器时间戳写入数据库 661 //将当前计时器时间戳写入数据库
644 - UserStepEntity userStepEntity = StepUtil.getUserStepData(fragment.getActivity(), id);  
645 - if (userStepEntity != null) {  
646 - userStepEntity.setChronometerBase(fragment.binding.chronometer.getBase());  
647 - //设置当前暂停的时间戳  
648 - userStepEntity.setRecordTime(SystemClock.elapsedRealtime());  
649 - //设置当前用户暂停的时间戳  
650 - userStepEntity.setUserPauseTimeStamp(TimeUtil.getNowTimeStamp());  
651 - //设置暂停次数  
652 - userStepEntity.setPauseCount(userStepEntity.getPauseCount() + 1);  
653 - //更新数据  
654 - StepUtil.updateStepData(fragment.getActivity(), userStepEntity);  
655 - } 662 + UserStepEntity userStepEntity = StepUtil.getUserStepData(fragment.getActivity(), id);
  663 + if (userStepEntity != null) {
  664 + userStepEntity.setChronometerBase(fragment.binding.chronometer.getBase());
  665 + //设置当前暂停的时间戳
  666 + userStepEntity.setRecordTime(SystemClock.elapsedRealtime());
  667 + //设置当前用户暂停的时间戳
  668 + userStepEntity.setUserPauseTimeStamp(TimeUtil.getNowTimeStamp());
  669 + //设置暂停次数
  670 + userStepEntity.setPauseCount(userStepEntity.getPauseCount() + 1);
  671 + //更新数据
  672 + StepUtil.updateStepData(fragment.getActivity(), userStepEntity);
  673 + }
656 // } 674 // }
657 } 675 }
658 676
@@ -785,7 +803,7 @@ public class RunMainFragmentView implements MvpView { @@ -785,7 +803,7 @@ public class RunMainFragmentView implements MvpView {
785 LatLng current = new LatLng(location.getLatitude(), location.getLongitude()); 803 LatLng current = new LatLng(location.getLatitude(), location.getLongitude());
786 if (null != current) { 804 if (null != current) {
787 //开始比较数据 805 //开始比较数据
788 - double distance = DistanceUtil.getDistance(current, endLatLng); 806 + int distance = (int) DistanceUtil.getDistance(current, endLatLng);
789 if (distance < Constant.LOCA_END_POINT_ACCURACY) { 807 if (distance < Constant.LOCA_END_POINT_ACCURACY) {
790 //设置数据 808 //设置数据
791 if (userStepEntity != null) { 809 if (userStepEntity != null) {
@@ -800,25 +818,7 @@ public class RunMainFragmentView implements MvpView { @@ -800,25 +818,7 @@ public class RunMainFragmentView implements MvpView {
800 isfirstEndTip = false; 818 isfirstEndTip = false;
801 } 819 }
802 //进行提示 820 //进行提示
803 - if (null == tipDialog) {  
804 - ChineseToSpeechUtil.speech(getContext(), "您已到达终点附近,可以结束运动了!");  
805 - if (mVibrator != null) {  
806 - //设置震动周期,数组表示时间:等待+执行,单位是毫秒,下面操作代表:等待100,执行100,等待100,执行1000,  
807 - //后面的数字如果为-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始  
808 - mVibrator.vibrate(new long[]{Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME, Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME}, Constant.VIBRATOR_REPEAT_TIME);  
809 - }  
810 - tipDialog = new TipDialog(getContext(), getContext().getResources().getString(R.string.run_race_arrive_end_tip), "好的", R.color.green_round, new TipDialog.DialogInterface() {  
811 - @Override  
812 - public void onClick(TipDialog dialog) {  
813 - dialog.dismiss();  
814 - }  
815 - });  
816 - tipDialog.setCancelable(false);  
817 - tipDialog.setCanceledOnTouchOutside(false);  
818 - }  
819 - if (!tipDialog.isShowing()) {  
820 - tipDialog.show();  
821 - } 821 + showEndTipDialog();
822 } 822 }
823 } 823 }
824 } 824 }
@@ -826,23 +826,57 @@ public class RunMainFragmentView implements MvpView { @@ -826,23 +826,57 @@ public class RunMainFragmentView implements MvpView {
826 826
827 } 827 }
828 828
  829 + public void showEndTipDialog() {
  830 + if (null == getContext()) {
  831 + return;
  832 + }
  833 + //进行提示
  834 + if (null != endTipDialog && !endTipDialog.isShowing()) {
  835 + endTipDialog.show();
  836 + ChineseToSpeechUtil.speech(getContext(), "您已到达终点附近,可以结束运动了!");
  837 + if (mVibrator != null) {
  838 + //设置震动周期,数组表示时间:等待+执行,单位是毫秒,下面操作代表:等待100,执行100,等待100,执行1000,
  839 + //后面的数字如果为-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始
  840 + mVibrator.vibrate(new long[]{Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME, Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME}, Constant.VIBRATOR_REPEAT_TIME);
  841 + }
  842 + }
  843 + }
  844 +
829 /** 845 /**
830 * 设置停止状态标志位 846 * 设置停止状态标志位
831 */ 847 */
832 private void setStopStartFlag() { 848 private void setStopStartFlag() {
833 CommonInfo.setTsRunBaiduTraceService(getContext(), false); 849 CommonInfo.setTsRunBaiduTraceService(getContext(), false);
834 CommonInfo.setIsRunKeepAliveService(getContext(), false); 850 CommonInfo.setIsRunKeepAliveService(getContext(), false);
  851 + CommonInfo.setIsRunStepService(getContext(), false);
835 CommonInfo.setIsWriteUserStep(getContext(), false); 852 CommonInfo.setIsWriteUserStep(getContext(), false);
836 if (StepService.mClient != null) { 853 if (StepService.mClient != null) {
837 StepService.mClient.stopGather(StepService.traceListener); 854 StepService.mClient.stopGather(StepService.traceListener);
838 // StepService.CURRENT_STEP = 0; 855 // StepService.CURRENT_STEP = 0;
839 } 856 }
  857 +// fragment.getActivity().stopService(new Intent(fragment.getActivity(), StepService.class));
  858 + }
  859 +
  860 + /**
  861 + * 停止计步服务
  862 + */
  863 + private void stopRunService() {
  864 + CommonInfo.setTsRunBaiduTraceService(getContext(), false);
  865 + CommonInfo.setIsRunKeepAliveService(getContext(), false);
  866 + CommonInfo.setIsRunStepService(getContext(), false);
  867 + CommonInfo.setIsWriteUserStep(getContext(), false);
  868 + if (StepService.mClient != null) {
  869 + StepService.mClient.stopGather(StepService.traceListener);
  870 + }
840 fragment.getActivity().stopService(new Intent(fragment.getActivity(), StepService.class)); 871 fragment.getActivity().stopService(new Intent(fragment.getActivity(), StepService.class));
  872 + fragment.getActivity().stopService(new Intent(fragment.getActivity(), KeepLiveService.class));
  873 +
841 } 874 }
842 875
843 public void onDestroy() { 876 public void onDestroy() {
844 if (mLocClient != null) { 877 if (mLocClient != null) {
845 mLocClient.stop(); 878 mLocClient.stop();
  879 + mLocClient = null;
846 } 880 }
847 } 881 }
848 882
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
@@ -591,8 +591,9 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -591,8 +591,9 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
591 CommonInfo.resetRace(getContext()); 591 CommonInfo.resetRace(getContext());
592 dialog.dismiss(); 592 dialog.dismiss();
593 //重置按钮 593 //重置按钮
594 - fragment.binding.tvRunNow.setText("立即开始");  
595 - fragment.binding.rlScrollViewStartBtn.setTag(BTN_START_RACE); 594 + if (null != runRaceDetailInfo) {
  595 + initStartBtnState(runRaceDetailInfo);
  596 + }
596 } 597 }
597 }, "是", new SelectDialog.DialogInterface() { 598 }, "是", new SelectDialog.DialogInterface() {
598 @Override 599 @Override
@@ -620,8 +621,9 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -620,8 +621,9 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
620 //清除数据 621 //清除数据
621 CommonInfo.resetRace(getContext()); 622 CommonInfo.resetRace(getContext());
622 //更改当前按钮 623 //更改当前按钮
623 - fragment.binding.tvRunNow.setText("立即开始");  
624 - fragment.binding.rlScrollViewStartBtn.setTag(BTN_START_RACE); 624 + if (null != runRaceDetailInfo) {
  625 + initStartBtnState(runRaceDetailInfo);
  626 + }
625 627
626 } 628 }
627 }, "是", new SelectDialog.DialogInterface() { 629 }, "是", new SelectDialog.DialogInterface() {
@@ -743,11 +745,13 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -743,11 +745,13 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
743 private void stopStepService() { 745 private void stopStepService() {
744 CommonInfo.setTsRunBaiduTraceService(getContext(), false); 746 CommonInfo.setTsRunBaiduTraceService(getContext(), false);
745 CommonInfo.setIsRunKeepAliveService(getContext(), false); 747 CommonInfo.setIsRunKeepAliveService(getContext(), false);
  748 + CommonInfo.setIsRunStepService(getContext(), false);
746 CommonInfo.setIsWriteUserStep(getContext(), false); 749 CommonInfo.setIsWriteUserStep(getContext(), false);
747 CommonInfo.setIsFirstStepSendTraceTip(getContext(), true); 750 CommonInfo.setIsFirstStepSendTraceTip(getContext(), true);
748 if (StepService.mClient != null) { 751 if (StepService.mClient != null) {
749 StepService.mClient.stopGather(StepService.traceListener); 752 StepService.mClient.stopGather(StepService.traceListener);
750 } 753 }
  754 + fragment.getActivity().stopService(new Intent(fragment.getActivity(), KeepLiveService.class));
751 fragment.getActivity().stopService(new Intent(fragment.getActivity(), StepService.class)); 755 fragment.getActivity().stopService(new Intent(fragment.getActivity(), StepService.class));
752 } 756 }
753 757
@@ -1100,6 +1104,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -1100,6 +1104,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
1100 if ((currnetTime - userPauseTime) <= (9 * 60 * 60 * 1000)) { 1104 if ((currnetTime - userPauseTime) <= (9 * 60 * 60 * 1000)) {
1101 Log.e(TAG, "小于9小时"); 1105 Log.e(TAG, "小于9小时");
1102 fragment.binding.tvRunNow.setText("继续运动"); 1106 fragment.binding.tvRunNow.setText("继续运动");
  1107 + fragment.binding.rlScrollViewStartBtn.setBackgroundColor(getContext().getResources().getColor(R.color.green_round));
1103 fragment.binding.rlScrollViewStartBtn.setTag(BTN_CONTINUE_RACE); 1108 fragment.binding.rlScrollViewStartBtn.setTag(BTN_CONTINUE_RACE);
1104 } else { 1109 } else {
1105 Log.e(TAG, "大于9小时"); 1110 Log.e(TAG, "大于9小时");
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunningMapFragmentView.java
@@ -89,7 +89,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { @@ -89,7 +89,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
89 private List<LatLng> currentPoints; 89 private List<LatLng> currentPoints;
90 private LatLng endLatLng;//终点坐标 90 private LatLng endLatLng;//终点坐标
91 private UserStepEntity userStepEntity; 91 private UserStepEntity userStepEntity;
92 - private TipDialog tipDialog; 92 + private TipDialog endTipDialog;
93 //创建震动服务对象 93 //创建震动服务对象
94 private Vibrator mVibrator; 94 private Vibrator mVibrator;
95 private boolean isfirstEndTip = true;//是否是第一次提示到达终点 95 private boolean isfirstEndTip = true;//是否是第一次提示到达终点
@@ -106,6 +106,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { @@ -106,6 +106,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
106 if (getContext() == null) { 106 if (getContext() == null) {
107 return; 107 return;
108 } 108 }
  109 + initEndTipDialog();
109 //获取手机震动服务 110 //获取手机震动服务
110 mVibrator = (Vibrator) getContext().getSystemService(Service.VIBRATOR_SERVICE); 111 mVibrator = (Vibrator) getContext().getSystemService(Service.VIBRATOR_SERVICE);
111 userStepEntity = StepUtil.getUserStepData(getContext(), CommonInfo.getUserId(getContext())); 112 userStepEntity = StepUtil.getUserStepData(getContext(), CommonInfo.getUserId(getContext()));
@@ -345,7 +346,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { @@ -345,7 +346,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
345 LatLng current = new LatLng(location.getLatitude(), location.getLongitude()); 346 LatLng current = new LatLng(location.getLatitude(), location.getLongitude());
346 if (null != current) { 347 if (null != current) {
347 //开始比较数据 348 //开始比较数据
348 - double distance = DistanceUtil.getDistance(current, endLatLng); 349 + int distance = (int) DistanceUtil.getDistance(current, endLatLng);
349 if (distance < Constant.LOCA_END_POINT_ACCURACY) { 350 if (distance < Constant.LOCA_END_POINT_ACCURACY) {
350 //设置数据 351 //设置数据
351 if (userStepEntity != null) { 352 if (userStepEntity != null) {
@@ -361,26 +362,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { @@ -361,26 +362,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
361 isfirstEndTip = false; 362 isfirstEndTip = false;
362 } 363 }
363 //进行提示 364 //进行提示
364 - if (null == tipDialog) {  
365 - ChineseToSpeechUtil.speech(getContext(), "您已到达终点附近,可以结束运动了!");  
366 - if (mVibrator != null) {  
367 - //设置震动周期,数组表示时间:等待+执行,单位是毫秒,下面操作代表:等待100,执行100,等待100,执行1000,  
368 - //后面的数字如果为-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始  
369 - mVibrator.vibrate(new long[]{Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME, Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME}, Constant.VIBRATOR_REPEAT_TIME);  
370 - }  
371 -  
372 - tipDialog = new TipDialog(getContext(), getContext().getResources().getString(R.string.run_race_arrive_end_tip), "好的", R.color.green_round, new TipDialog.DialogInterface() {  
373 - @Override  
374 - public void onClick(TipDialog dialog) {  
375 - dialog.dismiss();  
376 - }  
377 - });  
378 - tipDialog.setCancelable(false);  
379 - tipDialog.setCanceledOnTouchOutside(false);  
380 - }  
381 - if (!tipDialog.isShowing()) {  
382 - tipDialog.show();  
383 - } 365 + showEndTipDialog();
384 } 366 }
385 } 367 }
386 } 368 }
@@ -430,6 +412,32 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { @@ -430,6 +412,32 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
430 } 412 }
431 } 413 }
432 414
  415 + private void initEndTipDialog() {
  416 + endTipDialog = new TipDialog(getContext(), getContext().getResources().getString(R.string.run_race_arrive_end_tip), "好的", R.color.green_round, new TipDialog.DialogInterface() {
  417 + @Override
  418 + public void onClick(TipDialog dialog) {
  419 + dialog.dismiss();
  420 + }
  421 + });
  422 + endTipDialog.setCancelable(false);
  423 + endTipDialog.setCanceledOnTouchOutside(false);
  424 + }
  425 +
  426 + public void showEndTipDialog() {
  427 + if (null == getContext()) {
  428 + return;
  429 + }
  430 + //进行提示
  431 + if (null != endTipDialog && !endTipDialog.isShowing()) {
  432 + endTipDialog.show();
  433 + ChineseToSpeechUtil.speech(getContext(), "您已到达终点附近,可以结束运动了!");
  434 + if (mVibrator != null) {
  435 + //设置震动周期,数组表示时间:等待+执行,单位是毫秒,下面操作代表:等待100,执行100,等待100,执行1000,
  436 + //后面的数字如果为-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始
  437 + mVibrator.vibrate(new long[]{Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME, Constant.VIBRATOR_DELAY_TIME, Constant.VIBRATOR_RUN_TIME}, Constant.VIBRATOR_REPEAT_TIME);
  438 + }
  439 + }
  440 + }
433 441
434 /** 442 /**
435 * 同步计时器 443 * 同步计时器
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/model/Constant.java
@@ -24,6 +24,7 @@ public class Constant { @@ -24,6 +24,7 @@ public class Constant {
24 public static final int COLL_SERVICE_STEP_COUNT_ONRESUME = 15;//运营从后台回到前台,更新步数 24 public static final int COLL_SERVICE_STEP_COUNT_ONRESUME = 15;//运营从后台回到前台,更新步数
25 public static final int UPDATA_COLL_TRACE_LIST = 16;//更新轨迹列表 25 public static final int UPDATA_COLL_TRACE_LIST = 16;//更新轨迹列表
26 public static final int UPDATE_RACE_STATE_BTN = 17;//更新赛事详情页按钮数据 26 public static final int UPDATE_RACE_STATE_BTN = 17;//更新赛事详情页按钮数据
  27 + public static final int ARRIVE_END_POINT = 18;//到达终点附近
27 /*************************************用户其他值,非标志位************************************************************/ 28 /*************************************用户其他值,非标志位************************************************************/
28 public static long SERVICE_ID = 0;//公司账号 29 public static long SERVICE_ID = 0;//公司账号
29 // public static final long SERVICE_ID = 213553; 30 // public static final long SERVICE_ID = 213553;
@@ -31,7 +32,7 @@ public class Constant { @@ -31,7 +32,7 @@ public class Constant {
31 public static final int GATHER_INTERVAL = 2;//位置采集周期 32 public static final int GATHER_INTERVAL = 2;//位置采集周期
32 public static final int PACK_INTERVAL = 10;//位置采集周期 33 public static final int PACK_INTERVAL = 10;//位置采集周期
33 public static final int VIBRATOR_DELAY_TIME = 100;//震动等待时间(ms) 34 public static final int VIBRATOR_DELAY_TIME = 100;//震动等待时间(ms)
34 - public static final int VIBRATOR_RUN_TIME = 1000;//震动执行时间(ms) 35 + public static final int VIBRATOR_RUN_TIME = 2000;//震动执行时间(ms)
35 public static final int VIBRATOR_REPEAT_TIME = -1;//震动重复次数(-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始) 36 public static final int VIBRATOR_REPEAT_TIME = -1;//震动重复次数(-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始)
36 /*****************************************运营工具其他值,非标志位****************************************************/ 37 /*****************************************运营工具其他值,非标志位****************************************************/
37 public static final double PASS_RATE = 0.7;//通过率70% 38 public static final double PASS_RATE = 0.7;//通过率70%
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/receivers/ServiceReceiver.java
@@ -23,6 +23,7 @@ public class ServiceReceiver extends BroadcastReceiver { @@ -23,6 +23,7 @@ public class ServiceReceiver extends BroadcastReceiver {
23 //唤醒锁 23 //唤醒锁
24 private PowerManager.WakeLock wakeLock = null; 24 private PowerManager.WakeLock wakeLock = null;
25 private final String TAG = "ServiceReceiver"; 25 private final String TAG = "ServiceReceiver";
  26 + private AudioManager audioManager;
26 27
27 public ServiceReceiver() { 28 public ServiceReceiver() {
28 29
@@ -105,7 +106,9 @@ public class ServiceReceiver extends BroadcastReceiver { @@ -105,7 +106,9 @@ public class ServiceReceiver extends BroadcastReceiver {
105 106
106 private void initSound(Context context) { 107 private void initSound(Context context) {
107 try { 108 try {
108 - AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); 109 + if (null==audioManager){
  110 + audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
  111 + }
109 int currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); 112 int currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
110 if (0 == currentVolume) { 113 if (0 == currentVolume) {
111 audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 1, AudioManager.FLAG_PLAY_SOUND); 114 audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 1, AudioManager.FLAG_PLAY_SOUND);
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/KeepLiveService.java
@@ -43,7 +43,7 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion @@ -43,7 +43,7 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion
43 private NotificationManager mNM; 43 private NotificationManager mNM;
44 private Notification notification = null; 44 private Notification notification = null;
45 //是否在后台运行 45 //是否在后台运行
46 - public static boolean isKeepService = true; 46 + public static boolean isKeepService = false;
47 public static KeepLiveService instance; 47 public static KeepLiveService instance;
48 private int startId; 48 private int startId;
49 private final String TAG = "KeepLiveService"; 49 private final String TAG = "KeepLiveService";
@@ -52,6 +52,7 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion @@ -52,6 +52,7 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion
52 private boolean isRegisterReceiver = false; 52 private boolean isRegisterReceiver = false;
53 private boolean isStartForeground = false; 53 private boolean isStartForeground = false;
54 private final int NOTIFICATION_ID = 1; 54 private final int NOTIFICATION_ID = 1;
  55 +
55 public KeepLiveService() { 56 public KeepLiveService() {
56 } 57 }
57 58
@@ -159,13 +160,25 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion @@ -159,13 +160,25 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion
159 Log.e("isRun onStartCommand", "" + isRun); 160 Log.e("isRun onStartCommand", "" + isRun);
160 161
161 if (isRun) { 162 if (isRun) {
162 - if (runnable != null) {  
163 - handler.postDelayed(runnable, 5000);  
164 - } 163 +// if (runnable != null) {
  164 +// handler.postDelayed(runnable, 5000);
  165 +// }
165 showHideForegroundNotification(); 166 showHideForegroundNotification();
166 // startService(new Intent(getApplicationContext(), HideKeepTipService.class)); 167 // startService(new Intent(getApplicationContext(), HideKeepTipService.class));
167 // Log.e(TAG, "启动HideKeepTipService"); 168 // Log.e(TAG, "启动HideKeepTipService");
168 startPlaySong(); 169 startPlaySong();
  170 + } else {
  171 + try {
  172 + if (myReceiver != null && isRegisterReceiver) {
  173 + unregisterReceiver(myReceiver);
  174 + }
  175 + } catch (Exception e) {
  176 + Log.e(TAG, "run: ");
  177 + }
  178 + stopPlaySong();
  179 + if (isStartForeground) {
  180 + stopForeground(true);
  181 + }
169 } 182 }
170 return START_STICKY; 183 return START_STICKY;
171 } 184 }
@@ -237,7 +250,7 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion @@ -237,7 +250,7 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion
237 .build(); 250 .build();
238 // 0 隐藏前台服务通知 251 // 0 隐藏前台服务通知
239 startForeground(NOTIFICATION_ID, notification); 252 startForeground(NOTIFICATION_ID, notification);
240 - isStartForeground=true; 253 + isStartForeground = true;
241 } 254 }
242 255
243 @Override 256 @Override
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/StepService.java
@@ -26,6 +26,15 @@ import android.util.Log; @@ -26,6 +26,15 @@ import android.util.Log;
26 import android.widget.RemoteViews; 26 import android.widget.RemoteViews;
27 import android.widget.Toast; 27 import android.widget.Toast;
28 28
  29 +import com.baidu.location.BDAbstractLocationListener;
  30 +import com.baidu.location.BDLocation;
  31 +import com.baidu.location.LocationClient;
  32 +import com.baidu.location.LocationClientOption;
  33 +import com.baidu.mapapi.map.MapStatus;
  34 +import com.baidu.mapapi.map.MapStatusUpdateFactory;
  35 +import com.baidu.mapapi.map.MyLocationData;
  36 +import com.baidu.mapapi.model.LatLng;
  37 +import com.baidu.mapapi.utils.DistanceUtil;
29 import com.baidu.trace.LBSTraceClient; 38 import com.baidu.trace.LBSTraceClient;
30 import com.baidu.trace.Trace; 39 import com.baidu.trace.Trace;
31 import com.baidu.trace.api.fence.AddMonitoredPersonResponse; 40 import com.baidu.trace.api.fence.AddMonitoredPersonResponse;
@@ -52,6 +61,7 @@ import com.baidu.trace.model.OnTraceListener; @@ -52,6 +61,7 @@ import com.baidu.trace.model.OnTraceListener;
52 import com.baidu.trace.model.PushMessage; 61 import com.baidu.trace.model.PushMessage;
53 import com.baidu.trace.model.StatusCodes; 62 import com.baidu.trace.model.StatusCodes;
54 import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; 63 import com.cnlive.moudle.pedometer.commonInfo.CommonInfo;
  64 +import com.cnlive.moudle.pedometer.frame.view.RunMainFragmentView;
55 import com.cnlive.moudle.pedometer.model.Constant; 65 import com.cnlive.moudle.pedometer.model.Constant;
56 import com.cnlive.moudle.pedometer.model.MessageEvent; 66 import com.cnlive.moudle.pedometer.model.MessageEvent;
57 import com.cnlive.moudle.pedometer.model.step.StepCount; 67 import com.cnlive.moudle.pedometer.model.step.StepCount;
@@ -59,6 +69,7 @@ import com.cnlive.moudle.pedometer.model.step.StepValuePassListener; @@ -59,6 +69,7 @@ import com.cnlive.moudle.pedometer.model.step.StepValuePassListener;
59 import com.cnlive.moudle.pedometer.sql.db.DbCore; 69 import com.cnlive.moudle.pedometer.sql.db.DbCore;
60 import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; 70 import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity;
61 import com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity; 71 import com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity;
  72 +import com.cnlive.moudle.pedometer.utils.GsonUtil;
62 import com.cnlive.moudle.pedometer.utils.ServiceUtils; 73 import com.cnlive.moudle.pedometer.utils.ServiceUtils;
63 import com.cnlive.moudle.pedometer.utils.StepUtil; 74 import com.cnlive.moudle.pedometer.utils.StepUtil;
64 import com.cnlive.moudle.pedometer.utils.TimeUtil; 75 import com.cnlive.moudle.pedometer.utils.TimeUtil;
@@ -141,7 +152,8 @@ public class StepService extends Service implements SensorEventListener { @@ -141,7 +152,8 @@ public class StepService extends Service implements SensorEventListener {
141 private static boolean pauseFlag;//是否暂停 152 private static boolean pauseFlag;//是否暂停
142 private static int speedCurrentStep;//用于检测速度步数 153 private static int speedCurrentStep;//用于检测速度步数
143 private boolean updateSpeedStepFlag;//是否是已经更新速度 154 private boolean updateSpeedStepFlag;//是否是已经更新速度
144 - 155 + private LatLng endLatLng;//终点坐标
  156 + private UserStepEntity userStepEntity;
145 /****************************************************鹰眼轨迹相关************************************************/ 157 /****************************************************鹰眼轨迹相关************************************************/
146 /** 158 /**
147 * 轨迹服务监听器 159 * 轨迹服务监听器
@@ -163,6 +175,10 @@ public class StepService extends Service implements SensorEventListener { @@ -163,6 +175,10 @@ public class StepService extends Service implements SensorEventListener {
163 * 轨迹服务 175 * 轨迹服务
164 */ 176 */
165 public static Trace mTrace = null; 177 public static Trace mTrace = null;
  178 + //定位
  179 + public MyLocationListenner myListener = new MyLocationListenner();
  180 + private LocationClient mLocClient;
  181 + private boolean isHasSendEndTip = true;//是否发送到达终点提示
166 182
167 public StepService() { 183 public StepService() {
168 184
@@ -506,7 +522,7 @@ public class StepService extends Service implements SensorEventListener { @@ -506,7 +522,7 @@ public class StepService extends Service implements SensorEventListener {
506 Log.e(TAG, "onListMonitoredPersonCallback: "); 522 Log.e(TAG, "onListMonitoredPersonCallback: ");
507 } 523 }
508 }; 524 };
509 - if (userStepEntity != null &&!TextUtils.isEmpty(userStepEntity.getFenceId())) { 525 + if (userStepEntity != null && !TextUtils.isEmpty(userStepEntity.getFenceId())) {
510 List<Long> fenids = new ArrayList<>(); 526 List<Long> fenids = new ArrayList<>();
511 fenids.add(Long.parseLong(userStepEntity.getFenceId())); 527 fenids.add(Long.parseLong(userStepEntity.getFenceId()));
512 MonitoredStatusRequest request1 = MonitoredStatusRequest.buildServerRequest(Constant.TAG, 528 MonitoredStatusRequest request1 = MonitoredStatusRequest.buildServerRequest(Constant.TAG,
@@ -553,6 +569,7 @@ public class StepService extends Service implements SensorEventListener { @@ -553,6 +569,7 @@ public class StepService extends Service implements SensorEventListener {
553 } 569 }
554 }).start(); 570 }).start();
555 startTimeCount(); 571 startTimeCount();
  572 + initLocationClient();
556 } else { 573 } else {
557 EventBus.getDefault().post(new MessageEvent(Constant.START_TRACE_GATHER_FAIL, "")); 574 EventBus.getDefault().post(new MessageEvent(Constant.START_TRACE_GATHER_FAIL, ""));
558 } 575 }
@@ -640,6 +657,10 @@ public class StepService extends Service implements SensorEventListener { @@ -640,6 +657,10 @@ public class StepService extends Service implements SensorEventListener {
640 @Override 657 @Override
641 public void onDestroy() { 658 public void onDestroy() {
642 super.onDestroy(); 659 super.onDestroy();
  660 + if (null != mLocClient) {
  661 + mLocClient.stop();
  662 + mLocClient = null;
  663 + }
643 //取消前台进程 664 //取消前台进程
644 stopForeground(true); 665 stopForeground(true);
645 if (mBatInfoReceiver != null) { 666 if (mBatInfoReceiver != null) {
@@ -1203,5 +1224,97 @@ public class StepService extends Service implements SensorEventListener { @@ -1203,5 +1224,97 @@ public class StepService extends Service implements SensorEventListener {
1203 return String.format("%02d:%02d:%02d", h, m, s); 1224 return String.format("%02d:%02d:%02d", h, m, s);
1204 } 1225 }
1205 1226
  1227 + private void initLocationClient() {
  1228 + if (null == mLocClient) {
  1229 + // 定位初始化
  1230 + mLocClient = new LocationClient(getApplicationContext());
  1231 + mLocClient.registerLocationListener(myListener);
  1232 + }
  1233 + LocationClientOption option = new LocationClientOption();
  1234 + option.setOpenGps(true); // 打开gps
  1235 + //可选,设置返回经纬度坐标类型,默认GCJ02
  1236 + //GCJ02:国测局坐标;
  1237 + //BD09ll:百度经纬度坐标;
  1238 + //BD09:百度墨卡托坐标;
  1239 + //海外地区定位,无需设置坐标类型,统一返回WGS84类型坐标
  1240 + option.setCoorType("gcj02"); // 设置坐标类型
  1241 + //可选,默认false,设置是否开启Gps定位
  1242 + option.setOpenGps(true);
  1243 + //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者,该模式下开发者无需再关心定位间隔是多少,定位SDK本身发现位置变化就会及时回调给开发者
  1244 + option.setOpenAutoNotifyMode();
  1245 + //可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
  1246 + //LocationMode.Hight_Accuracy:高精度;
  1247 + //LocationMode. Battery_Saving:低功耗;
  1248 + //LocationMode. Device_Sensors:仅使用设备;
  1249 + option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
  1250 + //可选,设置是否需要地址信息,默认不需要
  1251 + option.setIsNeedAddress(false);
  1252 + //可选,设置是否需要地址描述
  1253 + option.setIsNeedLocationDescribe(false);
  1254 + //可选,设置是否需要设备方向结果
  1255 + option.setNeedDeviceDirect(false);
  1256 + //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者
  1257 + //minTimeInterval - 最短定位时间间隔,单位毫秒,最小值0,开发者可以在设置希望的位置回调最短时间间隔
  1258 + //minDistance - 最短定位距离间隔,单位米,最小值0,开发者可以设置希望的位置回调距离间隔
  1259 + //locSensitivity - 定位变化敏感程度,LOC_SENSITIVITY_HIGHT,LOC_SENSITIVITY_MIDDLE,LOC_SENSITIVITY_LOW
  1260 + option.setOpenAutoNotifyMode(3000, 1, LocationClientOption.LOC_SENSITIVITY_HIGHT);
  1261 + //可选,定位SDK内部是一个service,并放到了独立进程。
  1262 + //设置是否在stop的时候杀死这个进程,默认(建议)不杀死,即setIgnoreKillProcess(true)
  1263 + option.setIgnoreKillProcess(true);
  1264 + mLocClient.setLocOption(option);
  1265 + mLocClient.start();
  1266 + }
  1267 +
  1268 + /**
  1269 + * //设置定位监听器,获取到用户当前位置 杨帅
  1270 + * 定位SDK监听函数
  1271 + */
  1272 + public class MyLocationListenner extends BDAbstractLocationListener {
1206 1273
  1274 + @Override
  1275 + public void onReceiveLocation(BDLocation location) {
  1276 + // map view 销毁后不在处理新接收的位置
  1277 + if (location == null || null == getApplicationContext()) {
  1278 + return;
  1279 + }
  1280 + //进行精度过滤
  1281 +// if (location.getRadius() > Constant.LOCA_ACCURACY) {
  1282 +// return;
  1283 +// }
  1284 + //进行数据比较(先看看数据库是否有数据)
  1285 + if (null == endLatLng) {
  1286 + userStepEntity = StepUtil.getUserStepData(getApplicationContext(), CommonInfo.getUserId(getApplicationContext()));
  1287 + if (null != userStepEntity) {
  1288 + if (!TextUtils.isEmpty(userStepEntity.getEndLatLng())) {
  1289 + endLatLng = GsonUtil.GsonToBean(userStepEntity.getEndLatLng(), LatLng.class);
  1290 + }
  1291 + }
  1292 + }
  1293 + //开始比较数据
  1294 + if (null != endLatLng) {
  1295 + LatLng current = new LatLng(location.getLatitude(), location.getLongitude());
  1296 + if (null != current) {
  1297 + //开始比较数据
  1298 + int distance = (int) DistanceUtil.getDistance(current, endLatLng);
  1299 + if (distance < Constant.LOCA_END_POINT_ACCURACY) {
  1300 + if (isHasSendEndTip) {
  1301 + isHasSendEndTip = false;
  1302 + Log.e(TAG, "onReceiveLocation: 到达" );
  1303 + //发送到达终点通知
  1304 + EventBus.getDefault().post(new MessageEvent(Constant.ARRIVE_END_POINT, ""));
  1305 + }
  1306 + if (null == userStepEntity) {
  1307 + userStepEntity = StepUtil.getUserStepData(getApplicationContext(), CommonInfo.getUserId(getApplicationContext()));
  1308 + }
  1309 + //设置数据
  1310 + if (userStepEntity != null) {
  1311 + userStepEntity.setIsArriveEndPoint(true);
  1312 + //更新数据
  1313 + StepUtil.updateStepData(getApplicationContext(), userStepEntity);
  1314 + }
  1315 + }
  1316 + }
  1317 + }
  1318 + }
  1319 + }
1207 } 1320 }
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/db/DbCore.java
@@ -62,8 +62,9 @@ public class DbCore { @@ -62,8 +62,9 @@ public class DbCore {
62 if (daoMaster == null) { 62 if (daoMaster == null) {
63 daoMaster = getDaoMaster(); 63 daoMaster = getDaoMaster();
64 } 64 }
65 - //不使用缓存  
66 - daoSession = daoMaster.newSession(IdentityScopeType.None); 65 +// //不使用缓存
  66 +// daoSession = daoMaster.newSession(IdentityScopeType.None);
  67 + daoSession = daoMaster.newSession();
67 } 68 }
68 return daoSession; 69 return daoSession;
69 } 70 }
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RegistrationInfoFragment.java
@@ -5,7 +5,9 @@ import android.os.Bundle; @@ -5,7 +5,9 @@ import android.os.Bundle;
5 import android.support.annotation.NonNull; 5 import android.support.annotation.NonNull;
6 import android.support.annotation.Nullable; 6 import android.support.annotation.Nullable;
7 import android.text.TextUtils; 7 import android.text.TextUtils;
  8 +import android.util.Log;
8 import android.view.View; 9 import android.view.View;
  10 +import android.widget.Toast;
9 11
10 import com.baidu.trace.LBSTraceClient; 12 import com.baidu.trace.LBSTraceClient;
11 import com.baidu.trace.Trace; 13 import com.baidu.trace.Trace;
@@ -30,6 +32,7 @@ import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; @@ -30,6 +32,7 @@ import com.cnlive.moudle.pedometer.commonInfo.CommonInfo;
30 import com.cnlive.moudle.pedometer.frame.presenter.RegistrationInfoPresenter; 32 import com.cnlive.moudle.pedometer.frame.presenter.RegistrationInfoPresenter;
31 import com.cnlive.moudle.pedometer.frame.view.RegistrationInfoView; 33 import com.cnlive.moudle.pedometer.frame.view.RegistrationInfoView;
32 import com.cnlive.moudle.pedometer.model.Constant; 34 import com.cnlive.moudle.pedometer.model.Constant;
  35 +import com.cnlive.moudle.pedometer.utils.NetUtil;
33 import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil; 36 import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil;
34 import com.example.moudle_pedometer.R; 37 import com.example.moudle_pedometer.R;
35 import com.example.moudle_pedometer.databinding.FragmentRegistrationInfoBinding; 38 import com.example.moudle_pedometer.databinding.FragmentRegistrationInfoBinding;
@@ -69,7 +72,14 @@ public class RegistrationInfoFragment extends MvpBindingFragment&lt;RegistrationInf @@ -69,7 +72,14 @@ public class RegistrationInfoFragment extends MvpBindingFragment&lt;RegistrationInf
69 72
70 public void commitInfo() { 73 public void commitInfo() {
71 if (!TextUtils.isEmpty(fenceId)) { 74 if (!TextUtils.isEmpty(fenceId)) {
72 - addMonitorToFence((int) (Double.parseDouble(fenceId))); 75 + if (NetUtil.isNetworkConnected(getActivity())) {
  76 + addMonitorToFence((int) (Double.parseDouble(fenceId)));
  77 + } else {
  78 + if (null != getMvpView()) {
  79 + getMvpView().allowClickRegistBtn();
  80 + }
  81 + AlertUtil.showDeftToast(getActivity(), "无法连接网络");
  82 + }
73 } 83 }
74 } 84 }
75 85
@@ -79,7 +89,7 @@ public class RegistrationInfoFragment extends MvpBindingFragment&lt;RegistrationInf @@ -79,7 +89,7 @@ public class RegistrationInfoFragment extends MvpBindingFragment&lt;RegistrationInf
79 * @param fenceId 89 * @param fenceId
80 */ 90 */
81 public void addMonitorToFence(int fenceId) { 91 public void addMonitorToFence(int fenceId) {
82 - if (null!=getMvpView()){ 92 + if (null != getMvpView()) {
83 getMvpView().limitClickRegistBtn(); 93 getMvpView().limitClickRegistBtn();
84 } 94 }
85 if (null == getPresenter()) { 95 if (null == getPresenter()) {
@@ -148,7 +158,7 @@ public class RegistrationInfoFragment extends MvpBindingFragment&lt;RegistrationInf @@ -148,7 +158,7 @@ public class RegistrationInfoFragment extends MvpBindingFragment&lt;RegistrationInf
148 binding.sexText.getText().toString().trim().equals("未选择") ? "" : binding.sexText.getText().toString().trim(), 158 binding.sexText.getText().toString().trim().equals("未选择") ? "" : binding.sexText.getText().toString().trim(),
149 binding.birthday.getText().toString().trim().equals("未选择") ? "" : binding.birthday.getText().toString().trim()); 159 binding.birthday.getText().toString().trim().equals("未选择") ? "" : binding.birthday.getText().toString().trim());
150 } else { 160 } else {
151 - if (null!=getMvpView()){ 161 + if (null != getMvpView()) {
152 getMvpView().allowClickRegistBtn(); 162 getMvpView().allowClickRegistBtn();
153 } 163 }
154 QMUITipDialogUtil.dismessDialog(); 164 QMUITipDialogUtil.dismessDialog();
@@ -180,6 +190,9 @@ public class RegistrationInfoFragment extends MvpBindingFragment&lt;RegistrationInf @@ -180,6 +190,9 @@ public class RegistrationInfoFragment extends MvpBindingFragment&lt;RegistrationInf
180 @Override 190 @Override
181 public void onFailed(String msg) { 191 public void onFailed(String msg) {
182 QMUITipDialogUtil.dismessDialog(); 192 QMUITipDialogUtil.dismessDialog();
  193 + if (null != getMvpView()) {
  194 + getMvpView().allowClickRegistBtn();
  195 + }
183 AlertUtil.showDeftToast(getContext(), msg); 196 AlertUtil.showDeftToast(getContext(), msg);
184 } 197 }
185 198
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunMainFragment.java
@@ -214,6 +214,13 @@ public class RunMainFragment extends QMUIFragment&lt;RunMainFragmentView, RunMainFr @@ -214,6 +214,13 @@ public class RunMainFragment extends QMUIFragment&lt;RunMainFragmentView, RunMainFr
214 tipDialog.show(); 214 tipDialog.show();
215 } 215 }
216 } 216 }
  217 + //到达终点
  218 + else if (messageEvent.getMessageType() == Constant.ARRIVE_END_POINT) {
  219 + if (null == getMvpView()) {
  220 + return;
  221 + }
  222 + getMvpView().showEndTipDialog();
  223 + }
217 } 224 }
218 225
219 @Override 226 @Override
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunningMapFragment.java
@@ -217,6 +217,13 @@ public class RunningMapFragment extends QMUIFragment&lt;RunningMapFragmentView, Run @@ -217,6 +217,13 @@ public class RunningMapFragment extends QMUIFragment&lt;RunningMapFragmentView, Run
217 tipDialog.show(); 217 tipDialog.show();
218 } 218 }
219 } 219 }
  220 + //到达终点
  221 + else if (messageEvent.getMessageType() == Constant.ARRIVE_END_POINT) {
  222 + if (null == getMvpView()) {
  223 + return;
  224 + }
  225 + getMvpView().showEndTipDialog();
  226 + }
220 } 227 }
221 228
222 private void initTipDialog() { 229 private void initTipDialog() {
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/MyMapUtil.java
@@ -69,75 +69,86 @@ public class MyMapUtil { @@ -69,75 +69,86 @@ public class MyMapUtil {
69 * @param geoCodeResult 69 * @param geoCodeResult
70 */ 70 */
71 public static void getGeoCoderResult(LatLng latLng, GeoCodeResult geoCodeResult) { 71 public static void getGeoCoderResult(LatLng latLng, GeoCodeResult geoCodeResult) {
72 - if (null == latLng) {  
73 - return;  
74 - }  
75 - if (null == mSearch) {  
76 - mSearch = GeoCoder.newInstance();  
77 - }  
78 - mSearch.setOnGetGeoCodeResultListener(new OnGetGeoCoderResultListener() { 72 + try {
  73 + if (null == latLng) {
  74 + return;
  75 + }
  76 + if (null == mSearch) {
  77 + mSearch = GeoCoder.newInstance();
  78 + }
  79 + mSearch.setOnGetGeoCodeResultListener(new OnGetGeoCoderResultListener() {
79 80
80 - @Override  
81 - public void onGetGeoCodeResult(com.baidu.mapapi.search.geocode.GeoCodeResult geoCodeResult) { 81 + @Override
  82 + public void onGetGeoCodeResult(com.baidu.mapapi.search.geocode.GeoCodeResult geoCodeResult) {
82 83
83 - } 84 + }
84 85
85 - @Override  
86 - public void onGetReverseGeoCodeResult(ReverseGeoCodeResult reverseGeoCodeResult) { 86 + @Override
  87 + public void onGetReverseGeoCodeResult(ReverseGeoCodeResult reverseGeoCodeResult) {
87 // Log.e(TAG, "status:" + reverseGeoCodeResult.status + ",error" + reverseGeoCodeResult.error); 88 // Log.e(TAG, "status:" + reverseGeoCodeResult.status + ",error" + reverseGeoCodeResult.error);
88 - //成功  
89 - if (0 == reverseGeoCodeResult.status) {  
90 - queryGeoCount = 0;  
91 - if (null != geoCodeResult) {  
92 - List<PoiInfo> pois = reverseGeoCodeResult.getPoiList();  
93 - if (null != pois && pois.size() > 0) {  
94 - if (!TextUtils.isEmpty(pois.get(0).name)) {  
95 - geoCodeResult.success(pois.get(0).name);  
96 - } else {  
97 - geoCodeResult.success(null);  
98 - }  
99 - } else {  
100 - //如果街道号或者街道为空  
101 - if ((null == reverseGeoCodeResult.getAddressDetail().street || TextUtils.isEmpty(reverseGeoCodeResult.getAddressDetail().street)) && (null == reverseGeoCodeResult.getAddressDetail().streetNumber || TextUtils.isEmpty(reverseGeoCodeResult.getAddressDetail().streetNumber))) {  
102 - if (!TextUtils.isEmpty(reverseGeoCodeResult.getAddress()) && !TextUtils.isEmpty(reverseGeoCodeResult.getSematicDescription())) {  
103 - geoCodeResult.success(reverseGeoCodeResult.getAddress() + "," + reverseGeoCodeResult.getSematicDescription());  
104 - } else if (!TextUtils.isEmpty(reverseGeoCodeResult.getAddress())) {  
105 - geoCodeResult.success(reverseGeoCodeResult.getAddress()); 89 + if (null == reverseGeoCodeResult) {
  90 + if (null != geoCodeResult) {
  91 + geoCodeResult.success(null);
  92 + }
  93 + }
  94 + //成功
  95 + if (0 == reverseGeoCodeResult.status) {
  96 + queryGeoCount = 0;
  97 + if (null != geoCodeResult) {
  98 + List<PoiInfo> pois = reverseGeoCodeResult.getPoiList();
  99 + if (null != pois && pois.size() > 0) {
  100 + if (!TextUtils.isEmpty(pois.get(0).name)) {
  101 + geoCodeResult.success(pois.get(0).name);
106 } else { 102 } else {
107 geoCodeResult.success(null); 103 geoCodeResult.success(null);
108 } 104 }
109 } else { 105 } else {
110 - if (!TextUtils.isEmpty(reverseGeoCodeResult.getAddress())) {  
111 - geoCodeResult.success(reverseGeoCodeResult.getAddress()); 106 + //如果街道号或者街道为空
  107 + if ((null == reverseGeoCodeResult.getAddressDetail().street || TextUtils.isEmpty(reverseGeoCodeResult.getAddressDetail().street)) && (null == reverseGeoCodeResult.getAddressDetail().streetNumber || TextUtils.isEmpty(reverseGeoCodeResult.getAddressDetail().streetNumber))) {
  108 + if (!TextUtils.isEmpty(reverseGeoCodeResult.getAddress()) && !TextUtils.isEmpty(reverseGeoCodeResult.getSematicDescription())) {
  109 + geoCodeResult.success(reverseGeoCodeResult.getAddress() + "," + reverseGeoCodeResult.getSematicDescription());
  110 + } else if (!TextUtils.isEmpty(reverseGeoCodeResult.getAddress())) {
  111 + geoCodeResult.success(reverseGeoCodeResult.getAddress());
  112 + } else {
  113 + geoCodeResult.success(null);
  114 + }
112 } else { 115 } else {
113 - geoCodeResult.success(null); 116 + if (!TextUtils.isEmpty(reverseGeoCodeResult.getAddress())) {
  117 + geoCodeResult.success(reverseGeoCodeResult.getAddress());
  118 + } else {
  119 + geoCodeResult.success(null);
  120 + }
114 } 121 }
115 } 122 }
116 } 123 }
  124 + } else if (104 == reverseGeoCodeResult.status) {
  125 + if (0 == queryGeoCount) {
  126 + queryGeoCount = 1;
  127 + new Handler().postDelayed(new Runnable() {
  128 + @Override
  129 + public void run() {
  130 + getGeoCoderResult(latLng, geoCodeResult);
  131 + }
  132 + }, 1000);
  133 + }
117 } 134 }
118 - } else if (104 == reverseGeoCodeResult.status) {  
119 - if (0 == queryGeoCount) {  
120 - queryGeoCount = 1;  
121 - new Handler().postDelayed(new Runnable() {  
122 - @Override  
123 - public void run() {  
124 - getGeoCoderResult(latLng, geoCodeResult);  
125 - }  
126 - }, 1000);  
127 - }  
128 - }  
129 - //失败  
130 - else {  
131 - queryGeoCount = 0;  
132 - if (null != geoCodeResult) {  
133 - geoCodeResult.success(null); 135 + //失败
  136 + else {
  137 + queryGeoCount = 0;
  138 + if (null != geoCodeResult) {
  139 + geoCodeResult.success(null);
  140 + }
134 } 141 }
135 } 142 }
  143 + });
  144 + mSearch.reverseGeoCode(new ReverseGeoCodeOption()
  145 + .location(latLng)
  146 + .radius(Constant.COLL_GEORESULT_RADIUS));
  147 + } catch (Exception e) {
  148 + if (null != geoCodeResult) {
  149 + geoCodeResult.success(null);
136 } 150 }
137 - });  
138 - mSearch.reverseGeoCode(new ReverseGeoCodeOption()  
139 - .location(latLng)  
140 - .radius(Constant.COLL_GEORESULT_RADIUS)); 151 + }
141 } 152 }
142 153
143 /** 154 /**
moudle_pedometer/src/main/res/drawable/shape_load.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="20dp" />
  4 + <solid android:color="#CC000000" />
  5 +</shape>
0 \ No newline at end of file 6 \ No newline at end of file
moudle_pedometer/src/main/res/layout/fragment_coll_finish_run_map.xml
@@ -127,5 +127,47 @@ @@ -127,5 +127,47 @@
127 android:textColor="@color/white" 127 android:textColor="@color/white"
128 android:textSize="18sp" /> 128 android:textSize="18sp" />
129 </LinearLayout> 129 </LinearLayout>
  130 + <!--load-->
  131 + <LinearLayout
  132 + android:id="@+id/ll_loading"
  133 + android:layout_width="match_parent"
  134 + android:layout_height="match_parent"
  135 + android:focusable="true"
  136 + android:clickable="true"
  137 + android:visibility="gone"
  138 + android:focusableInTouchMode="true"
  139 + android:gravity="center">
  140 +
  141 + <LinearLayout
  142 + android:layout_width="wrap_content"
  143 + android:layout_height="wrap_content"
  144 + android:layout_gravity="center"
  145 + android:background="@drawable/shape_load"
  146 + android:gravity="center"
  147 + android:orientation="vertical">
  148 +
  149 + <ProgressBar
  150 + android:layout_width="wrap_content"
  151 + android:layout_height="wrap_content"
  152 + android:layout_marginTop="10dp"
  153 + android:indeterminateTint="@color/white"
  154 + android:maxWidth="30dp"
  155 + android:maxHeight="30dp"
  156 + android:minWidth="20dp"
  157 + android:minHeight="20dp"
  158 + android:padding="10dp" />
  159 +
  160 + <TextView
  161 + android:id="@+id/tv_loading_tip"
  162 + android:layout_width="wrap_content"
  163 + android:layout_height="wrap_content"
  164 + android:layout_marginLeft="15dp"
  165 + android:layout_marginRight="15dp"
  166 + android:layout_marginBottom="15dp"
  167 + android:textSize="13sp"
  168 + android:text="正在截取赛事图片,请稍后"
  169 + android:textColor="@color/white" />
  170 + </LinearLayout>
  171 + </LinearLayout>
130 </FrameLayout> 172 </FrameLayout>
131 </layout> 173 </layout>
132 \ No newline at end of file 174 \ No newline at end of file
moudle_pedometer/src/main/res/layout/fragment_finish_run_map.xml
@@ -147,5 +147,6 @@ @@ -147,5 +147,6 @@
147 android:textColor="@color/white" 147 android:textColor="@color/white"
148 android:textSize="18sp" /> 148 android:textSize="18sp" />
149 </LinearLayout> 149 </LinearLayout>
  150 +
150 </FrameLayout> 151 </FrameLayout>
151 </layout> 152 </layout>
152 \ No newline at end of file 153 \ No newline at end of file