Commit f561e9e0382d9fad42ec92219d338dd74bf497dc

Authored by 韩亚云
2 parents df774258 3b0c1282

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

Showing 62 changed files with 664 additions and 425 deletions
.idea/gradle.xml
... ... @@ -3,9 +3,6 @@
3 3 <component name="GradleSettings">
4 4 <option name="linkedExternalProjectsSettings">
5 5 <GradleProjectSettings>
6   - <compositeConfiguration>
7   - <compositeBuild compositeDefinitionSource="SCRIPT" />
8   - </compositeConfiguration>
9 6 <option name="distributionType" value="DEFAULT_WRAPPED" />
10 7 <option name="externalProjectPath" value="$PROJECT_DIR$" />
11 8 <option name="modules">
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/commonInfo/CommonInfo.java 0 → 100644
  1 +package com.cnlive.moudle.pedometer.commonInfo;
  2 +
  3 +import android.content.Context;
  4 +
  5 +import com.cnlive.moudle.pedometer.utils.MySpHelper;
  6 +import com.cnlive.moudle.pedometer.utils.TimeUtil;
  7 +
  8 +public class CommonInfo {
  9 +
  10 + /**
  11 + * 设置计步时间
  12 + *
  13 + * @param context
  14 + */
  15 + public static void setStepStartTime(Context context, long currentTime) {
  16 + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putLong("stepStartTime", currentTime);
  17 + }
  18 +
  19 + /**
  20 + * 获取计步时间
  21 + *
  22 + * @param context
  23 + */
  24 + public static long getStepStartTime(Context context) {
  25 + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getLong("stepStartTime", 0);
  26 + }
  27 +
  28 + /**
  29 + * 是否允许写入步数
  30 + *
  31 + * @param context
  32 + */
  33 + public static void setIsWriteUserStep(Context context, boolean isAllow) {
  34 + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean("writeUserStep:", isAllow);
  35 + }
  36 +
  37 + /**
  38 + * 是否允许写入步数
  39 + *
  40 + * @param context
  41 + */
  42 + public static boolean getIsWriteUserStep(Context context) {
  43 + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("writeUserStep", true);
  44 + }
  45 +
  46 + /**
  47 + * @param context
  48 + * @param uid
  49 + */
  50 + public static void setUserId(Context context, String uid) {
  51 + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString("userId", uid);
  52 + }
  53 +
  54 + /**
  55 + * @param context
  56 + */
  57 + public static String getUserId(Context context) {
  58 + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString("userId", "");
  59 + }
  60 +
  61 + /**
  62 + * 设置是否运行计步服务
  63 + *
  64 + * @param context
  65 + * @param isAllow
  66 + */
  67 + public static void setIsRunStepService(Context context, boolean isAllow) {
  68 + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean("runStepService", isAllow);
  69 +
  70 + }
  71 +
  72 + /**
  73 + * 获取是否运行计步服务
  74 + *
  75 + * @param context
  76 + */
  77 + public static boolean getIsRunStepService(Context context) {
  78 + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("runStepService", false);
  79 + }
  80 +
  81 + /*重置
  82 + * @param context
  83 + */
  84 + public static void reset(Context context) {
  85 + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("writeUserStep");
  86 + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("stepStartTime");
  87 + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("runStepService");
  88 +
  89 + }
  90 +}
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunMainFragmentView.java
... ... @@ -10,7 +10,17 @@ import android.util.Log;
10 10 import android.view.MotionEvent;
11 11 import android.view.View;
12 12 import android.widget.Chronometer;
13   -
  13 +import android.widget.Toast;
  14 +
  15 +import com.baidu.location.BDAbstractLocationListener;
  16 +import com.baidu.location.BDLocation;
  17 +import com.baidu.location.LocationClient;
  18 +import com.baidu.location.LocationClientOption;
  19 +import com.baidu.mapapi.map.MapStatus;
  20 +import com.baidu.mapapi.map.MyLocationData;
  21 +import com.baidu.mapapi.model.LatLng;
  22 +import com.baidu.mapapi.utils.DistanceUtil;
  23 +import com.cnlive.moudle.pedometer.commonInfo.CommonInfo;
14 24 import com.cnlive.moudle.pedometer.model.RunningFinishBean;
15 25 import com.cnlive.moudle.pedometer.model.RunningMapBean;
16 26 import com.cnlive.moudle.pedometer.model.Constant;
... ... @@ -23,9 +33,11 @@ import com.cnlive.moudle.pedometer.ui.activity.RunningMapActivity;
23 33 import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment;
24 34 import com.cnlive.moudle.pedometer.ui.widget.SelectDialog;
25 35 import com.cnlive.moudle.pedometer.utils.ButtonAnimUtil;
  36 +import com.cnlive.moudle.pedometer.utils.MyMapUtil;
26 37 import com.cnlive.moudle.pedometer.utils.MySpHelper;
27 38 import com.cnlive.moudle.pedometer.utils.StepUtil;
28 39 import com.cnlive.moudle.pedometer.utils.TimeUtil;
  40 +import com.cnlive.strike.application.GlideApp;
29 41 import com.example.moudle_pedometer.R;
30 42 import com.hannesdorfmann.mosby3.mvp.MvpView;
31 43  
... ... @@ -41,13 +53,14 @@ public class RunMainFragmentView implements MvpView {
41 53 private Handler handler;
42 54 private Runnable runnable;
43 55 private Runnable animRunnable;
44   -
45 56 private long mRecordTime;//计时时间
46 57 private boolean firstTimeFlag;//是否是首次计时
47 58 private int timeCountDown;//时间倒计时
48   -
49 59 private String uid;
50 60 private boolean needWriteDataFlag = true;//是否需要将计时器基值写入到数据库
  61 + // 定位相关
  62 + private LocationClient mLocClient;
  63 + public MyLocationListenner myListener = new MyLocationListenner();
51 64  
52 65 public RunMainFragmentView(RunMainFragment fragment) {
53 66 this.fragment = fragment;
... ... @@ -57,8 +70,44 @@ public class RunMainFragmentView implements MvpView {
57 70 return fragment == null ? null : fragment.getActivity();
58 71 }
59 72  
60   - public void showStartTimeTip() {
61   -
  73 + private void initLocationClient() {
  74 + // 定位初始化
  75 + mLocClient = new LocationClient(getContext());
  76 + mLocClient.registerLocationListener(myListener);
  77 + LocationClientOption option = new LocationClientOption();
  78 + option.setOpenGps(true); // 打开gps
  79 + //可选,设置返回经纬度坐标类型,默认GCJ02
  80 + //GCJ02:国测局坐标;
  81 + //BD09ll:百度经纬度坐标;
  82 + //BD09:百度墨卡托坐标;
  83 + //海外地区定位,无需设置坐标类型,统一返回WGS84类型坐标
  84 + option.setCoorType("gcj02"); // 设置坐标类型
  85 + //可选,默认false,设置是否开启Gps定位
  86 + option.setOpenGps(true);
  87 + //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者,该模式下开发者无需再关心定位间隔是多少,定位SDK本身发现位置变化就会及时回调给开发者
  88 + option.setOpenAutoNotifyMode();
  89 + //可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
  90 + //LocationMode.Hight_Accuracy:高精度;
  91 + //LocationMode. Battery_Saving:低功耗;
  92 + //LocationMode. Device_Sensors:仅使用设备;
  93 + option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
  94 + //可选,设置是否需要地址信息,默认不需要
  95 + option.setIsNeedAddress(false);
  96 + //可选,设置是否需要地址描述
  97 + option.setIsNeedLocationDescribe(false);
  98 + //可选,设置是否需要设备方向结果
  99 + option.setNeedDeviceDirect(false);
  100 + //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者
  101 + //minTimeInterval - 最短定位时间间隔,单位毫秒,最小值0,开发者可以在设置希望的位置回调最短时间间隔
  102 + //minDistance - 最短定位距离间隔,单位米,最小值0,开发者可以设置希望的位置回调距离间隔
  103 + //locSensitivity - 定位变化敏感程度,LOC_SENSITIVITY_HIGHT,LOC_SENSITIVITY_MIDDLE,LOC_SENSITIVITY_LOW
  104 + option.setOpenAutoNotifyMode(3000, 1, LocationClientOption.LOC_SENSITIVITY_HIGHT);
  105 + //可选,定位SDK内部是一个service,并放到了独立进程。
  106 + //设置是否在stop的时候杀死这个进程,默认(建议)不杀死,即setIgnoreKillProcess(true)
  107 + option.setIgnoreKillProcess(true);
  108 +
  109 + mLocClient.setLocOption(option);
  110 + mLocClient.start();
62 111 }
63 112  
64 113 /**
... ... @@ -66,7 +115,8 @@ public class RunMainFragmentView implements MvpView {
66 115 */
67 116 public void initView() {
68 117 uid = "yangshuai";
69   - MySpHelper.getInstance(getContext(), Context.MODE_MULTI_PROCESS).putString("userId", uid);
  118 + CommonInfo.setUserId(getContext(), uid);
  119 + initLocationClient();
70 120 fragment.binding.llRunMainRoot.setVisibility(View.GONE);
71 121 ButtonAnimUtil.startAnimation(fragment.binding.llStartTimeTip, false);
72 122 firstTimeFlag = true;
... ... @@ -127,9 +177,10 @@ public class RunMainFragmentView implements MvpView {
127 177  
128 178 }
129 179 });
130   - UserStepEntity userStepEntity = StepUtil.getUserStepData(fragment.getActivity(), uid);
  180 + UserStepEntity userStepEntity = StepUtil.getUserStepData(getContext(), uid);
  181 + boolean isRunStep = CommonInfo.getIsRunStepService(getContext());
131 182 //当前用户已经在运动
132   - if (userStepEntity == null) {
  183 + if (!isRunStep) {
133 184 //依次倒计时
134 185 handler.postDelayed(runnable, 1000);
135 186 } else {
... ... @@ -142,12 +193,13 @@ public class RunMainFragmentView implements MvpView {
142 193 //开始计时
143 194 if (firstTimeFlag) {
144 195 firstTimeFlag = false;
145   - if ((userStepEntity.getPauseTimeStamp() != 0) && (userStepEntity.getRecordTime() != 0)) {
146   - fragment.binding.chronometer.setBase(userStepEntity.getPauseTimeStamp() + (SystemClock.elapsedRealtime() - userStepEntity.getRecordTime()));
147   - } else {
148   - fragment.binding.chronometer.setFormat("00:00:01");
149   - fragment.binding.chronometer.setBase(SystemClock.elapsedRealtime());
150   -
  196 + if (userStepEntity != null) {
  197 + if ((userStepEntity.getPauseTimeStamp() != 0) && (userStepEntity.getRecordTime() != 0)) {
  198 + fragment.binding.chronometer.setBase(userStepEntity.getPauseTimeStamp() + (SystemClock.elapsedRealtime() - userStepEntity.getRecordTime()));
  199 + } else {
  200 + fragment.binding.chronometer.setFormat("00:00:01");
  201 + fragment.binding.chronometer.setBase(SystemClock.elapsedRealtime());
  202 + }
151 203 }
152 204 fragment.binding.chronometer.start();
153 205 }
... ... @@ -249,18 +301,17 @@ public class RunMainFragmentView implements MvpView {
249 301 SelectDialog selectDialog = new SelectDialog(fragment.getActivity(), "确定结束运动吗?", "确定", new SelectDialog.DialogInterface() {
250 302 @Override
251 303 public void onClick(SelectDialog dialog) {
252   - MySpHelper.getInstance(getContext(), Context.MODE_MULTI_PROCESS).putBoolean("writeUserStep:" + uid, false);
  304 + CommonInfo.setIsWriteUserStep(getContext(), false);
253 305 fragment.binding.cpCurrent.setVisibility(View.GONE);
254 306 ButtonAnimUtil.setViewDefault(fragment.binding.flStop);
255 307 //清空数据
256   - StepUtil.clearRunData(getContext(), uid);
  308 + CommonInfo.reset(getContext());
257 309 dialog.dismiss();
258 310 if (StepService.mClient != null) {
259 311 StepService.mClient.stopGather(StepService.traceListener);
260 312 }
261   - MySpHelper.getInstance(getContext(), Context.MODE_MULTI_PROCESS).putLong("stepStartTime", 0);
  313 + CommonInfo.setStepStartTime(getContext(), 0);
262 314 fragment.getActivity().stopService(new Intent(fragment.getActivity(), StepService.class));
263   - MySpHelper.getInstance(getContext(), Context.MODE_MULTI_PROCESS).putString("userId", "");
264 315 RunningFinishBean runningFinishBean = new RunningFinishBean();
265 316 runningFinishBean.setStartPoint("开始地点");
266 317 runningFinishBean.setEndPoint("结束地点");
... ... @@ -405,7 +456,7 @@ public class RunMainFragmentView implements MvpView {
405 456 */
406 457 public void startStepService(Context context, String userId) {
407 458 Intent intent = new Intent(fragment.getActivity(), StepService.class);
408   -// intent.putExtra("userId", userId);
  459 + intent.putExtra("userId", userId);
409 460 ContextCompat.startForegroundService(fragment.getActivity(), intent);
410 461  
411 462 }
... ... @@ -419,7 +470,7 @@ public class RunMainFragmentView implements MvpView {
419 470 //设置行走公里
420 471 fragment.binding.tvRunDistance.setText(StepUtil.getWalkDistanceKM(step) + "");
421 472 //设置行走步数
422   - fragment.binding.tvStepCount.setText(step+"");
  473 + fragment.binding.tvStepCount.setText(step + "");
423 474 //设置S速度
424 475 int second = (int) ((SystemClock.elapsedRealtime() - fragment.binding.chronometer.getBase()) / 1000);
425 476 if (second != 0) {
... ... @@ -436,6 +487,81 @@ public class RunMainFragmentView implements MvpView {
436 487 }
437 488  
438 489  
  490 + /**
  491 + * //设置定位监听器,获取到用户当前位置 杨帅
  492 + * 定位SDK监听函数
  493 + */
  494 + public class MyLocationListenner extends BDAbstractLocationListener {
  495 +
  496 +
  497 + @Override
  498 + public void onReceiveLocation(BDLocation location) {
  499 + if (location == null) {
  500 + return;
  501 + }
  502 + //正在搜索GPS信号
  503 + if (location.getGpsAccuracyStatus() == BDLocation.GPS_ACCURACY_UNKNOWN) {
  504 + if (!getContext().getString(R.string.loc_gps_accuracy_unknown).equals(fragment.binding.tvLookTrace.getText().toString())) {
  505 + fragment.binding.tvLookTrace.setText(getContext().getString(R.string.loc_gps_accuracy_unknown));
  506 + fragment.binding.tvLookTrace.setTextColor(getContext().getResources().getColor(R.color.red));
  507 + }
  508 + if (fragment.binding.tvLookTrace.getVisibility()!=View.VISIBLE){
  509 + fragment.binding.tvLookTrace.setVisibility(View.VISIBLE);
  510 + }
  511 + if (fragment.binding.ivGps.getTag()==null||!fragment.binding.ivGps.getTag().toString().equals("rt_training_gps_0")) {
  512 + fragment.binding.ivGps.setTag("rt_training_gps_0");
  513 + //设置图标
  514 + fragment.binding.ivGps.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_0));
  515 + }
  516 +
  517 +
  518 + }
  519 + //GPS 质量判断差
  520 + else if (location.getGpsAccuracyStatus() == BDLocation.GPS_ACCURACY_BAD) {
  521 + if (!getContext().getString(R.string.loc_gps_accuracy_bad).equals(fragment.binding.tvLookTrace.getText().toString())) {
  522 + fragment.binding.tvLookTrace.setText(getContext().getString(R.string.loc_gps_accuracy_bad));
  523 + fragment.binding.tvLookTrace.setTextColor(getContext().getResources().getColor(R.color.text_gray99));
  524 +
  525 + }
  526 + if (fragment.binding.tvLookTrace.getVisibility()!=View.VISIBLE){
  527 + fragment.binding.tvLookTrace.setVisibility(View.VISIBLE);
  528 + }
  529 + if (fragment.binding.ivGps.getTag()==null||!fragment.binding.ivGps.getTag().toString().equals("GPS_ACCURACY_BAD")) {
  530 + fragment.binding.ivGps.setTag("GPS_ACCURACY_BAD");
  531 + //设置图标
  532 + fragment.binding.ivGps.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_1));
  533 + }
  534 + }
  535 + //GPS 质量判断中等
  536 + else if (location.getGpsAccuracyStatus() == BDLocation.GPS_ACCURACY_MID) {
  537 + if (fragment.binding.tvLookTrace.getVisibility() == View.VISIBLE) {
  538 + fragment.binding.tvLookTrace.setVisibility(View.GONE);
  539 + }
  540 + if (fragment.binding.ivGps.getTag()==null||!fragment.binding.ivGps.getTag().toString().equals("GPS_ACCURACY_MID")) {
  541 + fragment.binding.ivGps.setTag("GPS_ACCURACY_MID");
  542 + //设置图标
  543 + fragment.binding.ivGps.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_2));
  544 + }
  545 + }//GPS 质量判断好
  546 + else if (location.getGpsAccuracyStatus() == BDLocation.GPS_ACCURACY_GOOD) {
  547 + if (fragment.binding.tvLookTrace.getVisibility() == View.VISIBLE) {
  548 + fragment.binding.tvLookTrace.setVisibility(View.GONE);
  549 + }
  550 + if (fragment.binding.ivGps.getTag()==null||!fragment.binding.ivGps.getTag().toString().equals("GPS_ACCURACY_GOOD")) {
  551 + fragment.binding.ivGps.setTag("GPS_ACCURACY_GOOD");
  552 + //设置图标
  553 + fragment.binding.ivGps.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_3));
  554 + }
  555 + }
  556 + }
  557 + }
  558 +
  559 + public void onDestroy() {
  560 + if (mLocClient != null) {
  561 + mLocClient.stop();
  562 + }
  563 + }
439 564 }
440 565  
441 566  
  567 +
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
... ... @@ -103,7 +103,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
103 103  
104 104 private String startPoint = "首都师范大学南门";
105 105 private String endPoint = "首都师范大学篮球场";
106   - 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},{\"latitude\":39.933903844942,\"latitudeE6\":3.9933903844942E7,\"longitude\":116.30918357649,\"longitudeE6\":1.1630918357649E8}]";
  106 + 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}]";
107 107 private LinkedList<LatLng> importLatLngs;//关键点
108 108 private LatLng startLatLng = new LatLng(39.934733, 116.308646);//起始点
109 109 private List<LatLng> trackPoints;
... ... @@ -283,7 +283,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
283 283 //设置定位模式, 默认为 LocationMode.NORMAL 普通态
284 284 mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL;
285 285 // 设置定位图标修改为自定义marker
286   - Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.rt_ic_location), 40, 40);
  286 + Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.rt_ic_location), 50, 50);
287 287 mCurrentMarker = BitmapDescriptorFactory.fromBitmap(pointBitmap);
288 288 //设置定位蓝点精度圆圈的填充颜色为透明色
289 289 accuracyCircleFillColor = getContext().getResources().getColor(R.color.transparent);
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunningMapFragmentView.java
... ... @@ -240,11 +240,61 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
240 240  
241 241 @Override
242 242 public void onReceiveLocation(BDLocation location) {
243   - Log.e(TAG, "onReceiveLocation: 状态" + location.getGpsAccuracyStatus());
244 243 // map view 销毁后不在处理新接收的位置
245 244 if (location == null || mMapView == null) {
246 245 return;
247 246 }
  247 +
  248 + //正在搜索GPS信号
  249 + if (location.getGpsAccuracyStatus() == BDLocation.GPS_ACCURACY_UNKNOWN) {
  250 + if (fragment.binding.tvGpsPopBg.getVisibility() != View.VISIBLE) {
  251 + fragment.binding.tvGpsPopBg.setVisibility(View.VISIBLE);
  252 + }
  253 + if (!getContext().getResources().getString(R.string.loc_gps_accuracy_unknown).equals(fragment.binding.tvGpsPopBg.getText().toString())) {
  254 + fragment.binding.tvGpsPopBg.setText(getContext().getResources().getString(R.string.loc_gps_accuracy_unknown));
  255 + }
  256 + //设置图标
  257 + if (fragment.binding.ivGpsState.getTag() == null || !"GPS_ACCURACY_UNKNOWN".equals(fragment.binding.ivGpsState.getTag().toString())) {
  258 + fragment.binding.ivGpsState.setTag("GPS_ACCURACY_UNKNOWN");
  259 + fragment.binding.ivGpsState.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_0));
  260 + }
  261 + }
  262 + //GPS 质量判断差
  263 + else if (location.getGpsAccuracyStatus() == BDLocation.GPS_ACCURACY_BAD) {
  264 + if (fragment.binding.tvGpsPopBg.getVisibility() != View.VISIBLE) {
  265 + fragment.binding.tvGpsPopBg.setVisibility(View.VISIBLE);
  266 + }
  267 + if (!getContext().getResources().getString(R.string.loc_gps_accuracy_bad).equals(fragment.binding.tvGpsPopBg.getText().toString())) {
  268 + fragment.binding.tvGpsPopBg.setText(getContext().getResources().getString(R.string.loc_gps_accuracy_bad));
  269 + }
  270 + //设置图标
  271 + if (fragment.binding.ivGpsState.getTag() == null || !"GPS_ACCURACY_BAD".equals(fragment.binding.ivGpsState.getTag().toString())) {
  272 + fragment.binding.ivGpsState.setTag("GPS_ACCURACY_BAD");
  273 + fragment.binding.ivGpsState.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_1));
  274 + }
  275 + }
  276 + //GPS 质量判断中等
  277 + else if (location.getGpsAccuracyStatus() == BDLocation.GPS_ACCURACY_MID) {
  278 + if (fragment.binding.tvGpsPopBg.getVisibility() != View.GONE) {
  279 + fragment.binding.tvGpsPopBg.setVisibility(View.GONE);
  280 + }
  281 + //设置图标
  282 + if (fragment.binding.ivGpsState.getTag()== null || !"GPS_ACCURACY_MID".equals(fragment.binding.ivGpsState.getTag().toString())) {
  283 + fragment.binding.ivGpsState.setTag("GPS_ACCURACY_MID");
  284 + fragment.binding.ivGpsState.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_2));
  285 + }
  286 + }//GPS 质量判断好
  287 + else if (location.getGpsAccuracyStatus() == BDLocation.GPS_ACCURACY_GOOD) {
  288 + if (fragment.binding.tvGpsPopBg.getVisibility() != View.GONE) {
  289 + fragment.binding.tvGpsPopBg.setVisibility(View.GONE);
  290 + }
  291 + //设置图标
  292 + if (fragment.binding.ivGpsState.getTag() == null || !"GPS_ACCURACY_GOOD".equals(fragment.binding.ivGpsState.getTag().toString())) {
  293 + fragment.binding.ivGpsState.setTag("GPS_ACCURACY_GOOD");
  294 + fragment.binding.ivGpsState.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_3));
  295 + }
  296 + }
  297 +
248 298 if (isFirstLoc) {
249 299 isFirstLoc = false;
250 300 if (location.getRadius() > 20) {
... ... @@ -268,7 +318,7 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
268 318 return;
269 319 }
270 320 MapStatus.Builder builder = new MapStatus.Builder();
271   - //不是第一次定位
  321 + //不是第一次定位状态
272 322 if (!isFirstLoc) {
273 323 if (currentPoints.size() > 0) {
274 324 //进行判断
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/receivers/ServiceReceiver.java
... ... @@ -8,7 +8,6 @@ import android.os.Build;
8 8 import android.os.PowerManager;
9 9 import android.util.Log;
10 10  
11   -import com.cnlive.moudle.pedometer.service.KeepLiveService;
12 11 import com.cnlive.moudle.pedometer.utils.MySpHelper;
13 12 import com.cnlive.moudle.pedometer.utils.ServiceUtils;
14 13  
... ... @@ -41,9 +40,9 @@ public class ServiceReceiver extends BroadcastReceiver {
41 40 if (isRun) {
42 41 if (!ServiceUtils.isServiceRunning(context, "com.cnlive.moudle.pedometer.service.KeepLiveService")) {
43 42 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
44   - context.startForegroundService(new Intent(context, KeepLiveService.class));
  43 +// context.startForegroundService(new Intent(context, KeepLiveService.class));
45 44 } else {
46   - context.startService(new Intent(context, KeepLiveService.class));
  45 +// context.startService(new Intent(context, KeepLiveService.class));
47 46 }
48 47 Log.e(TAG, "启动KeepLiveService");
49 48 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/KeepLiveService.java deleted 100644 → 0
1   -package com.cnlive.moudle.pedometer.service;
2   -
3   -import android.annotation.SuppressLint;
4   -import android.app.Notification;
5   -import android.app.NotificationChannel;
6   -import android.app.NotificationManager;
7   -import android.app.Service;
8   -import android.content.ComponentName;
9   -import android.content.Context;
10   -import android.content.Intent;
11   -import android.content.IntentFilter;
12   -import android.media.MediaPlayer;
13   -import android.os.Build;
14   -import android.os.Handler;
15   -import android.os.IBinder;
16   -import android.os.PowerManager;
17   -import android.support.v4.app.NotificationCompat;
18   -import android.util.Log;
19   -
20   -import com.cnlive.moudle.pedometer.receivers.ServiceReceiver;
21   -import com.cnlive.moudle.pedometer.utils.MySpHelper;
22   -import com.example.moudle_pedometer.R;
23   -
24   -
25   -/**
26   - * @author ShinnyYang
27   - * 维持后台运行的服务
28   - */
29   -public class KeepLiveService extends Service implements MediaPlayer.OnCompletionListener {
30   - //唤醒锁
31   - private PowerManager.WakeLock wakeLock = null;
32   - //电源管理器
33   - private PowerManager powerManager = null;
34   - //音频播放器
35   - public static MediaPlayer mMediaPlayer;
36   - //广播
37   - private static ServiceReceiver myReceiver;
38   - private String CHANNEL_ONE_ID = "com.cnlive.keep";
39   - private String CHANNEL_ONE_NAME = "KeepLive";
40   - private NotificationManager mNM;
41   - private Notification notification = null;
42   - //是否在后台运行
43   - public static boolean isKeepService = true;
44   - public static KeepLiveService instance;
45   - private int startId;
46   - private final String TAG = "KeepLiveService";
47   - private Handler handler;
48   - private Runnable runnable;
49   -
50   - public KeepLiveService() {
51   - }
52   -
53   - public static KeepLiveService getInstance() {
54   - if (instance == null) {
55   - instance = new KeepLiveService();
56   - return instance;
57   - } else {
58   - return instance;
59   - }
60   - }
61   -
62   - @Override
63   - public void onCreate() {
64   - super.onCreate();
65   - instance = this;
66   -// if (!ServiceUtils.isServiceRunning(getApplicationContext(), "com.cnlive.moudle.pedometer.service.StepService")) {
67   -// startService(new Intent(getApplicationContext(), StepService.class));
68   -// }
69   - init();
70   - initBroadCastReceiver();
71   - handler = new Handler();
72   - runnable = new Runnable() {
73   - @Override
74   - public void run() {
75   - //跨进程读取配置文件
76   -// UserService.getUid(getApplicationContext()
77   - boolean isRun = MySpHelper.getInstance(getApplicationContext(), Context.MODE_MULTI_PROCESS).getBoolean("keepService", false);
78   - if (isRun) {
79   - handler.postDelayed(this, 5000);
80   - } else {
81   - if (myReceiver != null) {
82   - unregisterReceiver(myReceiver);
83   - }
84   - stopPlaySong();
85   - stopForeground(true);
86   - }
87   -
88   - }
89   - };
90   -
91   - }
92   -
93   - @Override
94   - public void onTaskRemoved(Intent rootIntent) {
95   - super.onTaskRemoved(rootIntent);
96   - Log.e("onTaskRemoved", "onTaskRemoved");
97   - }
98   -
99   - /**
100   - * 初始化广播
101   - */
102   - private void initBroadCastReceiver() {
103   - if (wakeLock != null) {
104   - myReceiver = new ServiceReceiver(wakeLock);
105   - } else {
106   - myReceiver = new ServiceReceiver();
107   - }
108   - IntentFilter intentFilter = new IntentFilter();
109   - intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
110   - intentFilter.addAction(Intent.ACTION_SCREEN_ON);
111   -// intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
112   - intentFilter.addAction(Intent.ACTION_TIME_CHANGED);
113   -// intentFilter.addAction(Intent.ACTION_POWER_CONNECTED);
114   -// intentFilter.addAction(Intent.ACTION_POWER_DISCONNECTED);
115   - intentFilter.addAction("com.cnlive.strike.receiver.ServiceReceiver");
116   - intentFilter.addAction("close.KeepService");
117   - registerReceiver(myReceiver, intentFilter);
118   - }
119   -
120   - /**
121   - * 初始化相关参数
122   - */
123   - @SuppressLint("InvalidWakeLockTag")
124   - private void init() {
125   - if (null == powerManager) {
126   - powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
127   - }
128   - if (null == wakeLock) {
129   - wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "track upload");
130   - }
131   - if (null == mNM) {
132   - mNM = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
133   - }
134   -
135   - }
136   -
137   - @SuppressLint("WrongConstant")
138   - @Override
139   - public int onStartCommand(Intent intent, int flags, int startId) {
140   - this.startId = startId;
141   - //跨进程读取配置文件
142   -// UserService.getUid(getApplicationContext()
143   - boolean isRun = MySpHelper.getInstance(getApplicationContext(), Context.MODE_MULTI_PROCESS).getBoolean("keepService", false);
144   - Log.e("isRun onStartCommand", "" + isRun);
145   - if (isRun) {
146   - if (runnable != null) {
147   - handler.postDelayed(runnable, 5000);
148   - }
149   - showHideForegroundNotification();
150   - Log.e(TAG, "启动HideKeepTipService");
151   - startPlaySong();
152   - }
153   - return START_STICKY;
154   - }
155   -
156   - //开始、暂停播放
157   - public void startPlaySong() {
158   - if (mMediaPlayer == null) {
159   - mMediaPlayer = MediaPlayer.create(getApplicationContext(), R.raw.no_kill);
160   - }
161   - mMediaPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK);
162   - mMediaPlayer.setOnCompletionListener(this);
163   -// mMediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
164   -// @Override
165   -// public boolean onError(MediaPlayer mediaPlayer, int i, int i1) {
166   -// mMediaPlayer.reset();
167   -// mMediaPlayer.release();
168   -// mMediaPlayer = null;
169   -// startPlaySong();
170   -// return false;
171   -// }
172   -// });
173   - if (!mMediaPlayer.isPlaying()) {
174   - mMediaPlayer.start();
175   - Log.e(TAG, "开始播放");
176   - }
177   -
178   - }
179   -
180   - //停止播放销毁对象
181   - public void stopPlaySong() {
182   -
183   - if (mMediaPlayer != null) {
184   - mMediaPlayer.stop();
185   - mMediaPlayer.release();
186   - mMediaPlayer = null;
187   - Log.e("停止播放", "停止");
188   - }
189   - }
190   -
191   -
192   - private void showHideForegroundNotification() {
193   - NotificationChannel channel = null;
194   - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
195   - channel = new NotificationChannel(CHANNEL_ONE_ID, CHANNEL_ONE_NAME,
196   - NotificationManager.IMPORTANCE_HIGH);
197   - channel.enableLights(false);
198   - channel.enableVibration(false);
199   - channel.setVibrationPattern(new long[]{0});
200   - channel.setSound(null, null);
201   - channel.setLockscreenVisibility(NotificationCompat.VISIBILITY_PRIVATE);
202   - mNM.createNotificationChannel(channel);
203   - }
204   - notification = new NotificationCompat.Builder(this, CHANNEL_ONE_ID)
205   - .setWhen(System.currentTimeMillis())
206   - .setSound(null)
207   - .build();
208   - // 0 隐藏前台服务通知
209   - startForeground(100, notification);
210   -// stopForeground(true);
211   - }
212   -
213   - @Override
214   - public void onDestroy() {
215   - super.onDestroy();
216   - Log.e("onDestroy", "onDestroy:" + notification);
217   - if (myReceiver != null) {
218   - unregisterReceiver(myReceiver);
219   - }
220   - try {
221   -// stopForeground(true);
222   - } catch (Exception e) {
223   - }
224   - stopPlaySong();
225   - // 重启自己
226   - if (isKeepService) {
227   - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
228   - startForegroundService(new Intent(getApplicationContext(), KeepLiveService.class));
229   - } else {
230   - startService(new Intent(getApplicationContext(), KeepLiveService.class));
231   - }
232   - //发送重启广播
233   - sendRestartBroadCast();
234   - }
235   -
236   -
237   - }
238   -
239   -
240   - /**
241   - * 发送重启广播
242   - */
243   - private void sendRestartBroadCast() {
244   - Intent intent = new Intent(" com.cnlive.moudle.pedometer.receivers.MyReceiver");
245   - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
246   - intent.setComponent(new ComponentName(getPackageName(), " com.cnlive.moudle.pedometer.receivers.MyReceiver"));//高版本Android发送广播需要加这句
247   - }
248   - sendBroadcast(intent);
249   - }
250   -
251   - @Override
252   - public IBinder onBind(Intent intent) {
253   - // TODO: Return the communication channel to the service.
254   - throw new UnsupportedOperationException("Not yet implemented");
255   - }
256   -
257   -
258   - /**
259   - * 歌曲播放完成
260   - *
261   - * @param mediaPlayer
262   - */
263   - @Override
264   - public void onCompletion(MediaPlayer mediaPlayer) {
265   -// UserService.getUid(getApplicationContext()
266   - boolean isRun = MySpHelper.getInstance(getApplicationContext(), Context.MODE_MULTI_PROCESS).getBoolean("keepService", false);
267   -
268   - if (isRun) {
269   - Log.e(TAG, "重新播放");
270   - mediaPlayer.start();
271   - Intent intent = new Intent("com.cnlive.strike.receiver.ServiceReceiver");
272   - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
273   - intent.setComponent(new ComponentName(getPackageName(), "com.cnlive.strike.receiver.ServiceReceiver"));//高版本Android发送广播需要加这句
274   - }
275   - sendBroadcast(intent);
276   - } else {
277   - Log.e(TAG, "停止重新播放");
278   - stopPlaySong();
279   - }
280   -
281   -
282   - }
283   -}
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/StepService.java
... ... @@ -11,7 +11,6 @@ import android.content.ComponentName;
11 11 import android.content.Context;
12 12 import android.content.Intent;
13 13 import android.content.IntentFilter;
14   -import android.content.SharedPreferences;
15 14 import android.hardware.Sensor;
16 15 import android.hardware.SensorEvent;
17 16 import android.hardware.SensorEventListener;
... ... @@ -27,19 +26,18 @@ import android.util.Log;
27 26 import android.widget.RemoteViews;
28 27 import android.widget.Toast;
29 28  
30   -import com.baidu.mapapi.model.LatLng;
31 29 import com.baidu.trace.LBSTraceClient;
32 30 import com.baidu.trace.Trace;
33   -import com.baidu.trace.api.entity.OnEntityListener;
34 31 import com.baidu.trace.api.fence.FenceAlarmPushInfo;
35 32 import com.baidu.trace.api.fence.MonitoredAction;
36 33 import com.baidu.trace.api.track.LatestPoint;
37 34 import com.baidu.trace.api.track.LatestPointResponse;
38 35 import com.baidu.trace.api.track.OnTrackListener;
  36 +import com.baidu.trace.model.LocationMode;
39 37 import com.baidu.trace.model.OnTraceListener;
40 38 import com.baidu.trace.model.PushMessage;
41 39 import com.baidu.trace.model.StatusCodes;
42   -import com.baidu.trace.model.TraceLocation;
  40 +import com.cnlive.moudle.pedometer.commonInfo.CommonInfo;
43 41 import com.cnlive.moudle.pedometer.model.Constant;
44 42 import com.cnlive.moudle.pedometer.model.MessageEvent;
45 43 import com.cnlive.moudle.pedometer.model.step.StepCount;
... ... @@ -49,9 +47,7 @@ import com.cnlive.moudle.pedometer.sql.db.DbCore;
49 47 import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity;
50 48 import com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity;
51 49 import com.cnlive.moudle.pedometer.utils.MySpHelper;
52   -import com.cnlive.moudle.pedometer.utils.TimeUtil;
53 50 import com.example.moudle_pedometer.R;
54   -import com.orhanobut.logger.Logger;
55 51  
56 52 import org.greenrobot.eventbus.EventBus;
57 53 import org.greenrobot.eventbus.Subscribe;
... ... @@ -180,6 +176,8 @@ public class StepService extends Service implements SensorEventListener {
180 176 mClient = new LBSTraceClient(getApplicationContext());
181 177 // 设置定位和打包周期
182 178 mClient.setInterval(gatherInterval, packInterval);
  179 + //设置定位模式
  180 + mClient.setLocationMode(LocationMode.High_Accuracy);
183 181 }
184 182 if (mTrace == null) {
185 183 mTrace = new Trace(serviceId, entityName);
... ... @@ -314,6 +312,7 @@ public class StepService extends Service implements SensorEventListener {
314 312 @Override
315 313 public void onPushCallback(byte messageType, PushMessage pushMessage) {
316 314 Log.e(TAG, "onPushCallback: ");
  315 +
317 316 if (messageType < 0x03 || messageType > 0x04) {
318 317 return;
319 318 }
... ... @@ -341,9 +340,9 @@ public class StepService extends Service implements SensorEventListener {
341 340 //开启轨迹服务
342 341 if (mClient != null) {
343 342 mClient.startTrace(mTrace, traceListener);
344   - long stepStartTime = MySpHelper.getInstance(getApplicationContext(), Context.MODE_MULTI_PROCESS).getLong("stepStartTime", 0);
  343 + long stepStartTime = CommonInfo.getStepStartTime(getApplicationContext());
345 344 if (stepStartTime == 0) {
346   - MySpHelper.getInstance(getApplicationContext(), Context.MODE_MULTI_PROCESS).putLong("stepStartTime", TimeUtil.getCurrentTime());
  345 + CommonInfo.getStepStartTime(getApplicationContext());
347 346 }
348 347 }
349 348  
... ... @@ -357,13 +356,12 @@ public class StepService extends Service implements SensorEventListener {
357 356 @SuppressLint("WrongConstant")
358 357 @Override
359 358 public int onStartCommand(Intent intent, int flags, int startId) {
360   -// userId=intent.getExtras().getString("userId");
361   - userId = MySpHelper.getInstance(getApplicationContext(), Context.MODE_MULTI_PROCESS).getString("userId", "");
  359 + userId =CommonInfo.getUserId(getApplicationContext());
362 360 if (userId != null && !TextUtils.isEmpty(userId)) {
363 361 if (!EventBus.getDefault().isRegistered(this)) {
364 362 EventBus.getDefault().register(this);
365 363 }
366   - MySpHelper.getInstance(getApplicationContext(), Context.MODE_MULTI_PROCESS).putBoolean("writeUserStep:" + userId, true);
  364 + CommonInfo.setIsWriteUserStep(getApplicationContext(), true);
367 365 entityName = userId;
368 366 initTodayData(userId);
369 367 initTrace();
... ... @@ -397,6 +395,7 @@ public class StepService extends Service implements SensorEventListener {
397 395 }
398 396  
399 397 private void init() {
  398 + CommonInfo.setIsRunStepService(getApplicationContext(), true);
400 399 if (null == mNM) {
401 400 mNM = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
402 401 }
... ... @@ -896,7 +895,7 @@ public class StepService extends Service implements SensorEventListener {
896 895 * 保存记步数据
897 896 */
898 897 private void save() {
899   - boolean isWriteUserStep = MySpHelper.getInstance(getApplicationContext(), Context.MODE_MULTI_PROCESS).getBoolean("writeUserStep:" + userId, false);
  898 + boolean isWriteUserStep = CommonInfo.getIsWriteUserStep(getApplicationContext());
900 899 if (!isWriteUserStep) {
901 900 return;
902 901 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/PedometerMainActivity.java
... ... @@ -246,4 +246,5 @@ public class PedometerMainActivity extends QMUIFragmentActivity {
246 246 public void onBackPressed() {
247 247 return;
248 248 }
  249 +
249 250 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/RunRaceDetailActivity.java
... ... @@ -15,6 +15,7 @@ import com.baidu.mapapi.SDKInitializer;
15 15 import com.cnlive.libs.base.ui.QMUIFragment;
16 16 import com.cnlive.libs.base.ui.QMUIFragmentActivity;
17 17 import com.cnlive.libs.base.util.StatusBarUtil2;
  18 +import com.cnlive.moudle.pedometer.commonInfo.CommonInfo;
18 19 import com.cnlive.moudle.pedometer.model.RunningMapBean;
19 20 import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity;
20 21 import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment;
... ... @@ -34,6 +35,7 @@ import java.util.List;
34 35 */
35 36 @Route(path = "/moudle_pedometer/RunRaceDetailActivity")
36 37 public class RunRaceDetailActivity extends QMUIFragmentActivity {
  38 + private QMUIFragment fragment;
37 39  
38 40 @Override
39 41 protected int getContextViewId() {
... ... @@ -45,15 +47,17 @@ public class RunRaceDetailActivity extends QMUIFragmentActivity {
45 47 super.onCreate(savedInstanceState);
46 48 StatusBarUtil2.setColor(this, getResources().getColor(R.color.run_main_bg), 0);
47 49 //判断用户是否结束运动
48   - String uid = "yangshuai";
49   - UserStepEntity userStepEntity = StepUtil.getUserStepData(getApplicationContext(), uid);
50   - //没有在数据库中找到相关记录
51   - if (userStepEntity == null) {
52   - addFragment(new RunRaceDetailFragment());
  50 + boolean isRunStep = CommonInfo.getIsRunStepService(this);
  51 + //没有找到相关记录
  52 + if (!isRunStep) {
  53 + fragment = new RunRaceDetailFragment();
53 54 }
54 55 //找到记录
55 56 else {
56   - addFragment(new RunMainFragment());
  57 + fragment = new RunMainFragment();
  58 + }
  59 + if (fragment != null) {
  60 + addFragment(fragment);
57 61 }
58 62 }
59 63  
... ... @@ -71,4 +75,14 @@ public class RunRaceDetailActivity extends QMUIFragmentActivity {
71 75  
72 76 }
73 77 }
  78 +
  79 + @Override
  80 + public void onBackPressed() {
  81 + super.onBackPressed();
  82 + if (fragment != null) {
  83 + if (fragment instanceof RunMainFragment) {
  84 + return;
  85 + }
  86 + }
  87 + }
74 88 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunMainFragment.java
... ... @@ -68,6 +68,9 @@ public class RunMainFragment extends QMUIFragment&lt;RunMainFragmentView, RunMainFr
68 68 if (EventBus.getDefault().isRegistered(this)) {
69 69 EventBus.getDefault().unregister(this);
70 70 }
  71 + if (getMvpView() != null) {
  72 + getMvpView().onDestroy();
  73 + }
71 74 }
72 75  
73 76 @Override
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunningMapFragment.java
... ... @@ -16,6 +16,7 @@ import android.view.View;
16 16 import com.baidu.mapapi.model.LatLng;
17 17 import com.cnlive.libs.base.ui.QMUIFragment;
18 18 import com.cnlive.libs.base.util.StatusBarUtil2;
  19 +import com.cnlive.moudle.pedometer.commonInfo.CommonInfo;
19 20 import com.cnlive.moudle.pedometer.frame.presenter.RunningMapFragmentPresenter;
20 21 import com.cnlive.moudle.pedometer.frame.view.RunningMapFragmentView;
21 22 import com.cnlive.moudle.pedometer.model.RunningMapBean;
... ... @@ -49,7 +50,7 @@ public class RunningMapFragment extends QMUIFragment&lt;RunningMapFragmentView, Run
49 50 private static final String TAG = "RunningMapFragment";
50 51 private RunningMapBean runningMapBean;
51 52 private SensorManager mSensorManager;
52   - 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},{\"latitude\":39.933903844942,\"latitudeE6\":3.9933903844942E7,\"longitude\":116.30918357649,\"longitudeE6\":1.1630918357649E8}]";
  53 + 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}]";
53 54 //创建震动服务对象
54 55 private Vibrator mVibrator;
55 56 private TipDialog tipDialog;
... ... @@ -107,7 +108,7 @@ public class RunningMapFragment extends QMUIFragment&lt;RunningMapFragmentView, Run
107 108 }
108 109 //开始进行历史轨迹查询
109 110 if (getPresenter() != null && !TextUtils.isEmpty(StepService.entityName)) {
110   - long stepStartTime = MySpHelper.getInstance(getActivity(), Context.MODE_MULTI_PROCESS).getLong("stepStartTime", 0);
  111 + long stepStartTime = CommonInfo.getStepStartTime(getActivity());
111 112 long startTime = 0;
112 113 if (stepStartTime != 0) {
113 114 startTime = stepStartTime;
... ... @@ -179,6 +180,7 @@ public class RunningMapFragment extends QMUIFragment&lt;RunningMapFragmentView, Run
179 180 if (EventBus.getDefault().isRegistered(this)) {
180 181 EventBus.getDefault().unregister(this);
181 182 }
  183 +
182 184 }
183 185  
184 186 @Subscribe(threadMode = ThreadMode.MAIN)
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/MyMapUtil.java
... ... @@ -14,6 +14,7 @@ import com.baidu.mapapi.model.LatLng;
14 14 import com.baidu.mapapi.utils.DistanceUtil;
15 15 import com.baidu.trace.model.SortType;
16 16 import com.cnlive.moudle.pedometer.model.RoutePoint;
  17 +import com.example.moudle_pedometer.R;
17 18  
18 19 import java.util.ArrayList;
19 20 import java.util.List;
... ... @@ -96,17 +97,23 @@ public class MyMapUtil {
96 97 /**
97 98 * 绘制服务器传过来的轨迹
98 99 */
99   - public static Overlay drawServerLineTrack(Context context, BaiduMap baiduMap, List<LatLng> points, SortType sortType, int lineColor, int startIconRes, int endIconRes) {
  100 + public static List<Overlay> drawServerLineTrack(Context context, BaiduMap baiduMap, List<LatLng> points, SortType sortType, int lineColor, int startIconRes, int endIconRes) {
100 101 // 绘制新覆盖物前,清空之前的覆盖物
101 102 if (points == null || points.size() == 0) {
102 103 return null;
103 104 }
  105 + List<Overlay> resultOverlays = new ArrayList<>();
104 106 //只有一个点
105 107 if (points.size() == 1) {
106   - Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), startIconRes), 40, 40);
107   - OverlayOptions startOptions = new MarkerOptions().position(points.get(0)).icon(BitmapDescriptorFactory.fromBitmap(pointBitmap));
108   -// .zIndex(9).draggable(true);
109   - return baiduMap.addOverlay(startOptions);
  108 + Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), startIconRes), 24, 30);
  109 + OverlayOptions startOptions = null;
  110 + if (pointBitmap != null) {
  111 + startOptions = new MarkerOptions().position(points.get(0)).icon(BitmapDescriptorFactory.fromBitmap(pointBitmap));
  112 + if (startOptions != null) {
  113 + resultOverlays.add(baiduMap.addOverlay(startOptions));
  114 + }
  115 + return resultOverlays;
  116 + }
110 117 }
111 118  
112 119 LatLng startPoint;
... ... @@ -120,30 +127,73 @@ public class MyMapUtil {
120 127 }
121 128  
122 129 // 添加起点图标
123   - Bitmap startPointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), startIconRes), 40, 40);
124   - OverlayOptions startOptions = new MarkerOptions()
125   - .position(startPoint)
126   - .icon(BitmapDescriptorFactory.fromBitmap(startPointBitmap))
127   - .perspective(false)
128   - .animateType(MarkerOptions.MarkerAnimateType.grow)
129   - ;
130   -// .zIndex(9).draggable(true);
  130 + Bitmap startPointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), startIconRes), 24, 30);
  131 + OverlayOptions startOptions = null;
  132 + if (startPointBitmap != null) {
  133 + startOptions = new MarkerOptions()
  134 + .position(startPoint)
  135 + .icon(BitmapDescriptorFactory.fromBitmap(startPointBitmap))
  136 + .perspective(false)
  137 + .animateType(MarkerOptions.MarkerAnimateType.grow);
  138 + }
131 139 // 添加终点图标
132   - Bitmap endPointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), endIconRes), 40, 40);
133   - OverlayOptions endOptions = new MarkerOptions()
134   - .position(endPoint)
135   - .icon(BitmapDescriptorFactory.fromBitmap(endPointBitmap))
136   - .perspective(false)
137   - .animateType(MarkerOptions.MarkerAnimateType.grow);
138   -// .zIndex(9).draggable(true);
139   -
  140 + Bitmap endPointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), endIconRes), 24, 30);
  141 + OverlayOptions endOptions = null;
  142 + if (endPointBitmap != null) {
  143 + endOptions = new MarkerOptions()
  144 + .position(endPoint)
  145 + .icon(BitmapDescriptorFactory.fromBitmap(endPointBitmap))
  146 + .perspective(false)
  147 + .anchor(0.6f, 0.96f)
  148 + .animateType(MarkerOptions.MarkerAnimateType.grow);
  149 + }
  150 + // 添加圆形范围
  151 + Bitmap startCircleBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), R.drawable.circle_point_raduis), 60, 60);
  152 + OverlayOptions startCircleOptions = null;
  153 + OverlayOptions endCircleOptions = null;
  154 + if (startCircleBitmap != null) {
  155 + startCircleOptions = new MarkerOptions()
  156 + .position(startPoint)
  157 + .icon(BitmapDescriptorFactory.fromBitmap(startCircleBitmap))
  158 + .perspective(false)
  159 + .anchor(0.5f, 0.6f)
  160 + .animateType(MarkerOptions.MarkerAnimateType.grow);
  161 +
  162 + endCircleOptions = new MarkerOptions()
  163 + .position(endPoint)
  164 + .icon(BitmapDescriptorFactory.fromBitmap(startCircleBitmap))
  165 + .perspective(false)
  166 + .anchor(0.5f, 0.6f)
  167 + .animateType(MarkerOptions.MarkerAnimateType.grow);
  168 + }
140 169 // 添加路线(轨迹)
141   - OverlayOptions polylineOptions = new PolylineOptions().width(10)
142   - .color(context.getResources().getColor(lineColor)).points(points);
  170 + OverlayOptions polylineOptions = null;
  171 + if (points != null && points.size() > 1) {
  172 + polylineOptions = new PolylineOptions().width(10)
  173 + .color(context.getResources().getColor(lineColor)).points(points);
  174 + }
  175 + if (endCircleOptions != null) {
  176 + resultOverlays.add(baiduMap.addOverlay(endCircleOptions));
  177 + }
  178 + if (startCircleOptions != null) {
  179 + resultOverlays.add(baiduMap.addOverlay(startCircleOptions));
  180 + }
  181 + if (startOptions != null) {
  182 + resultOverlays.add(baiduMap.addOverlay(startOptions));
143 183  
144   - baiduMap.addOverlay(startOptions);
145   - baiduMap.addOverlay(endOptions);
146   - return baiduMap.addOverlay(polylineOptions);
  184 + }
  185 + if (endOptions != null) {
  186 + resultOverlays.add(baiduMap.addOverlay(endOptions));
  187 + }
  188 + if (polylineOptions != null) {
  189 + resultOverlays.add(baiduMap.addOverlay(polylineOptions));
  190 +
  191 + }
  192 + if (resultOverlays != null) {
  193 + return resultOverlays;
  194 + } else {
  195 + return null;
  196 + }
147 197 }
148 198  
149 199  
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/MySpHelper.java
... ... @@ -140,4 +140,14 @@ public class MySpHelper {
140 140 private SharedPreferences getSP(String name) {
141 141 return context.getSharedPreferences(name, SP_MODE);
142 142 }
  143 +
  144 + public void removeKey(String key) {
  145 + try {
  146 + SharedPreferences.Editor editor = getSP().edit();
  147 + editor.remove(key);
  148 + editor.commit();
  149 + } catch (NullPointerException e) {
  150 + Log.d("hcj", "" + e);
  151 + }
  152 + }
143 153 }
... ...
moudle_pedometer/src/main/res/drawable-hdpi/circle_point_raduis.png 0 → 100644

2.73 KB

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

2.03 KB

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

1.38 KB

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

1.62 KB

moudle_pedometer/src/main/res/drawable-hdpi/icon_end.png

6.57 KB | W: | H:

2.85 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
moudle_pedometer/src/main/res/drawable-hdpi/icon_start.png

5.93 KB | W: | H:

2.97 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
moudle_pedometer/src/main/res/drawable-hdpi/rt_ic_location.png 0 → 100644

5.19 KB

moudle_pedometer/src/main/res/drawable-hdpi/rt_ic_location.webp deleted 100644 → 0
No preview for this file type
moudle_pedometer/src/main/res/drawable-hdpi/rt_training_gps_0.png 0 → 100644

414 Bytes

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

306 Bytes

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

440 Bytes

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

444 Bytes

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

1.03 KB

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

6.33 KB

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

3.11 KB

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

2.44 KB

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

1.89 KB

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

1.99 KB

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

3.58 KB

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

3.73 KB

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

5.19 KB

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

146 Bytes

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

133 Bytes

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

212 Bytes

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

188 Bytes

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

9.53 KB

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

6.3 KB

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

4.66 KB

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

3.54 KB

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

3.79 KB

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

6.98 KB

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

7.3 KB

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

5.19 KB

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

501 Bytes

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

384 Bytes

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

723 Bytes

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

636 Bytes

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

18.7 KB

moudle_pedometer/src/main/res/drawable/layer_gps_shadow.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  3 +
  4 + <!--边-->
  5 + <item>
  6 + <shape android:shape="rectangle">
  7 + <padding
  8 + android:bottom="3px"
  9 + android:left="2px"
  10 + android:right="2px"
  11 + android:top="2px" />
  12 +
  13 + <solid android:color="#00eeeeee" />
  14 +
  15 + <corners android:radius="50dp" />
  16 + </shape>
  17 + </item>
  18 + <item>
  19 + <shape android:shape="rectangle">
  20 + <padding
  21 + android:bottom="3px"
  22 + android:left="2px"
  23 + android:right="2px"
  24 + android:top="2px" />
  25 +
  26 + <solid android:color="#0Deeeeee" />
  27 +
  28 + <corners android:radius="50dp" />
  29 + </shape>
  30 + </item>
  31 + <item>
  32 + <shape android:shape="rectangle">
  33 + <padding
  34 + android:bottom="3px"
  35 + android:left="2px"
  36 + android:right="2px"
  37 + android:top="2px" />
  38 + <solid android:color="#0D4F4F4F" />
  39 + <corners android:radius="50dp" />
  40 + </shape>
  41 + </item>
  42 + <item>
  43 + <shape android:shape="rectangle">
  44 + <padding
  45 + android:bottom="3px"
  46 + android:left="2px"
  47 + android:right="2px"
  48 + android:top="2px" />
  49 + <solid android:color="#0D4F4F4F" />
  50 + <corners android:radius="50dp" />
  51 + </shape>
  52 + </item>
  53 + <item>
  54 + <shape android:shape="rectangle">
  55 + <padding
  56 + android:bottom="3px"
  57 + android:left="2px"
  58 + android:right="2px"
  59 + android:top="2px" />
  60 + <solid android:color="#1A4F4F4F" />
  61 + <corners android:radius="50dp" />
  62 + </shape>
  63 + </item>
  64 +
  65 + <!--中心背景 -->
  66 + <item>
  67 + <shape
  68 + android:shape="rectangle"
  69 + android:useLevel="false">
  70 + <!--实心 -->
  71 + <solid android:color="@color/white" />
  72 + <corners android:radius="50dp" />
  73 + <size
  74 + android:width="32dp"
  75 + android:height="32dp" />
  76 +
  77 + </shape>
  78 + </item>
  79 +
  80 +</layer-list>
0 81 \ No newline at end of file
... ...
moudle_pedometer/src/main/res/drawable/layer_shadow.xml
... ... @@ -5,64 +5,64 @@
5 5 <item>
6 6 <shape android:shape="rectangle">
7 7 <padding
8   - android:bottom="7px"
9   - android:left="7px"
10   - android:right="7px"
11   - android:top="5px" />
12   -
13   - <solid android:color="#00eeeeee" />
14   -
  8 + android:bottom="6px"
  9 + android:left="3px"
  10 + android:right="3px"
  11 + android:top="3px" />
  12 + <solid android:color="#0DF8F8FF" />
15 13 <corners android:radius="5dp" />
16 14 </shape>
17 15 </item>
18 16 <item>
19 17 <shape android:shape="rectangle">
20 18 <padding
21   - android:bottom="7px"
22   - android:left="7px"
23   - android:right="7px"
24   - android:top="5px" />
25   -
26   - <solid android:color="#0Deeeeee" />
27   -
  19 + android:bottom="6px"
  20 + android:left="3px"
  21 + android:right="3px"
  22 + android:top="3px" />
  23 + <solid android:color="#0DE8E8E8" />
28 24 <corners android:radius="5dp" />
29 25 </shape>
30 26 </item>
31 27 <item>
32 28 <shape android:shape="rectangle">
33 29 <padding
34   - android:bottom="7px"
35   - android:left="7px"
36   - android:right="7px"
37   - android:top="5px" />
38   - <solid android:color="#0Deeeeee" />
  30 + android:bottom="6px"
  31 + android:left="3px"
  32 + android:right="3px"
  33 + android:top="3px" />
  34 + <solid android:color="#0DCFCFCF" />
  35 +
39 36 <corners android:radius="5dp" />
40 37 </shape>
41 38 </item>
42 39 <item>
43 40 <shape android:shape="rectangle">
44 41 <padding
45   - android:bottom="7px"
46   - android:left="7px"
47   - android:right="7px"
48   - android:top="5px" />
49   - <solid android:color="#0Deeeeee" />
  42 + android:bottom="6px"
  43 + android:left="3px"
  44 + android:right="3px"
  45 + android:top="3px" />
  46 + <solid android:color="#0DB5B5B5" />
50 47 <corners android:radius="5dp" />
51 48 </shape>
52 49 </item>
53 50 <item>
54 51 <shape android:shape="rectangle">
55 52 <padding
56   - android:bottom="7px"
57   - android:left="7px"
58   - android:right="7px"
59   - android:top="5px" />
  53 + android:bottom="6px"
  54 + android:left="3px"
  55 + android:right="3px"
  56 + android:top="3px" />
  57 +
  58 + <solid android:color="#0D9C9C9C" />
60 59  
61   - <solid android:color="#0Deeeeee" />
62 60 <corners android:radius="5dp" />
63 61 </shape>
64 62 </item>
65 63  
  64 +
  65 +
66 66 <!--中心背景 -->
67 67 <item>
68 68 <shape
... ...
moudle_pedometer/src/main/res/drawable/shape_30dp_white_raduis_bg.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<shape xmlns:android="http://schemas.android.com/apk/res/android">
  3 + <solid android:color="@color/white" />
  4 + <corners android:radius="50dp" />
  5 +</shape>
0 6 \ No newline at end of file
... ...
moudle_pedometer/src/main/res/drawable/shape_circle_green_25.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 + <solid android:color="@color/green_25" />
  5 +</shape>
0 6 \ No newline at end of file
... ...
moudle_pedometer/src/main/res/layout/fragment_run_main.xml
... ... @@ -79,24 +79,47 @@
79 79 android:textSize="18sp"
80 80 android:textStyle="bold" />
81 81  
  82 + <ImageView
  83 + android:id="@+id/iv_gps"
  84 + android:layout_width="18dp"
  85 + android:layout_height="5dp"
  86 + android:layout_centerVertical="true"
  87 + android:layout_marginLeft="5dp"
  88 + android:layout_toRightOf="@id/tv_gps"
  89 + />
  90 +
82 91 <TextView
83 92 android:id="@+id/tv_look_trace"
84 93 android:layout_width="wrap_content"
85 94 android:layout_height="wrap_content"
86 95 android:layout_centerVertical="true"
87   - android:layout_marginLeft="15dp"
88   - android:layout_toRightOf="@id/tv_gps"
89   - android:text="(点击查看轨迹)"
90   - android:textColor="@color/text_gray"
  96 + android:layout_marginLeft="5dp"
  97 + android:layout_toRightOf="@id/iv_gps"
  98 + android:textColor="@color/text_gray99"
91 99 android:textSize="12sp"
92 100 android:textStyle="bold" />
93 101  
94   - <ImageView
95   - android:layout_width="55dp"
96   - android:layout_height="55dp"
  102 + <LinearLayout
  103 + android:layout_width="wrap_content"
  104 + android:layout_height="wrap_content"
97 105 android:layout_alignParentRight="true"
98 106 android:layout_marginRight="15dp"
99   - android:src="@drawable/rt_ic_home_map" />
  107 + android:gravity="center"
  108 + android:orientation="vertical">
  109 +
  110 + <ImageView
  111 + android:layout_width="55dp"
  112 + android:layout_height="55dp"
  113 + android:src="@drawable/rt_ic_home_map" />
  114 +
  115 + <TextView
  116 + android:layout_width="wrap_content"
  117 + android:layout_height="wrap_content"
  118 + android:layout_marginTop="5dp"
  119 + android:text="点击查看轨迹"
  120 + android:textColor="@color/text_gray99"
  121 + android:textSize="10sp" />
  122 + </LinearLayout>
100 123 </RelativeLayout>
101 124 <!--计时-->
102 125 <LinearLayout
... ... @@ -139,9 +162,9 @@
139 162 android:layout_marginTop="5dp"
140 163 android:gravity="center"
141 164 android:text="配速"
142   - android:textColor="@color/text_gray"
  165 + android:textColor="@color/text_gray99"
143 166 android:textSize="15sp"
144   - android:textStyle="bold" />
  167 + />
145 168 </LinearLayout>
146 169 <!--用时-->
147 170 <LinearLayout
... ... @@ -172,9 +195,9 @@
172 195 android:layout_marginTop="5dp"
173 196 android:gravity="center"
174 197 android:text="用时"
175   - android:textColor="@color/text_gray"
  198 + android:textColor="@color/text_gray99"
176 199 android:textSize="15sp"
177   - android:textStyle="bold" />
  200 + />
178 201 </LinearLayout>
179 202 <!--热量-->
180 203 <LinearLayout
... ... @@ -206,9 +229,9 @@
206 229 android:layout_marginTop="5dp"
207 230 android:gravity="center"
208 231 android:text="步"
209   - android:textColor="@color/text_gray"
  232 + android:textColor="@color/text_gray99"
210 233 android:textSize="15sp"
211   - android:textStyle="bold" />
  234 + />
212 235 </LinearLayout>
213 236 </LinearLayout>
214 237  
... ...
moudle_pedometer/src/main/res/layout/fragment_running_map.xml
... ... @@ -11,11 +11,21 @@
11 11 android:layout_width="match_parent"
12 12 android:layout_height="match_parent"></com.baidu.mapapi.map.MapView>
13 13  
  14 + <!--地图上面加一层类似于全透明黑色蒙版-->
  15 + <LinearLayout
  16 + android:layout_width="match_parent"
  17 + android:layout_height="match_parent"
  18 + android:background="#0D000000"
  19 + android:clickable="false"
  20 + android:focusable="false"
  21 + android:focusableInTouchMode="false"></LinearLayout>
  22 +
14 23 <FrameLayout
15 24 android:id="@+id/fl_back"
16   - android:layout_width="55dp"
17   - android:layout_height="55dp"
18   - android:background="@drawable/button_fab_white"
  25 + android:layout_width="40dp"
  26 + android:layout_height="40dp"
  27 + android:layout_margin="10dp"
  28 + android:background="@drawable/circle_white_shadow_bg"
19 29 android:focusable="true">
20 30  
21 31 <ImageView
... ... @@ -23,11 +33,59 @@
23 33 android:layout_height="20dp"
24 34 android:layout_gravity="center"
25 35 android:layout_marginLeft="-2dp"
  36 + android:layout_marginBottom="3dp"
26 37 android:background="@drawable/icon_back"
27 38 android:focusable="false" />
28 39 </FrameLayout>
29 40  
30 41 <LinearLayout
  42 + android:layout_width="wrap_content"
  43 + android:layout_height="wrap_content"
  44 + android:layout_gravity="top|right"
  45 + android:layout_marginTop="15dp"
  46 + android:layout_marginRight="10dp"
  47 + android:orientation="vertical">
  48 +
  49 + <LinearLayout
  50 + android:layout_width="80dp"
  51 + android:layout_height="35dp"
  52 + android:layout_gravity="right"
  53 + android:background="@drawable/gps_white_shadow"
  54 + android:gravity="center">
  55 +
  56 + <TextView
  57 + android:layout_width="wrap_content"
  58 + android:layout_height="wrap_content"
  59 + android:layout_marginBottom="3dp"
  60 + android:text="GPS"
  61 + android:textColor="@color/text_black"
  62 + android:textSize="12sp"
  63 + android:textStyle="bold" />
  64 +
  65 + <ImageView
  66 + android:id="@+id/iv_gps_state"
  67 + android:layout_width="18dp"
  68 + android:layout_height="5dp"
  69 + android:layout_marginLeft="5dp"
  70 + android:layout_marginBottom="3dp" />
  71 + </LinearLayout>
  72 + <!---->
  73 + <TextView
  74 + android:id="@+id/tv_gps_pop_bg"
  75 + android:layout_width="wrap_content"
  76 + android:layout_height="45dp"
  77 + android:layout_marginTop="-5dp"
  78 + android:background="@drawable/gps_tip_bg"
  79 + android:gravity="center"
  80 + android:paddingLeft="15dp"
  81 + android:paddingRight="15dp"
  82 + android:textColor="@color/text_black"
  83 + android:textSize="12sp"
  84 + android:visibility="gone"/>
  85 + <!---->
  86 + </LinearLayout>
  87 +
  88 + <LinearLayout
31 89 android:layout_width="match_parent"
32 90 android:layout_height="wrap_content"
33 91 android:layout_gravity="bottom"
... ... @@ -35,32 +93,33 @@
35 93  
36 94 <FrameLayout
37 95 android:id="@+id/fl_location"
38   - android:layout_width="55dp"
39   - android:layout_height="55dp"
  96 + android:layout_width="40dp"
  97 + android:layout_height="40dp"
  98 + android:layout_marginLeft="10dp"
40 99 android:layout_marginBottom="20dp"
41   - android:background="@drawable/button_fab_white"
  100 + android:background="@drawable/circle_white_shadow_bg"
42 101 android:focusable="true">
43 102  
44 103 <ImageView
45 104 android:layout_width="20dp"
46 105 android:layout_height="20dp"
47 106 android:layout_gravity="center"
  107 + android:layout_marginBottom="3dp"
48 108 android:background="@drawable/rt_ic_location_blank"
49 109 android:focusable="false" />
50 110 </FrameLayout>
51 111  
52 112 <LinearLayout
53 113 android:layout_width="match_parent"
54   - android:layout_height="100dp"
55   - android:layout_marginLeft="10dp"
56   - android:layout_marginRight="10dp"
57   - android:layout_marginBottom="20dp"
58   - android:background="@drawable/shape_10dp_white_raduis_bg">
  114 + android:layout_height="130dp"
  115 + android:layout_marginBottom="10dp"
  116 + android:background="@drawable/white_shadow_bg"
  117 + android:scaleX="1.02">
59 118  
60 119 <LinearLayout
61 120 android:layout_width="0dp"
62 121 android:layout_height="match_parent"
63   - android:layout_weight="1"
  122 + android:layout_weight="1.2"
64 123 android:gravity="center"
65 124 android:orientation="vertical"
66 125 android:paddingLeft="5dp"
... ... @@ -87,7 +146,7 @@
87 146 <LinearLayout
88 147 android:layout_width="0dp"
89 148 android:layout_height="match_parent"
90   - android:layout_weight="1.5"
  149 + android:layout_weight="1.2"
91 150 android:gravity="center"
92 151 android:orientation="vertical">
93 152  
... ...
moudle_pedometer/src/main/res/layout/layout_run_detail_person_score.xml
... ... @@ -7,11 +7,12 @@
7 7 <LinearLayout
8 8 android:layout_width="match_parent"
9 9 android:layout_height="180dp"
10   - android:layout_marginLeft="1dp"
11   - android:layout_marginRight="1dp"
12   - android:layout_marginBottom="5dp"
13   - android:background="@drawable/layer_shadow"
14   - android:orientation="vertical">
  10 + android:background="@drawable/white_shadow_bg"
  11 + android:orientation="vertical"
  12 + android:paddingLeft="15dp"
  13 + android:paddingTop="5dp"
  14 + android:paddingRight="15dp"
  15 + android:paddingBottom="15dp">
15 16  
16 17 <LinearLayout
17 18 android:layout_width="match_parent"
... ...
moudle_pedometer/src/main/res/layout/layout_run_detail_rank.xml
... ... @@ -11,11 +11,11 @@
11 11 <LinearLayout
12 12 android:layout_width="match_parent"
13 13 android:layout_height="150dp"
14   - android:layout_marginLeft="1dp"
15   - android:layout_marginTop="10dp"
16   - android:layout_marginRight="1dp"
17   - android:layout_marginBottom="15dp"
18   - android:background="@drawable/layer_shadow"
  14 + android:paddingLeft="15dp"
  15 + android:paddingTop="5dp"
  16 + android:paddingRight="15dp"
  17 + android:paddingBottom="15dp"
  18 + android:background="@drawable/white_shadow_bg"
19 19 android:orientation="vertical">
20 20  
21 21 <LinearLayout
... ...
moudle_pedometer/src/main/res/values/colors.xml
... ... @@ -3,6 +3,8 @@
3 3 <color name="run_main_bg">#3D3745</color>
4 4 <color name="run_main_time_bg">#5BC4A4</color>
5 5 <color name="text_gray">#666666</color>
  6 + <color name="text_gray99">#999999</color>
  7 +
6 8 <color name="green_round">#5BC4A4</color>
7 9 <color name="red_round">#F97070</color>
8 10 <color name="gray_round">#D6D6D6</color>
... ... @@ -22,6 +24,8 @@
22 24  
23 25 <color name="green">#23D026</color>
24 26 <color name="green_50">#8023D026</color>
  27 + <color name="green_25">#4023D41E</color>
  28 +
25 29  
26 30 <color name="red">#EF5544</color>
27 31 <color name="bg">#012648</color>
... ...
moudle_pedometer/src/main/res/values/strings.xml
... ... @@ -63,5 +63,9 @@
63 63 <string name="all_time">累计用时</string>
64 64 <string name="has_take_part_line">我跑过的线路</string>
65 65 <string name="chek_all_line">查看全部路线</string>
  66 + <string name="loc_gps_accuracy_unknown">无信号,无法进行数据记录</string>
  67 + <string name="loc_gps_accuracy_bad">信号糟糕,数据准确度低</string>
  68 + <string name="loc_gps_accuracy_mid">GPS信号质量中等</string>
  69 + <string name="loc_gps_accuracy_good">GPS信号质量好</string>
66 70 <!---->
67 71 </resources>
... ...