Commit 8072d95a6dca1e990cf7870102247ed6ee751ee7

Authored by 杨帅
1 parent 8409813c

1、完成活动赛事详情页面搭建

Showing 42 changed files with 1920 additions and 246 deletions
app/src/main/AndroidManifest.xml
... ... @@ -23,13 +23,8 @@
23 23  
24 24 <meta-data
25 25 android:name="com.baidu.lbsapi.API_KEY"
26   - android:value="Q7y9SGcZVs0tmhbNTiaz0jHm4S1xGzE2" />
  26 + android:value="${BAIDU_MAP_APP_KEY}" />
27 27  
28   - <!--跑步-->
29   - <service
30   - android:name="com.baidu.location.f"
31   - android:enabled="true"
32   - android:process=":remote" />
33 28  
34 29 </application>
35 30  
... ...
app/src/main/java/com/example/modulepedometer/MainActivity.java
... ... @@ -8,6 +8,7 @@ import android.view.View;
8 8  
9 9 import com.alibaba.android.arouter.launcher.ARouter;
10 10 import com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity;
  11 +import com.cnlive.moudle.pedometer.ui.activity.RunRaceDetailActivity;
11 12  
12 13  
13 14 public class MainActivity extends AppCompatActivity {
... ... @@ -17,7 +18,8 @@ public class MainActivity extends AppCompatActivity {
17 18 super.onCreate(savedInstanceState);
18 19 setContentView(R.layout.activity_main);
19 20 ARouter.getInstance()
20   - .build("/moudle_pedometer/InterestActivity")
  21 +// .build("/moudle_pedometer/InterestActivity")
  22 + .build("/moudle_pedometer/RunRaceDetailActivity")
21 23 .navigation(this);
22 24 finish();
23 25 // BottomSheetDialog bottomSheetDialog=new BottomSheetDialog(this);
... ...
moudle_pedometer/src/main/AndroidManifest.xml
... ... @@ -3,10 +3,6 @@
3 3 xmlns:tools="http://schemas.android.com/tools"
4 4 package="com.example.moudle_pedometer">
5 5  
6   - <permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" />
7   - <permission android:name="android.permission.FORCE_STOP_PACKAGES" />
8   -
9   -
10 6 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
11 7 <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
12 8 <uses-permission android:name="android.permission.WAKE_LOCK" />
... ... @@ -14,7 +10,28 @@
14 10 <uses-permission android:name="android.permission.VIBRATE" />
15 11 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
16 12 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
17   - <uses-permission android:name="android.permission.BROADCAST_STICKY" />
  13 + <!--//获取设备网络状态,禁用后无法获取网络状态-->
  14 + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  15 + <!--//网络权限,当禁用后,无法进行检索等相关业务-->
  16 + <uses-permission android:name="android.permission.INTERNET" />
  17 + <!--//读取设备硬件信息,统计数据-->
  18 + <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  19 + <!--//读取系统信息,包含系统版本等信息,用作统计-->
  20 + <uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" />
  21 + <!--//获取设备的网络状态,鉴权所需网络代理-->
  22 + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  23 + <!--//允许sd卡写权限,需写入地图数据,禁用后无法显示地图-->
  24 + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  25 + <!--//这个权限用于进行网络定位-->
  26 + <uses-permission
  27 + android:name="android.permission.WRITE_SETTINGS"
  28 + tools:ignore="ProtectedPermissions" />
  29 + <!--//这个权限用于访问GPS定位-->
  30 + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  31 + <!--//获取统计数据-->
  32 + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  33 + <!--//使用步行AR导航,配置Camera权限-->
  34 + <uses-permission android:name="android.permission.CAMERA" />
18 35 <uses-permission
19 36 android:name="android.permission.SET_ALWAYS_FINISH"
20 37 tools:ignore="ProtectedPermissions" />
... ... @@ -45,7 +62,10 @@
45 62 android:required="true" />
46 63  
47 64 <application android:persistent="true">
48   -
  65 + <service
  66 + android:name="com.baidu.location.f"
  67 + android:enabled="true"
  68 + android:process=":remote" />
49 69 <service
50 70  
51 71 android:name="com.cnlive.moudle.pedometer.service.StepService"
... ... @@ -89,6 +109,10 @@
89 109 <activity
90 110 android:name="com.cnlive.moudle.pedometer.ui.activity.RunningMapActivity"
91 111 android:process=":step" />
  112 +
  113 + <activity
  114 + android:name="com.cnlive.moudle.pedometer.ui.activity.RunRaceDetailActivity"
  115 + android:process=":step" />
92 116 </application>
93 117  
94 118 </manifest>
95 119 \ No newline at end of file
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/presenter/RunRaceDetailFragmentPresenter.java 0 → 100644
  1 +package com.cnlive.moudle.pedometer.frame.presenter;
  2 +
  3 +import com.cnlive.moudle.pedometer.frame.view.RunRaceDetailFragmentView;
  4 +import com.cnlive.moudle.pedometer.frame.view.RunningMapFragmentView;
  5 +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
  6 +
  7 +public class RunRaceDetailFragmentPresenter extends MvpBasePresenter<RunRaceDetailFragmentView> {
  8 +}
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunMainFragmentView.java
1 1 package com.cnlive.moudle.pedometer.frame.view;
2 2  
3   -import android.animation.Animator;
4   -import android.animation.AnimatorSet;
5   -import android.animation.ObjectAnimator;
6 3 import android.content.Context;
7 4 import android.content.Intent;
8   -import android.os.Build;
9 5 import android.os.Handler;
10 6 import android.os.SystemClock;
11 7 import android.support.v4.content.ContextCompat;
12 8 import android.util.Log;
13 9 import android.view.MotionEvent;
14 10 import android.view.View;
15   -import android.view.ViewAnimationUtils;
16   -import android.view.animation.DecelerateInterpolator;
17 11 import android.widget.Chronometer;
18 12  
  13 +import com.cnlive.moudle.pedometer.model.RunningMapBean;
19 14 import com.cnlive.moudle.pedometer.model.Constant;
20 15 import com.cnlive.moudle.pedometer.model.MessageEvent;
21 16 import com.cnlive.moudle.pedometer.service.StepService;
... ... @@ -23,6 +18,7 @@ import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity;
23 18 import com.cnlive.moudle.pedometer.ui.activity.RunningMapActivity;
24 19 import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment;
25 20 import com.cnlive.moudle.pedometer.ui.widget.SelectDialog;
  21 +import com.cnlive.moudle.pedometer.utils.ButtonAnimUtil;
26 22 import com.cnlive.moudle.pedometer.utils.StepUtil;
27 23 import com.example.moudle_pedometer.R;
28 24 import com.hannesdorfmann.mosby3.mvp.MvpView;
... ... @@ -31,10 +27,6 @@ import org.greenrobot.eventbus.EventBus;
31 27  
32 28 public class RunMainFragmentView implements MvpView {
33 29 private final String TAG = "RunMainFragmentView";
34   - private final int DEFAULT_ZOOM_DURATION = 50;//默认缩放动画时间间隔
35   - private final int SHOW_VIEW_ZOOM_DURATION = 150;//显示控件缩放动画时间间隔
36   - private final int HIDE_VIEW_ZOOM_DURATION = 100;//隐藏控件缩放动画时间间隔
37   -
38 30 private RunMainFragment fragment;
39 31 private boolean stopStartFlag = false;
40 32 private boolean continueStartFlag = false;
... ... @@ -48,7 +40,7 @@ public class RunMainFragmentView implements MvpView {
48 40 private int timeCountDown;//时间倒计时
49 41  
50 42 private String uid;
51   -
  43 + private boolean needWriteDataFlag = true;//是否需要将计时器基值写入到数据库
52 44  
53 45 public RunMainFragmentView(RunMainFragment fragment) {
54 46 this.fragment = fragment;
... ... @@ -68,7 +60,7 @@ public class RunMainFragmentView implements MvpView {
68 60 public void initView() {
69 61 uid = "123";
70 62 fragment.binding.llRunMainRoot.setVisibility(View.GONE);
71   - startAnimation(fragment.binding.llStartTimeTip, false);
  63 + ButtonAnimUtil.startAnimation(fragment.binding.llStartTimeTip, false);
72 64 firstTimeFlag = true;
73 65 handler = new Handler();
74 66 timeCountDown = 4;
... ... @@ -80,11 +72,11 @@ public class RunMainFragmentView implements MvpView {
80 72 timeCountDown--;
81 73 fragment.binding.tvTimeCountDown.setVisibility(View.VISIBLE);
82 74 fragment.binding.tvTimeCountDown.setText(timeCountDown + "");
83   - setTimeShowZoomIn(fragment.binding.tvTimeCountDown);
  75 + ButtonAnimUtil.setTimeShowZoomIn(fragment.binding.tvTimeCountDown);
84 76 //依次倒计时
85 77 handler.postDelayed(runnable, 1000);
86 78 } else {
87   - startAnimation(fragment.binding.llStartTimeTip, true);
  79 + ButtonAnimUtil.startAnimation(fragment.binding.llStartTimeTip, true);
88 80 fragment.binding.llRunMainRoot.setVisibility(View.VISIBLE);
89 81 new Handler().postDelayed(new Runnable() {
90 82 @Override
... ... @@ -121,6 +113,7 @@ public class RunMainFragmentView implements MvpView {
121 113 } else {
122 114 chronometer.setFormat("%s");
123 115 }
  116 +
124 117 }
125 118 });
126 119 UserStepEntity userStepEntity = StepUtil.getUserStepData(fragment.getActivity(), uid);
... ... @@ -163,12 +156,12 @@ public class RunMainFragmentView implements MvpView {
163 156 }
164 157 if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
165 158 if (!continueStartFlag) {
166   - setViewZoomIn(fragment.binding.flContinue);
  159 + ButtonAnimUtil.setViewZoomIn(fragment.binding.flContinue);
167 160 continueStartFlag = true;
168 161  
169 162 }
170 163 } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
171   - setViewZoomOut(fragment.binding.flContinue);
  164 + ButtonAnimUtil.setViewZoomOut(fragment.binding.flContinue);
172 165 continueStartFlag = false;
173 166 }
174 167 return false;
... ... @@ -178,6 +171,7 @@ public class RunMainFragmentView implements MvpView {
178 171 fragment.binding.flContinue.setOnClickListener(new View.OnClickListener() {
179 172 @Override
180 173 public void onClick(View view) {
  174 + needWriteDataFlag = true;
181 175 //将当前计时器时间戳写入数据库
182 176 setSQLPauseTime();
183 177 //为了点击时可以显示缩放动画,这里延迟一个动画时间进行(包括放大和缩小)
... ... @@ -188,12 +182,12 @@ public class RunMainFragmentView implements MvpView {
188 182 //隐藏两个按钮
189 183 fragment.binding.flStopTip.setVisibility(View.INVISIBLE);
190 184 fragment.binding.llTwoBottomButton.setVisibility(View.GONE);
191   - setViewShowZoomIn(fragment.binding.llPause);
  185 + ButtonAnimUtil.setViewShowZoomIn(fragment.binding.llPause);
192 186 //显示暂停按钮
193 187 fragment.binding.llPause.setVisibility(View.VISIBLE);
194 188 //
195 189 }
196   - }, DEFAULT_ZOOM_DURATION * 2);
  190 + }, ButtonAnimUtil.DEFAULT_ZOOM_DURATION * 2);
197 191 //继续计步
198 192 EventBus.getDefault().post(new MessageEvent(Constant.SERVICE_STEP_COUNT_CONTINUE, ""));
199 193 //开始计时
... ... @@ -215,7 +209,13 @@ public class RunMainFragmentView implements MvpView {
215 209 }
216 210 if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
217 211 if (!stopStartFlag) {
218   - setViewZoomIn(fragment.binding.flStop);
  212 + fragment.binding.cpCurrent.setProgress(0);
  213 + fragment.binding.cpCurrent.setMax(100);
  214 + fragment.binding.cpCurrent.setCircleWidth(5);
  215 + fragment.binding.cpCurrent.setBackgroundColor(getContext().getResources().getColor(R.color.circle_stop));
  216 + fragment.binding.cpCurrent.setVisibility(View.VISIBLE);
  217 +
  218 + ButtonAnimUtil.setViewZoomIn(fragment.binding.flStop);
219 219 stopStartFlag = true;
220 220 runnable = new Runnable() {
221 221 @Override
... ... @@ -254,15 +254,11 @@ public class RunMainFragmentView implements MvpView {
254 254 }
255 255 }
256 256 };
257   - fragment.binding.cpCurrent.setProgress(0);
258   - fragment.binding.cpCurrent.setMax(100);
259   - fragment.binding.cpCurrent.setCircleWidth(5);
260   - fragment.binding.cpCurrent.setBackgroundColor(getContext().getResources().getColor(R.color.circle_stop));
261   - fragment.binding.cpCurrent.setVisibility(View.VISIBLE);
262 257 handler.postDelayed(runnable, 20);
  258 +
263 259 }
264 260 } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
265   - setViewZoomOut(fragment.binding.flStop);
  261 + ButtonAnimUtil.setViewZoomOut(fragment.binding.flStop);
266 262 stopStartFlag = false;
267 263 fragment.binding.cpCurrent.setVisibility(View.GONE);
268 264 stopIndex = 0;
... ... @@ -276,12 +272,12 @@ public class RunMainFragmentView implements MvpView {
276 272 public boolean onTouch(View view, MotionEvent motionEvent) {
277 273 if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
278 274 if (!pauseStartFlag) {
279   - setViewZoomIn(fragment.binding.flPause);
  275 + ButtonAnimUtil.setViewZoomIn(fragment.binding.flPause);
280 276 pauseStartFlag = true;
281 277  
282 278 }
283 279 } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
284   - setViewZoomOut(fragment.binding.flPause);
  280 + ButtonAnimUtil.setViewZoomOut(fragment.binding.flPause);
285 281 pauseStartFlag = false;
286 282 }
287 283 return false;
... ... @@ -293,18 +289,19 @@ public class RunMainFragmentView implements MvpView {
293 289 public void onClick(View view) {
294 290 //将当前计时器时间戳写入数据库
295 291 setSQLPauseTime();
296   - setViewHideZoomOut(fragment.binding.llPause);
  292 + needWriteDataFlag = false;
  293 + ButtonAnimUtil.setViewHideZoomOut(fragment.binding.llPause);
297 294 handler.postDelayed(new Runnable() {
298 295 @Override
299 296 public void run() {
300 297 //隐藏本身
301 298 fragment.binding.llPause.setVisibility(View.GONE);
302 299 }
303   - }, HIDE_VIEW_ZOOM_DURATION);
  300 + }, ButtonAnimUtil.HIDE_VIEW_ZOOM_DURATION);
304 301 //显示继续按钮
305 302 fragment.binding.llTwoBottomButton.setVisibility(View.VISIBLE);
306   - setViewShowZoomIn(fragment.binding.flContinue);
307   - setViewShowZoomIn(fragment.binding.flStop);
  303 + ButtonAnimUtil.setViewShowZoomIn(fragment.binding.flContinue);
  304 + ButtonAnimUtil.setViewShowZoomIn(fragment.binding.flStop);
308 305 //停止计时
309 306 fragment.binding.chronometer.stop();
310 307 mRecordTime = SystemClock.elapsedRealtime();
... ... @@ -318,21 +315,37 @@ public class RunMainFragmentView implements MvpView {
318 315 fragment.binding.rlGps.setOnClickListener(new View.OnClickListener() {
319 316 @Override
320 317 public void onClick(View view) {
321   - RunningMapActivity.startActivity(fragment.getActivity());
  318 + RunningMapBean runningMapBean = new RunningMapBean();
  319 + runningMapBean.setTimeBase(fragment.binding.chronometer.getBase());
  320 + //判断用户是否点击暂停按钮
  321 + if (needWriteDataFlag) {
  322 + runningMapBean.setPause(false);
  323 + runningMapBean.setRecordTime(SystemClock.elapsedRealtime());
  324 + }
  325 + //点击暂停
  326 + else {
  327 + runningMapBean.setPause(true);
  328 + runningMapBean.setPauseShowTime(fragment.binding.chronometer.getText().toString());
  329 + runningMapBean.setRecordTime(mRecordTime);
  330 + }
  331 + runningMapBean.setDistance(fragment.binding.tvRunDistance.getText().toString());
  332 + runningMapBean.setCurrentSpeed(fragment.binding.tvSpeed.getText().toString());
  333 + RunningMapActivity.startActivity(fragment.getActivity(), runningMapBean);
322 334 }
323 335 });
324 336 }
325 337  
326 338 public void setSQLPauseTime() {
327   - //将当前计时器时间戳写入数据库
328   - UserStepEntity userStepEntity = StepUtil.getUserStepData(fragment.getActivity(), uid);
329   - if (userStepEntity != null) {
330   - userStepEntity.setPauseTimeStamp(fragment.binding.chronometer.getBase());
331   - //设置当前暂停的时间戳
332   - userStepEntity.setRecordTime(SystemClock.elapsedRealtime());
333   - //更新数据
334   - StepUtil.updateStepData(fragment.getActivity(), userStepEntity);
335   -
  339 + if (needWriteDataFlag) {
  340 + //将当前计时器时间戳写入数据库
  341 + UserStepEntity userStepEntity = StepUtil.getUserStepData(fragment.getActivity(), uid);
  342 + if (userStepEntity != null) {
  343 + userStepEntity.setPauseTimeStamp(fragment.binding.chronometer.getBase());
  344 + //设置当前暂停的时间戳
  345 + userStepEntity.setRecordTime(SystemClock.elapsedRealtime());
  346 + //更新数据
  347 + StepUtil.updateStepData(fragment.getActivity(), userStepEntity);
  348 + }
336 349 }
337 350 }
338 351  
... ... @@ -361,7 +374,8 @@ public class RunMainFragmentView implements MvpView {
361 374 //设置S速度
362 375 int second = (int) ((SystemClock.elapsedRealtime() - fragment.binding.chronometer.getBase()) / 1000);
363 376 if (second != 0) {
364   - fragment.binding.tvSpeed.setText(StepUtil.getCurrentSpeed(second, StepUtil.getWalkDistanceKM(step) * 1000) + "m/s");
  377 +// fragment.binding.tvSpeed.setText(StepUtil.getCurrentSpeed(second, StepUtil.getWalkDistanceKM(step) * 1000)+"");
  378 + fragment.binding.tvSpeed.setText(StepUtil.getPaceSpeed(second, StepUtil.getWalkDistanceKM(step)));
365 379 } else {
366 380 fragment.binding.tvSpeed.setText("--");
367 381  
... ... @@ -372,147 +386,6 @@ public class RunMainFragmentView implements MvpView {
372 386 fragment.binding.tvSpeed.setText("--");
373 387 }
374 388  
375   - //设置控件放大动画
376   - private void setViewZoomIn(View view) {
377   - AnimatorSet animatorSetsuofang = new AnimatorSet();//组合动画
378   - ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 1, 1.2f);
379   - ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 1, 1.2f);
380   - animatorSetsuofang.setDuration(DEFAULT_ZOOM_DURATION);
381   - animatorSetsuofang.setInterpolator(new DecelerateInterpolator());
382   - animatorSetsuofang.play(scaleX).with(scaleY);//两个动画同时开始
383   - animatorSetsuofang.start();
384   - }
385   -
386   - //设置控件缩小动画
387   - private void setViewZoomOut(View view) {
388   - AnimatorSet animatorSetsuofang = new AnimatorSet();//组合动画
389   - ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 1.2f, 1);
390   - ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 1.2f, 1);
391   - animatorSetsuofang.setDuration(DEFAULT_ZOOM_DURATION);
392   - animatorSetsuofang.setInterpolator(new DecelerateInterpolator());
393   - animatorSetsuofang.play(scaleX).with(scaleY);//两个动画同时开始
394   - animatorSetsuofang.start();
395   - }
396   -
397   - //设置控件显示放大动画
398   - private void setViewShowZoomIn(View view) {
399   - AnimatorSet animatorSetsuofang = new AnimatorSet();//组合动画
400   - ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 0, 1.2f);
401   - ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 0, 1.2f);
402   - animatorSetsuofang.setDuration(SHOW_VIEW_ZOOM_DURATION);
403   - animatorSetsuofang.setInterpolator(new DecelerateInterpolator());
404   - animatorSetsuofang.play(scaleX).with(scaleY);//两个动画同时开始
405   - animatorSetsuofang.start();
406   - new Handler().postDelayed(new Runnable() {
407   - @Override
408   - public void run() {
409   - AnimatorSet animatorSetsuofang = new AnimatorSet();//组合动画
410   - ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 1.2f, 1);
411   - ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 1.2f, 1);
412   - animatorSetsuofang.setDuration(SHOW_VIEW_ZOOM_DURATION);
413   - animatorSetsuofang.setInterpolator(new DecelerateInterpolator());
414   - animatorSetsuofang.play(scaleX).with(scaleY);//两个动画同时开始
415   - animatorSetsuofang.start();
416   - }
417   - }, SHOW_VIEW_ZOOM_DURATION);
418   - }
419   -
420   - //设置控件隐藏缩小动画
421   - private void setViewHideZoomOut(View view) {
422   - AnimatorSet animatorSetsuofang = new AnimatorSet();//组合动画
423   - ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 1, 0);
424   - ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 1, 0);
425   - animatorSetsuofang.setDuration(HIDE_VIEW_ZOOM_DURATION);
426   - animatorSetsuofang.setInterpolator(new DecelerateInterpolator());
427   - animatorSetsuofang.play(scaleX).with(scaleY);//两个动画同时开始
428   - animatorSetsuofang.start();
429   - }
430   -
431   - //设置时间显示放大动画
432   - private void setTimeShowZoomIn(View view) {
433   - ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 0, 1.4f);
434   - ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 0, 1.4f);
435   - ObjectAnimator scaleX1 = ObjectAnimator.ofFloat(view, "scaleX", 1.4f, 1);
436   - ObjectAnimator scaleY1 = ObjectAnimator.ofFloat(view, "scaleY", 1.4f, 1);
437   - ObjectAnimator scaleX2 = ObjectAnimator.ofFloat(view, "scaleX", 1, 0);
438   - ObjectAnimator scaleY2 = ObjectAnimator.ofFloat(view, "scaleY", 1, 0);
439   - AnimatorSet animatorSetsuofang = new AnimatorSet();//组合动画
440   - animatorSetsuofang.setDuration(100);
441   - animatorSetsuofang.setInterpolator(new DecelerateInterpolator());
442   - animatorSetsuofang.play(scaleX).with(scaleY);
443   - animatorSetsuofang.start();
444   - new Handler().postDelayed(new Runnable() {
445   - @Override
446   - public void run() {
447   - AnimatorSet animatorSetsuofang2 = new AnimatorSet();//组合动画
448   - animatorSetsuofang2.setDuration(100);
449   - animatorSetsuofang2.setInterpolator(new DecelerateInterpolator());
450   - animatorSetsuofang2.play(scaleX1).with(scaleY1);
451   - animatorSetsuofang2.start();
452   - }
453   - }, 100);
454   -
455   - new Handler().postDelayed(new Runnable() {
456   - @Override
457   - public void run() {
458   - AnimatorSet animatorSetsuofang3 = new AnimatorSet();//组合动画
459   - animatorSetsuofang3.setDuration(10);
460   - animatorSetsuofang3.setInterpolator(new DecelerateInterpolator());
461   - animatorSetsuofang3.play(scaleX2).with(scaleY2);
462   - animatorSetsuofang3.start();
463   - }
464   - }, 300);
465   -
466   - }
467   -
468   - /**
469   - * 设置控件展开特效
470   - *
471   - * @param view
472   - * @param closeFlag
473   - */
474   - private void startAnimation(View view, boolean closeFlag) {
475   - //因为CircularReveal动画是api21之后才有的,所以加个判断语句,免得崩溃
476   - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
477   - int cicular_R = view.getHeight() / 2 > view.getWidth() / 2 ? view.getHeight() / 2 : view.getWidth() / 2;
478   - Animator animator = null;
479   - if (!closeFlag) {
480   - animator = ViewAnimationUtils.createCircularReveal(view, (int) view.getWidth() / 2, (int) view.getHeight() / 2, 0, cicular_R);
481   - } else {
482   - animator = ViewAnimationUtils.createCircularReveal(view, (int) view.getWidth() / 2, (int) view.getHeight() / 2, cicular_R, 0);
483   - }
484   - animator.addListener(new Animator.AnimatorListener() {
485   - @Override
486   - public void onAnimationStart(Animator animator) {
487   -
488   - }
489   -
490   - @Override
491   - public void onAnimationEnd(Animator animator) {
492   - if (closeFlag) {
493   - view.setVisibility(View.GONE);
494   - }
495   - }
496   -
497   - @Override
498   - public void onAnimationCancel(Animator animator) {
499   -
500   - }
501   -
502   - @Override
503   - public void onAnimationRepeat(Animator animator) {
504   -
505   - }
506   - });
507   - animator.setDuration(350);
508   - animator.start();
509   - } else {
510   - if (closeFlag) {
511   - view.setVisibility(View.GONE);
512   - }
513   - }
514   -
515   - }
516 389  
517 390 }
518 391  
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java 0 → 100644
  1 +package com.cnlive.moudle.pedometer.frame.view;
  2 +
  3 +import android.content.Context;
  4 +
  5 +import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment;
  6 +import com.cnlive.moudle.pedometer.ui.fragment.RunRaceDetailFragment;
  7 +import com.hannesdorfmann.mosby3.mvp.MvpView;
  8 +
  9 +public class RunRaceDetailFragmentView implements MvpView {
  10 + private RunRaceDetailFragment fragment;
  11 +
  12 + public RunRaceDetailFragmentView(RunRaceDetailFragment fragment) {
  13 + this.fragment = fragment;
  14 + }
  15 +
  16 + public Context getContext() {
  17 + return fragment == null ? null : fragment.getActivity();
  18 + }
  19 +}
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunningMapFragmentView.java
1 1 package com.cnlive.moudle.pedometer.frame.view;
2 2  
3 3 import android.content.Context;
  4 +import android.graphics.Bitmap;
  5 +import android.graphics.BitmapFactory;
  6 +import android.hardware.Sensor;
  7 +import android.hardware.SensorEvent;
  8 +import android.hardware.SensorEventListener;
  9 +import android.hardware.SensorManager;
  10 +import android.os.SystemClock;
  11 +import android.util.Log;
  12 +import android.view.MotionEvent;
  13 +import android.view.View;
  14 +import android.widget.Chronometer;
4 15  
  16 +import com.baidu.location.BDAbstractLocationListener;
  17 +import com.baidu.location.BDLocation;
  18 +import com.baidu.location.LocationClient;
  19 +import com.baidu.location.LocationClientOption;
  20 +import com.baidu.mapapi.map.BaiduMap;
  21 +import com.baidu.mapapi.map.BitmapDescriptor;
  22 +import com.baidu.mapapi.map.BitmapDescriptorFactory;
  23 +import com.baidu.mapapi.map.MapStatus;
  24 +import com.baidu.mapapi.map.MapStatusUpdateFactory;
  25 +import com.baidu.mapapi.map.MapView;
  26 +import com.baidu.mapapi.map.MarkerOptions;
  27 +import com.baidu.mapapi.map.MyLocationConfiguration;
  28 +import com.baidu.mapapi.map.MyLocationData;
  29 +import com.baidu.mapapi.map.UiSettings;
  30 +import com.baidu.mapapi.model.LatLng;
  31 +import com.cnlive.moudle.pedometer.model.RunningMapBean;
5 32 import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment;
6 33 import com.cnlive.moudle.pedometer.ui.fragment.RunningMapFragment;
  34 +import com.cnlive.moudle.pedometer.utils.BitmapUtil;
  35 +import com.cnlive.moudle.pedometer.utils.ButtonAnimUtil;
  36 +import com.cnlive.moudle.pedometer.utils.StepUtil;
  37 +import com.example.moudle_pedometer.R;
7 38 import com.hannesdorfmann.mosby3.mvp.MvpView;
8 39  
9   -public class RunningMapFragmentView implements MvpView {
  40 +import org.greenrobot.eventbus.EventBus;
  41 +
  42 +public class RunningMapFragmentView implements MvpView, SensorEventListener {
  43 + private static final String TAG = "RunningMapFragmentView";
10 44 private RunningMapFragment fragment;
  45 + private BaiduMap baiduMap;
  46 + private MapView mMapView;
  47 + private UiSettings mUiSettings;
  48 + private MyLocationConfiguration.LocationMode mCurrentMode;//定位模式
  49 + private BitmapDescriptor mCurrentMarker;//定位图标
  50 + private static int accuracyCircleFillColor;
  51 + private static int accuracyCircleStrokeColor;
  52 + private static MyLocationData mylocation;
  53 + boolean isFirstLoc = true; // 是否首次定位
  54 + private MarkerOptions currentMark;
  55 + private LatLng firstLatLng;
  56 + private Double lastX = 0.0;
  57 + private int mCurrentDirection = 0;
  58 + private double mCurrentLat = 0.0;
  59 + private double mCurrentLon = 0.0;
  60 + private float mCurrentAccracy;
  61 + // 定位相关
  62 + private LocationClient mLocClient;
  63 + public MyLocationListenner myListener = new MyLocationListenner();
11 64  
12 65 public RunningMapFragmentView(RunningMapFragment fragment) {
13 66 this.fragment = fragment;
... ... @@ -18,5 +71,238 @@ public class RunningMapFragmentView implements MvpView {
18 71 }
19 72  
20 73 public void initView() {
  74 + this.mMapView = fragment.binding.mapView;
  75 + if (baiduMap == null) {
  76 + baiduMap = mMapView.getMap();
  77 + }
  78 + if (mUiSettings == null) {
  79 + mUiSettings = baiduMap.getUiSettings();
  80 + }
  81 + //设置定位模式, 默认为 LocationMode.NORMAL 普通态
  82 + mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL;
  83 + // 设置定位图标修改为自定义marker
  84 + Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.rt_ic_location), 40, 40);
  85 + mCurrentMarker = BitmapDescriptorFactory.fromBitmap(pointBitmap);
  86 + //设置定位蓝点精度圆圈的填充颜色为透明色
  87 + accuracyCircleFillColor = getContext().getResources().getColor(R.color.transparent);
  88 + //设置定位蓝点精度圆圈的边框颜色的为透明色
  89 + accuracyCircleStrokeColor = getContext().getResources().getColor(R.color.transparent);
  90 + MyLocationConfiguration locationConfiguration = new MyLocationConfiguration(mCurrentMode,
  91 + true, mCurrentMarker, accuracyCircleFillColor, accuracyCircleStrokeColor);
  92 + //设置样式
  93 + baiduMap.setMyLocationConfiguration(locationConfiguration);
  94 + //启动所有手势
  95 + mUiSettings.setAllGesturesEnabled(true);
  96 + //通过设置enable为true或false 选择是否显示缩放按钮
  97 + mMapView.showZoomControls(false);
  98 + mUiSettings.setEnlargeCenterWithDoubleClickEnable(true);
  99 + //隐藏自带的指南针,改用自定义指南针 杨帅
  100 + baiduMap.getUiSettings().setCompassEnabled(true);
  101 + //显示定位图层
  102 + baiduMap.setMyLocationEnabled(true);
  103 + // 定位初始化
  104 + mLocClient = new LocationClient(getContext());
  105 + mLocClient.registerLocationListener(myListener);
  106 + LocationClientOption option = new LocationClientOption();
  107 + option.setOpenGps(true); // 打开gps
  108 + option.setCoorType("gcj02"); // 设置坐标类型
  109 + option.setScanSpan(3000);
  110 + mLocClient.setLocOption(option);
  111 + mLocClient.start();
  112 +
  113 + //返回键
  114 + fragment.binding.flBack.setOnTouchListener(new View.OnTouchListener() {
  115 + @Override
  116 + public boolean onTouch(View view, MotionEvent motionEvent) {
  117 + Log.e(TAG, "onTouch: " + motionEvent.getAction());
  118 + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
  119 + ButtonAnimUtil.setViewZoomIn(fragment.binding.flBack);
  120 + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
  121 + ButtonAnimUtil.setViewZoomOut(fragment.binding.flBack);
  122 + }
  123 + return false;
  124 + }
  125 + });
  126 + //返回键点击事件
  127 + fragment.binding.flBack.setOnClickListener(new View.OnClickListener() {
  128 + @Override
  129 + public void onClick(View view) {
  130 + fragment.getActivity().finish();
  131 + }
  132 + });
  133 +//重新定位
  134 + fragment.binding.flLocation.setOnTouchListener(new View.OnTouchListener() {
  135 + @Override
  136 + public boolean onTouch(View view, MotionEvent motionEvent) {
  137 + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
  138 + ButtonAnimUtil.setViewZoomIn(fragment.binding.flLocation);
  139 + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
  140 + ButtonAnimUtil.setViewZoomOut(fragment.binding.flLocation);
  141 + }
  142 + return false;
  143 + }
  144 + });
  145 + fragment.binding.flLocation.setOnClickListener(new View.OnClickListener() {
  146 + @Override
  147 + public void onClick(View view) {
  148 + mLocClient.restart();
  149 + isFirstLoc = true;
  150 + }
  151 + });
  152 +
  153 + }
  154 +
  155 +
  156 + /**
  157 + * //设置定位监听器,获取到用户当前位置 杨帅
  158 + * 定位SDK监听函数
  159 + */
  160 + public class MyLocationListenner extends BDAbstractLocationListener {
  161 +
  162 + @Override
  163 + public void onReceiveLocation(BDLocation location) {
  164 + // map view 销毁后不在处理新接收的位置
  165 + if (location == null || mMapView == null) {
  166 + return;
  167 + }
  168 +// mCurrentLat = location.getLatitude();
  169 +// mCurrentLon = location.getLongitude();
  170 + mCurrentAccracy = location.getRadius();
  171 + mylocation = new MyLocationData.Builder()
  172 + .accuracy(location.getRadius())
  173 + // 此处设置开发者获取到的方向信息,顺时针0-360
  174 + .direction(location.getDirection()).latitude(location.getLatitude())
  175 + .longitude(location.getLongitude()).build();
  176 + if (mylocation == null) {
  177 + return;
  178 + }
  179 +
  180 + MapStatus.Builder builder = new MapStatus.Builder();
  181 +
  182 + if (isFirstLoc) {
  183 + isFirstLoc = false;
  184 + firstLatLng = new LatLng(location.getLatitude(),
  185 + location.getLongitude());
  186 + baiduMap.setMyLocationData(mylocation);
  187 + builder.target(firstLatLng).zoom(17.0f);
  188 + baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
  189 +// //显示当前位置图标
  190 +// Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.rt_ic_location), 40, 40);
  191 +// currentMark = new MarkerOptions().position(firstLatLng).icon(BitmapDescriptorFactory.fromBitmap(pointBitmap));
  192 +// baiduMap.addOverlay(currentMark);
  193 +
  194 +
  195 + }
  196 + }
  197 + }
  198 +
  199 +
  200 + /**
  201 + * 同步计时器
  202 + */
  203 + public void updateChronometer(RunningMapBean runningMapBean) {
  204 + //设置计时监听
  205 + fragment.binding.chronometer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
  206 + @Override
  207 + public void onChronometerTick(Chronometer chronometer) {
  208 + int hour = (int) ((SystemClock.elapsedRealtime() - chronometer.getBase()) / 1000 / 60 / 60);
  209 + int minute = (int) ((SystemClock.elapsedRealtime() - chronometer.getBase()) / 1000 / 60) % 60;
  210 + int second = (int) ((SystemClock.elapsedRealtime() - chronometer.getBase()) / 1000) % 60;
  211 + if (hour < 1) {
  212 + if (minute == 59 && second == 59) {
  213 + chronometer.setFormat("0" + "%s");
  214 + } else {
  215 + chronometer.setFormat("0" + String.valueOf(hour) + ":%s");
  216 + }
  217 + } else if (hour < 10) {
  218 + chronometer.setFormat("0" + "%s");
  219 + } else {
  220 + chronometer.setFormat("%s");
  221 + }
  222 +
  223 + }
  224 + });
  225 + fragment.binding.chronometer.setBase(runningMapBean.getTimeBase() + (SystemClock.elapsedRealtime() - runningMapBean.getRecordTime()));
  226 + //判断是否点击暂停按钮
  227 + if (runningMapBean.isPause()) {
  228 + //点击暂停按钮,那么就只显示文本
  229 + fragment.binding.chronometer.setText(runningMapBean.getPauseShowTime());
  230 + } else {
  231 + fragment.binding.chronometer.start();
  232 + }
  233 + //设置速度
  234 + fragment.binding.tvCurrentSpeed.setText(runningMapBean.getCurrentSpeed());
  235 + //设置距离
  236 + fragment.binding.tvCurrentDiatance.setText(runningMapBean.getDistance());
  237 + }
  238 +
  239 + /**
  240 + * 更新行走距离
  241 + *
  242 + * @param step
  243 + */
  244 + public void updateRunDistance(int step) {
  245 + //设置行走公里
  246 + fragment.binding.tvCurrentDiatance.setText(StepUtil.getWalkDistanceKM(step) + "");
  247 + //设置行走步数
  248 + fragment.binding.tvCurrentSpeed.setText(step + "步");
  249 + //设置S速度
  250 + int second = (int) ((SystemClock.elapsedRealtime() - fragment.binding.chronometer.getBase()) / 1000);
  251 + if (second != 0) {
  252 +// fragment.binding.tvCurrentSpeed.setText(StepUtil.getCurrentSpeed(second, StepUtil.getWalkDistanceKM(step) * 1000) + "");
  253 + fragment.binding.tvCurrentSpeed.setText(StepUtil.getPaceSpeed(second, StepUtil.getWalkDistanceKM(step)));
  254 + } else {
  255 + fragment.binding.tvCurrentSpeed.setText("--");
  256 + }
  257 + }
  258 +
  259 + public void resetSpeed() {
  260 + fragment.binding.tvCurrentSpeed.setText("--");
  261 + }
  262 +
  263 + @Override
  264 + public void onSensorChanged(SensorEvent sensorEvent) {
  265 + double x = sensorEvent.values[SensorManager.DATA_X];
  266 + if (Math.abs(x - lastX) > 1.0) {
  267 + mCurrentDirection = (int) x;
  268 + if (firstLatLng != null) {
  269 + mylocation = new MyLocationData.Builder()
  270 + .accuracy(mCurrentAccracy)
  271 + // 此处设置开发者获取到的方向信息,顺时针0-360
  272 + .direction(mCurrentDirection).latitude(firstLatLng.latitude)
  273 + .longitude(firstLatLng.longitude).build();
  274 + baiduMap.setMyLocationData(mylocation);
  275 + }
  276 + }
  277 + lastX = x;
  278 + }
  279 +
  280 + @Override
  281 + public void onAccuracyChanged(Sensor sensor, int i) {
  282 +
21 283 }
  284 +
  285 + public void onResume() {
  286 + if (mMapView != null) {
  287 + mMapView.onResume();
  288 + }
  289 + }
  290 +
  291 + public void onPause() {
  292 + if (mMapView != null) {
  293 + mMapView.onPause();
  294 + }
  295 + }
  296 +
  297 + public void onDestroy() {
  298 + if (mMapView != null) {
  299 + mMapView.onDestroy();
  300 + mMapView = null;
  301 + }
  302 + if (mLocClient != null) {
  303 + mLocClient.stop();
  304 + }
  305 + }
  306 +
  307 +
22 308 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/model/Constant.java
... ... @@ -5,6 +5,7 @@ public class Constant {
5 5 public static final int SERVICE_STEP_COUNT_PAUSE = 1;//步数暂停
6 6 public static final int SERVICE_STEP_COUNT_CONTINUE = 2;//继续计步
7 7 public static final int SERVICE_STEP_COUNT_RESET_SPEED = 3;//重置速度
  8 + public static final int FRAGMENT_RUN_CHRONOMETER = 4;//同步计时器
8 9  
9 10  
10 11 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/model/RunningMapBean.java 0 → 100644
  1 +package com.cnlive.moudle.pedometer.model;
  2 +
  3 +import java.io.Serializable;
  4 +
  5 +/**
  6 + * 计时器相关数据
  7 + *
  8 + * @author ShinnyYang
  9 + */
  10 +public class RunningMapBean implements Serializable {
  11 + public RunningMapBean() {
  12 + }
  13 +
  14 +// public RunningMapBean(long timeBase, String formatTime) {
  15 +// this.timeBase = timeBase;
  16 +// this.formatTime = formatTime;
  17 +// }
  18 +
  19 + private long timeBase;
  20 + private long recordTime;
  21 + private String formatTime;
  22 + private String currentSpeed;
  23 + private String distance;
  24 + private String pauseShowTime;
  25 + private boolean pause;
  26 +
  27 + public long getRecordTime() {
  28 + return recordTime;
  29 + }
  30 +
  31 + public void setRecordTime(long recordTime) {
  32 + this.recordTime = recordTime;
  33 + }
  34 +
  35 + public long getTimeBase() {
  36 + return timeBase;
  37 + }
  38 +
  39 + public void setTimeBase(long timeBase) {
  40 + this.timeBase = timeBase;
  41 + }
  42 +
  43 + public String getFormatTime() {
  44 + return formatTime;
  45 + }
  46 +
  47 + public void setFormatTime(String formatTime) {
  48 + this.formatTime = formatTime;
  49 + }
  50 +
  51 + public String getCurrentSpeed() {
  52 + return currentSpeed;
  53 + }
  54 +
  55 + public void setCurrentSpeed(String currentSpeed) {
  56 + this.currentSpeed = currentSpeed;
  57 + }
  58 +
  59 + public String getDistance() {
  60 + return distance;
  61 + }
  62 +
  63 + public void setDistance(String distance) {
  64 + this.distance = distance;
  65 + }
  66 +
  67 + public boolean isPause() {
  68 + return pause;
  69 + }
  70 +
  71 + public void setPause(boolean pause) {
  72 + this.pause = pause;
  73 + }
  74 +
  75 + public String getPauseShowTime() {
  76 + return pauseShowTime;
  77 + }
  78 +
  79 + public void setPauseShowTime(String pauseShowTime) {
  80 + this.pauseShowTime = pauseShowTime;
  81 + }
  82 +}
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/StepService.java
... ... @@ -140,8 +140,8 @@ public class StepService extends Service implements SensorEventListener {
140 140 @SuppressLint("WrongConstant")
141 141 @Override
142 142 public int onStartCommand(Intent intent, int flags, int startId) {
143   - userId = intent.getExtras().getString("userId");
144   - if (userId != null) {
  143 + if (intent.getExtras().getString("userId") != null) {
  144 + userId = intent.getExtras().getString("userId");
145 145 if (!EventBus.getDefault().isRegistered(this)) {
146 146 EventBus.getDefault().register(this);
147 147 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/PedometerMainActivity.java
1 1 package com.cnlive.moudle.pedometer.ui.activity;
2 2  
3 3 import android.Manifest;
  4 +import android.content.Context;
4 5 import android.content.Intent;
5 6 import android.content.pm.PackageInfo;
6 7 import android.content.pm.PackageManager;
  8 +import android.location.LocationManager;
7 9 import android.os.Build;
8 10 import android.provider.Settings;
9 11 import android.os.Bundle;
  12 +import android.support.annotation.NonNull;
10 13 import android.support.v4.app.NotificationManagerCompat;
11 14 import android.support.v4.content.ContextCompat;
12 15 import android.util.Log;
... ... @@ -19,6 +22,8 @@ import com.cnlive.libs.base.ui.QMUIFragment;
19 22 import com.cnlive.libs.base.ui.QMUIFragmentActivity;
20 23 import com.cnlive.libs.base.util.StatusBarUtil2;
21 24 import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment;
  25 +import com.cnlive.moudle.pedometer.utils.lib_permisshelper.PermissionsListener;
  26 +import com.cnlive.moudle.pedometer.utils.lib_permisshelper.PermissionsUtils;
22 27 import com.example.moudle_pedometer.R;
23 28  
24 29  
... ... @@ -30,8 +35,11 @@ import static android.provider.Settings.EXTRA_APP_PACKAGE;
30 35 */
31 36 @Route(path = "/moudle_pedometer/InterestActivity")
32 37 public class PedometerMainActivity extends QMUIFragmentActivity {
  38 + private static final String TAG = "PedometerMainActivity";
  39 +
33 40 private NotificationManagerCompat notificationManagerCompat;
34 41 private boolean isOpen;
  42 + private PermissionsUtils mPermissionsUtils = new PermissionsUtils();//权限申请
35 43  
36 44 @Override
37 45 protected int getContextViewId() {
... ... @@ -49,7 +57,7 @@ public class PedometerMainActivity extends QMUIFragmentActivity {
49 57 //包括BD09LL和GCJ02两种坐标,默认是BD09LL坐标。
50 58 SDKInitializer.setCoordType(CoordType.GCJ02);
51 59 // setContentView(R.layout.activity_pedometer_main);
52   - addFragment();
  60 + getPermissionsWithTip();
53 61 }
54 62  
55 63  
... ... @@ -155,5 +163,83 @@ public class PedometerMainActivity extends QMUIFragmentActivity {
155 163 }
156 164  
157 165  
  166 + /**
  167 + * 一次申请一组权限(使用拒绝弹框)点击事件
  168 + */
  169 + public void getPermissionsWithTip() {
  170 + mPermissionsUtils
  171 + .setPermissionsListener(new PermissionsListener() {
  172 + @Override
  173 + public void onDenied(String[] deniedPermissions) {
  174 + getPermissionsWithTip();
  175 + Log.e(TAG, "onDenied: ");
  176 + }
  177 +
  178 + @Override
  179 + public void onGranted() {
  180 +
  181 + //判断GPS是否开启
  182 + if (!isOPen(getApplicationContext())) {
  183 +// KLog.e("gps未开启");
  184 +// //开启GPS
  185 + Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
  186 + startActivityForResult(intent, 10);
  187 + } else {
  188 + addFragment();
  189 + }
  190 + }
  191 + })
  192 + .withActivity(PedometerMainActivity.this)
  193 + .getPermissions(PedometerMainActivity.this
  194 + , 100
  195 + , Manifest.permission.INTERNET
  196 + , Manifest.permission.READ_EXTERNAL_STORAGE
  197 + , Manifest.permission.WRITE_EXTERNAL_STORAGE
  198 + , Manifest.permission.ACCESS_FINE_LOCATION
  199 + , Manifest.permission.ACCESS_COARSE_LOCATION
  200 + );
  201 +// .getPermissionsWithTips(MainActivity.this
  202 +// ,100
  203 +// , new String[]{"人家要录音","我们需要读取你的信息,磨磨唧唧的","我要上网","我要读内存卡","我要看日历","我要定位"}
  204 +// , Manifest.permission.RECORD_AUDIO
  205 +// , Manifest.permission.READ_SMS
  206 +// , Manifest.permission.INTERNET
  207 +// , Manifest.permission.READ_EXTERNAL_STORAGE
  208 +// , Manifest.permission.READ_CALENDAR
  209 +// , Manifest.permission.ACCESS_FINE_LOCATION);
  210 + }
  211 +
  212 + /**
  213 + * 判断GPS是否开启,GPS或者AGPS开启一个就认为是开启的
  214 + *
  215 + * @param context
  216 + * @return true 表示开启
  217 + */
  218 + public static final boolean isOPen(final Context context) {
  219 + LocationManager locationManager
  220 + = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
  221 + // 通过GPS卫星定位,定位级别可以精确到街(通过24颗卫星定位,在室外和空旷的地方定位准确、速度快)
  222 + boolean gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
  223 + // 通过WLAN或移动网络(3G/2G)确定的位置(也称作AGPS,辅助GPS定位。主要用于在室内或遮盖物(建筑群或茂密的深林等)密集的地方定位)
  224 + boolean network = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
  225 + if (gps || network) {
  226 + return true;
  227 + }
  228 +
  229 + return false;
  230 + }
158 231  
  232 + /**
  233 + * 权限回调
  234 + *
  235 + * @param requestCode
  236 + * @param permissions
  237 + * @param grantResults
  238 + */
  239 + @Override
  240 + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
  241 + @NonNull int[] grantResults) {
  242 + super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  243 + mPermissionsUtils.dealResult(requestCode, permissions, grantResults);
  244 + }
159 245 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/RunRaceDetailActivity.java 0 → 100644
  1 +package com.cnlive.moudle.pedometer.ui.activity;
  2 +
  3 +import android.os.Bundle;
  4 +import android.support.design.widget.BottomSheetDialog;
  5 +import android.view.View;
  6 +
  7 +import com.alibaba.android.arouter.facade.annotation.Route;
  8 +import com.baidu.mapapi.CoordType;
  9 +import com.baidu.mapapi.SDKInitializer;
  10 +import com.cnlive.libs.base.ui.QMUIFragment;
  11 +import com.cnlive.libs.base.ui.QMUIFragmentActivity;
  12 +import com.cnlive.libs.base.util.StatusBarUtil2;
  13 +import com.cnlive.moudle.pedometer.model.RunningMapBean;
  14 +import com.cnlive.moudle.pedometer.ui.fragment.RunRaceDetailFragment;
  15 +import com.cnlive.moudle.pedometer.ui.fragment.RunningMapFragment;
  16 +import com.example.moudle_pedometer.R;
  17 +
  18 +/**
  19 + * 活动赛事详情页
  20 + *
  21 + * @author ShinnyYang
  22 + */
  23 +@Route(path = "/moudle_pedometer/RunRaceDetailActivity")
  24 +public class RunRaceDetailActivity extends QMUIFragmentActivity {
  25 + @Override
  26 + protected int getContextViewId() {
  27 + return R.id.fragment_run_trace_detail;
  28 + }
  29 +
  30 + @Override
  31 + protected void onCreate(Bundle savedInstanceState) {
  32 + super.onCreate(savedInstanceState);
  33 + StatusBarUtil2.setColor(this, getResources().getColor(R.color.run_main_bg), 0);
  34 + //在使用SDK各组件之前初始化context信息,传入ApplicationContext
  35 + SDKInitializer.initialize(getApplicationContext());
  36 + //自4.3.0起,百度地图SDK所有接口均支持百度坐标和国测局坐标,用此方法设置您使用的坐标类型.
  37 + //包括BD09LL和GCJ02两种坐标,默认是BD09LL坐标。
  38 + SDKInitializer.setCoordType(CoordType.GCJ02);
  39 + addFragment();
  40 + BottomSheetDialog bottomSheetDialog=new BottomSheetDialog(this);
  41 + View view=getLayoutInflater().inflate(R.layout.bottom_sheet_dialog_run_race_detail,null);
  42 + bottomSheetDialog.setContentView(view);
  43 + bottomSheetDialog.show();
  44 + bottomSheetDialog.setCancelable(false);
  45 + }
  46 +
  47 + private void addFragment() {
  48 + QMUIFragment fragment = new RunRaceDetailFragment();
  49 + getSupportFragmentManager().beginTransaction()
  50 + .add(getContextViewId(), fragment, fragment.getClass().getSimpleName())
  51 + .addToBackStack(fragment.getClass().getSimpleName())
  52 + .commit();
  53 + }
  54 +}
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/RunningMapActivity.java
... ... @@ -10,20 +10,31 @@ import android.view.View;
10 10 import android.view.Window;
11 11 import android.view.WindowManager;
12 12  
  13 +import com.baidu.mapapi.CoordType;
  14 +import com.baidu.mapapi.SDKInitializer;
13 15 import com.cnlive.libs.base.ui.QMUIFragment;
14 16 import com.cnlive.libs.base.ui.QMUIFragmentActivity;
15 17 import com.cnlive.libs.base.util.StatusBarUtil2;
16   -import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment;
  18 +import com.cnlive.moudle.pedometer.model.RunningMapBean;
17 19 import com.cnlive.moudle.pedometer.ui.fragment.RunningMapFragment;
18 20 import com.example.moudle_pedometer.R;
19   -import com.qmuiteam.qmui.util.QMUIStatusBarHelper;
20 21  
21 22 public class RunningMapActivity extends QMUIFragmentActivity {
  23 + private static final String TAG = "RunningMapActivity";
  24 +
22 25 @Override
23 26 protected void onCreate(Bundle savedInstanceState) {
24 27 super.onCreate(savedInstanceState);
  28 + //在使用SDK各组件之前初始化context信息,传入ApplicationContext
  29 + SDKInitializer.initialize(getApplicationContext());
  30 + //自4.3.0起,百度地图SDK所有接口均支持百度坐标和国测局坐标,用此方法设置您使用的坐标类型.
  31 + //包括BD09LL和GCJ02两种坐标,默认是BD09LL坐标。
  32 + SDKInitializer.setCoordType(CoordType.GCJ02);
25 33 StatusBarUtil2.setColor(this, getResources().getColor(R.color.run_main_bg), 0);
26   - addFragment();
  34 + RunningMapBean chronometerBean = (RunningMapBean) getIntent().getExtras().getSerializable("runningMapBean");
  35 + if (chronometerBean != null) {
  36 + addFragment(chronometerBean);
  37 + }
27 38 }
28 39  
29 40 /**
... ... @@ -59,16 +70,17 @@ public class RunningMapActivity extends QMUIFragmentActivity {
59 70 return R.id.fragment_running_map;
60 71 }
61 72  
62   - private void addFragment() {
63   - QMUIFragment fragment = new RunningMapFragment();
  73 + private void addFragment(RunningMapBean chronometerBean) {
  74 + QMUIFragment fragment = RunningMapFragment.getInstance(chronometerBean);
64 75 getSupportFragmentManager().beginTransaction()
65 76 .add(getContextViewId(), fragment, fragment.getClass().getSimpleName())
66 77 .addToBackStack(fragment.getClass().getSimpleName())
67 78 .commit();
68 79 }
69 80  
70   - public static void startActivity(Activity activity) {
  81 + public static void startActivity(Activity activity, RunningMapBean runningMapBean) {
71 82 Intent intent = new Intent(activity, RunningMapActivity.class);
  83 + intent.putExtra("runningMapBean", runningMapBean);
72 84 activity.startActivity(intent);
73 85 }
74 86 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunMainFragment.java
... ... @@ -26,27 +26,6 @@ public class RunMainFragment extends QMUIFragment&lt;RunMainFragmentView, RunMainFr
26 26  
27 27  
28 28 @Override
29   - protected int getToolbarId() {
30   - return 0;
31   - }
32   -
33   - @Override
34   - public String getTitle() {
35   - return null;
36   - }
37   -
38   - @Override
39   - protected int getLayoutId() {
40   - return R.layout.fragment_run_main;
41   - }
42   -
43   - @Override
44   - public void onActivityCreated(@Nullable Bundle savedInstanceState) {
45   - super.onActivityCreated(savedInstanceState);
46   -
47   - }
48   -
49   - @Override
50 29 public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
51 30 super.onViewCreated(view, savedInstanceState);
52 31 EventBus.getDefault().register(this);
... ... @@ -65,6 +44,21 @@ public class RunMainFragment extends QMUIFragment&lt;RunMainFragmentView, RunMainFr
65 44 }
66 45  
67 46 @Override
  47 + public void onActivityCreated(@Nullable Bundle savedInstanceState) {
  48 + super.onActivityCreated(savedInstanceState);
  49 +
  50 + }
  51 +
  52 + @Override
  53 + public void onPause() {
  54 + super.onPause();
  55 + //记录当前计时器相关数据
  56 + if (getMvpView() != null) {
  57 + getMvpView().setSQLPauseTime();
  58 + }
  59 + }
  60 +
  61 + @Override
68 62 public void onDestroy() {
69 63  
70 64 super.onDestroy();
... ... @@ -73,6 +67,21 @@ public class RunMainFragment extends QMUIFragment&lt;RunMainFragmentView, RunMainFr
73 67 }
74 68 }
75 69  
  70 + @Override
  71 + protected int getToolbarId() {
  72 + return 0;
  73 + }
  74 +
  75 + @Override
  76 + public String getTitle() {
  77 + return null;
  78 + }
  79 +
  80 + @Override
  81 + protected int getLayoutId() {
  82 + return R.layout.fragment_run_main;
  83 + }
  84 +
76 85 @Subscribe(threadMode = ThreadMode.MAIN)
77 86 public void Event(MessageEvent messageEvent) {
78 87 //更新步数
... ... @@ -89,12 +98,4 @@ public class RunMainFragment extends QMUIFragment&lt;RunMainFragmentView, RunMainFr
89 98 }
90 99 }
91 100  
92   - @Override
93   - public void onPause() {
94   - super.onPause();
95   - //记录当前计时器相关数据
96   - if (getMvpView() != null) {
97   - getMvpView().setSQLPauseTime();
98   - }
99   - }
100 101 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunRaceDetailFragment.java 0 → 100644
  1 +package com.cnlive.moudle.pedometer.ui.fragment;
  2 +
  3 +import com.cnlive.libs.base.ui.QMUIFragment;
  4 +import com.cnlive.moudle.pedometer.frame.presenter.RunRaceDetailFragmentPresenter;
  5 +import com.cnlive.moudle.pedometer.frame.view.RunRaceDetailFragmentView;
  6 +import com.example.moudle_pedometer.R;
  7 +import com.example.moudle_pedometer.databinding.FragmentRunRaceDetailBinding;
  8 +
  9 +/**
  10 + * 活动赛事详情页
  11 + *
  12 + * @author ShinnyYang
  13 + */
  14 +public class RunRaceDetailFragment extends QMUIFragment<RunRaceDetailFragmentView, RunRaceDetailFragmentPresenter, FragmentRunRaceDetailBinding> {
  15 + @Override
  16 + protected int getToolbarId() {
  17 + return 0;
  18 + }
  19 +
  20 + @Override
  21 + public String getTitle() {
  22 + return null;
  23 + }
  24 +
  25 + @Override
  26 + protected int getLayoutId() {
  27 + return R.layout.fragment_run_race_detail;
  28 + }
  29 +}
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunningMapFragment.java
1 1 package com.cnlive.moudle.pedometer.ui.fragment;
2 2  
  3 +import android.hardware.Sensor;
  4 +import android.hardware.SensorManager;
3 5 import android.os.Bundle;
4 6 import android.support.annotation.Nullable;
  7 +import android.util.Log;
  8 +import android.view.View;
5 9  
6 10 import com.cnlive.libs.base.ui.QMUIFragment;
7 11 import com.cnlive.libs.base.util.StatusBarUtil2;
8 12 import com.cnlive.moudle.pedometer.frame.presenter.RunningMapFragmentPresenter;
9 13 import com.cnlive.moudle.pedometer.frame.view.RunningMapFragmentView;
  14 +import com.cnlive.moudle.pedometer.model.RunningMapBean;
  15 +import com.cnlive.moudle.pedometer.model.Constant;
  16 +import com.cnlive.moudle.pedometer.model.MessageEvent;
10 17 import com.example.moudle_pedometer.R;
11 18 import com.example.moudle_pedometer.databinding.FragmentRunningMapBinding;
12   -import com.qmuiteam.qmui.util.QMUIStatusBarHelper;
13 19  
  20 +import org.greenrobot.eventbus.EventBus;
  21 +import org.greenrobot.eventbus.Subscribe;
  22 +import org.greenrobot.eventbus.ThreadMode;
  23 +
  24 +import static android.content.Context.SENSOR_SERVICE;
  25 +
  26 +/**
  27 + * 正在跑步的地图界面
  28 + *
  29 + * @author ShinnyYang
  30 + */
14 31 public class RunningMapFragment extends QMUIFragment<RunningMapFragmentView, RunningMapFragmentPresenter, FragmentRunningMapBinding> {
  32 + private static final String TAG = "RunningMapFragment";
  33 + private RunningMapBean runningMapBean;
  34 + private SensorManager mSensorManager;
  35 +
15 36 @Override
16 37 protected int getToolbarId() {
17 38 return 0;
... ... @@ -27,10 +48,92 @@ public class RunningMapFragment extends QMUIFragment&lt;RunningMapFragmentView, Run
27 48 return R.layout.fragment_running_map;
28 49 }
29 50  
  51 + public static RunningMapFragment getInstance(RunningMapBean runningMapBean) {
  52 + RunningMapFragment fragment = new RunningMapFragment();
  53 + Bundle bundle = new Bundle();
  54 + if (runningMapBean != null) {
  55 + bundle.putSerializable("runningMapBean", runningMapBean);
  56 + }
  57 + fragment.setArguments(bundle);
  58 + return fragment;
  59 + }
  60 +
30 61 @Override
31 62 public void onActivityCreated(@Nullable Bundle savedInstanceState) {
32 63 super.onActivityCreated(savedInstanceState);
33 64 StatusBarUtil2.setColor(getActivity(), getResources().getColor(R.color.run_main_bg), 0);
  65 + }
  66 +
  67 + @Override
  68 + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  69 + super.onViewCreated(view, savedInstanceState);
  70 + EventBus.getDefault().register(this);
  71 + mSensorManager = (SensorManager) getActivity().getSystemService(SENSOR_SERVICE);//获取传感器管理服务
  72 + if (getArguments() != null) {
  73 + runningMapBean = (RunningMapBean) getArguments().getSerializable("runningMapBean");
  74 + }
  75 + if (getMvpView() != null) {
  76 + getMvpView().initView();
  77 + if (runningMapBean != null) {
  78 + getMvpView().updateChronometer(runningMapBean);
  79 + }
  80 + }
  81 + }
  82 +
  83 + @Override
  84 + public void onResume() {
  85 + super.onResume();
  86 + if (getMvpView() != null) {
  87 + getMvpView().onResume();
  88 + }
  89 + if (getMvpView() != null) {
  90 + //为系统的方向传感器注册监听器
  91 + mSensorManager.registerListener(getMvpView(), mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION),
  92 + SensorManager.SENSOR_DELAY_UI);
  93 + }
  94 + }
  95 +
  96 + @Override
  97 + public void onStop() {
  98 + super.onStop();
  99 + if (getMvpView() != null) {
  100 + //取消注册传感器监听
  101 + mSensorManager.unregisterListener(getMvpView());
  102 + }
  103 + }
  104 +
  105 + @Override
  106 + public void onPause() {
  107 + super.onPause();
  108 + if (getMvpView() != null) {
  109 + getMvpView().onPause();
  110 + }
  111 + }
  112 +
  113 + @Override
  114 + public void onDestroy() {
  115 + super.onDestroy();
  116 + if (getMvpView() != null) {
  117 + getMvpView().onDestroy();
  118 + }
  119 + if (EventBus.getDefault().isRegistered(this)) {
  120 + EventBus.getDefault().unregister(this);
  121 + }
  122 + }
34 123  
  124 + @Subscribe(threadMode = ThreadMode.MAIN)
  125 + public void Event(MessageEvent messageEvent) {
  126 + //更新步数
  127 + if (messageEvent.getMessageType() == Constant.SERVICE_STEP_COUNT_UPDATE) {
  128 + if (getMvpView() != null) {
  129 + getMvpView().updateRunDistance((Integer) messageEvent.getMessageContent());
  130 + }
  131 + }
  132 + //重置速度
  133 + else if (messageEvent.getMessageType() == Constant.SERVICE_STEP_COUNT_RESET_SPEED) {
  134 + if (getMvpView() != null) {
  135 + getMvpView().resetSpeed();
  136 + }
  137 + }
35 138 }
36 139 }
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/widget/FivePersonIconView.java 0 → 100644
  1 +package com.cnlive.moudle.pedometer.ui.widget;
  2 +
  3 +import android.content.Context;
  4 +import android.os.Build;
  5 +import android.support.annotation.Nullable;
  6 +import android.util.AttributeSet;
  7 +import android.util.Log;
  8 +import android.view.LayoutInflater;
  9 +import android.view.View;
  10 +import android.widget.ImageView;
  11 +import android.widget.LinearLayout;
  12 +
  13 +import com.example.moudle_pedometer.R;
  14 +import com.qmuiteam.qmui.widget.QMUIRadiusImageView;
  15 +
  16 +/**
  17 + * 5个连续的用户头像
  18 + *
  19 + * @author ShinnyYang
  20 + */
  21 +public class FivePersonIconView extends LinearLayout {
  22 + private static final String TAG = "FivePersonIconView";
  23 + private Context context;
  24 + private QMUIRadiusImageView qr1;
  25 + private QMUIRadiusImageView qr2;
  26 + private QMUIRadiusImageView qr3;
  27 + private QMUIRadiusImageView qr4;
  28 + private QMUIRadiusImageView qr5;
  29 + private ImageView iv_right;
  30 + private int index = 0;
  31 + private final int MAX_ICON = 5;//一共有多少个icon
  32 + private final int DEFAULT_LEFT_MARGIN = 10;//默认左侧缩进多少(单位dp)
  33 + private boolean isShowRight;
  34 +// public FivePersonIconView(Context context) {
  35 +// super(context);
  36 +// this.context = context;
  37 +//
  38 +// }
  39 +
  40 + public FivePersonIconView(Context context, AttributeSet attrs) {
  41 + super(context, attrs);
  42 + this.context = context;
  43 + //加载布局文件
  44 + LayoutInflater.from(context).inflate(R.layout.five_persion_icon, this);
  45 + qr1 = findViewById(R.id.qm_iv1);
  46 + qr2 = findViewById(R.id.qm_iv2);
  47 + qr3 = findViewById(R.id.qm_iv3);
  48 + qr4 = findViewById(R.id.qm_iv4);
  49 + qr5 = findViewById(R.id.qm_iv5);
  50 + iv_right = findViewById(R.id.iv_right);
  51 + isShowRight = true;
  52 + if (!isShowRight) {
  53 + iv_right.setVisibility(GONE);
  54 + } else {
  55 + iv_right.setVisibility(VISIBLE);
  56 + }
  57 + }
  58 +
  59 +// public FivePersonIconView(Context context, AttributeSet attrs, int defStyleAttr) {
  60 +// super(context, attrs, defStyleAttr);
  61 +// this.context = context;
  62 +//
  63 +// }
  64 +
  65 +
  66 + @Override
  67 + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  68 + super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  69 + index++;
  70 + if (index == 1) {
  71 + Log.e(TAG, "onMeasure:");
  72 + //根据xml中我们编码时给的宽和高,动态设置这5个图标的距离
  73 + //计算不进行左侧缩进时,总体宽度
  74 + int noMargin = 0;
  75 + if (isShowRight) {
  76 + int ivRightWidth = getMeasuredHeight() / 4;
  77 + int ivRightHeight = getMeasuredHeight() / 3;
  78 + LayoutParams params3 = new LayoutParams(ivRightWidth, ivRightHeight);
  79 + params3.setMargins(dip2px(context, 5), 0, 0, 0);
  80 + iv_right.setLayoutParams(params3);
  81 + noMargin = getMeasuredHeight() * MAX_ICON + dip2px(context, DEFAULT_LEFT_MARGIN) + ivRightWidth;
  82 + } else {
  83 + noMargin = getMeasuredHeight() * MAX_ICON + dip2px(context, DEFAULT_LEFT_MARGIN);
  84 +
  85 + }
  86 +
  87 + //获取当前用户设定的总长度
  88 + int userSetViewWidth = getMeasuredWidth();
  89 + //先试试设置默认缩进行不行
  90 + int defaultMargin = getMeasuredHeight() * MAX_ICON - dip2px(context, DEFAULT_LEFT_MARGIN);
  91 + if (defaultMargin <= userSetViewWidth) {
  92 + return;
  93 + }
  94 +
  95 + Log.e(TAG + index, "noMargin: " + noMargin + ",userSetViewWidth:" + userSetViewWidth);
  96 + //需要进一步缩放的距离(默认10dp)
  97 + int needMargin = dip2px(context, DEFAULT_LEFT_MARGIN);
  98 + //判断是否需要进一步缩放
  99 + if (noMargin > userSetViewWidth) {
  100 + int leftMargin = noMargin - userSetViewWidth;
  101 + //平分需要设置的间隔
  102 + needMargin = leftMargin / (MAX_ICON - 1);
  103 + Log.e(TAG, "onMeasure: 平分后" + needMargin);
  104 + if (needMargin <= dip2px(context, DEFAULT_LEFT_MARGIN)) {
  105 + needMargin = dip2px(context, DEFAULT_LEFT_MARGIN);
  106 + }
  107 + } else {
  108 + Log.e(TAG, "onMeasure: 不平分" + needMargin);
  109 + needMargin = dip2px(context, DEFAULT_LEFT_MARGIN);
  110 + }
  111 +
  112 +
  113 + LayoutParams params1 = new LayoutParams(getMeasuredHeight(), getMeasuredHeight());
  114 + params1.setMargins(0, 0, 0, 0);
  115 + qr1.setLayoutParams(params1);
  116 +
  117 + LayoutParams params2 = new LayoutParams(getMeasuredHeight(), getMeasuredHeight());
  118 + params2.setMargins(-needMargin, 0, 0, 0);
  119 + qr2.setLayoutParams(params2);
  120 + qr3.setLayoutParams(params2);
  121 + qr4.setLayoutParams(params2);
  122 + qr5.setLayoutParams(params2);
  123 + }
  124 + }
  125 +
  126 +
  127 + /**
  128 + * 根据手机的分辨率从 dp 的单位 转成为 px(像素)
  129 + */
  130 + public int dip2px(Context context, float dpValue) {
  131 + final float scale = context.getResources().getDisplayMetrics().density;
  132 + return (int) (dpValue * scale + 0.5f);
  133 + }
  134 +
  135 + /**
  136 + * 根据手机的分辨率从 px(像素) 的单位 转成为 dp
  137 + */
  138 + public int px2dip(Context context, float pxValue) {
  139 + final float scale = context.getResources().getDisplayMetrics().density;
  140 + return (int) (pxValue / scale + 0.5f);
  141 + }
  142 +}
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/BitmapUtil.java 0 → 100644
  1 +package com.cnlive.moudle.pedometer.utils;
  2 +
  3 +/**
  4 + * @Package dcpollution.upenv.com.dcpollution.util
  5 + * @Description: (用一句话描述该文件做什么)
  6 + * @Author:杨帅
  7 + * @Date 2018/5/16,0016 下午 05:10
  8 + * @Version V1.0
  9 + */
  10 +
  11 +import android.annotation.SuppressLint;
  12 +import android.content.Context;
  13 +import android.graphics.Bitmap;
  14 +import android.graphics.Matrix;
  15 +import android.telephony.TelephonyManager;
  16 +import android.view.WindowManager;
  17 +import android.widget.Toast;
  18 +
  19 +/**
  20 + * @Package com.upenv.util
  21 + * @Description: 工具类
  22 + * @Author:杨帅
  23 + * @Date 2018/5/7,0007 下午 02:03
  24 + * @Version V1.0
  25 + */
  26 +public class BitmapUtil {
  27 + private static final String TAG = "BitmapUtil";
  28 +
  29 + /**
  30 + * 获取设备串号
  31 + *
  32 + * @param context
  33 + * @return
  34 + */
  35 + public static String getImei(Context context) {
  36 + TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(context.TELEPHONY_SERVICE);
  37 + @SuppressLint("MissingPermission") String imei = telephonyManager.getDeviceId();//报错不用管,可以正常运行(手机型号+串号)
  38 + return imei;
  39 + }
  40 +
  41 + /**
  42 + * 根据手机的分辨率从 dp 的单位 转成为 px(像素)
  43 + */
  44 + public static int dip2px(Context context, float dpValue) {
  45 + final float scale = context.getResources().getDisplayMetrics().density;
  46 + return (int) (dpValue * scale + 0.5f);
  47 + }
  48 +
  49 + /**
  50 + * 根据手机的分辨率从 px(像素) 的单位 转成为 dp
  51 + */
  52 + public static int px2dip(Context context, float pxValue) {
  53 + final float scale = context.getResources().getDisplayMetrics().density;
  54 + return (int) (pxValue / scale + 0.5f);
  55 + }
  56 +
  57 + /**
  58 + * 获取到指定大小的bitmap,单位dp
  59 + *
  60 + * @return
  61 + */
  62 + public static Bitmap getBitmapFromDp(Context context, Bitmap bitmap, int width, int height) {
  63 + int w = bitmap.getWidth();
  64 + int h = bitmap.getHeight();
  65 + // 设置想要的大小
  66 + int newWidth = dip2px(context, width);
  67 + int newHeight = dip2px(context, height);
  68 + // 计算缩放比例
  69 + float scaleWidth = ((float) newWidth) / w;
  70 + float scaleHeight = ((float) newHeight) / h;
  71 + Matrix matrix = new Matrix();
  72 + matrix.postScale(scaleWidth, scaleHeight);
  73 + Bitmap mbitmap = Bitmap.createBitmap(bitmap, 0, 0, w, h, matrix, true);
  74 + return mbitmap;
  75 + }
  76 +
  77 + /**
  78 + * 显示toast提示
  79 + *
  80 + * @param context
  81 + * @param message
  82 + */
  83 + public static void showToast(Context context, String message) {
  84 + Toast.makeText(context, message, Toast.LENGTH_LONG).show();
  85 + }
  86 +
  87 + public static int getScreenWidth(Context context) {
  88 + WindowManager wm = (WindowManager) context
  89 + .getSystemService(Context.WINDOW_SERVICE);
  90 + int width = wm.getDefaultDisplay().getWidth();
  91 + int height = wm.getDefaultDisplay().getHeight();
  92 + return width;
  93 + }
  94 +
  95 + /**
  96 + * 获取屏幕高度
  97 + *
  98 + * @param context
  99 + * @return
  100 + */
  101 + public static int getScreenHeight(Context context) {
  102 + WindowManager wm = (WindowManager) context
  103 + .getSystemService(Context.WINDOW_SERVICE);
  104 + int height = wm.getDefaultDisplay().getHeight();
  105 + return height;
  106 + }
  107 +
  108 +}
  109 +
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/ButtonAnimUtil.java 0 → 100644
  1 +package com.cnlive.moudle.pedometer.utils;
  2 +
  3 +import android.animation.Animator;
  4 +import android.animation.AnimatorSet;
  5 +import android.animation.ObjectAnimator;
  6 +import android.os.Build;
  7 +import android.os.Handler;
  8 +import android.view.View;
  9 +import android.view.ViewAnimationUtils;
  10 +import android.view.animation.DecelerateInterpolator;
  11 +
  12 +/**
  13 + * 圆形按钮点击特效
  14 + *
  15 + * @author ShinnyYang
  16 + */
  17 +public class ButtonAnimUtil {
  18 + public static final int DEFAULT_ZOOM_DURATION = 50;//默认缩放动画时间间隔
  19 + public static final int SHOW_VIEW_ZOOM_DURATION = 150;//显示控件缩放动画时间间隔
  20 + public static final int HIDE_VIEW_ZOOM_DURATION = 100;//隐藏控件缩放动画时间间隔
  21 +
  22 + //设置控件放大动画
  23 + public static void setViewZoomIn(View view) {
  24 + AnimatorSet animatorSetsuofang = new AnimatorSet();//组合动画
  25 + ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 1, 1.2f);
  26 + ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 1, 1.2f);
  27 + animatorSetsuofang.setDuration(DEFAULT_ZOOM_DURATION);
  28 + animatorSetsuofang.setInterpolator(new DecelerateInterpolator());
  29 + animatorSetsuofang.play(scaleX).with(scaleY);//两个动画同时开始
  30 + animatorSetsuofang.start();
  31 + }
  32 +
  33 + //设置控件缩小动画
  34 + public static void setViewZoomOut(View view) {
  35 + AnimatorSet animatorSetsuofang = new AnimatorSet();//组合动画
  36 + ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 1.2f, 1);
  37 + ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 1.2f, 1);
  38 + animatorSetsuofang.setDuration(DEFAULT_ZOOM_DURATION);
  39 + animatorSetsuofang.setInterpolator(new DecelerateInterpolator());
  40 + animatorSetsuofang.play(scaleX).with(scaleY);//两个动画同时开始
  41 + animatorSetsuofang.start();
  42 + }
  43 +
  44 + //设置控件显示放大动画
  45 + public static void setViewShowZoomIn(View view) {
  46 + AnimatorSet animatorSetsuofang = new AnimatorSet();//组合动画
  47 + ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 0, 1.2f);
  48 + ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 0, 1.2f);
  49 + animatorSetsuofang.setDuration(SHOW_VIEW_ZOOM_DURATION);
  50 + animatorSetsuofang.setInterpolator(new DecelerateInterpolator());
  51 + animatorSetsuofang.play(scaleX).with(scaleY);//两个动画同时开始
  52 + animatorSetsuofang.start();
  53 + new Handler().postDelayed(new Runnable() {
  54 + @Override
  55 + public void run() {
  56 + AnimatorSet animatorSetsuofang = new AnimatorSet();//组合动画
  57 + ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 1.2f, 1);
  58 + ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 1.2f, 1);
  59 + animatorSetsuofang.setDuration(SHOW_VIEW_ZOOM_DURATION);
  60 + animatorSetsuofang.setInterpolator(new DecelerateInterpolator());
  61 + animatorSetsuofang.play(scaleX).with(scaleY);//两个动画同时开始
  62 + animatorSetsuofang.start();
  63 + }
  64 + }, SHOW_VIEW_ZOOM_DURATION);
  65 + }
  66 +
  67 + //设置控件隐藏缩小动画
  68 + public static void setViewHideZoomOut(View view) {
  69 + AnimatorSet animatorSetsuofang = new AnimatorSet();//组合动画
  70 + ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 1, 0);
  71 + ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 1, 0);
  72 + animatorSetsuofang.setDuration(HIDE_VIEW_ZOOM_DURATION);
  73 + animatorSetsuofang.setInterpolator(new DecelerateInterpolator());
  74 + animatorSetsuofang.play(scaleX).with(scaleY);//两个动画同时开始
  75 + animatorSetsuofang.start();
  76 + }
  77 +
  78 + //设置时间显示放大动画
  79 + public static void setTimeShowZoomIn(View view) {
  80 + ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 0, 1.4f);
  81 + ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 0, 1.4f);
  82 + ObjectAnimator scaleX1 = ObjectAnimator.ofFloat(view, "scaleX", 1.4f, 1);
  83 + ObjectAnimator scaleY1 = ObjectAnimator.ofFloat(view, "scaleY", 1.4f, 1);
  84 + ObjectAnimator scaleX2 = ObjectAnimator.ofFloat(view, "scaleX", 1, 0);
  85 + ObjectAnimator scaleY2 = ObjectAnimator.ofFloat(view, "scaleY", 1, 0);
  86 + AnimatorSet animatorSetsuofang = new AnimatorSet();//组合动画
  87 + animatorSetsuofang.setDuration(100);
  88 + animatorSetsuofang.setInterpolator(new DecelerateInterpolator());
  89 + animatorSetsuofang.play(scaleX).with(scaleY);
  90 + animatorSetsuofang.start();
  91 + new Handler().postDelayed(new Runnable() {
  92 + @Override
  93 + public void run() {
  94 + AnimatorSet animatorSetsuofang2 = new AnimatorSet();//组合动画
  95 + animatorSetsuofang2.setDuration(100);
  96 + animatorSetsuofang2.setInterpolator(new DecelerateInterpolator());
  97 + animatorSetsuofang2.play(scaleX1).with(scaleY1);
  98 + animatorSetsuofang2.start();
  99 + }
  100 + }, 100);
  101 +
  102 + new Handler().postDelayed(new Runnable() {
  103 + @Override
  104 + public void run() {
  105 + AnimatorSet animatorSetsuofang3 = new AnimatorSet();//组合动画
  106 + animatorSetsuofang3.setDuration(10);
  107 + animatorSetsuofang3.setInterpolator(new DecelerateInterpolator());
  108 + animatorSetsuofang3.play(scaleX2).with(scaleY2);
  109 + animatorSetsuofang3.start();
  110 + }
  111 + }, 300);
  112 +
  113 + }
  114 +
  115 +
  116 + /**
  117 + * 设置控件展开特效
  118 + *
  119 + * @param view
  120 + * @param closeFlag
  121 + */
  122 + public static void startAnimation(View view, boolean closeFlag) {
  123 + //因为CircularReveal动画是api21之后才有的,所以加个判断语句,免得崩溃
  124 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
  125 + int cicular_R = view.getHeight() / 2 > view.getWidth() / 2 ? view.getHeight() / 2 : view.getWidth() / 2;
  126 + Animator animator = null;
  127 + if (!closeFlag) {
  128 + animator = ViewAnimationUtils.createCircularReveal(view, (int) view.getWidth() / 2, (int) view.getHeight() / 2, 0, cicular_R);
  129 + } else {
  130 + animator = ViewAnimationUtils.createCircularReveal(view, (int) view.getWidth() / 2, (int) view.getHeight() / 2, cicular_R, 0);
  131 + }
  132 + animator.addListener(new Animator.AnimatorListener() {
  133 + @Override
  134 + public void onAnimationStart(Animator animator) {
  135 +
  136 + }
  137 +
  138 + @Override
  139 + public void onAnimationEnd(Animator animator) {
  140 + if (closeFlag) {
  141 + view.setVisibility(View.GONE);
  142 + }
  143 + }
  144 +
  145 + @Override
  146 + public void onAnimationCancel(Animator animator) {
  147 +
  148 + }
  149 +
  150 + @Override
  151 + public void onAnimationRepeat(Animator animator) {
  152 +
  153 + }
  154 + });
  155 + animator.setDuration(350);
  156 + animator.start();
  157 + } else {
  158 + if (closeFlag) {
  159 + view.setVisibility(View.GONE);
  160 + }
  161 + }
  162 +
  163 + }
  164 +
  165 +}
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/ScreenUtil.java 0 → 100644
  1 +package com.cnlive.moudle.pedometer.utils;
  2 +
  3 +import android.app.Activity;
  4 +import android.content.Context;
  5 +import android.graphics.Bitmap;
  6 +import android.graphics.Matrix;
  7 +import android.os.Build;
  8 +import android.view.WindowManager;
  9 +
  10 +/*屏幕显示相关设置
  11 + *@date:2018/7/25 19:56
  12 + *@auther:杨帅
  13 + */public class ScreenUtil {
  14 + //版本 大于等于 19 才会生效(状态栏透明 2018/7/16 15:23 杨帅)
  15 + public static void initWindow(Activity activity) {
  16 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
  17 + activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  18 + activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
  19 + }
  20 + }
  21 +
  22 + /**
  23 + * 获取屏幕信息
  24 + *
  25 + * @param context
  26 + * @return 屏幕的宽度、高度
  27 + */
  28 + public static ScreenInfo getScreenInfo(Context context) {
  29 + ScreenInfo info = new ScreenInfo();
  30 + WindowManager wm = (WindowManager) context
  31 + .getSystemService(Context.WINDOW_SERVICE);
  32 + int width = wm.getDefaultDisplay().getWidth();
  33 + int height = wm.getDefaultDisplay().getHeight();
  34 + info.setWidth(width);
  35 + info.setHeight(height);
  36 + return info;
  37 + }
  38 +
  39 + /**
  40 + * 获取屏幕宽度
  41 + *
  42 + * @param context
  43 + * @return
  44 + */
  45 + public static int getScreenWidth(Context context) {
  46 + WindowManager wm = (WindowManager) context
  47 + .getSystemService(Context.WINDOW_SERVICE);
  48 + int width = wm.getDefaultDisplay().getWidth();
  49 + return width;
  50 + }
  51 +
  52 + /**
  53 + * 获取屏幕高度
  54 + *
  55 + * @param context
  56 + * @return
  57 + */
  58 + public static int getScreenHeight(Context context) {
  59 + WindowManager wm = (WindowManager) context
  60 + .getSystemService(Context.WINDOW_SERVICE);
  61 + int height = wm.getDefaultDisplay().getHeight();
  62 + return height;
  63 + }
  64 +
  65 + /**
  66 + * 根据手机的分辨率从 dp 的单位 转成为 px(像素)
  67 + */
  68 + public static int dip2px(Context context, float dpValue) {
  69 + final float scale = context.getResources().getDisplayMetrics().density;
  70 + return (int) (dpValue * scale + 0.5f);
  71 + }
  72 +
  73 + /**
  74 + * 根据手机的分辨率从 px(像素) 的单位 转成为 dp
  75 + */
  76 + public static int px2dip(Context context, float pxValue) {
  77 + final float scale = context.getResources().getDisplayMetrics().density;
  78 + return (int) (pxValue / scale + 0.5f);
  79 + }
  80 +
  81 +
  82 + public static class ScreenInfo {
  83 + private int width;
  84 + private int height;
  85 +
  86 + public int getWidth() {
  87 + return width;
  88 + }
  89 +
  90 + public void setWidth(int width) {
  91 + this.width = width;
  92 + }
  93 +
  94 + public int getHeight() {
  95 + return height;
  96 + }
  97 +
  98 + public void setHeight(int height) {
  99 + this.height = height;
  100 + }
  101 + }
  102 +}
... ...
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/StepUtil.java
... ... @@ -23,6 +23,23 @@ public class StepUtil {
23 23 private static final String TAG = "StepUtil";
24 24 private static final String dbName = "Step.db";
25 25  
  26 +
  27 + /**
  28 + * 计算配速
  29 + */
  30 + public static String getPaceSpeed(double second, double distance) {
  31 + if (distance != 0) {
  32 + //计算分
  33 + int minute = (int) (second / distance / 60);
  34 + //获取秒
  35 + double miaoMin = ((double) (second / distance / 60)) - ((int) (second / distance / 60));
  36 + int miao = (int) (miaoMin * 60);
  37 + return minute + "'" + miao + "''";
  38 + } else {
  39 + return "--";
  40 + }
  41 + }
  42 +
26 43 /**
27 44 * 更新数据
28 45 *
... ... @@ -78,13 +95,16 @@ public class StepUtil {
78 95 Log.e(TAG, "clearRunData: " + list.size());
79 96 // for (int i = 0; i < list.size(); i++) {
80 97 DbCore.getDaoSession().getUserStepEntityDao().deleteInTx(list);
81   -
  98 + DbCore.getDaoSession().getUserStepEntityDao().detachAll();
  99 + DbCore.getDaoSession().clear();
82 100 // }
83 101 }
84 102 }
85 103  
86 104 public static UserStepEntity getUserStepData(Context context, String uid) {
87 105 DbCore.init(context, dbName);
  106 + DbCore.getDaoSession().getUserStepEntityDao().detachAll();
  107 + DbCore.getDaoSession().clear();
88 108 String CURRENT_DATE = getTodayDate();
89 109 List<UserStepEntity> list = DbCore.getDaoSession().getUserStepEntityDao().queryBuilder().where(UserStepEntityDao.Properties.UserId.eq(uid), UserStepEntityDao.Properties.Date.eq(CURRENT_DATE)).list();
90 110 if (list != null && list.size() > 0) {
... ...
moudle_pedometer/src/main/res/drawable-hdpi/button_fab_white.png 0 → 100644

5.99 KB

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

241 Bytes

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

219 Bytes

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

1005 Bytes

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

225 Bytes

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_blank.png 0 → 100644

743 Bytes

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

6.52 KB

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

538 Bytes

moudle_pedometer/src/main/res/drawable/icon_race_location_green.png 0 → 100644

487 Bytes

moudle_pedometer/src/main/res/drawable/shape_10dp_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="10dp" />
  5 +</shape>
0 6 \ No newline at end of file
... ...
moudle_pedometer/src/main/res/drawable/shape_circle_50_black.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/black_50" />
  5 +</shape>
0 6 \ No newline at end of file
... ...
moudle_pedometer/src/main/res/drawable/shape_circle_green.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<shape xmlns:android="http://schemas.android.com/apk/res/android">
  3 + <corners android:radius="100dp" />
  4 + <solid android:color="@color/green" />
  5 +</shape>
0 6 \ No newline at end of file
... ...
moudle_pedometer/src/main/res/drawable/shape_circle_red.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/red" />
  5 +</shape>
0 6 \ No newline at end of file
... ...
moudle_pedometer/src/main/res/layout/bottom_sheet_dialog_run_race_detail.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<layout xmlns:android="http://schemas.android.com/apk/res/android">
  3 +
  4 + <ScrollView
  5 + android:layout_width="match_parent"
  6 + android:layout_height="match_parent">
  7 +
  8 + <LinearLayout
  9 + android:layout_width="match_parent"
  10 + android:layout_height="wrap_content"
  11 + android:orientation="vertical"
  12 + android:paddingLeft="10dp">
  13 + <!--活动标题-->
  14 + <TextView
  15 + android:id="@+id/tv_race_title"
  16 + android:layout_width="wrap_content"
  17 + android:layout_height="wrap_content"
  18 + android:layout_marginTop="10dp"
  19 + android:text="奥森南园跑道"
  20 + android:textSize="18sp"
  21 + android:textStyle="bold" />
  22 + <!--活动地点-->
  23 + <LinearLayout
  24 + android:layout_width="match_parent"
  25 + android:layout_height="wrap_content"
  26 + android:layout_marginTop="10dp">
  27 +
  28 + <ImageView
  29 + android:layout_width="20dp"
  30 + android:layout_height="20dp"
  31 + android:background="@drawable/icon_race_location_green" />
  32 +
  33 + <TextView
  34 + android:layout_width="wrap_content"
  35 + android:layout_height="wrap_content"
  36 + android:layout_marginLeft="5dp"
  37 + android:text="活动地点"
  38 + android:textColor="@color/bottom_sheet_dialog_race_location_text"
  39 + android:textSize="14sp" />
  40 + </LinearLayout>
  41 + <!--活动地点详情-->
  42 + <LinearLayout
  43 + android:layout_width="match_parent"
  44 + android:layout_height="wrap_content"
  45 + android:layout_marginTop="10dp">
  46 +
  47 + <TextView
  48 + android:layout_width="wrap_content"
  49 + android:layout_height="wrap_content"
  50 + android:layout_marginLeft="25dp"
  51 + android:text="北京"
  52 + android:textColor="@color/black"
  53 + android:textSize="15sp" />
  54 +
  55 + <TextView
  56 + android:layout_width="wrap_content"
  57 + android:layout_height="wrap_content"
  58 + android:layout_marginLeft="25dp"
  59 + android:text="首都师范大学"
  60 + android:textColor="@color/black"
  61 + android:textSize="15sp" />
  62 +
  63 + <TextView
  64 + android:layout_width="wrap_content"
  65 + android:layout_height="wrap_content"
  66 + android:layout_marginLeft="25dp"
  67 + android:text="全长4.42公里"
  68 + android:textColor="@color/black"
  69 + android:textSize="15sp" />
  70 + </LinearLayout>
  71 + <!--起点-->
  72 + <LinearLayout
  73 + android:layout_width="match_parent"
  74 + android:layout_height="wrap_content"
  75 + android:layout_marginTop="10dp"
  76 + android:gravity="center_vertical">
  77 +
  78 + <View
  79 + android:layout_width="10dp"
  80 + android:layout_height="10dp"
  81 + android:layout_marginLeft="25dp"
  82 + android:background="@drawable/shape_circle_green" />
  83 +
  84 + <TextView
  85 + android:layout_width="wrap_content"
  86 + android:layout_height="wrap_content"
  87 + android:layout_marginLeft="10dp"
  88 + android:text="(起)"
  89 + android:textColor="@color/bottom_sheet_dialog_race_location_text"
  90 + android:textSize="14sp" />
  91 +
  92 + <TextView
  93 + android:layout_width="wrap_content"
  94 + android:layout_height="wrap_content"
  95 + android:layout_marginLeft="10dp"
  96 + android:text="首都师范大学操场东门"
  97 + android:textColor="@color/black"
  98 + android:textSize="15sp" />
  99 + </LinearLayout>
  100 + <!--终点-->
  101 + <LinearLayout
  102 + android:layout_width="match_parent"
  103 + android:layout_height="wrap_content"
  104 + android:layout_marginTop="10dp"
  105 + android:gravity="center_vertical">
  106 +
  107 + <View
  108 + android:layout_width="10dp"
  109 + android:layout_height="10dp"
  110 + android:layout_marginLeft="25dp"
  111 + android:background="@drawable/shape_circle_red" />
  112 +
  113 + <TextView
  114 + android:layout_width="wrap_content"
  115 + android:layout_height="wrap_content"
  116 + android:layout_marginLeft="10dp"
  117 + android:text="(止)"
  118 + android:textColor="@color/bottom_sheet_dialog_race_location_text"
  119 + android:textSize="14sp" />
  120 +
  121 + <TextView
  122 + android:layout_width="wrap_content"
  123 + android:layout_height="wrap_content"
  124 + android:layout_marginLeft="10dp"
  125 + android:text="首都师范大学操场西门"
  126 + android:textColor="@color/black"
  127 + android:textSize="15sp" />
  128 + </LinearLayout>
  129 + <!--报名时间-->
  130 + <LinearLayout
  131 + android:layout_width="match_parent"
  132 + android:layout_height="wrap_content"
  133 + android:layout_marginTop="10dp">
  134 +
  135 + <ImageView
  136 + android:layout_width="20dp"
  137 + android:layout_height="20dp"
  138 + android:background="@drawable/icon_race_location_green" />
  139 +
  140 + <TextView
  141 + android:layout_width="wrap_content"
  142 + android:layout_height="wrap_content"
  143 + android:layout_marginLeft="5dp"
  144 + android:text="报名时间"
  145 + android:textColor="@color/bottom_sheet_dialog_race_location_text"
  146 + android:textSize="14sp" />
  147 + </LinearLayout>
  148 + <!--时间-->
  149 + <LinearLayout
  150 + android:layout_width="match_parent"
  151 + android:layout_height="wrap_content"
  152 + android:layout_marginTop="10dp">
  153 +
  154 + <TextView
  155 + android:layout_width="wrap_content"
  156 + android:layout_height="wrap_content"
  157 + android:layout_marginLeft="25dp"
  158 + android:text="2019.05.01"
  159 + android:textColor="@color/black"
  160 + android:textSize="15sp" />
  161 +
  162 + <TextView
  163 + android:layout_width="wrap_content"
  164 + android:layout_height="match_parent"
  165 + android:layout_marginLeft="5dp"
  166 + android:text="——"
  167 + android:textColor="@color/black"
  168 + android:textSize="15sp" />
  169 +
  170 + <TextView
  171 + android:layout_width="wrap_content"
  172 + android:layout_height="wrap_content"
  173 + android:layout_marginLeft="5dp"
  174 + android:text="2019.09.01"
  175 + android:textColor="@color/black"
  176 + android:textSize="15sp" />
  177 + </LinearLayout>
  178 +
  179 + <View
  180 + android:layout_width="match_parent"
  181 + android:layout_height="1dp"
  182 + android:layout_marginTop="5dp"
  183 + android:background="@color/line" />
  184 + <!--活动时间-->
  185 + <LinearLayout
  186 + android:layout_width="match_parent"
  187 + android:layout_height="wrap_content"
  188 + android:layout_marginTop="10dp">
  189 +
  190 + <ImageView
  191 + android:layout_width="20dp"
  192 + android:layout_height="20dp"
  193 + android:background="@drawable/icon_race_location_green" />
  194 +
  195 + <TextView
  196 + android:layout_width="wrap_content"
  197 + android:layout_height="wrap_content"
  198 + android:layout_marginLeft="5dp"
  199 + android:text="活动时间"
  200 + android:textColor="@color/bottom_sheet_dialog_race_location_text"
  201 + android:textSize="14sp" />
  202 + </LinearLayout>
  203 + <!--活动时间的具体日期-->
  204 + <LinearLayout
  205 + android:layout_width="match_parent"
  206 + android:layout_height="wrap_content"
  207 + android:layout_marginTop="10dp">
  208 +
  209 + <TextView
  210 + android:layout_width="wrap_content"
  211 + android:layout_height="wrap_content"
  212 + android:layout_marginLeft="25dp"
  213 + android:text="2019.05.01"
  214 + android:textColor="@color/black"
  215 + android:textSize="15sp" />
  216 +
  217 + <TextView
  218 + android:layout_width="wrap_content"
  219 + android:layout_height="match_parent"
  220 + android:layout_marginLeft="5dp"
  221 + android:text="——"
  222 + android:textColor="@color/black"
  223 + android:textSize="15sp" />
  224 +
  225 + <TextView
  226 + android:layout_width="wrap_content"
  227 + android:layout_height="wrap_content"
  228 + android:layout_marginLeft="5dp"
  229 + android:text="2019.09.01"
  230 + android:textColor="@color/black"
  231 + android:textSize="15sp" />
  232 + </LinearLayout>
  233 +
  234 + <View
  235 + android:layout_width="match_parent"
  236 + android:layout_height="1dp"
  237 + android:layout_marginTop="5dp"
  238 + android:background="@color/line" />
  239 + <!--参与人数-->
  240 + <LinearLayout
  241 + android:layout_width="match_parent"
  242 + android:layout_height="wrap_content"
  243 + android:layout_marginTop="10dp">
  244 +
  245 + <ImageView
  246 + android:layout_width="20dp"
  247 + android:layout_height="20dp"
  248 + android:background="@drawable/icon_race_location_green" />
  249 +
  250 + <TextView
  251 + android:layout_width="wrap_content"
  252 + android:layout_height="wrap_content"
  253 + android:layout_marginLeft="5dp"
  254 + android:text="参与人数"
  255 + android:textColor="@color/bottom_sheet_dialog_race_location_text"
  256 + android:textSize="14sp" />
  257 + </LinearLayout>
  258 + <!--相关的人数-->
  259 + <LinearLayout
  260 + android:layout_width="match_parent"
  261 + android:layout_height="wrap_content"
  262 + android:gravity="center_vertical">
  263 +
  264 + <TextView
  265 + android:layout_width="wrap_content"
  266 + android:layout_height="wrap_content"
  267 + android:layout_marginLeft="25dp"
  268 + android:text="123"
  269 + android:textColor="@color/black"
  270 + android:textSize="17sp"
  271 + android:textStyle="bold" />
  272 +
  273 + <TextView
  274 + android:layout_width="wrap_content"
  275 + android:layout_height="wrap_content"
  276 + android:layout_marginLeft="5dp"
  277 + android:text="人参与"
  278 + android:textColor="@color/black"
  279 + android:textSize="15sp" />
  280 +
  281 + <LinearLayout
  282 + android:layout_width="match_parent"
  283 + android:layout_height="wrap_content"
  284 + android:gravity="right|center">
  285 +
  286 + <com.cnlive.moudle.pedometer.ui.widget.FivePersonIconView
  287 + android:layout_width="match_parent"
  288 + android:layout_height="40dp"
  289 + android:layout_marginRight="10dp"></com.cnlive.moudle.pedometer.ui.widget.FivePersonIconView>
  290 +
  291 +
  292 + </LinearLayout>
  293 + </LinearLayout>
  294 + <!---->
  295 + </LinearLayout>
  296 + </ScrollView>
  297 +</layout>
0 298 \ No newline at end of file
... ...
moudle_pedometer/src/main/res/layout/five_persion_icon.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:app="http://schemas.android.com/apk/res-auto"
  4 + android:layout_width="match_parent"
  5 + android:layout_height="wrap_content"
  6 + android:gravity="center_vertical|right">
  7 +
  8 +
  9 + <com.qmuiteam.qmui.widget.QMUIRadiusImageView
  10 + android:id="@+id/qm_iv1"
  11 + android:layout_width="40dp"
  12 + android:layout_height="40dp"
  13 + android:layout_marginLeft="10dp"
  14 + android:background="@drawable/tc_ic_workout_level_adjust_coach"
  15 + app:qmui_corner_radius="100dp" />
  16 +
  17 + <com.qmuiteam.qmui.widget.QMUIRadiusImageView
  18 + android:id="@+id/qm_iv2"
  19 + android:layout_width="40dp"
  20 + android:layout_height="40dp"
  21 + android:layout_marginLeft="-10dp"
  22 + android:background="@drawable/tc_ic_workout_level_adjust_coach"
  23 + app:qmui_corner_radius="100dp" />
  24 +
  25 + <com.qmuiteam.qmui.widget.QMUIRadiusImageView
  26 + android:id="@+id/qm_iv3"
  27 + android:layout_width="40dp"
  28 + android:layout_height="40dp"
  29 + android:layout_marginLeft="-10dp"
  30 + android:background="@drawable/tc_ic_workout_level_adjust_coach"
  31 + app:qmui_corner_radius="100dp" />
  32 +
  33 + <com.qmuiteam.qmui.widget.QMUIRadiusImageView
  34 + android:id="@+id/qm_iv4"
  35 + android:layout_width="40dp"
  36 + android:layout_height="40dp"
  37 + android:layout_marginLeft="-10dp"
  38 + android:background="@drawable/tc_ic_workout_level_adjust_coach"
  39 + app:qmui_corner_radius="100dp" />
  40 +
  41 + <com.qmuiteam.qmui.widget.QMUIRadiusImageView
  42 + android:id="@+id/qm_iv5"
  43 + android:layout_width="40dp"
  44 + android:layout_height="40dp"
  45 + android:layout_marginLeft="-10dp"
  46 + android:background="@drawable/tc_ic_workout_level_adjust_coach"
  47 + app:qmui_corner_radius="100dp" />
  48 +
  49 + <ImageView
  50 + android:id="@+id/iv_right"
  51 + android:layout_width="9dp"
  52 + android:layout_height="15dp"
  53 + android:layout_marginLeft="5dp"
  54 + android:background="@drawable/tc_suit_right_arrow" />
  55 +</LinearLayout>
0 56 \ No newline at end of file
... ...
moudle_pedometer/src/main/res/layout/fragment_run_main.xml
... ... @@ -116,21 +116,28 @@
116 116 android:layout_marginBottom="5dp"
117 117 android:src="@drawable/rt_outdoor_video_pace" />
118 118  
119   - <TextView
120   - android:id="@+id/tv_speed"
121   - android:layout_width="wrap_content"
  119 + <LinearLayout
  120 + android:layout_width="match_parent"
122 121 android:layout_height="wrap_content"
123   - android:text="--"
124   - android:textColor="@color/white"
125   - android:textSize="20sp"
126   - android:textStyle="bold" />
  122 + android:gravity="center">
  123 +
  124 + <TextView
  125 + android:id="@+id/tv_speed"
  126 + android:layout_width="wrap_content"
  127 + android:layout_height="wrap_content"
  128 + android:text="--"
  129 + android:textColor="@color/white"
  130 + android:textSize="20sp"
  131 + android:textStyle="bold" />
  132 +
  133 + </LinearLayout>
127 134  
128 135 <TextView
129 136 android:layout_width="wrap_content"
130 137 android:layout_height="wrap_content"
131 138 android:layout_marginTop="5dp"
132 139 android:gravity="center"
133   - android:text="速度"
  140 + android:text="时速"
134 141 android:textColor="@color/text_gray"
135 142 android:textSize="17sp"
136 143 android:textStyle="bold" />
... ... @@ -401,7 +408,7 @@
401 408 android:layout_height="match_parent"
402 409 android:background="@color/run_main_time_bg"
403 410 android:gravity="center"
404   - >
  411 + >
405 412  
406 413 <TextView
407 414 android:id="@+id/tv_time_count_down"
... ...
moudle_pedometer/src/main/res/layout/fragment_run_race_detail.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<layout xmlns:android="http://schemas.android.com/apk/res/android">
  3 +
  4 + <FrameLayout
  5 + android:layout_width="match_parent"
  6 + android:layout_height="match_parent">
  7 +
  8 + <com.baidu.mapapi.map.MapView
  9 + android:id="@+id/mapView"
  10 + android:layout_width="match_parent"
  11 + android:layout_height="match_parent"></com.baidu.mapapi.map.MapView>
  12 +
  13 + <FrameLayout
  14 + android:layout_width="40dp"
  15 + android:layout_height="40dp"
  16 + android:layout_margin="10dp"
  17 + android:background="@drawable/shape_circle_50_black">
  18 +
  19 + <ImageView
  20 + android:layout_width="15dp"
  21 + android:layout_height="20dp"
  22 + android:layout_gravity="center"
  23 + android:background="@drawable/ic_white_back" />
  24 + </FrameLayout>
  25 +
  26 + <FrameLayout
  27 + android:layout_width="40dp"
  28 + android:layout_height="40dp"
  29 + android:layout_gravity="right"
  30 + android:layout_margin="10dp"
  31 + android:background="@drawable/shape_circle_50_black">
  32 +
  33 + <ImageView
  34 + android:layout_width="25dp"
  35 + android:layout_height="25dp"
  36 + android:layout_gravity="center"
  37 + android:background="@drawable/icon_share" />
  38 + </FrameLayout>
  39 + </FrameLayout>
  40 +
  41 +</layout>
0 42 \ No newline at end of file
... ...
moudle_pedometer/src/main/res/layout/fragment_running_map.xml
... ... @@ -7,7 +7,139 @@
7 7 android:orientation="vertical">
8 8  
9 9 <com.baidu.mapapi.map.MapView
  10 + android:id="@+id/mapView"
10 11 android:layout_width="match_parent"
11 12 android:layout_height="match_parent"></com.baidu.mapapi.map.MapView>
  13 +
  14 + <FrameLayout
  15 + android:id="@+id/fl_back"
  16 + android:layout_width="60dp"
  17 + android:layout_height="60dp"
  18 + android:background="@drawable/button_fab_white"
  19 + android:focusable="true">
  20 +
  21 + <ImageView
  22 + android:layout_width="25dp"
  23 + android:layout_height="25dp"
  24 + android:layout_gravity="center"
  25 + android:layout_marginLeft="2dp"
  26 + android:background="@drawable/mo_ic_dialog_back"
  27 + android:focusable="false" />
  28 + </FrameLayout>
  29 +
  30 + <LinearLayout
  31 + android:layout_width="match_parent"
  32 + android:layout_height="wrap_content"
  33 + android:layout_gravity="bottom"
  34 + android:orientation="vertical">
  35 +
  36 + <FrameLayout
  37 + android:id="@+id/fl_location"
  38 + android:layout_width="60dp"
  39 + android:layout_height="60dp"
  40 + android:layout_marginBottom="20dp"
  41 + android:background="@drawable/button_fab_white"
  42 + android:focusable="true">
  43 +
  44 + <ImageView
  45 + android:layout_width="60dp"
  46 + android:layout_height="60dp"
  47 + android:layout_gravity="center"
  48 + android:background="@drawable/rt_ic_location_blank"
  49 + android:focusable="false" />
  50 + </FrameLayout>
  51 +
  52 + <LinearLayout
  53 + 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">
  59 +
  60 + <LinearLayout
  61 + android:layout_width="0dp"
  62 + android:layout_height="match_parent"
  63 + android:layout_weight="1"
  64 + android:gravity="center"
  65 + android:orientation="vertical"
  66 + android:paddingLeft="5dp"
  67 + android:paddingRight="5dp">
  68 +
  69 + <TextView
  70 + android:id="@+id/tv_current_speed"
  71 + android:layout_width="wrap_content"
  72 + android:layout_height="wrap_content"
  73 + android:text="--"
  74 + android:textColor="@color/black"
  75 + android:textSize="20sp"
  76 + android:textStyle="bold" />
  77 +
  78 + <TextView
  79 + android:layout_width="wrap_content"
  80 + android:layout_height="wrap_content"
  81 + android:layout_marginTop="10dp"
  82 + android:text="配速"
  83 + android:textColor="@color/black"
  84 + android:textSize="15sp" />
  85 + </LinearLayout>
  86 +
  87 + <LinearLayout
  88 + android:layout_width="0dp"
  89 + android:layout_height="match_parent"
  90 + android:layout_weight="1.5"
  91 + android:gravity="center"
  92 + android:orientation="vertical">
  93 +
  94 + <Chronometer
  95 + android:id="@+id/chronometer"
  96 + android:layout_width="wrap_content"
  97 + android:layout_height="wrap_content"
  98 + android:format="00:00:00"
  99 + android:textColor="@color/black"
  100 + android:textSize="20sp"
  101 + android:textStyle="bold" />
  102 +
  103 + <TextView
  104 + android:layout_width="wrap_content"
  105 + android:layout_height="wrap_content"
  106 + android:layout_marginTop="10dp"
  107 + android:text="用时"
  108 + android:textColor="@color/black"
  109 + android:textSize="15sp" />
  110 + </LinearLayout>
  111 +
  112 +
  113 + <LinearLayout
  114 + android:layout_width="0dp"
  115 + android:layout_height="match_parent"
  116 + android:layout_weight="1"
  117 + android:gravity="center"
  118 + android:orientation="vertical"
  119 + android:paddingLeft="5dp"
  120 + android:paddingRight="5dp">
  121 +
  122 + <TextView
  123 + android:id="@+id/tv_current_diatance"
  124 + android:layout_width="wrap_content"
  125 + android:layout_height="wrap_content"
  126 + android:text="--"
  127 + android:textColor="@color/black"
  128 + android:textSize="20sp"
  129 + android:textStyle="bold" />
  130 +
  131 + <TextView
  132 + android:layout_width="wrap_content"
  133 + android:layout_height="wrap_content"
  134 + android:layout_marginTop="10dp"
  135 + android:text="距离(km)"
  136 + android:textColor="@color/black"
  137 + android:textSize="15sp" />
  138 + </LinearLayout>
  139 +
  140 + </LinearLayout>
  141 + </LinearLayout>
  142 + <!---->
  143 +
12 144 </FrameLayout>
13 145 </layout>
14 146 \ No newline at end of file
... ...
moudle_pedometer/src/main/res/values/colors.xml
... ... @@ -12,4 +12,12 @@
12 12 <color name="btn_green">#23D41E</color>
13 13 <color name="transparent">#00000000</color>
14 14  
  15 + <!--圆形shape -->
  16 + <!--半透明黑色-->
  17 + <color name="black_50">#80000000</color>
  18 + <color name="green">#23D026</color>
  19 + <color name="red">#EF5544</color>
  20 +
  21 +
  22 + <color name="bottom_sheet_dialog_race_location_text">#C3C3C3</color>
15 23 </resources>
... ...
moudle_pedometer/src/main/res/values/ids.xml
... ... @@ -2,5 +2,6 @@
2 2 <resources>
3 3 <item name="fragment_run_main" type="id" />
4 4 <item name="fragment_running_map" type="id" />
  5 + <item name="fragment_run_trace_detail" type="id" />
5 6  
6 7 </resources>
... ...