Commit de53e4b91521fabf66ac60981baeea8e6ec9277d
Merge branch 'master' of bj.gitlab.cnlive.com:cnlive-team/ModulePedometer
Showing
33 changed files
with
749 additions
and
225 deletions
moudle_pedometer/src/main/AndroidManifest.xml
| ... | ... | @@ -59,7 +59,9 @@ |
| 59 | 59 | <activity android:name="com.cnlive.moudle.pedometer.ui.activity.MyRecordActivity" /> |
| 60 | 60 | <activity android:name="com.cnlive.moudle.pedometer.ui.activity.ShareRecordActivity" /> |
| 61 | 61 | <activity android:name="com.cnlive.moudle.pedometer.ui.activity.RaceRecordActivity" /> |
| 62 | - <activity android:name="com.cnlive.moudle.pedometer.ui.activity.RegistrationInfoActivity" /> | |
| 62 | + <activity | |
| 63 | + android:name="com.cnlive.moudle.pedometer.ui.activity.RegistrationInfoActivity" | |
| 64 | + android:process=":step" /> | |
| 63 | 65 | |
| 64 | 66 | <service |
| 65 | 67 | android:name="com.cnlive.moudle.pedometer.service.StepService" |
| ... | ... | @@ -169,9 +171,9 @@ |
| 169 | 171 | <action android:name="com.example.myservice.MyReceiver" /> |
| 170 | 172 | </intent-filter> |
| 171 | 173 | </receiver> |
| 174 | + | |
| 172 | 175 | <activity |
| 173 | 176 | android:name="com.cnlive.moudle.collectionTrace.ui.activity.CollPedometerMainActivity" |
| 174 | - android:launchMode="singleTask" | |
| 175 | 177 | android:process=":step" /> |
| 176 | 178 | <activity |
| 177 | 179 | android:name="com.cnlive.moudle.collectionTrace.ui.activity.CollRunningFinishActivity" | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/presenter/CollRunRaceDetailFragmentPresenter.java
| ... | ... | @@ -25,7 +25,7 @@ import static com.cnlive.libs.base.logic.Config.STATE_LOAD; |
| 25 | 25 | |
| 26 | 26 | public class CollRunRaceDetailFragmentPresenter extends MvpBasePresenter<CollRunRaceDetailFragmentView> { |
| 27 | 27 | |
| 28 | - public void getRunRaceDetailInfo(Context context, String id, String userId,String state) { | |
| 28 | + public void getRunRaceDetailInfo(Context context, String id, String userId, String state) { | |
| 29 | 29 | //设置请求参数 |
| 30 | 30 | Map<String, String> paramsMap = new HashMap<>(); |
| 31 | 31 | //赛事id |
| ... | ... | @@ -97,7 +97,7 @@ public class CollRunRaceDetailFragmentPresenter extends MvpBasePresenter<CollRun |
| 97 | 97 | getView().showRetryView(code, new View.OnClickListener() { |
| 98 | 98 | @Override |
| 99 | 99 | public void onClick(View view) { |
| 100 | - getRunRaceDetailInfo(context, id, userId,state); | |
| 100 | + getRunRaceDetailInfo(context, id, userId, state); | |
| 101 | 101 | } |
| 102 | 102 | }); |
| 103 | 103 | } |
| ... | ... | @@ -108,7 +108,7 @@ public class CollRunRaceDetailFragmentPresenter extends MvpBasePresenter<CollRun |
| 108 | 108 | return; |
| 109 | 109 | } |
| 110 | 110 | if (baseInfo.getData() != null) { |
| 111 | - getView().initView(baseInfo.getData()); | |
| 111 | + getView().initView(baseInfo.getData(), userId); | |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | }).start(); | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/presenter/CollRunningMapFragmentPresenter.java
| ... | ... | @@ -46,6 +46,7 @@ import com.baidu.trace.model.StatusCodes; |
| 46 | 46 | import com.baidu.trace.model.TraceLocation; |
| 47 | 47 | import com.baidu.trace.model.TransportMode; |
| 48 | 48 | import com.cnlive.moudle.collectionTrace.frame.view.CollRunningMapFragmentView; |
| 49 | +import com.cnlive.moudle.pedometer.model.Constant; | |
| 49 | 50 | import com.cnlive.moudle.pedometer.service.StepService; |
| 50 | 51 | import com.cnlive.moudle.pedometer.utils.CommonUtil; |
| 51 | 52 | import com.cnlive.moudle.pedometer.utils.GsonUtil; |
| ... | ... | @@ -68,8 +69,6 @@ public class CollRunningMapFragmentPresenter extends MvpBasePresenter<CollRunnin |
| 68 | 69 | private int realTimePageSize = 1000; |
| 69 | 70 | //分页索引 |
| 70 | 71 | private int realTimePageIndex = 1; |
| 71 | - //查询标识 | |
| 72 | - private int tag = 1; | |
| 73 | 72 | /** |
| 74 | 73 | * 历史轨迹请求 |
| 75 | 74 | */ |
| ... | ... | @@ -115,7 +114,7 @@ public class CollRunningMapFragmentPresenter extends MvpBasePresenter<CollRunnin |
| 115 | 114 | } |
| 116 | 115 | |
| 117 | 116 | if (historyTrackRequest == null) { |
| 118 | - historyTrackRequest = new HistoryTrackRequest(tag, StepService.serviceId, entityName); | |
| 117 | + historyTrackRequest = new HistoryTrackRequest(Constant.TAG, Constant.SERVICE_ID, entityName); | |
| 119 | 118 | //设置查询设备名称 |
| 120 | 119 | historyTrackRequest.setEntityName(entityName); |
| 121 | 120 | //历史轨迹开始时间 |
| ... | ... | @@ -151,7 +150,7 @@ public class CollRunningMapFragmentPresenter extends MvpBasePresenter<CollRunnin |
| 151 | 150 | //创建里程查询 |
| 152 | 151 | if (distanceRequest == null) { |
| 153 | 152 | // 创建里程查询请求实例 |
| 154 | - distanceRequest = new DistanceRequest(tag, StepService.serviceId, entityName); | |
| 153 | + distanceRequest = new DistanceRequest(Constant.TAG, Constant.SERVICE_ID, entityName); | |
| 155 | 154 | // 设置开始时间 |
| 156 | 155 | distanceRequest.setStartTime(startTime); |
| 157 | 156 | // 设置结束时间 |
| ... | ... | @@ -293,8 +292,8 @@ public class CollRunningMapFragmentPresenter extends MvpBasePresenter<CollRunnin |
| 293 | 292 | List<String> names = new ArrayList<>(); |
| 294 | 293 | names.add(entityName); |
| 295 | 294 | realTimeListRequest = new LocRequest(); |
| 296 | - realTimeListRequest.setServiceId(StepService.serviceId); | |
| 297 | - realTimeListRequest.setTag(1); | |
| 295 | + realTimeListRequest.setServiceId(Constant.SERVICE_ID); | |
| 296 | + realTimeListRequest.setTag(Constant.TAG); | |
| 298 | 297 | } |
| 299 | 298 | if (realTimePoints == null) { |
| 300 | 299 | realTimePoints = new ArrayList<>(); |
| ... | ... | @@ -480,7 +479,9 @@ public class CollRunningMapFragmentPresenter extends MvpBasePresenter<CollRunnin |
| 480 | 479 | // } |
| 481 | 480 | // } |
| 482 | 481 | |
| 483 | - FenceListRequest request = FenceListRequest.buildServerRequest(tag, StepService.serviceId, "yangshuai", null, CoordType.gcj02); | |
| 482 | + | |
| 483 | + | |
| 484 | + FenceListRequest request = FenceListRequest.buildServerRequest(Constant.TAG, Constant.SERVICE_ID, "yangshuai", null, CoordType.gcj02); | |
| 484 | 485 | |
| 485 | 486 | //发起查询围栏请求 |
| 486 | 487 | if (StepService.mClient != null) { |
| ... | ... | @@ -489,8 +490,8 @@ public class CollRunningMapFragmentPresenter extends MvpBasePresenter<CollRunnin |
| 489 | 490 | |
| 490 | 491 | List<Long> fenid = new ArrayList<>(); |
| 491 | 492 | fenid.add(1L); |
| 492 | - MonitoredStatusRequest request1 = MonitoredStatusRequest.buildServerRequest(tag, | |
| 493 | - StepService.serviceId, "yangshuai", fenid); | |
| 493 | + MonitoredStatusRequest request1 = MonitoredStatusRequest.buildServerRequest(Constant.TAG, | |
| 494 | + Constant.SERVICE_ID, "yangshuai", fenid); | |
| 494 | 495 | Handler handler = new Handler(); |
| 495 | 496 | Runnable runnable = new Runnable() { |
| 496 | 497 | @Override | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunMainFragmentView.java
| ... | ... | @@ -107,7 +107,6 @@ public class CollRunMainFragmentView implements MvpView { |
| 107 | 107 | */ |
| 108 | 108 | public void initView() { |
| 109 | 109 | uid = "yangshuai"; |
| 110 | - CollCommonInfo.setUserId(getContext(), uid); | |
| 111 | 110 | initLocationClient(); |
| 112 | 111 | CollUserStepEntity userStepEntity = CollStepUtil.getCollUserStepData(getContext(), uid); |
| 113 | 112 | if (userStepEntity != null) { |
| ... | ... | @@ -147,8 +146,7 @@ public class CollRunMainFragmentView implements MvpView { |
| 147 | 146 | } |
| 148 | 147 | } |
| 149 | 148 | }, 10); |
| 150 | - //开启计步服务 | |
| 151 | - startStepService(getContext(), uid); | |
| 149 | + | |
| 152 | 150 | } |
| 153 | 151 | } |
| 154 | 152 | }; |
| ... | ... | @@ -453,23 +451,7 @@ public class CollRunMainFragmentView implements MvpView { |
| 453 | 451 | } |
| 454 | 452 | } |
| 455 | 453 | |
| 456 | - /** | |
| 457 | - * 启动计步服务 | |
| 458 | - * | |
| 459 | - * @param userId | |
| 460 | - */ | |
| 461 | - public void startStepService(Context context, String userId) { | |
| 462 | - if (CollCommonInfo.getStepStartTime(context) == 0) { | |
| 463 | - CollCommonInfo.setStepStartTime(context, TimeUtil.getNowTimeStamp()); | |
| 464 | - } | |
| 465 | - CollCommonInfo.setIsRunKeepAliveService(context, true); | |
| 466 | - CollCommonInfo.setIsRunStepService(context, true); | |
| 467 | - CollCommonInfo.setTsRunBaiduTraceService(context, true); | |
| 468 | - CollCommonInfo.setIsWriteUserStep(context, true); | |
| 469 | - Intent intent = new Intent(fragment.getActivity(), CollKeepLiveService.class); | |
| 470 | - ContextCompat.startForegroundService(fragment.getActivity(), intent); | |
| 471 | 454 | |
| 472 | - } | |
| 473 | 455 | |
| 474 | 456 | /** |
| 475 | 457 | * 更新行走距离 | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunRaceDetailFragmentView.java
| 1 | 1 | package com.cnlive.moudle.collectionTrace.frame.view; |
| 2 | 2 | |
| 3 | 3 | import android.content.Context; |
| 4 | +import android.content.Intent; | |
| 4 | 5 | import android.graphics.Bitmap; |
| 5 | 6 | import android.graphics.BitmapFactory; |
| 6 | 7 | import android.hardware.Sensor; |
| 7 | 8 | import android.hardware.SensorEvent; |
| 8 | 9 | import android.hardware.SensorEventListener; |
| 9 | 10 | import android.hardware.SensorManager; |
| 11 | +import android.support.v4.content.ContextCompat; | |
| 10 | 12 | import android.text.TextUtils; |
| 11 | 13 | import android.util.Log; |
| 12 | 14 | import android.view.View; |
| ... | ... | @@ -41,12 +43,15 @@ import com.baidu.mapapi.search.route.RoutePlanSearch; |
| 41 | 43 | import com.baidu.mapapi.search.route.TransitRouteResult; |
| 42 | 44 | import com.baidu.mapapi.search.route.WalkingRoutePlanOption; |
| 43 | 45 | import com.baidu.mapapi.search.route.WalkingRouteResult; |
| 46 | +import com.cnlive.moudle.collectionTrace.service.CollKeepLiveService; | |
| 44 | 47 | import com.cnlive.moudle.collectionTrace.ui.activity.StartCollectTraceActivity; |
| 45 | 48 | import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunRaceDetailFragment; |
| 49 | +import com.cnlive.moudle.pedometer.commonInfo.CollCommonInfo; | |
| 46 | 50 | import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo; |
| 47 | 51 | import com.cnlive.moudle.pedometer.utils.BitmapUtil; |
| 48 | 52 | import com.cnlive.moudle.pedometer.utils.GsonUtil; |
| 49 | 53 | import com.cnlive.moudle.pedometer.utils.MyMapUtil; |
| 54 | +import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil; | |
| 50 | 55 | import com.cnlive.moudle.pedometer.utils.TimeUtil; |
| 51 | 56 | import com.cnlive.strike.application.GlideApp; |
| 52 | 57 | import com.example.moudle_pedometer.R; |
| ... | ... | @@ -106,12 +111,13 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen |
| 106 | 111 | } |
| 107 | 112 | |
| 108 | 113 | |
| 109 | - public void initView(RunRaceDetailInfo runRaceDetailInfo) { | |
| 114 | + public void initView(RunRaceDetailInfo runRaceDetailInfo, String uid) { | |
| 110 | 115 | if (fragment.getActivity() == null) { |
| 111 | 116 | return; |
| 112 | 117 | } |
| 118 | + CollCommonInfo.setUserId(getContext(), uid); | |
| 113 | 119 | this.runRaceDetailInfo = runRaceDetailInfo; |
| 114 | -// //初始化地图点位 | |
| 120 | + //初始化地图点位 | |
| 115 | 121 | if (runRaceDetailInfo.getLatLongitude() != null) { |
| 116 | 122 | Log.e(TAG, "initView: 长度:" + runRaceDetailInfo.getLatLongitude().length()); |
| 117 | 123 | trackPoints = GsonUtil.jsonToList(runRaceDetailInfo.getLatLongitude(), LatLng.class); |
| ... | ... | @@ -205,6 +211,7 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen |
| 205 | 211 | |
| 206 | 212 | } |
| 207 | 213 | |
| 214 | + | |
| 208 | 215 | public void initMap() { |
| 209 | 216 | //隐藏底部滑动卡片 |
| 210 | 217 | fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN); | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/StartTraceFragmentView.java
| 1 | 1 | package com.cnlive.moudle.collectionTrace.frame.view; |
| 2 | 2 | |
| 3 | 3 | import android.content.Context; |
| 4 | +import android.content.Intent; | |
| 4 | 5 | import android.graphics.Bitmap; |
| 5 | 6 | import android.graphics.BitmapFactory; |
| 6 | 7 | import android.hardware.Sensor; |
| 7 | 8 | import android.hardware.SensorEvent; |
| 8 | 9 | import android.hardware.SensorEventListener; |
| 9 | 10 | import android.hardware.SensorManager; |
| 11 | +import android.support.v4.content.ContextCompat; | |
| 10 | 12 | import android.text.TextUtils; |
| 11 | 13 | import android.view.View; |
| 12 | 14 | import android.widget.Toast; |
| ... | ... | @@ -26,13 +28,17 @@ import com.baidu.mapapi.map.MyLocationData; |
| 26 | 28 | import com.baidu.mapapi.map.UiSettings; |
| 27 | 29 | import com.baidu.mapapi.model.LatLng; |
| 28 | 30 | import com.baidu.mapapi.search.route.RoutePlanSearch; |
| 31 | +import com.cnlive.moudle.collectionTrace.service.CollKeepLiveService; | |
| 29 | 32 | import com.cnlive.moudle.collectionTrace.ui.activity.CollPedometerMainActivity; |
| 30 | 33 | import com.cnlive.moudle.collectionTrace.ui.activity.CollRunRaceDetailActivity; |
| 31 | 34 | import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunRaceDetailFragment; |
| 32 | 35 | import com.cnlive.moudle.collectionTrace.ui.fragment.StartTraceFragment; |
| 36 | +import com.cnlive.moudle.pedometer.commonInfo.CollCommonInfo; | |
| 33 | 37 | import com.cnlive.moudle.pedometer.ui.widget.SelectDialog; |
| 34 | 38 | import com.cnlive.moudle.pedometer.ui.widget.TipDialog; |
| 35 | 39 | import com.cnlive.moudle.pedometer.utils.BitmapUtil; |
| 40 | +import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil; | |
| 41 | +import com.cnlive.moudle.pedometer.utils.TimeUtil; | |
| 36 | 42 | import com.example.moudle_pedometer.R; |
| 37 | 43 | import com.hannesdorfmann.mosby3.mvp.MvpView; |
| 38 | 44 | |
| ... | ... | @@ -83,8 +89,9 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { |
| 83 | 89 | public void onClick(SelectDialog dialog) { |
| 84 | 90 | dialog.dismiss(); |
| 85 | 91 | isShowFollowAddress = false; |
| 86 | - CollPedometerMainActivity.startActivity(fragment.getActivity()); | |
| 87 | - fragment.getActivity().finish(); | |
| 92 | + //开启计步服务 | |
| 93 | + startStepService(getContext()); | |
| 94 | + | |
| 88 | 95 | } |
| 89 | 96 | }); |
| 90 | 97 | selectDialog.setCancelable(false); |
| ... | ... | @@ -107,6 +114,23 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { |
| 107 | 114 | } |
| 108 | 115 | |
| 109 | 116 | /** |
| 117 | + * 启动计步服务 | |
| 118 | + */ | |
| 119 | + public void startStepService(Context context) { | |
| 120 | + QMUITipDialogUtil.loadingDialog(getContext(), "请稍后", false); | |
| 121 | + if (CollCommonInfo.getStepStartTime(context) == 0) { | |
| 122 | + CollCommonInfo.setStepStartTime(context, TimeUtil.getNowTimeStamp()); | |
| 123 | + } | |
| 124 | + CollCommonInfo.setIsRunKeepAliveService(context, true); | |
| 125 | + CollCommonInfo.setIsRunStepService(context, true); | |
| 126 | + CollCommonInfo.setTsRunBaiduTraceService(context, true); | |
| 127 | + CollCommonInfo.setIsWriteUserStep(context, true); | |
| 128 | + Intent intent = new Intent(fragment.getActivity(), CollKeepLiveService.class); | |
| 129 | + ContextCompat.startForegroundService(fragment.getActivity(), intent); | |
| 130 | + | |
| 131 | + } | |
| 132 | + | |
| 133 | + /** | |
| 110 | 134 | * 初始化地图 |
| 111 | 135 | */ |
| 112 | 136 | public void initMap() { | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/service/CollKeepLiveService.java
| ... | ... | @@ -146,15 +146,12 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple |
| 146 | 146 | this.startId = startId; |
| 147 | 147 | //跨进程读取配置文件 |
| 148 | 148 | boolean isRun = CollCommonInfo.getIsRunKeepAliveService(getApplicationContext()); |
| 149 | - Log.e("isRun onStartCommand", "" + isRun); | |
| 150 | 149 | |
| 151 | 150 | if (isRun) { |
| 152 | 151 | if (runnable != null) { |
| 153 | 152 | handler.postDelayed(runnable, 5000); |
| 154 | 153 | } |
| 155 | 154 | showHideForegroundNotification(); |
| 156 | -// startService(new Intent(getApplicationContext(), HideKeepTipService.class)); | |
| 157 | - Log.e(TAG, "启动HideKeepTipService"); | |
| 158 | 155 | startPlaySong(); |
| 159 | 156 | } |
| 160 | 157 | return START_STICKY; |
| ... | ... | @@ -220,7 +217,6 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple |
| 220 | 217 | @Override |
| 221 | 218 | public void onDestroy() { |
| 222 | 219 | super.onDestroy(); |
| 223 | - Log.e("onDestroy", "onDestroy:" + notification); | |
| 224 | 220 | if (myReceiver != null) { |
| 225 | 221 | unregisterReceiver(myReceiver); |
| 226 | 222 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/service/CollStepService.java
| ... | ... | @@ -37,6 +37,7 @@ import com.baidu.trace.model.LocationMode; |
| 37 | 37 | import com.baidu.trace.model.OnTraceListener; |
| 38 | 38 | import com.baidu.trace.model.PushMessage; |
| 39 | 39 | import com.baidu.trace.model.StatusCodes; |
| 40 | +import com.cnlive.moudle.pedometer.commonInfo.CollCommonInfo; | |
| 40 | 41 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 41 | 42 | import com.cnlive.moudle.pedometer.model.Constant; |
| 42 | 43 | import com.cnlive.moudle.pedometer.model.MessageEvent; |
| ... | ... | @@ -138,12 +139,6 @@ public class CollStepService extends Service implements SensorEventListener { |
| 138 | 139 | * 轨迹监听器(用于接收纠偏后实时位置回调) |
| 139 | 140 | */ |
| 140 | 141 | private OnTrackListener realTimeTraceListener = null; |
| 141 | - //位置采集周期 | |
| 142 | - private int gatherInterval = 3; | |
| 143 | - //打包周期 | |
| 144 | - private int packInterval = 10; | |
| 145 | - // 轨迹服务ID | |
| 146 | - public static final long serviceId = 213511; | |
| 147 | 142 | // public static final long serviceId = 213553;//杨帅 |
| 148 | 143 | |
| 149 | 144 | // 设备标识 |
| ... | ... | @@ -158,6 +153,8 @@ public class CollStepService extends Service implements SensorEventListener { |
| 158 | 153 | */ |
| 159 | 154 | public static Trace mTrace = null; |
| 160 | 155 | |
| 156 | + private boolean isFirstSendNotification = true; | |
| 157 | + | |
| 161 | 158 | public CollStepService() { |
| 162 | 159 | |
| 163 | 160 | } |
| ... | ... | @@ -168,26 +165,20 @@ public class CollStepService extends Service implements SensorEventListener { |
| 168 | 165 | super.onCreate(); |
| 169 | 166 | init(); |
| 170 | 167 | initBroadcastReceiver(); |
| 171 | - if (!ServiceUtils.isServiceRunning(getApplicationContext(), "com.cnlive.moudle.collectionTrace.service.CollKeepLiveService")) { | |
| 172 | - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |
| 173 | - startForegroundService(new Intent(getApplicationContext(), CollKeepLiveService.class)); | |
| 174 | - } else { | |
| 175 | - startService(new Intent(getApplicationContext(), CollKeepLiveService.class)); | |
| 176 | - } | |
| 177 | - } | |
| 178 | 168 | showStartForegroundNotification(); |
| 179 | 169 | } |
| 180 | 170 | |
| 181 | 171 | private void initTrace() { |
| 172 | + | |
| 182 | 173 | if (mClient == null) { |
| 183 | 174 | mClient = new LBSTraceClient(getApplicationContext()); |
| 184 | 175 | // 设置定位和打包周期 |
| 185 | - mClient.setInterval(gatherInterval, packInterval); | |
| 176 | + mClient.setInterval(Constant.GATHER_INTERVAL, Constant.PACK_INTERVAL); | |
| 186 | 177 | //设置定位模式 |
| 187 | 178 | mClient.setLocationMode(LocationMode.High_Accuracy); |
| 188 | 179 | } |
| 189 | 180 | if (mTrace == null) { |
| 190 | - mTrace = new Trace(serviceId, entityName); | |
| 181 | + mTrace = new Trace(Constant.SERVICE_ID, entityName); | |
| 191 | 182 | } |
| 192 | 183 | //初始化实时轨迹监听器 |
| 193 | 184 | realTimeTraceListener = new OnTrackListener() { |
| ... | ... | @@ -279,6 +270,17 @@ public class CollStepService extends Service implements SensorEventListener { |
| 279 | 270 | public void onStartGatherCallback(int errorNo, String message) { |
| 280 | 271 | if (StatusCodes.SUCCESS == errorNo || StatusCodes.GATHER_STARTED == errorNo) { |
| 281 | 272 | Toast.makeText(getApplicationContext(), "开始采集", Toast.LENGTH_LONG).show(); |
| 273 | + boolean isFirstSendNotification = CollCommonInfo.getIsFirstStepSendTraceTip(getApplicationContext()); | |
| 274 | + if (isFirstSendNotification) { | |
| 275 | + CollCommonInfo.setIsFirstStepSendTraceTip(getApplicationContext(), false); | |
| 276 | + EventBus.getDefault().post(new MessageEvent(Constant.COLL_START_TRACE_GATHER_SUCCESS, "")); | |
| 277 | + } | |
| 278 | + } else { | |
| 279 | + boolean isFirstSendNotification = CollCommonInfo.getIsFirstStepSendTraceTip(getApplicationContext()); | |
| 280 | + if (isFirstSendNotification) { | |
| 281 | + CollCommonInfo.setIsFirstStepSendTraceTip(getApplicationContext(), false); | |
| 282 | + EventBus.getDefault().post(new MessageEvent(Constant.COLL_START_TRACE_GATHER_FAIL, "")); | |
| 283 | + } | |
| 282 | 284 | } |
| 283 | 285 | } |
| 284 | 286 | |
| ... | ... | @@ -362,7 +364,7 @@ public class CollStepService extends Service implements SensorEventListener { |
| 362 | 364 | @SuppressLint("WrongConstant") |
| 363 | 365 | @Override |
| 364 | 366 | public int onStartCommand(Intent intent, int flags, int startId) { |
| 365 | - userId = CommonInfo.getUserId(getApplicationContext()); | |
| 367 | + userId = CollCommonInfo.getUserId(getApplicationContext()); | |
| 366 | 368 | if (userId != null && !TextUtils.isEmpty(userId)) { |
| 367 | 369 | if (!EventBus.getDefault().isRegistered(this)) { |
| 368 | 370 | EventBus.getDefault().register(this); |
| ... | ... | @@ -380,6 +382,9 @@ public class CollStepService extends Service implements SensorEventListener { |
| 380 | 382 | } |
| 381 | 383 | }).start(); |
| 382 | 384 | startTimeCount(); |
| 385 | + } else { | |
| 386 | + EventBus.getDefault().post(new MessageEvent(Constant.COLL_START_TRACE_GATHER_FAIL, "")); | |
| 387 | + | |
| 383 | 388 | } |
| 384 | 389 | // if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { |
| 385 | 390 | // //开始配置JobInfo | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/activity/CollPedometerMainActivity.java
| ... | ... | @@ -32,7 +32,7 @@ import static android.provider.Settings.EXTRA_APP_PACKAGE; |
| 32 | 32 | */ |
| 33 | 33 | @Route(path = "/moudle_pedometer/InterestActivity") |
| 34 | 34 | public class CollPedometerMainActivity extends QMUIFragmentActivity { |
| 35 | - private static final String TAG = "CollPedometerMainActivity"; | |
| 35 | + private static final String TAG = "CollPedometerMain"; | |
| 36 | 36 | |
| 37 | 37 | private NotificationManagerCompat notificationManagerCompat; |
| 38 | 38 | private boolean isOpen; |
| ... | ... | @@ -56,6 +56,7 @@ public class CollPedometerMainActivity extends QMUIFragmentActivity { |
| 56 | 56 | @Override |
| 57 | 57 | protected void onDestroy() { |
| 58 | 58 | super.onDestroy(); |
| 59 | + Log.e(TAG, "onDestroy: "); | |
| 59 | 60 | } |
| 60 | 61 | |
| 61 | 62 | private void check() { |
| ... | ... | @@ -112,38 +113,8 @@ public class CollPedometerMainActivity extends QMUIFragmentActivity { |
| 112 | 113 | |
| 113 | 114 | @Override |
| 114 | 115 | protected void onResume() { |
| 115 | - | |
| 116 | - boolean result = false; | |
| 117 | - if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECEIVE_BOOT_COMPLETED) == PackageManager.PERMISSION_GRANTED) { | |
| 118 | - result = true; | |
| 119 | - } | |
| 120 | - Log.e("i", "" + result + "," + getPackageName()); | |
| 121 | - PackageManager pm = getPackageManager(); | |
| 122 | - pm.checkPermission("android.permission.RECEIVE_BOOT_COMPLETED", getPackageName()); | |
| 123 | - try { | |
| 124 | - PackageInfo packageInfo = pm.getPackageInfo(getPackageName(), PackageManager.GET_PERMISSIONS); | |
| 125 | - for (int i = 0; i < packageInfo.requestedPermissions.length; i++) { | |
| 126 | - } | |
| 127 | -// Log.e("i", "" + packageInfo.requestedPermissions[i]); | |
| 128 | - } catch (PackageManager.NameNotFoundException e) { | |
| 129 | - e.printStackTrace(); | |
| 130 | - } | |
| 131 | - | |
| 132 | 116 | super.onResume(); |
| 133 | 117 | check(); |
| 134 | -// PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE); | |
| 135 | - | |
| 136 | -// if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { | |
| 137 | -// boolean hasIgnored = powerManager.isIgnoringBatteryOptimizations(getPackageName()); | |
| 138 | -// if (!hasIgnored) { | |
| 139 | -// Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); | |
| 140 | -// intent.setData(Uri.parse("package:" + getPackageName())); | |
| 141 | -// PackageManager pm = getPackageManager(); | |
| 142 | -// if (intent.resolveActivity(pm) != null) { | |
| 143 | -// startActivity(intent); | |
| 144 | -// } | |
| 145 | -// } | |
| 146 | -// } | |
| 147 | 118 | getPermissionsWithTip(); |
| 148 | 119 | } |
| 149 | 120 | |
| ... | ... | @@ -178,7 +149,9 @@ public class CollPedometerMainActivity extends QMUIFragmentActivity { |
| 178 | 149 | startActivityForResult(intent, 10); |
| 179 | 150 | Toast.makeText(getApplicationContext(), getString(R.string.open_gps_tip), Toast.LENGTH_LONG).show(); |
| 180 | 151 | } else { |
| 181 | - addFragment(); | |
| 152 | + if (getCurrentFragment() == null) { | |
| 153 | + addFragment(); | |
| 154 | + } | |
| 182 | 155 | } |
| 183 | 156 | } |
| 184 | 157 | }) |
| ... | ... | @@ -227,4 +200,6 @@ public class CollPedometerMainActivity extends QMUIFragmentActivity { |
| 227 | 200 | Intent intent = new Intent(activity, CollPedometerMainActivity.class); |
| 228 | 201 | activity.startActivity(intent); |
| 229 | 202 | } |
| 203 | + | |
| 204 | + | |
| 230 | 205 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/activity/CollRunRaceDetailActivity.java
| ... | ... | @@ -4,6 +4,7 @@ import android.app.Activity; |
| 4 | 4 | import android.content.Intent; |
| 5 | 5 | import android.os.Bundle; |
| 6 | 6 | import android.support.annotation.Nullable; |
| 7 | +import android.util.Log; | |
| 7 | 8 | |
| 8 | 9 | import com.alibaba.android.arouter.facade.annotation.Route; |
| 9 | 10 | import com.cnlive.libs.base.ui.QMUIFragment; |
| ... | ... | @@ -13,6 +14,7 @@ import com.cnlive.libs.base.util.StatusBarUtil2; |
| 13 | 14 | import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunMainFragment; |
| 14 | 15 | import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunRaceDetailFragment; |
| 15 | 16 | import com.cnlive.moudle.pedometer.commonInfo.CollCommonInfo; |
| 17 | +import com.cnlive.moudle.pedometer.utils.CheckUtil; | |
| 16 | 18 | import com.example.moudle_pedometer.R; |
| 17 | 19 | |
| 18 | 20 | /** |
| ... | ... | @@ -22,6 +24,7 @@ import com.example.moudle_pedometer.R; |
| 22 | 24 | */ |
| 23 | 25 | @Route(path = "/moudle_pedometer/CollRunRaceDetailActivity") |
| 24 | 26 | public class CollRunRaceDetailActivity extends QMUIFragmentActivity { |
| 27 | + private final String TAG = "CollRunRaceDetail"; | |
| 25 | 28 | private QMUIFragment fragment; |
| 26 | 29 | |
| 27 | 30 | @Override |
| ... | ... | @@ -38,7 +41,7 @@ public class CollRunRaceDetailActivity extends QMUIFragmentActivity { |
| 38 | 41 | // boolean isRunStep = CollCommonInfo.getIsRunStepService(this); |
| 39 | 42 | // //没有找到相关记录 |
| 40 | 43 | // if (!isRunStep) { |
| 41 | - fragment = new CollRunRaceDetailFragment(); | |
| 44 | + fragment = new CollRunRaceDetailFragment(); | |
| 42 | 45 | // } |
| 43 | 46 | // //找到记录 |
| 44 | 47 | // else { |
| ... | ... | @@ -47,6 +50,18 @@ public class CollRunRaceDetailActivity extends QMUIFragmentActivity { |
| 47 | 50 | if (fragment != null) { |
| 48 | 51 | addFragment(fragment); |
| 49 | 52 | } |
| 53 | + | |
| 54 | + | |
| 55 | + } | |
| 56 | + | |
| 57 | + @Override | |
| 58 | + protected void onResume() { | |
| 59 | + super.onResume(); | |
| 60 | + boolean isSet = CheckUtil.isIgnoringBatteryOptimizationss(this); | |
| 61 | + if (!isSet) { | |
| 62 | + isSet = CheckUtil.isIgnoringBatteryOptimizationss(this); | |
| 63 | + } | |
| 64 | + | |
| 50 | 65 | } |
| 51 | 66 | |
| 52 | 67 | private void addFragment(QMUIFragment fragment) { | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/activity/StartCollectTraceActivity.java
| ... | ... | @@ -35,6 +35,5 @@ public class StartCollectTraceActivity extends QMUIFragmentActivity { |
| 35 | 35 | public static void startActivity(Activity activity) { |
| 36 | 36 | Intent intent = new Intent(activity, StartCollectTraceActivity.class); |
| 37 | 37 | activity.startActivity(intent); |
| 38 | - activity.finish(); | |
| 39 | 38 | } |
| 40 | 39 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/fragment/CollRunMainFragment.java
| ... | ... | @@ -2,9 +2,13 @@ package com.cnlive.moudle.collectionTrace.ui.fragment; |
| 2 | 2 | |
| 3 | 3 | import android.os.Bundle; |
| 4 | 4 | import android.os.Handler; |
| 5 | +import android.support.annotation.NonNull; | |
| 5 | 6 | import android.support.annotation.Nullable; |
| 6 | 7 | import android.text.TextUtils; |
| 8 | +import android.util.Log; | |
| 9 | +import android.view.LayoutInflater; | |
| 7 | 10 | import android.view.View; |
| 11 | +import android.view.ViewGroup; | |
| 8 | 12 | |
| 9 | 13 | import com.cnlive.libs.base.ui.QMUIFragment; |
| 10 | 14 | import com.cnlive.libs.base.util.StatusBarUtil2; |
| ... | ... | @@ -23,6 +27,12 @@ public class CollRunMainFragment extends QMUIFragment<CollRunMainFragmentView, C |
| 23 | 27 | private final String TAG = "CollRunMainFragment"; |
| 24 | 28 | private String userId = "yangshuai"; |
| 25 | 29 | |
| 30 | + @NonNull | |
| 31 | + @Override | |
| 32 | + protected View onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) { | |
| 33 | + return super.onCreateView(inflater, container); | |
| 34 | + } | |
| 35 | + | |
| 26 | 36 | @Override |
| 27 | 37 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { |
| 28 | 38 | super.onViewCreated(view, savedInstanceState); |
| ... | ... | @@ -32,6 +42,7 @@ public class CollRunMainFragment extends QMUIFragment<CollRunMainFragmentView, C |
| 32 | 42 | new Handler().postDelayed(new Runnable() { |
| 33 | 43 | @Override |
| 34 | 44 | public void run() { |
| 45 | + | |
| 35 | 46 | getMvpView().initView(); |
| 36 | 47 | } |
| 37 | 48 | }, 5); | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/fragment/CollRunRaceDetailFragment.java
| ... | ... | @@ -11,11 +11,19 @@ import android.widget.Button; |
| 11 | 11 | import com.cnlive.libs.base.ui.QMUIFragment; |
| 12 | 12 | import com.cnlive.moudle.collectionTrace.frame.presenter.CollRunRaceDetailFragmentPresenter; |
| 13 | 13 | import com.cnlive.moudle.collectionTrace.frame.view.CollRunRaceDetailFragmentView; |
| 14 | +import com.cnlive.moudle.collectionTrace.ui.activity.StartCollectTraceActivity; | |
| 15 | +import com.cnlive.moudle.pedometer.model.Constant; | |
| 16 | +import com.cnlive.moudle.pedometer.model.MessageEvent; | |
| 14 | 17 | import com.cnlive.moudle.pedometer.ui.activity.RunLineActivity; |
| 18 | +import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil; | |
| 15 | 19 | import com.example.moudle_pedometer.R; |
| 16 | 20 | import com.example.moudle_pedometer.databinding.FragmentCollectRunRaceDetailBinding; |
| 17 | 21 | import com.qmuiteam.qmui.widget.QMUITopBar; |
| 18 | 22 | |
| 23 | +import org.greenrobot.eventbus.EventBus; | |
| 24 | +import org.greenrobot.eventbus.Subscribe; | |
| 25 | +import org.greenrobot.eventbus.ThreadMode; | |
| 26 | + | |
| 19 | 27 | import static android.content.Context.SENSOR_SERVICE; |
| 20 | 28 | |
| 21 | 29 | /** |
| ... | ... | @@ -60,7 +68,6 @@ public class CollRunRaceDetailFragment extends QMUIFragment<CollRunRaceDetailFra |
| 60 | 68 | @Override |
| 61 | 69 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { |
| 62 | 70 | super.onViewCreated(view, savedInstanceState); |
| 63 | - | |
| 64 | 71 | mSensorManager = (SensorManager) getActivity().getSystemService(SENSOR_SERVICE);//获取传感器管理服务 |
| 65 | 72 | if (getMvpView() != null) { |
| 66 | 73 | getMvpView().initMap(); |
| ... | ... | @@ -111,6 +118,7 @@ public class CollRunRaceDetailFragment extends QMUIFragment<CollRunRaceDetailFra |
| 111 | 118 | } |
| 112 | 119 | |
| 113 | 120 | } |
| 121 | + | |
| 114 | 122 | /** |
| 115 | 123 | * 屏蔽边缘返回 |
| 116 | 124 | * 杨帅 |
| ... | ... | @@ -167,4 +175,7 @@ public class CollRunRaceDetailFragment extends QMUIFragment<CollRunRaceDetailFra |
| 167 | 175 | // FivePersonIconView fivePersonIconView = view.findViewById(R.id.five_join_person); |
| 168 | 176 | // fivePersonIconView.initIconData(data); |
| 169 | 177 | // } |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 170 | 181 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/fragment/CollRunningMapFragment.java
| ... | ... | @@ -25,6 +25,7 @@ import com.cnlive.moudle.pedometer.utils.ChineseToSpeechUtil; |
| 25 | 25 | import com.cnlive.moudle.pedometer.utils.GsonUtil; |
| 26 | 26 | import com.cnlive.moudle.pedometer.utils.TimeUtil; |
| 27 | 27 | import com.example.moudle_pedometer.R; |
| 28 | +import com.example.moudle_pedometer.databinding.FragmentCollectRunningMapBinding; | |
| 28 | 29 | import com.example.moudle_pedometer.databinding.FragmentRunningMapBinding; |
| 29 | 30 | |
| 30 | 31 | import org.greenrobot.eventbus.EventBus; |
| ... | ... | @@ -41,7 +42,7 @@ import static android.content.Context.SENSOR_SERVICE; |
| 41 | 42 | * |
| 42 | 43 | * @author ShinnyYang |
| 43 | 44 | */ |
| 44 | -public class CollRunningMapFragment extends QMUIFragment<CollRunningMapFragmentView, CollRunningMapFragmentPresenter, FragmentRunningMapBinding> { | |
| 45 | +public class CollRunningMapFragment extends QMUIFragment<CollRunningMapFragmentView, CollRunningMapFragmentPresenter, FragmentCollectRunningMapBinding> { | |
| 45 | 46 | private static final String TAG = "CollRunningMapFragment"; |
| 46 | 47 | private RunningMapBean runningMapBean; |
| 47 | 48 | private SensorManager mSensorManager; |
| ... | ... | @@ -62,7 +63,7 @@ public class CollRunningMapFragment extends QMUIFragment<CollRunningMapFragmentV |
| 62 | 63 | |
| 63 | 64 | @Override |
| 64 | 65 | protected int getLayoutId() { |
| 65 | - return R.layout.fragment_running_map; | |
| 66 | + return R.layout.fragment_collect_running_map; | |
| 66 | 67 | } |
| 67 | 68 | |
| 68 | 69 | public static CollRunningMapFragment getInstance(RunningMapBean runningMapBean) { |
| ... | ... | @@ -118,7 +119,7 @@ public class CollRunningMapFragment extends QMUIFragment<CollRunningMapFragmentV |
| 118 | 119 | // Log.e(TAG, "onViewCreated: " + "hour:" + hour + ",minute" + minute + ",second:" + second); |
| 119 | 120 | getPresenter().queryHistoryTrace(getActivity(), StepService.entityName, startTime, endTime); |
| 120 | 121 | //查询实时轨迹 |
| 121 | - getPresenter().queryRealTimeTrace(getActivity(), StepService.entityName, startTime); | |
| 122 | +// getPresenter().queryRealTimeTrace(getActivity(), StepService.entityName, startTime); | |
| 122 | 123 | |
| 123 | 124 | } |
| 124 | 125 | |
| ... | ... | @@ -128,7 +129,6 @@ public class CollRunningMapFragment extends QMUIFragment<CollRunningMapFragmentV |
| 128 | 129 | com.baidu.trace.model.LatLng tempLatLng = new com.baidu.trace.model.LatLng(latLng.latitude, latLng.longitude); |
| 129 | 130 | fenceLatLngs.add(tempLatLng); |
| 130 | 131 | } |
| 131 | - getPresenter().createFence(getActivity(), fenceLatLngs); | |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | @Override | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/fragment/StartTraceFragment.java
| ... | ... | @@ -5,12 +5,22 @@ import android.hardware.SensorManager; |
| 5 | 5 | import android.os.Bundle; |
| 6 | 6 | import android.support.annotation.Nullable; |
| 7 | 7 | import android.view.View; |
| 8 | + | |
| 8 | 9 | import com.cnlive.libs.base.ui.QMUIFragment; |
| 9 | 10 | import com.cnlive.moudle.collectionTrace.frame.presenter.StartTraceFragmentPresenter; |
| 10 | 11 | import com.cnlive.moudle.collectionTrace.frame.view.StartTraceFragmentView; |
| 12 | +import com.cnlive.moudle.collectionTrace.ui.activity.CollPedometerMainActivity; | |
| 13 | +import com.cnlive.moudle.collectionTrace.ui.activity.StartCollectTraceActivity; | |
| 14 | +import com.cnlive.moudle.pedometer.model.Constant; | |
| 15 | +import com.cnlive.moudle.pedometer.model.MessageEvent; | |
| 16 | +import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil; | |
| 11 | 17 | import com.example.moudle_pedometer.R; |
| 12 | 18 | import com.example.moudle_pedometer.databinding.FragmentStartCollectTraceBinding; |
| 13 | 19 | |
| 20 | +import org.greenrobot.eventbus.EventBus; | |
| 21 | +import org.greenrobot.eventbus.Subscribe; | |
| 22 | +import org.greenrobot.eventbus.ThreadMode; | |
| 23 | + | |
| 14 | 24 | import static android.content.Context.SENSOR_SERVICE; |
| 15 | 25 | |
| 16 | 26 | public class StartTraceFragment extends QMUIFragment<StartTraceFragmentView, StartTraceFragmentPresenter, FragmentStartCollectTraceBinding> { |
| ... | ... | @@ -35,6 +45,7 @@ public class StartTraceFragment extends QMUIFragment<StartTraceFragmentView, Sta |
| 35 | 45 | @Override |
| 36 | 46 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { |
| 37 | 47 | super.onViewCreated(view, savedInstanceState); |
| 48 | + EventBus.getDefault().register(this); | |
| 38 | 49 | mSensorManager = (SensorManager) getActivity().getSystemService(SENSOR_SERVICE);//获取传感器管理服务 |
| 39 | 50 | |
| 40 | 51 | if (getMvpView() != null) { |
| ... | ... | @@ -68,6 +79,9 @@ public class StartTraceFragment extends QMUIFragment<StartTraceFragmentView, Sta |
| 68 | 79 | if (getMvpView() != null) { |
| 69 | 80 | getMvpView().onDestroy(); |
| 70 | 81 | } |
| 82 | + if (EventBus.getDefault().isRegistered(this)) { | |
| 83 | + EventBus.getDefault().unregister(this); | |
| 84 | + } | |
| 71 | 85 | } |
| 72 | 86 | |
| 73 | 87 | /** |
| ... | ... | @@ -81,4 +95,22 @@ public class StartTraceFragment extends QMUIFragment<StartTraceFragmentView, Sta |
| 81 | 95 | return 0; |
| 82 | 96 | |
| 83 | 97 | } |
| 98 | + | |
| 99 | + @Subscribe(threadMode = ThreadMode.MAIN) | |
| 100 | + public void Event(MessageEvent messageEvent) { | |
| 101 | + //启动鹰眼成功 | |
| 102 | + if (messageEvent.getMessageType() == Constant.COLL_START_TRACE_GATHER_SUCCESS) { | |
| 103 | + if (getMvpView() != null) { | |
| 104 | + QMUITipDialogUtil.dismessDialog(); | |
| 105 | + CollPedometerMainActivity.startActivity(getActivity()); | |
| 106 | + } | |
| 107 | + } | |
| 108 | + //启动鹰眼失败 | |
| 109 | + else if (messageEvent.getMessageType() == Constant.COLL_START_TRACE_GATHER_FAIL) { | |
| 110 | + if (getMvpView() != null) { | |
| 111 | + QMUITipDialogUtil.dismessDialog(); | |
| 112 | + QMUITipDialogUtil.textDialog(getContext(), "服务异常,请重试!", 1); | |
| 113 | + } | |
| 114 | + } | |
| 115 | + } | |
| 84 | 116 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/commonInfo/CollCommonInfo.java
| ... | ... | @@ -135,6 +135,26 @@ public class CollCommonInfo { |
| 135 | 135 | return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("CollRunBaiduTraceService", false); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | + /** | |
| 139 | + * 是否是第一次启动鹰眼服务的通知 | |
| 140 | + * | |
| 141 | + * @param context | |
| 142 | + * @param isAllow | |
| 143 | + */ | |
| 144 | + public static void setIsFirstStepSendTraceTip(Context context, boolean isAllow) { | |
| 145 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean("CollFirstStepSendTraceTip", isAllow); | |
| 146 | + } | |
| 147 | + | |
| 148 | + /** | |
| 149 | + * 是否是第一次启动鹰眼服务的通知 | |
| 150 | + * 默认返回true | |
| 151 | + * | |
| 152 | + * @param context | |
| 153 | + */ | |
| 154 | + public static boolean getIsFirstStepSendTraceTip(Context context) { | |
| 155 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("CollFirstStepSendTraceTip", true); | |
| 156 | + } | |
| 157 | + | |
| 138 | 158 | /*重置 |
| 139 | 159 | * @param context |
| 140 | 160 | */ |
| ... | ... | @@ -146,7 +166,7 @@ public class CollCommonInfo { |
| 146 | 166 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("CollKeepAliveService"); |
| 147 | 167 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("CollRunBaiduTraceService"); |
| 148 | 168 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("CollstreetId"); |
| 149 | - | |
| 169 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("CollFirstStepSendTraceTip"); | |
| 150 | 170 | } |
| 151 | 171 | |
| 152 | 172 | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/commonInfo/CommonInfo.java
| ... | ... | @@ -136,6 +136,26 @@ public class CommonInfo { |
| 136 | 136 | return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("RunBaiduTraceService", false); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | + /** | |
| 140 | + * 是否是第一次启动鹰眼服务的通知 | |
| 141 | + * | |
| 142 | + * @param context | |
| 143 | + * @param isAllow | |
| 144 | + */ | |
| 145 | + public static void setIsFirstStepSendTraceTip(Context context, boolean isAllow) { | |
| 146 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean("FirstStepSendTraceTip", isAllow); | |
| 147 | + } | |
| 148 | + | |
| 149 | + /** | |
| 150 | + * 是否是第一次启动鹰眼服务的通知 | |
| 151 | + * 默认返回true | |
| 152 | + * | |
| 153 | + * @param context | |
| 154 | + */ | |
| 155 | + public static boolean getIsFirstStepSendTraceTip(Context context) { | |
| 156 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("FirstStepSendTraceTip", true); | |
| 157 | + } | |
| 158 | + | |
| 139 | 159 | /*重置 |
| 140 | 160 | * @param context |
| 141 | 161 | */ |
| ... | ... | @@ -147,7 +167,7 @@ public class CommonInfo { |
| 147 | 167 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("KeepAliveService"); |
| 148 | 168 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("RunBaiduTraceService"); |
| 149 | 169 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("streetId"); |
| 150 | - | |
| 170 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("FirstStepSendTraceTip"); | |
| 151 | 171 | } |
| 152 | 172 | |
| 153 | 173 | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/presenter/RunningMapFragmentPresenter.java
| ... | ... | @@ -134,7 +134,7 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter<RunningMapFrag |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | if (historyTrackRequest == null) { |
| 137 | - historyTrackRequest = new HistoryTrackRequest(tag, StepService.serviceId, entityName); | |
| 137 | + historyTrackRequest = new HistoryTrackRequest(tag, Constant.SERVICE_ID, entityName); | |
| 138 | 138 | //设置查询设备名称 |
| 139 | 139 | historyTrackRequest.setEntityName(entityName); |
| 140 | 140 | //历史轨迹开始时间 |
| ... | ... | @@ -170,7 +170,7 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter<RunningMapFrag |
| 170 | 170 | //创建里程查询 |
| 171 | 171 | if (distanceRequest == null) { |
| 172 | 172 | // 创建里程查询请求实例 |
| 173 | - distanceRequest = new DistanceRequest(tag, StepService.serviceId, entityName); | |
| 173 | + distanceRequest = new DistanceRequest(tag, Constant.SERVICE_ID, entityName); | |
| 174 | 174 | // 设置开始时间 |
| 175 | 175 | distanceRequest.setStartTime(startTime); |
| 176 | 176 | // 设置结束时间 |
| ... | ... | @@ -317,7 +317,7 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter<RunningMapFrag |
| 317 | 317 | List<String> names = new ArrayList<>(); |
| 318 | 318 | names.add(entityName); |
| 319 | 319 | realTimeListRequest = new LocRequest(); |
| 320 | - realTimeListRequest.setServiceId(StepService.serviceId); | |
| 320 | + realTimeListRequest.setServiceId(Constant.SERVICE_ID); | |
| 321 | 321 | realTimeListRequest.setTag(1); |
| 322 | 322 | } |
| 323 | 323 | if (realTimePoints == null) { |
| ... | ... | @@ -504,7 +504,7 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter<RunningMapFrag |
| 504 | 504 | // } |
| 505 | 505 | // } |
| 506 | 506 | |
| 507 | - FenceListRequest request = FenceListRequest.buildServerRequest(tag, StepService.serviceId, "yangshuai", null, CoordType.gcj02); | |
| 507 | + FenceListRequest request = FenceListRequest.buildServerRequest(tag, Constant.SERVICE_ID, "yangshuai", null, CoordType.gcj02); | |
| 508 | 508 | |
| 509 | 509 | //发起查询围栏请求 |
| 510 | 510 | if (StepService.mClient != null) { |
| ... | ... | @@ -514,7 +514,7 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter<RunningMapFrag |
| 514 | 514 | List<Long> fenid = new ArrayList<>(); |
| 515 | 515 | fenid.add(1L); |
| 516 | 516 | MonitoredStatusRequest request1 = MonitoredStatusRequest.buildServerRequest(tag, |
| 517 | - StepService.serviceId, "yangshuai", fenid); | |
| 517 | + Constant.SERVICE_ID, "yangshuai", fenid); | |
| 518 | 518 | Handler handler = new Handler(); |
| 519 | 519 | Runnable runnable = new Runnable() { |
| 520 | 520 | @Override | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RegistrationInfoView.java
| ... | ... | @@ -3,6 +3,8 @@ package com.cnlive.moudle.pedometer.frame.view; |
| 3 | 3 | import android.content.Intent; |
| 4 | 4 | import android.view.View; |
| 5 | 5 | |
| 6 | +import com.cnlive.moudle.pedometer.model.Constant; | |
| 7 | +import com.cnlive.moudle.pedometer.model.MessageEvent; | |
| 6 | 8 | import com.cnlive.moudle.pedometer.ui.activity.RunRaceDetailActivity; |
| 7 | 9 | import com.cnlive.moudle.pedometer.ui.fragment.RegistrationInfoFragment; |
| 8 | 10 | import com.cnlive.moudle.pedometer.utils.DateTimeUtil; |
| ... | ... | @@ -13,6 +15,8 @@ import com.jzxiang.pickerview.TimePickerDialog; |
| 13 | 15 | import com.jzxiang.pickerview.data.Type; |
| 14 | 16 | import com.jzxiang.pickerview.listener.OnDateSetListener; |
| 15 | 17 | |
| 18 | +import org.greenrobot.eventbus.EventBus; | |
| 19 | + | |
| 16 | 20 | import java.text.ParseException; |
| 17 | 21 | import java.text.SimpleDateFormat; |
| 18 | 22 | import java.util.Calendar; |
| ... | ... | @@ -32,13 +36,13 @@ public class RegistrationInfoView implements MvpView, OnDateSetListener { |
| 32 | 36 | this.fragment = fragment; |
| 33 | 37 | } |
| 34 | 38 | |
| 35 | - public void initView(){ | |
| 39 | + public void initView() { | |
| 36 | 40 | fragment.binding.topbar.addLeftImageButton(R.drawable.top_back_black, R.id.fragment_back).setOnClickListener(v -> { |
| 37 | 41 | goLineDetail(); |
| 38 | 42 | }); |
| 39 | 43 | fragment.binding.topbar.setTitle("填写报名信息"); |
| 40 | 44 | fragment.binding.commitInfo.setOnClickListener(v -> fragment.commitInfo()); |
| 41 | - fragment.binding.toLineDetail.setOnClickListener(v ->goLineDetail()); | |
| 45 | + fragment.binding.toLineDetail.setOnClickListener(v -> goLineDetail()); | |
| 42 | 46 | sex = new BottomMenuDialog.Builder(fragment.getActivity()) |
| 43 | 47 | .addMenu("男", new View.OnClickListener() { |
| 44 | 48 | @Override |
| ... | ... | @@ -90,15 +94,16 @@ public class RegistrationInfoView implements MvpView, OnDateSetListener { |
| 90 | 94 | return date.getTime(); |
| 91 | 95 | } |
| 92 | 96 | |
| 93 | - public void toResult(){ | |
| 97 | + public void toResult() { | |
| 94 | 98 | fragment.binding.registerLy.setVisibility(View.GONE); |
| 95 | 99 | fragment.binding.commitInfo.setVisibility(View.GONE); |
| 96 | 100 | fragment.binding.resultLy.setVisibility(View.VISIBLE); |
| 101 | + EventBus.getDefault().post(new MessageEvent(Constant.REGISTRATION_SUCCESS, "")); | |
| 97 | 102 | } |
| 98 | 103 | |
| 99 | - private void goLineDetail(){ | |
| 104 | + private void goLineDetail() { | |
| 100 | 105 | Intent intent = new Intent(fragment.getActivity(), RunRaceDetailActivity.class); |
| 101 | - intent.putExtra("isRegisterResult",true); | |
| 106 | + intent.putExtra("isRegisterResult", true); | |
| 102 | 107 | fragment.getActivity().setResult(1002, intent); |
| 103 | 108 | fragment.getActivity().finish(); |
| 104 | 109 | } |
| ... | ... | @@ -106,6 +111,6 @@ public class RegistrationInfoView implements MvpView, OnDateSetListener { |
| 106 | 111 | @Override |
| 107 | 112 | public void onDateSet(TimePickerDialog timePickerView, long millseconds) { |
| 108 | 113 | // 生日(非必填) 未选择 |
| 109 | - fragment.binding.birthday.setText("生日(非必填) "+DateTimeUtil.formatDateTime(millseconds, "yyyy年MM月dd日")); | |
| 114 | + fragment.binding.birthday.setText("生日(非必填) " + DateTimeUtil.formatDateTime(millseconds, "yyyy年MM月dd日")); | |
| 110 | 115 | } |
| 111 | 116 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunMainFragmentView.java
| ... | ... | @@ -115,8 +115,7 @@ public class RunMainFragmentView implements MvpView { |
| 115 | 115 | * 初始化相关视图 |
| 116 | 116 | */ |
| 117 | 117 | public void initView() { |
| 118 | - uid = "yangshuai"; | |
| 119 | - CommonInfo.setUserId(getContext(), uid); | |
| 118 | + | |
| 120 | 119 | UserStepEntity userStepEntity = StepUtil.getUserStepData(getContext(), uid); |
| 121 | 120 | if (userStepEntity != null) { |
| 122 | 121 | StepUtil.clearRunData(getContext(), CommonInfo.getUserId(getContext())); |
| ... | ... | @@ -156,8 +155,6 @@ public class RunMainFragmentView implements MvpView { |
| 156 | 155 | } |
| 157 | 156 | } |
| 158 | 157 | }, 10); |
| 159 | - //开启计步服务 | |
| 160 | - startStepService(getContext(), uid); | |
| 161 | 158 | } |
| 162 | 159 | } |
| 163 | 160 | }; |
| ... | ... | @@ -460,23 +457,7 @@ public class RunMainFragmentView implements MvpView { |
| 460 | 457 | } |
| 461 | 458 | } |
| 462 | 459 | |
| 463 | - /** | |
| 464 | - * 启动计步服务 | |
| 465 | - * | |
| 466 | - * @param userId | |
| 467 | - */ | |
| 468 | - public void startStepService(Context context, String userId) { | |
| 469 | - if (CommonInfo.getStepStartTime(context) == 0) { | |
| 470 | - CommonInfo.setStepStartTime(context, TimeUtil.getNowTimeStamp()); | |
| 471 | - } | |
| 472 | - CommonInfo.setIsRunKeepAliveService(context, true); | |
| 473 | - CommonInfo.setIsRunStepService(context, true); | |
| 474 | - CommonInfo.setTsRunBaiduTraceService(context, true); | |
| 475 | - CommonInfo.setIsWriteUserStep(context, true); | |
| 476 | - Intent intent = new Intent(fragment.getActivity(), KeepLiveService.class); | |
| 477 | - ContextCompat.startForegroundService(fragment.getActivity(), intent); | |
| 478 | 460 | |
| 479 | - } | |
| 480 | 461 | |
| 481 | 462 | /** |
| 482 | 463 | * 更新行走距离 | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
| ... | ... | @@ -8,6 +8,7 @@ import android.hardware.Sensor; |
| 8 | 8 | import android.hardware.SensorEvent; |
| 9 | 9 | import android.hardware.SensorEventListener; |
| 10 | 10 | import android.hardware.SensorManager; |
| 11 | +import android.support.v4.content.ContextCompat; | |
| 11 | 12 | import android.text.TextUtils; |
| 12 | 13 | import android.util.Log; |
| 13 | 14 | import android.view.View; |
| ... | ... | @@ -45,7 +46,9 @@ import com.baidu.mapapi.search.route.WalkingRoutePlanOption; |
| 45 | 46 | import com.baidu.mapapi.search.route.WalkingRouteResult; |
| 46 | 47 | import com.baidu.mapapi.utils.DistanceUtil; |
| 47 | 48 | import com.baidu.trace.model.SortType; |
| 49 | +import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; | |
| 48 | 50 | import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo; |
| 51 | +import com.cnlive.moudle.pedometer.service.KeepLiveService; | |
| 49 | 52 | import com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity; |
| 50 | 53 | import com.cnlive.moudle.pedometer.ui.activity.RaceRecordActivity; |
| 51 | 54 | import com.cnlive.moudle.pedometer.ui.activity.RegistrationInfoActivity; |
| ... | ... | @@ -55,6 +58,7 @@ import com.cnlive.moudle.pedometer.ui.widget.TipDialog; |
| 55 | 58 | import com.cnlive.moudle.pedometer.utils.BitmapUtil; |
| 56 | 59 | import com.cnlive.moudle.pedometer.utils.GsonUtil; |
| 57 | 60 | import com.cnlive.moudle.pedometer.utils.MyMapUtil; |
| 61 | +import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil; | |
| 58 | 62 | import com.cnlive.moudle.pedometer.utils.ScreenUtil; |
| 59 | 63 | import com.cnlive.moudle.pedometer.utils.TimeUtil; |
| 60 | 64 | import com.cnlive.strike.application.GlideApp; |
| ... | ... | @@ -101,7 +105,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 101 | 105 | |
| 102 | 106 | private String startPoint = "首都师范大学南门"; |
| 103 | 107 | private String endPoint = "首都师范大学篮球场"; |
| 104 | -// private String test = "[{\"latitude\":39.933889208848,\"latitudeE6\":3.9933889208848E7,\"longitude\":116.30900265517,\"longitudeE6\":1.1630900265517001E8},{\"latitude\":39.933868507347,\"latitudeE6\":3.9933868507347E7,\"longitude\":116.30865416508,\"longitudeE6\":1.1630865416508E8},{\"latitude\":39.934756505077,\"latitudeE6\":3.9934756505077E7,\"longitude\":116.30860516469,\"longitudeE6\":1.1630860516468999E8},{\"latitude\":39.934781620502,\"latitudeE6\":3.9934781620502E7,\"longitude\":116.30961013007,\"longitudeE6\":1.1630961013007E8},{\"latitude\":39.934881620374,\"latitudeE6\":3.9934881620374E7,\"longitude\":116.30960513008,\"longitudeE6\":1.1630960513008E8},{\"latitude\":39.934077623132,\"latitudeE6\":3.9934077623132E7,\"longitude\":116.30965812942,\"longitudeE6\":1.1630965812942E8},{\"latitude\":39.933972618463,\"latitudeE6\":3.9933972618463E7,\"longitude\":116.30962113087,\"longitudeE6\":1.1630962113087E8},{\"latitude\":39.933932608856,\"latitudeE6\":3.9933932608856E7,\"longitude\":116.30953913383,\"longitudeE6\":1.1630953913383E8}]"; | |
| 108 | + // private String test = "[{\"latitude\":39.933889208848,\"latitudeE6\":3.9933889208848E7,\"longitude\":116.30900265517,\"longitudeE6\":1.1630900265517001E8},{\"latitude\":39.933868507347,\"latitudeE6\":3.9933868507347E7,\"longitude\":116.30865416508,\"longitudeE6\":1.1630865416508E8},{\"latitude\":39.934756505077,\"latitudeE6\":3.9934756505077E7,\"longitude\":116.30860516469,\"longitudeE6\":1.1630860516468999E8},{\"latitude\":39.934781620502,\"latitudeE6\":3.9934781620502E7,\"longitude\":116.30961013007,\"longitudeE6\":1.1630961013007E8},{\"latitude\":39.934881620374,\"latitudeE6\":3.9934881620374E7,\"longitude\":116.30960513008,\"longitudeE6\":1.1630960513008E8},{\"latitude\":39.934077623132,\"latitudeE6\":3.9934077623132E7,\"longitude\":116.30965812942,\"longitudeE6\":1.1630965812942E8},{\"latitude\":39.933972618463,\"latitudeE6\":3.9933972618463E7,\"longitude\":116.30962113087,\"longitudeE6\":1.1630962113087E8},{\"latitude\":39.933932608856,\"latitudeE6\":3.9933932608856E7,\"longitude\":116.30953913383,\"longitudeE6\":1.1630953913383E8}]"; | |
| 105 | 109 | private LinkedList<LatLng> importLatLngs;//关键点 |
| 106 | 110 | private LatLng startLatLng = new LatLng(39.934733, 116.308646);//起始点 |
| 107 | 111 | private List<LatLng> trackPoints; |
| ... | ... | @@ -198,7 +202,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 198 | 202 | fragment.binding.includeStreet.tvAddress.setText(runRaceDetailInfo.getAddress()); |
| 199 | 203 | //设置活动距离 |
| 200 | 204 | if (!TextUtils.isEmpty(runRaceDetailInfo.getMileage())) { |
| 201 | - fragment.binding.includeStreet.tvAddress.append("\t\t"+runRaceDetailInfo.getMileage()); | |
| 205 | + fragment.binding.includeStreet.tvAddress.append("\t\t" + runRaceDetailInfo.getMileage()); | |
| 202 | 206 | } |
| 203 | 207 | } |
| 204 | 208 | |
| ... | ... | @@ -228,7 +232,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 228 | 232 | fragment.binding.includeStreet.tvActiveEndTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getEnd_time(), "yyyy-MM-dd")); |
| 229 | 233 | } |
| 230 | 234 | //设置活动类型 |
| 231 | - if (!TextUtils.isEmpty(runRaceDetailInfo.getEventType())){ | |
| 235 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getEventType())) { | |
| 232 | 236 | fragment.binding.includeStreet.tvEventType.setText(runRaceDetailInfo.getEventType()); |
| 233 | 237 | } |
| 234 | 238 | //设置参加人数 |
| ... | ... | @@ -248,7 +252,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 248 | 252 | //显示 |
| 249 | 253 | fragment.binding.includePersonScore.llPersonScoreRoot.setVisibility(View.VISIBLE); |
| 250 | 254 | //设置完成人数 |
| 251 | - if (!TextUtils.isEmpty(runRaceDetailInfo.getFinishNum())){ | |
| 255 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getFinishNum())) { | |
| 252 | 256 | fragment.binding.includeRank.tvFinishPerson.setText(runRaceDetailInfo.getFinishNum()); |
| 253 | 257 | } |
| 254 | 258 | //设置个人行走距离 |
| ... | ... | @@ -290,7 +294,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 290 | 294 | |
| 291 | 295 | } |
| 292 | 296 | //设置路线描述 |
| 293 | - if (!TextUtils.isEmpty(runRaceDetailInfo.getDescription())){ | |
| 297 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getDescription())) { | |
| 294 | 298 | fragment.binding.includeStreetIntroduce.tvStreetIntroduce.setText(runRaceDetailInfo.getDescription()); |
| 295 | 299 | } |
| 296 | 300 | //设置路线介绍的图片 |
| ... | ... | @@ -300,11 +304,11 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 300 | 304 | |
| 301 | 305 | } |
| 302 | 306 | //判断用户是否报名 |
| 303 | - if (runRaceDetailInfo.isSignResult()){ | |
| 307 | + if (runRaceDetailInfo.isSignResult()) { | |
| 304 | 308 | fragment.binding.rlScrollViewStartBtn.setTag("1"); |
| 305 | 309 | fragment.binding.tvRunNow.setText("现在开始"); |
| 306 | 310 | fragment.binding.tvGoTip.setVisibility(View.VISIBLE); |
| 307 | - }else { | |
| 311 | + } else { | |
| 308 | 312 | fragment.binding.rlScrollViewStartBtn.setTag("0"); |
| 309 | 313 | fragment.binding.tvRunNow.setText("立即报名"); |
| 310 | 314 | fragment.binding.tvGoTip.setVisibility(View.GONE); |
| ... | ... | @@ -363,32 +367,15 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 363 | 367 | public void onClick(View view) { |
| 364 | 368 | //立即报名 |
| 365 | 369 | if ("0".equals(fragment.binding.rlScrollViewStartBtn.getTag())) { |
| 366 | - fragment.binding.rlScrollViewStartBtn.setTag("1"); | |
| 367 | - fragment.binding.tvRunNow.setText("现在开始"); | |
| 368 | - fragment.binding.tvGoTip.setVisibility(View.VISIBLE); | |
| 369 | - //设置未滑动 | |
| 370 | - fragment.binding.includeStreet.rlStartBtn.setTag("1"); | |
| 371 | - fragment.binding.includeStreet.tvRunNow.setText("现在开始"); | |
| 372 | - fragment.binding.includeStreet.tvGoTip.setVisibility(View.VISIBLE); | |
| 373 | 370 | RegistrationInfoActivity.newInstance(fragment.getActivity(), 1001); |
| 374 | 371 | } else { |
| 375 | - //开始运动 | |
| 376 | - fragment.binding.rlScrollViewStartBtn.setTag("0"); | |
| 377 | - fragment.binding.tvRunNow.setText("立即报名"); | |
| 378 | - fragment.binding.tvGoTip.setVisibility(View.GONE); | |
| 379 | - fragment.getActivity().startActivity(new Intent(getContext(), PedometerMainActivity.class)); | |
| 380 | - //设置未滑动 | |
| 381 | - fragment.binding.includeStreet.rlStartBtn.setTag("0"); | |
| 382 | - fragment.binding.includeStreet.tvRunNow.setText("立即报名"); | |
| 383 | - fragment.binding.includeStreet.tvGoTip.setVisibility(View.GONE); | |
| 384 | - fragment.getActivity().startActivity(new Intent(getContext(), PedometerMainActivity.class)); | |
| 385 | - | |
| 372 | + startStepService(getContext()); | |
| 386 | 373 | } |
| 387 | 374 | } |
| 388 | 375 | }); |
| 389 | 376 | //查看全部成绩点击事件 |
| 390 | 377 | fragment.binding.includePersonScore.checkAllCord.setOnClickListener(v -> { |
| 391 | - RaceRecordActivity.newInstance(fragment.getActivity(),runRaceDetailInfo.getTitle()); | |
| 378 | + RaceRecordActivity.newInstance(fragment.getActivity(), runRaceDetailInfo.getTitle()); | |
| 392 | 379 | }); |
| 393 | 380 | |
| 394 | 381 | fragment.binding.includeStreet.fiveJoinPerson.setOnClickListener(v -> { |
| ... | ... | @@ -407,15 +394,8 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 407 | 394 | } |
| 408 | 395 | |
| 409 | 396 | public void initMap() { |
| 410 | - List<String> icons = new ArrayList<>(); | |
| 411 | - icons.add("http://yweb0.cnliveimg.com/images/headImg/2019/0505/1557039035723_small.jpg"); | |
| 412 | - icons.add("http://yweb0.cnliveimg.com/images/headImg/2019/0505/1557034319038_small.jpg"); | |
| 413 | - icons.add("http://yweb0.cnliveimg.com/images/headImg/2018/0902/1535858459612_small.jpg"); | |
| 414 | - icons.add("http://yweb0.cnliveimg.com/images/headImg/2019/0523/1558599016203_small.jpg"); | |
| 415 | - icons.add("http://yweb0.cnliveimg.com/images/headImg/2019/0505/1557039035723_small.jpg"); | |
| 416 | 397 | //隐藏底部滑动卡片 |
| 417 | 398 | fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN); |
| 418 | - fragment.binding.includeStreet.fiveJoinPerson.initIconData(icons); | |
| 419 | 399 | this.mMapView = fragment.binding.mapView; |
| 420 | 400 | if (baiduMap == null) { |
| 421 | 401 | baiduMap = mMapView.getMap(); |
| ... | ... | @@ -863,4 +843,31 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 863 | 843 | fragment.binding.emptyLayout.show(false, titleText, detailText, getContext().getString(R.string.retry), R.drawable.wufalianjie, listener); |
| 864 | 844 | } |
| 865 | 845 | |
| 846 | + | |
| 847 | + /** | |
| 848 | + * 启动计步服务 | |
| 849 | + */ | |
| 850 | + public void startStepService(Context context) { | |
| 851 | + QMUITipDialogUtil.loadingDialog(getContext(), "请稍后", false); | |
| 852 | + if (CommonInfo.getStepStartTime(context) == 0) { | |
| 853 | + CommonInfo.setStepStartTime(context, TimeUtil.getNowTimeStamp()); | |
| 854 | + } | |
| 855 | + CommonInfo.setIsRunKeepAliveService(context, true); | |
| 856 | + CommonInfo.setIsRunStepService(context, true); | |
| 857 | + CommonInfo.setTsRunBaiduTraceService(context, true); | |
| 858 | + CommonInfo.setIsWriteUserStep(context, true); | |
| 859 | + Intent intent = new Intent(fragment.getActivity(), KeepLiveService.class); | |
| 860 | + ContextCompat.startForegroundService(fragment.getActivity(), intent); | |
| 861 | + | |
| 862 | + } | |
| 863 | + | |
| 864 | + | |
| 865 | + public void setRegistrationBtn() { | |
| 866 | + if (getContext() == null) { | |
| 867 | + return; | |
| 868 | + } | |
| 869 | + fragment.binding.rlScrollViewStartBtn.setTag("1"); | |
| 870 | + fragment.binding.tvRunNow.setText("现在开始"); | |
| 871 | + fragment.binding.tvGoTip.setVisibility(View.VISIBLE); | |
| 872 | + } | |
| 866 | 873 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/model/Constant.java
| 1 | 1 | package com.cnlive.moudle.pedometer.model; |
| 2 | 2 | |
| 3 | 3 | public class Constant { |
| 4 | + public static final long SERVICE_ID = 213511; | |
| 5 | + public static final int TAG = 1; | |
| 6 | + public static final int GATHER_INTERVAL = 3;//位置采集周期 | |
| 7 | + public static final int PACK_INTERVAL = 10;//位置采集周期 | |
| 8 | + | |
| 4 | 9 | public static final int SERVICE_STEP_COUNT_UPDATE = 0;//步数更新 |
| 5 | 10 | public static final int SERVICE_STEP_COUNT_PAUSE = 1;//步数暂停 |
| 6 | 11 | public static final int SERVICE_STEP_COUNT_CONTINUE = 2;//继续计步 |
| ... | ... | @@ -8,5 +13,10 @@ public class Constant { |
| 8 | 13 | public static final int FRAGMENT_RUN_CHRONOMETER = 4;//同步计时器 |
| 9 | 14 | public static final int EXIT_RANGE = 5;//超出范围 |
| 10 | 15 | public static final int ENTER_RANGE = 6;//进入范围 |
| 16 | + public static final int COLL_START_TRACE_GATHER_SUCCESS = 7;//启动轨迹服务成功(运营) | |
| 17 | + public static final int COLL_START_TRACE_GATHER_FAIL = 8;//启动轨迹服务失败(运营) | |
| 18 | + public static final int START_TRACE_GATHER_SUCCESS = 9;//启动轨迹服务成功(用户) | |
| 19 | + public static final int START_TRACE_GATHER_FAIL = 10;//启动轨迹服务失败(用户) | |
| 20 | + public static final int REGISTRATION_SUCCESS = 11;//用户报名成功 | |
| 11 | 21 | |
| 12 | 22 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/KeepLiveService.java
| ... | ... | @@ -221,7 +221,6 @@ public class KeepLiveService extends Service implements MediaPlayer.OnCompletion |
| 221 | 221 | @Override |
| 222 | 222 | public void onDestroy() { |
| 223 | 223 | super.onDestroy(); |
| 224 | - Log.e("onDestroy", "onDestroy:" + notification); | |
| 225 | 224 | if (myReceiver != null) { |
| 226 | 225 | unregisterReceiver(myReceiver); |
| 227 | 226 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/StepService.java
| ... | ... | @@ -37,6 +37,7 @@ import com.baidu.trace.model.LocationMode; |
| 37 | 37 | import com.baidu.trace.model.OnTraceListener; |
| 38 | 38 | import com.baidu.trace.model.PushMessage; |
| 39 | 39 | import com.baidu.trace.model.StatusCodes; |
| 40 | +import com.cnlive.moudle.pedometer.commonInfo.CollCommonInfo; | |
| 40 | 41 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 41 | 42 | import com.cnlive.moudle.pedometer.model.Constant; |
| 42 | 43 | import com.cnlive.moudle.pedometer.model.MessageEvent; |
| ... | ... | @@ -140,13 +141,6 @@ public class StepService extends Service implements SensorEventListener { |
| 140 | 141 | * 轨迹监听器(用于接收纠偏后实时位置回调) |
| 141 | 142 | */ |
| 142 | 143 | private OnTrackListener realTimeTraceListener = null; |
| 143 | - //位置采集周期 | |
| 144 | - private int gatherInterval = 3; | |
| 145 | - //打包周期 | |
| 146 | - private int packInterval = 10; | |
| 147 | - // 轨迹服务ID | |
| 148 | - public static final long serviceId = 213511;//杨帅 | |
| 149 | -// public static final long serviceId = 213553; | |
| 150 | 144 | |
| 151 | 145 | // 设备标识 |
| 152 | 146 | public static String entityName = ""; |
| ... | ... | @@ -184,12 +178,12 @@ public class StepService extends Service implements SensorEventListener { |
| 184 | 178 | if (mClient == null) { |
| 185 | 179 | mClient = new LBSTraceClient(getApplicationContext()); |
| 186 | 180 | // 设置定位和打包周期 |
| 187 | - mClient.setInterval(gatherInterval, packInterval); | |
| 181 | + mClient.setInterval(Constant.GATHER_INTERVAL, Constant.PACK_INTERVAL); | |
| 188 | 182 | //设置定位模式 |
| 189 | 183 | mClient.setLocationMode(LocationMode.High_Accuracy); |
| 190 | 184 | } |
| 191 | 185 | if (mTrace == null) { |
| 192 | - mTrace = new Trace(serviceId, entityName); | |
| 186 | + mTrace = new Trace(Constant.SERVICE_ID, entityName); | |
| 193 | 187 | } |
| 194 | 188 | //初始化实时轨迹监听器 |
| 195 | 189 | realTimeTraceListener = new OnTrackListener() { |
| ... | ... | @@ -241,6 +235,17 @@ public class StepService extends Service implements SensorEventListener { |
| 241 | 235 | if (mClient != null) { |
| 242 | 236 | mClient.startGather(traceListener); |
| 243 | 237 | Toast.makeText(getApplicationContext(), "开启轨迹服务", Toast.LENGTH_LONG).show(); |
| 238 | + boolean isFirstSendNotification = CommonInfo.getIsFirstStepSendTraceTip(getApplicationContext()); | |
| 239 | + if (isFirstSendNotification) { | |
| 240 | + CommonInfo.setIsFirstStepSendTraceTip(getApplicationContext(), false); | |
| 241 | + EventBus.getDefault().post(new MessageEvent(Constant.START_TRACE_GATHER_SUCCESS, "")); | |
| 242 | + } | |
| 243 | + } | |
| 244 | + } else { | |
| 245 | + boolean isFirstSendNotification = CommonInfo.getIsFirstStepSendTraceTip(getApplicationContext()); | |
| 246 | + if (isFirstSendNotification) { | |
| 247 | + CommonInfo.setIsFirstStepSendTraceTip(getApplicationContext(), false); | |
| 248 | + EventBus.getDefault().post(new MessageEvent(Constant.START_TRACE_GATHER_FAIL, "")); | |
| 244 | 249 | } |
| 245 | 250 | } |
| 246 | 251 | } |
| ... | ... | @@ -382,6 +387,8 @@ public class StepService extends Service implements SensorEventListener { |
| 382 | 387 | } |
| 383 | 388 | }).start(); |
| 384 | 389 | startTimeCount(); |
| 390 | + } else { | |
| 391 | + EventBus.getDefault().post(new MessageEvent(Constant.START_TRACE_GATHER_FAIL, "")); | |
| 385 | 392 | } |
| 386 | 393 | // if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { |
| 387 | 394 | // //开始配置JobInfo | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/DaoMaster.java
| ... | ... | @@ -21,14 +21,14 @@ public class DaoMaster extends AbstractDaoMaster { |
| 21 | 21 | |
| 22 | 22 | /** Creates underlying database table using DAOs. */ |
| 23 | 23 | public static void createAllTables(Database db, boolean ifNotExists) { |
| 24 | - UserStepEntityDao.createTable(db, ifNotExists); | |
| 25 | 24 | CollUserStepEntityDao.createTable(db, ifNotExists); |
| 25 | + UserStepEntityDao.createTable(db, ifNotExists); | |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** Drops underlying database table using DAOs. */ |
| 29 | 29 | public static void dropAllTables(Database db, boolean ifExists) { |
| 30 | - UserStepEntityDao.dropTable(db, ifExists); | |
| 31 | 30 | CollUserStepEntityDao.dropTable(db, ifExists); |
| 31 | + UserStepEntityDao.dropTable(db, ifExists); | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
| ... | ... | @@ -47,8 +47,8 @@ public class DaoMaster extends AbstractDaoMaster { |
| 47 | 47 | |
| 48 | 48 | public DaoMaster(Database db) { |
| 49 | 49 | super(db, SCHEMA_VERSION); |
| 50 | - registerDaoClass(UserStepEntityDao.class); | |
| 51 | 50 | registerDaoClass(CollUserStepEntityDao.class); |
| 51 | + registerDaoClass(UserStepEntityDao.class); | |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public DaoSession newSession() { | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/DaoSession.java
| ... | ... | @@ -8,11 +8,11 @@ import org.greenrobot.greendao.database.Database; |
| 8 | 8 | import org.greenrobot.greendao.identityscope.IdentityScopeType; |
| 9 | 9 | import org.greenrobot.greendao.internal.DaoConfig; |
| 10 | 10 | |
| 11 | -import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; | |
| 12 | 11 | import com.cnlive.moudle.pedometer.sql.entity.CollUserStepEntity; |
| 12 | +import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; | |
| 13 | 13 | |
| 14 | -import com.cnlive.moudle.pedometer.sql.dao.UserStepEntityDao; | |
| 15 | 14 | import com.cnlive.moudle.pedometer.sql.dao.CollUserStepEntityDao; |
| 15 | +import com.cnlive.moudle.pedometer.sql.dao.UserStepEntityDao; | |
| 16 | 16 | |
| 17 | 17 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. |
| 18 | 18 | |
| ... | ... | @@ -23,40 +23,40 @@ import com.cnlive.moudle.pedometer.sql.dao.CollUserStepEntityDao; |
| 23 | 23 | */ |
| 24 | 24 | public class DaoSession extends AbstractDaoSession { |
| 25 | 25 | |
| 26 | - private final DaoConfig userStepEntityDaoConfig; | |
| 27 | 26 | private final DaoConfig collUserStepEntityDaoConfig; |
| 27 | + private final DaoConfig userStepEntityDaoConfig; | |
| 28 | 28 | |
| 29 | - private final UserStepEntityDao userStepEntityDao; | |
| 30 | 29 | private final CollUserStepEntityDao collUserStepEntityDao; |
| 30 | + private final UserStepEntityDao userStepEntityDao; | |
| 31 | 31 | |
| 32 | 32 | public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> |
| 33 | 33 | daoConfigMap) { |
| 34 | 34 | super(db); |
| 35 | 35 | |
| 36 | - userStepEntityDaoConfig = daoConfigMap.get(UserStepEntityDao.class).clone(); | |
| 37 | - userStepEntityDaoConfig.initIdentityScope(type); | |
| 38 | - | |
| 39 | 36 | collUserStepEntityDaoConfig = daoConfigMap.get(CollUserStepEntityDao.class).clone(); |
| 40 | 37 | collUserStepEntityDaoConfig.initIdentityScope(type); |
| 41 | 38 | |
| 42 | - userStepEntityDao = new UserStepEntityDao(userStepEntityDaoConfig, this); | |
| 39 | + userStepEntityDaoConfig = daoConfigMap.get(UserStepEntityDao.class).clone(); | |
| 40 | + userStepEntityDaoConfig.initIdentityScope(type); | |
| 41 | + | |
| 43 | 42 | collUserStepEntityDao = new CollUserStepEntityDao(collUserStepEntityDaoConfig, this); |
| 43 | + userStepEntityDao = new UserStepEntityDao(userStepEntityDaoConfig, this); | |
| 44 | 44 | |
| 45 | - registerDao(UserStepEntity.class, userStepEntityDao); | |
| 46 | 45 | registerDao(CollUserStepEntity.class, collUserStepEntityDao); |
| 46 | + registerDao(UserStepEntity.class, userStepEntityDao); | |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | public void clear() { |
| 50 | - userStepEntityDaoConfig.clearIdentityScope(); | |
| 51 | 50 | collUserStepEntityDaoConfig.clearIdentityScope(); |
| 52 | - } | |
| 53 | - | |
| 54 | - public UserStepEntityDao getUserStepEntityDao() { | |
| 55 | - return userStepEntityDao; | |
| 51 | + userStepEntityDaoConfig.clearIdentityScope(); | |
| 56 | 52 | } |
| 57 | 53 | |
| 58 | 54 | public CollUserStepEntityDao getCollUserStepEntityDao() { |
| 59 | 55 | return collUserStepEntityDao; |
| 60 | 56 | } |
| 61 | 57 | |
| 58 | + public UserStepEntityDao getUserStepEntityDao() { | |
| 59 | + return userStepEntityDao; | |
| 60 | + } | |
| 61 | + | |
| 62 | 62 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/PedometerMainActivity.java
| ... | ... | @@ -24,6 +24,7 @@ import com.cnlive.libs.base.ui.QMUIFragment; |
| 24 | 24 | import com.cnlive.libs.base.ui.QMUIFragmentActivity; |
| 25 | 25 | import com.cnlive.libs.base.util.StatusBarUtil; |
| 26 | 26 | import com.cnlive.libs.base.util.StatusBarUtil2; |
| 27 | +import com.cnlive.moudle.collectionTrace.ui.activity.CollPedometerMainActivity; | |
| 27 | 28 | import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment; |
| 28 | 29 | import com.cnlive.moudle.pedometer.utils.MyMapUtil; |
| 29 | 30 | import com.cnlive.moudle.pedometer.utils.lib_permisshelper.PermissionsListener; |
| ... | ... | @@ -137,19 +138,7 @@ public class PedometerMainActivity extends QMUIFragmentActivity { |
| 137 | 138 | |
| 138 | 139 | super.onResume(); |
| 139 | 140 | check(); |
| 140 | -// PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE); | |
| 141 | - | |
| 142 | -// if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { | |
| 143 | -// boolean hasIgnored = powerManager.isIgnoringBatteryOptimizations(getPackageName()); | |
| 144 | -// if (!hasIgnored) { | |
| 145 | -// Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); | |
| 146 | -// intent.setData(Uri.parse("package:" + getPackageName())); | |
| 147 | -// PackageManager pm = getPackageManager(); | |
| 148 | -// if (intent.resolveActivity(pm) != null) { | |
| 149 | -// startActivity(intent); | |
| 150 | -// } | |
| 151 | -// } | |
| 152 | -// } | |
| 141 | +// | |
| 153 | 142 | getPermissionsWithTip(); |
| 154 | 143 | } |
| 155 | 144 | |
| ... | ... | @@ -184,7 +173,9 @@ public class PedometerMainActivity extends QMUIFragmentActivity { |
| 184 | 173 | startActivityForResult(intent, 10); |
| 185 | 174 | Toast.makeText(getApplicationContext(), getString(R.string.open_gps_tip), Toast.LENGTH_LONG).show(); |
| 186 | 175 | } else { |
| 187 | - addFragment(); | |
| 176 | + if (getCurrentFragment() == null) { | |
| 177 | + addFragment(); | |
| 178 | + } | |
| 188 | 179 | } |
| 189 | 180 | } |
| 190 | 181 | }) |
| ... | ... | @@ -229,4 +220,8 @@ public class PedometerMainActivity extends QMUIFragmentActivity { |
| 229 | 220 | return; |
| 230 | 221 | } |
| 231 | 222 | |
| 223 | + public static void startActivity(Activity activity) { | |
| 224 | + Intent intent = new Intent(activity, PedometerMainActivity.class); | |
| 225 | + activity.startActivity(intent); | |
| 226 | + } | |
| 232 | 227 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RegistrationInfoFragment.java
| ... | ... | @@ -5,25 +5,51 @@ import android.os.Bundle; |
| 5 | 5 | import android.support.annotation.NonNull; |
| 6 | 6 | import android.support.annotation.Nullable; |
| 7 | 7 | import android.support.v4.app.Fragment; |
| 8 | +import android.util.Log; | |
| 8 | 9 | import android.view.LayoutInflater; |
| 9 | 10 | import android.view.View; |
| 10 | 11 | import android.view.ViewGroup; |
| 12 | +import android.widget.Toast; | |
| 11 | 13 | |
| 14 | +import com.baidu.trace.LBSTraceClient; | |
| 15 | +import com.baidu.trace.api.fence.AddMonitoredPersonRequest; | |
| 16 | +import com.baidu.trace.api.fence.AddMonitoredPersonResponse; | |
| 17 | +import com.baidu.trace.api.fence.CreateFenceResponse; | |
| 18 | +import com.baidu.trace.api.fence.DeleteFenceResponse; | |
| 19 | +import com.baidu.trace.api.fence.DeleteMonitoredPersonResponse; | |
| 20 | +import com.baidu.trace.api.fence.FenceListResponse; | |
| 21 | +import com.baidu.trace.api.fence.FenceType; | |
| 22 | +import com.baidu.trace.api.fence.HistoryAlarmResponse; | |
| 23 | +import com.baidu.trace.api.fence.ListMonitoredPersonResponse; | |
| 24 | +import com.baidu.trace.api.fence.MonitoredStatus; | |
| 25 | +import com.baidu.trace.api.fence.MonitoredStatusByLocationResponse; | |
| 26 | +import com.baidu.trace.api.fence.MonitoredStatusInfo; | |
| 27 | +import com.baidu.trace.api.fence.MonitoredStatusResponse; | |
| 28 | +import com.baidu.trace.api.fence.OnFenceListener; | |
| 29 | +import com.baidu.trace.api.fence.UpdateFenceResponse; | |
| 30 | +import com.baidu.trace.model.LocationMode; | |
| 12 | 31 | import com.cnlive.libs.base.frame.fragment.MvpBindingFragment; |
| 13 | 32 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 14 | 33 | import com.cnlive.moudle.pedometer.frame.presenter.RegistrationInfoPresenter; |
| 15 | 34 | import com.cnlive.moudle.pedometer.frame.view.RegistrationInfoView; |
| 35 | +import com.cnlive.moudle.pedometer.model.Constant; | |
| 36 | +import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil; | |
| 16 | 37 | import com.example.moudle_pedometer.R; |
| 17 | 38 | import com.example.moudle_pedometer.databinding.FragmentRegistrationInfoBinding; |
| 18 | 39 | import com.jzxiang.pickerview.TimePickerDialog; |
| 19 | 40 | |
| 41 | +import java.util.ArrayList; | |
| 42 | +import java.util.List; | |
| 43 | + | |
| 20 | 44 | /** |
| 21 | 45 | * Created by hanyayun 019/05/29. |
| 22 | 46 | */ |
| 23 | -public class RegistrationInfoFragment extends MvpBindingFragment<RegistrationInfoView, RegistrationInfoPresenter,Object, FragmentRegistrationInfoBinding> { | |
| 47 | +public class RegistrationInfoFragment extends MvpBindingFragment<RegistrationInfoView, RegistrationInfoPresenter, Object, FragmentRegistrationInfoBinding> { | |
| 24 | 48 | |
| 25 | 49 | |
| 26 | 50 | public TimePickerDialog pickerDialog; |
| 51 | + private final String TAG = "RegistrationInfo"; | |
| 52 | + | |
| 27 | 53 | public static RegistrationInfoFragment newInstance() { |
| 28 | 54 | RegistrationInfoFragment fragment = new RegistrationInfoFragment(); |
| 29 | 55 | return fragment; |
| ... | ... | @@ -37,12 +63,100 @@ public class RegistrationInfoFragment extends MvpBindingFragment<RegistrationInf |
| 37 | 63 | @Override |
| 38 | 64 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
| 39 | 65 | super.onViewCreated(view, savedInstanceState); |
| 40 | - if(getMvpView() != null) getMvpView().initView(); | |
| 66 | + if (getMvpView() != null) getMvpView().initView(); | |
| 41 | 67 | } |
| 42 | 68 | |
| 43 | - public void commitInfo(){ | |
| 44 | - getPresenter().commitInfo(getActivity(),CommonInfo.getStreetId(getActivity()),"10514343","15210479774", | |
| 45 | - binding.sexText.getText().toString().trim().equals("未选择")?"":binding.sexText.getText().toString().trim(), | |
| 46 | - binding.birthday.getText().toString().trim().equals("未选择")?"":binding.birthday.getText().toString().trim()); | |
| 69 | + public void commitInfo() { | |
| 70 | + | |
| 71 | +// getPresenter().commitInfo(getActivity(), CommonInfo.getStreetId(getActivity()), "10514343", "15210479774", | |
| 72 | +// binding.sexText.getText().toString().trim().equals("未选择") ? "" : binding.sexText.getText().toString().trim(), | |
| 73 | +// binding.birthday.getText().toString().trim().equals("未选择") ? "" : binding.birthday.getText().toString().trim()); | |
| 74 | + addMonitorToFence(1); | |
| 47 | 75 | } |
| 76 | + | |
| 77 | + /** | |
| 78 | + * 将对象添加到围栏 | |
| 79 | + * | |
| 80 | + * @param fenceId | |
| 81 | + */ | |
| 82 | + public void addMonitorToFence(int fenceId) { | |
| 83 | + QMUITipDialogUtil.loadingDialog(getContext(), "请稍后", false); | |
| 84 | + LBSTraceClient mClient = new LBSTraceClient(getContext()); | |
| 85 | + // 设置定位和打包周期 | |
| 86 | + mClient.setInterval(Constant.GATHER_INTERVAL, Constant.PACK_INTERVAL); | |
| 87 | + //设置定位模式 | |
| 88 | + mClient.setLocationMode(LocationMode.High_Accuracy); | |
| 89 | + //将设备添加到围栏中 | |
| 90 | + AddMonitoredPersonRequest addMonitoredPersonRequest = AddMonitoredPersonRequest.buildServerRequest(Constant.TAG, Constant.SERVICE_ID, fenceId, CommonInfo.getUserId(getContext())); | |
| 91 | + // 初始化围栏监听器 | |
| 92 | + OnFenceListener onFenceListener = new OnFenceListener() { | |
| 93 | + // 创建围栏回调 | |
| 94 | + @Override | |
| 95 | + public void onCreateFenceCallback(CreateFenceResponse createFenceResponse) { | |
| 96 | + } | |
| 97 | + | |
| 98 | + // 更新围栏回调 | |
| 99 | + @Override | |
| 100 | + public void onUpdateFenceCallback(UpdateFenceResponse updateFenceResponse) { | |
| 101 | + | |
| 102 | + } | |
| 103 | + | |
| 104 | + // 删除围栏回调 | |
| 105 | + @Override | |
| 106 | + public void onDeleteFenceCallback(DeleteFenceResponse deleteFenceResponse) { | |
| 107 | + | |
| 108 | + } | |
| 109 | + | |
| 110 | + // 围栏列表回调 | |
| 111 | + @Override | |
| 112 | + public void onFenceListCallback(FenceListResponse fenceListResponse) { | |
| 113 | + } | |
| 114 | + | |
| 115 | + // 监控状态回调 | |
| 116 | + @Override | |
| 117 | + public void onMonitoredStatusCallback(MonitoredStatusResponse monitoredStatusResponse) { | |
| 118 | + } | |
| 119 | + | |
| 120 | + // 指定位置监控状态回调 | |
| 121 | + @Override | |
| 122 | + public void onMonitoredStatusByLocationCallback(MonitoredStatusByLocationResponse monitoredStatusByLocationResponse) { | |
| 123 | + } | |
| 124 | + | |
| 125 | + // 历史报警回调 | |
| 126 | + @Override | |
| 127 | + public void onHistoryAlarmCallback(HistoryAlarmResponse historyAlarmResponse) { | |
| 128 | + } | |
| 129 | + | |
| 130 | + @Override | |
| 131 | + public void onAddMonitoredPersonCallback(AddMonitoredPersonResponse addMonitoredPersonResponse) { | |
| 132 | + // 鉴权失败 | |
| 133 | + if (addMonitoredPersonResponse.getStatus() == 14004) { | |
| 134 | + if (mClient != null) { | |
| 135 | + //将设备添加到围栏中 | |
| 136 | + mClient.addFenceMonitoredPerson(addMonitoredPersonRequest, this); | |
| 137 | + } | |
| 138 | + } else if (addMonitoredPersonResponse.getStatus() == 0) { | |
| 139 | + QMUITipDialogUtil.dismessDialog(); | |
| 140 | + getPresenter().commitInfo(getActivity(), CommonInfo.getStreetId(getActivity()), "10514343", "15210479774", | |
| 141 | + binding.sexText.getText().toString().trim().equals("未选择") ? "" : binding.sexText.getText().toString().trim(), | |
| 142 | + binding.birthday.getText().toString().trim().equals("未选择") ? "" : binding.birthday.getText().toString().trim()); | |
| 143 | + } else { | |
| 144 | + QMUITipDialogUtil.dismessDialog(); | |
| 145 | + } | |
| 146 | + | |
| 147 | + } | |
| 148 | + | |
| 149 | + @Override | |
| 150 | + public void onDeleteMonitoredPersonCallback(DeleteMonitoredPersonResponse deleteMonitoredPersonResponse) { | |
| 151 | + } | |
| 152 | + | |
| 153 | + @Override | |
| 154 | + public void onListMonitoredPersonCallback(ListMonitoredPersonResponse listMonitoredPersonResponse) { | |
| 155 | + } | |
| 156 | + }; | |
| 157 | + //将设备添加到围栏中 | |
| 158 | + mClient.addFenceMonitoredPerson(addMonitoredPersonRequest, onFenceListener); | |
| 159 | + } | |
| 160 | + | |
| 161 | + | |
| 48 | 162 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunRaceDetailFragment.java
| ... | ... | @@ -15,12 +15,17 @@ import android.widget.LinearLayout; |
| 15 | 15 | |
| 16 | 16 | import com.cnlive.libs.base.ui.QMUIFragment; |
| 17 | 17 | import com.cnlive.libs.base.util.StatusBarUtil2; |
| 18 | +import com.cnlive.moudle.collectionTrace.ui.activity.CollPedometerMainActivity; | |
| 18 | 19 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 19 | 20 | import com.cnlive.moudle.pedometer.frame.presenter.RunRaceDetailFragmentPresenter; |
| 20 | 21 | import com.cnlive.moudle.pedometer.frame.view.RunRaceDetailFragmentView; |
| 22 | +import com.cnlive.moudle.pedometer.model.Constant; | |
| 23 | +import com.cnlive.moudle.pedometer.model.MessageEvent; | |
| 21 | 24 | import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; |
| 25 | +import com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity; | |
| 22 | 26 | import com.cnlive.moudle.pedometer.ui.widget.FivePersonIconView; |
| 23 | 27 | import com.cnlive.moudle.pedometer.utils.ChineseToSpeechUtil; |
| 28 | +import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil; | |
| 24 | 29 | import com.cnlive.moudle.pedometer.utils.ScreenUtil; |
| 25 | 30 | import com.cnlive.moudle.pedometer.utils.StepUtil; |
| 26 | 31 | import com.example.moudle_pedometer.R; |
| ... | ... | @@ -29,6 +34,8 @@ import com.qmuiteam.qmui.util.QMUIStatusBarHelper; |
| 29 | 34 | import com.sothree.slidinguppanel.SlidingUpPanelLayout; |
| 30 | 35 | |
| 31 | 36 | import org.greenrobot.eventbus.EventBus; |
| 37 | +import org.greenrobot.eventbus.Subscribe; | |
| 38 | +import org.greenrobot.eventbus.ThreadMode; | |
| 32 | 39 | |
| 33 | 40 | import java.util.ArrayList; |
| 34 | 41 | import java.util.List; |
| ... | ... | @@ -64,7 +71,9 @@ public class RunRaceDetailFragment extends QMUIFragment<RunRaceDetailFragmentVie |
| 64 | 71 | super.onViewCreated(view, savedInstanceState); |
| 65 | 72 | QMUIStatusBarHelper.setStatusBarLightMode(getActivity()); |
| 66 | 73 | StatusBarUtil2.setColor(getActivity(), getResources().getColor(R.color.white), 0); |
| 74 | + EventBus.getDefault().register(this); | |
| 67 | 75 | mSensorManager = (SensorManager) getActivity().getSystemService(SENSOR_SERVICE);//获取传感器管理服务 |
| 76 | + CommonInfo.setUserId(getContext(), "yangshuai"); | |
| 68 | 77 | if (getMvpView() != null) { |
| 69 | 78 | getMvpView().initMap(); |
| 70 | 79 | ; |
| ... | ... | @@ -112,7 +121,9 @@ public class RunRaceDetailFragment extends QMUIFragment<RunRaceDetailFragmentVie |
| 112 | 121 | if (getMvpView() != null) { |
| 113 | 122 | getMvpView().onDestroy(); |
| 114 | 123 | } |
| 115 | - | |
| 124 | + if (EventBus.getDefault().isRegistered(this)) { | |
| 125 | + EventBus.getDefault().unregister(this); | |
| 126 | + } | |
| 116 | 127 | } |
| 117 | 128 | |
| 118 | 129 | /** |
| ... | ... | @@ -171,4 +182,28 @@ public class RunRaceDetailFragment extends QMUIFragment<RunRaceDetailFragmentVie |
| 171 | 182 | // FivePersonIconView fivePersonIconView = view.findViewById(R.id.five_join_person); |
| 172 | 183 | // fivePersonIconView.initIconData(data); |
| 173 | 184 | // } |
| 185 | + | |
| 186 | + @Subscribe(threadMode = ThreadMode.MAIN) | |
| 187 | + public void Event(MessageEvent messageEvent) { | |
| 188 | + //启动鹰眼成功 | |
| 189 | + if (messageEvent.getMessageType() == Constant.START_TRACE_GATHER_SUCCESS) { | |
| 190 | + if (getMvpView() != null) { | |
| 191 | + QMUITipDialogUtil.dismessDialog(); | |
| 192 | + PedometerMainActivity.startActivity(getActivity()); | |
| 193 | + } | |
| 194 | + } | |
| 195 | + //启动鹰眼失败 | |
| 196 | + else if (messageEvent.getMessageType() == Constant.START_TRACE_GATHER_FAIL) { | |
| 197 | + if (getMvpView() != null) { | |
| 198 | + QMUITipDialogUtil.dismessDialog(); | |
| 199 | + QMUITipDialogUtil.textDialog(getContext(), "服务异常,请重试!", 1); | |
| 200 | + } | |
| 201 | + } | |
| 202 | + //报名成功 | |
| 203 | + else if (messageEvent.getMessageType() == Constant.REGISTRATION_SUCCESS) { | |
| 204 | + if (getMvpView() != null) { | |
| 205 | + getMvpView().setRegistrationBtn(); | |
| 206 | + } | |
| 207 | + } | |
| 208 | + } | |
| 174 | 209 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/CheckUtil.java
0 → 100644
| 1 | +package com.cnlive.moudle.pedometer.utils; | |
| 2 | + | |
| 3 | +import android.app.Activity; | |
| 4 | +import android.content.Context; | |
| 5 | +import android.content.Intent; | |
| 6 | +import android.content.pm.PackageManager; | |
| 7 | +import android.net.Uri; | |
| 8 | +import android.os.PowerManager; | |
| 9 | +import android.provider.Settings; | |
| 10 | + | |
| 11 | +import static android.content.Context.POWER_SERVICE; | |
| 12 | + | |
| 13 | +public class CheckUtil { | |
| 14 | + | |
| 15 | + public static boolean isIgnoringBatteryOptimizationss(Activity context) { | |
| 16 | + PowerManager powerManager = (PowerManager) context.getSystemService(POWER_SERVICE); | |
| 17 | + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { | |
| 18 | + boolean hasIgnored = powerManager.isIgnoringBatteryOptimizations(context.getPackageName()); | |
| 19 | + if (!hasIgnored) { | |
| 20 | + Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); | |
| 21 | + intent.setData(Uri.parse("package:" + context.getPackageName())); | |
| 22 | + PackageManager pm = context.getPackageManager(); | |
| 23 | + if (intent.resolveActivity(pm) != null) { | |
| 24 | + context.startActivity(intent); | |
| 25 | + } | |
| 26 | + return false; | |
| 27 | + } else { | |
| 28 | + return true; | |
| 29 | + } | |
| 30 | + } | |
| 31 | + return false; | |
| 32 | + } | |
| 33 | +} | ... | ... |
moudle_pedometer/src/main/res/layout/fragment_collect_run_race_detail.xml
| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | sothree:umanoDragView="@+id/dragView" |
| 11 | 11 | sothree:umanoFadeColor="@color/black_20" |
| 12 | 12 | sothree:umanoOverlay="true" |
| 13 | - sothree:umanoPanelHeight="141dp" | |
| 13 | + sothree:umanoPanelHeight="100dp" | |
| 14 | 14 | sothree:umanoParallaxOffset="250dp" |
| 15 | 15 | sothree:umanoScrollableView="@+id/scrollView" |
| 16 | 16 | sothree:umanoShadowHeight="0dp"> | ... | ... |
moudle_pedometer/src/main/res/layout/fragment_collect_running_map.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 | + android:orientation="vertical"> | |
| 8 | + | |
| 9 | + <com.baidu.mapapi.map.MapView | |
| 10 | + android:id="@+id/mapView" | |
| 11 | + android:layout_width="match_parent" | |
| 12 | + android:layout_height="match_parent"></com.baidu.mapapi.map.MapView> | |
| 13 | + | |
| 14 | + <!--地图上面加一层类似于全透明黑色蒙版--> | |
| 15 | + <LinearLayout | |
| 16 | + android:layout_width="match_parent" | |
| 17 | + android:layout_height="match_parent" | |
| 18 | + android:background="#0D000000" | |
| 19 | + android:clickable="false" | |
| 20 | + android:focusable="false" | |
| 21 | + android:focusableInTouchMode="false"></LinearLayout> | |
| 22 | + | |
| 23 | + <FrameLayout | |
| 24 | + android:id="@+id/fl_back" | |
| 25 | + android:layout_width="40dp" | |
| 26 | + android:layout_height="40dp" | |
| 27 | + android:layout_margin="10dp" | |
| 28 | + android:background="@drawable/circle_white_shadow_bg" | |
| 29 | + android:focusable="true"> | |
| 30 | + | |
| 31 | + <ImageView | |
| 32 | + android:layout_width="12dp" | |
| 33 | + android:layout_height="20dp" | |
| 34 | + android:layout_gravity="center" | |
| 35 | + android:layout_marginLeft="-2dp" | |
| 36 | + android:layout_marginBottom="3dp" | |
| 37 | + android:background="@drawable/icon_back" | |
| 38 | + android:focusable="false" /> | |
| 39 | + </FrameLayout> | |
| 40 | + | |
| 41 | + <LinearLayout | |
| 42 | + android:layout_width="wrap_content" | |
| 43 | + android:layout_height="wrap_content" | |
| 44 | + android:layout_gravity="top|right" | |
| 45 | + android:layout_marginTop="15dp" | |
| 46 | + android:layout_marginRight="10dp" | |
| 47 | + android:orientation="vertical"> | |
| 48 | + | |
| 49 | + <LinearLayout | |
| 50 | + android:layout_width="80dp" | |
| 51 | + android:layout_height="35dp" | |
| 52 | + android:layout_gravity="right" | |
| 53 | + android:background="@drawable/gps_white_shadow" | |
| 54 | + android:gravity="center"> | |
| 55 | + | |
| 56 | + <TextView | |
| 57 | + android:layout_width="wrap_content" | |
| 58 | + android:layout_height="wrap_content" | |
| 59 | + android:layout_marginBottom="4dp" | |
| 60 | + android:text="GPS" | |
| 61 | + android:textColor="@color/text_black" | |
| 62 | + android:textSize="12sp" | |
| 63 | + android:textStyle="bold" /> | |
| 64 | + | |
| 65 | + <ImageView | |
| 66 | + android:id="@+id/iv_gps_state" | |
| 67 | + android:layout_width="18dp" | |
| 68 | + android:layout_height="5dp" | |
| 69 | + android:layout_marginLeft="5dp" | |
| 70 | + android:layout_marginBottom="4dp" /> | |
| 71 | + </LinearLayout> | |
| 72 | + <!----> | |
| 73 | + <TextView | |
| 74 | + android:id="@+id/tv_gps_pop_bg" | |
| 75 | + android:layout_width="wrap_content" | |
| 76 | + android:layout_height="45dp" | |
| 77 | + android:layout_marginTop="-5dp" | |
| 78 | + android:background="@drawable/gps_tip_bg" | |
| 79 | + android:gravity="center" | |
| 80 | + android:paddingLeft="15dp" | |
| 81 | + android:paddingRight="15dp" | |
| 82 | + android:textColor="@color/text_black" | |
| 83 | + android:textSize="12sp" | |
| 84 | + android:visibility="gone" /> | |
| 85 | + <!----> | |
| 86 | + </LinearLayout> | |
| 87 | + | |
| 88 | + | |
| 89 | + <FrameLayout | |
| 90 | + android:id="@+id/fl_location" | |
| 91 | + android:layout_width="40dp" | |
| 92 | + android:layout_height="40dp" | |
| 93 | + android:layout_gravity="bottom" | |
| 94 | + android:layout_marginLeft="10dp" | |
| 95 | + android:layout_marginBottom="150dp" | |
| 96 | + android:background="@drawable/circle_white_shadow_bg" | |
| 97 | + android:focusable="true"> | |
| 98 | + | |
| 99 | + <ImageView | |
| 100 | + android:layout_width="20dp" | |
| 101 | + android:layout_height="20dp" | |
| 102 | + android:layout_gravity="center" | |
| 103 | + android:layout_marginBottom="4dp" | |
| 104 | + android:background="@drawable/rt_ic_location_blank" | |
| 105 | + android:focusable="false" /> | |
| 106 | + </FrameLayout> | |
| 107 | + | |
| 108 | + <FrameLayout | |
| 109 | + android:id="@+id/fl_take_import_point" | |
| 110 | + android:layout_width="50dp" | |
| 111 | + android:layout_height="50dp" | |
| 112 | + android:layout_gravity="right|bottom" | |
| 113 | + android:layout_marginRight="10dp" | |
| 114 | + android:layout_marginBottom="200dp" | |
| 115 | + android:background="@drawable/circle_white_shadow_bg" | |
| 116 | + android:focusable="true"> | |
| 117 | + | |
| 118 | + <TextView | |
| 119 | + android:layout_width="wrap_content" | |
| 120 | + android:layout_height="wrap_content" | |
| 121 | + android:layout_gravity="center" | |
| 122 | + android:layout_marginBottom="5dp" | |
| 123 | + android:text="打点" | |
| 124 | + android:textColor="@color/text_black" | |
| 125 | + android:textSize="15sp" /> | |
| 126 | + </FrameLayout> | |
| 127 | + | |
| 128 | + <FrameLayout | |
| 129 | + android:id="@+id/fl_end_point" | |
| 130 | + android:layout_width="50dp" | |
| 131 | + android:layout_height="50dp" | |
| 132 | + android:layout_gravity="right|bottom" | |
| 133 | + android:layout_marginRight="10dp" | |
| 134 | + android:layout_marginBottom="140dp" | |
| 135 | + android:background="@drawable/circle_white_shadow_bg" | |
| 136 | + android:focusable="true"> | |
| 137 | + | |
| 138 | + <TextView | |
| 139 | + android:layout_width="wrap_content" | |
| 140 | + android:layout_height="wrap_content" | |
| 141 | + android:layout_gravity="center" | |
| 142 | + android:layout_marginBottom="5dp" | |
| 143 | + android:text="结束" | |
| 144 | + android:textColor="@color/text_black" | |
| 145 | + android:textSize="15sp" /> | |
| 146 | + </FrameLayout> | |
| 147 | + | |
| 148 | + <LinearLayout | |
| 149 | + android:layout_width="match_parent" | |
| 150 | + android:layout_height="130dp" | |
| 151 | + android:layout_gravity="bottom" | |
| 152 | + android:layout_marginBottom="10dp" | |
| 153 | + android:background="@drawable/white_shadow_bg" | |
| 154 | + android:scaleX="1.02"> | |
| 155 | + | |
| 156 | + <LinearLayout | |
| 157 | + android:layout_width="0dp" | |
| 158 | + android:layout_height="match_parent" | |
| 159 | + android:layout_weight="1.2" | |
| 160 | + android:gravity="center" | |
| 161 | + android:orientation="vertical" | |
| 162 | + android:paddingLeft="5dp" | |
| 163 | + android:paddingRight="5dp"> | |
| 164 | + | |
| 165 | + <TextView | |
| 166 | + android:id="@+id/tv_current_speed" | |
| 167 | + android:layout_width="wrap_content" | |
| 168 | + android:layout_height="wrap_content" | |
| 169 | + android:text="--" | |
| 170 | + android:textColor="@color/black" | |
| 171 | + android:textSize="20sp" | |
| 172 | + android:textStyle="bold" /> | |
| 173 | + | |
| 174 | + <TextView | |
| 175 | + android:layout_width="wrap_content" | |
| 176 | + android:layout_height="wrap_content" | |
| 177 | + android:layout_marginTop="10dp" | |
| 178 | + android:text="配速" | |
| 179 | + android:textColor="@color/black" | |
| 180 | + android:textSize="15sp" /> | |
| 181 | + </LinearLayout> | |
| 182 | + | |
| 183 | + <LinearLayout | |
| 184 | + android:layout_width="0dp" | |
| 185 | + android:layout_height="match_parent" | |
| 186 | + android:layout_weight="1.2" | |
| 187 | + android:gravity="center" | |
| 188 | + android:orientation="vertical"> | |
| 189 | + | |
| 190 | + <Chronometer | |
| 191 | + android:id="@+id/chronometer" | |
| 192 | + android:layout_width="wrap_content" | |
| 193 | + android:layout_height="wrap_content" | |
| 194 | + android:format="00:00:00" | |
| 195 | + android:textColor="@color/black" | |
| 196 | + android:textSize="20sp" | |
| 197 | + android:textStyle="bold" /> | |
| 198 | + | |
| 199 | + <TextView | |
| 200 | + android:layout_width="wrap_content" | |
| 201 | + android:layout_height="wrap_content" | |
| 202 | + android:layout_marginTop="10dp" | |
| 203 | + android:text="用时" | |
| 204 | + android:textColor="@color/black" | |
| 205 | + android:textSize="15sp" /> | |
| 206 | + </LinearLayout> | |
| 207 | + | |
| 208 | + | |
| 209 | + <LinearLayout | |
| 210 | + android:layout_width="0dp" | |
| 211 | + android:layout_height="match_parent" | |
| 212 | + android:layout_weight="1" | |
| 213 | + android:gravity="center" | |
| 214 | + android:orientation="vertical" | |
| 215 | + android:paddingLeft="5dp" | |
| 216 | + android:paddingRight="5dp"> | |
| 217 | + | |
| 218 | + <TextView | |
| 219 | + android:id="@+id/tv_current_diatance" | |
| 220 | + android:layout_width="wrap_content" | |
| 221 | + android:layout_height="wrap_content" | |
| 222 | + android:text="--" | |
| 223 | + android:textColor="@color/black" | |
| 224 | + android:textSize="20sp" | |
| 225 | + android:textStyle="bold" /> | |
| 226 | + | |
| 227 | + <TextView | |
| 228 | + android:layout_width="wrap_content" | |
| 229 | + android:layout_height="wrap_content" | |
| 230 | + android:layout_marginTop="10dp" | |
| 231 | + android:text="距离(km)" | |
| 232 | + android:textColor="@color/black" | |
| 233 | + android:textSize="15sp" /> | |
| 234 | + </LinearLayout> | |
| 235 | + | |
| 236 | + </LinearLayout> | |
| 237 | + | |
| 238 | + <!----> | |
| 239 | + | |
| 240 | + </FrameLayout> | |
| 241 | +</layout> | |
| 0 | 242 | \ No newline at end of file | ... | ... |
moudle_pedometer/src/main/res/layout/fragment_run_main.xml
| ... | ... | @@ -20,7 +20,8 @@ |
| 20 | 20 | <RelativeLayout |
| 21 | 21 | android:id="@+id/rl_close" |
| 22 | 22 | android:layout_width="match_parent" |
| 23 | - android:layout_height="wrap_content"> | |
| 23 | + android:layout_height="wrap_content" | |
| 24 | + android:visibility="gone"> | |
| 24 | 25 | |
| 25 | 26 | <ImageView |
| 26 | 27 | android:layout_width="25dp" |
| ... | ... | @@ -33,7 +34,7 @@ |
| 33 | 34 | <LinearLayout |
| 34 | 35 | android:layout_width="match_parent" |
| 35 | 36 | android:layout_height="0dp" |
| 36 | - android:layout_weight="1" | |
| 37 | + android:layout_weight="1.2" | |
| 37 | 38 | android:gravity="center" |
| 38 | 39 | android:paddingLeft="50dp"> |
| 39 | 40 | |
| ... | ... | @@ -85,8 +86,7 @@ |
| 85 | 86 | android:layout_height="5dp" |
| 86 | 87 | android:layout_centerVertical="true" |
| 87 | 88 | android:layout_marginLeft="5dp" |
| 88 | - android:layout_toRightOf="@id/tv_gps" | |
| 89 | - /> | |
| 89 | + android:layout_toRightOf="@id/tv_gps" /> | |
| 90 | 90 | |
| 91 | 91 | <TextView |
| 92 | 92 | android:id="@+id/tv_look_trace" |
| ... | ... | @@ -163,8 +163,7 @@ |
| 163 | 163 | android:gravity="center" |
| 164 | 164 | android:text="配速" |
| 165 | 165 | android:textColor="@color/text_gray99" |
| 166 | - android:textSize="15sp" | |
| 167 | - /> | |
| 166 | + android:textSize="15sp" /> | |
| 168 | 167 | </LinearLayout> |
| 169 | 168 | <!--用时--> |
| 170 | 169 | <LinearLayout |
| ... | ... | @@ -196,8 +195,7 @@ |
| 196 | 195 | android:gravity="center" |
| 197 | 196 | android:text="用时" |
| 198 | 197 | android:textColor="@color/text_gray99" |
| 199 | - android:textSize="15sp" | |
| 200 | - /> | |
| 198 | + android:textSize="15sp" /> | |
| 201 | 199 | </LinearLayout> |
| 202 | 200 | <!--热量--> |
| 203 | 201 | <LinearLayout |
| ... | ... | @@ -230,8 +228,7 @@ |
| 230 | 228 | android:gravity="center" |
| 231 | 229 | android:text="步" |
| 232 | 230 | android:textColor="@color/text_gray99" |
| 233 | - android:textSize="15sp" | |
| 234 | - /> | |
| 231 | + android:textSize="15sp" /> | |
| 235 | 232 | </LinearLayout> |
| 236 | 233 | </LinearLayout> |
| 237 | 234 | |
| ... | ... | @@ -259,11 +256,11 @@ |
| 259 | 256 | <LinearLayout |
| 260 | 257 | android:id="@+id/ll_two_bottom_button" |
| 261 | 258 | android:layout_width="match_parent" |
| 262 | - android:layout_height="match_parent" | |
| 259 | + android:layout_height="wrap_content" | |
| 260 | + android:layout_gravity="center" | |
| 261 | + android:layout_marginBottom="25dp" | |
| 263 | 262 | android:gravity="center_horizontal" |
| 264 | - android:visibility="gone" | |
| 265 | - | |
| 266 | - > | |
| 263 | + android:visibility="gone"> | |
| 267 | 264 | |
| 268 | 265 | <LinearLayout |
| 269 | 266 | android:layout_width="wrap_content" | ... | ... |