Commit fabe252586d053703af1c58c16412af985679e06
1 parent
05f9cba9
1 路径工具,数据上传逻辑
Showing
14 changed files
with
695 additions
and
64 deletions
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/presenter/CollRunningFinishFragmetPresenter.java
| 1 | 1 | package com.cnlive.moudle.collectionTrace.frame.presenter; |
| 2 | 2 | |
| 3 | +import android.app.Activity; | |
| 4 | +import android.os.Handler; | |
| 5 | +import android.text.TextUtils; | |
| 6 | +import android.util.Log; | |
| 7 | + | |
| 8 | +import com.baidu.mapapi.map.Overlay; | |
| 9 | +import com.baidu.mapapi.model.LatLng; | |
| 10 | +import com.cnlive.libs.base.logic.Logic; | |
| 11 | +import com.cnlive.libs.base.logic.callback.DataCallback; | |
| 12 | +import com.cnlive.libs.base.logic.callback.FailureCallback; | |
| 13 | +import com.cnlive.libs.base.logic.callback.SuccessCallback; | |
| 14 | +import com.cnlive.moudle.collectionTrace.commonInfo.CollCommonInfo; | |
| 3 | 15 | import com.cnlive.moudle.collectionTrace.frame.view.CollRunningFinishFragmentView; |
| 16 | +import com.cnlive.moudle.collectionTrace.model.CollectPoint; | |
| 17 | +import com.cnlive.moudle.collectionTrace.utils.CollStepUtil; | |
| 18 | +import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; | |
| 19 | +import com.cnlive.moudle.pedometer.net.ApiServiceRunLin; | |
| 20 | +import com.cnlive.moudle.pedometer.net.SubscriptionRequest; | |
| 21 | +import com.cnlive.moudle.pedometer.net.bean.BaseInfo; | |
| 22 | +import com.cnlive.moudle.pedometer.sql.entity.CollUserStepEntity; | |
| 23 | +import com.cnlive.moudle.pedometer.sql.entity.FailedEntity; | |
| 24 | +import com.cnlive.moudle.pedometer.ui.activity.LineUpAgainActivity; | |
| 25 | +import com.cnlive.moudle.pedometer.ui.widget.SelectDialog; | |
| 26 | +import com.cnlive.moudle.pedometer.utils.GsonUtil; | |
| 27 | +import com.cnlive.moudle.pedometer.utils.MyMapUtil; | |
| 28 | +import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil; | |
| 29 | +import com.cnlive.moudle.pedometer.utils.StepUtil; | |
| 30 | +import com.example.moudle_pedometer.R; | |
| 4 | 31 | import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; |
| 5 | 32 | |
| 33 | +import java.util.HashMap; | |
| 34 | +import java.util.List; | |
| 35 | +import java.util.Map; | |
| 36 | + | |
| 37 | +import io.reactivex.disposables.Disposable; | |
| 38 | + | |
| 6 | 39 | public class CollRunningFinishFragmetPresenter extends MvpBasePresenter<CollRunningFinishFragmentView> { |
| 40 | + | |
| 41 | + public void uploadTraceDateToServer(Activity context, CollUserStepEntity userStepEntity, String roadmap) { | |
| 42 | + QMUITipDialogUtil.loadingDialog(context, "正在上传数据", false); | |
| 43 | + Map<String, String> paramsMap = new HashMap<>(); | |
| 44 | + //赛事id | |
| 45 | + if (!TextUtils.isEmpty(userStepEntity.getStreetId())) { | |
| 46 | + String eventId = userStepEntity.getStreetId(); | |
| 47 | + paramsMap.put("eventId", eventId); | |
| 48 | + } | |
| 49 | + //踩点图 | |
| 50 | + if (!TextUtils.isEmpty(roadmap)) { | |
| 51 | + paramsMap.put("roadmap", roadmap); | |
| 52 | + } | |
| 53 | + //运营人员sid | |
| 54 | + paramsMap.put("darenId", CollCommonInfo.getUserId(context)); | |
| 55 | + if (!TextUtils.isEmpty(userStepEntity.getImportPoint())) { | |
| 56 | + List<CollectPoint> collectPoints = GsonUtil.jsonToList(userStepEntity.getImportPoint(), CollectPoint.class); | |
| 57 | + //绘制运营打的点 | |
| 58 | + if (null != collectPoints) { | |
| 59 | + //根据打点集合,自适应缩放 | |
| 60 | + CollectPoint startPoint = null; | |
| 61 | + if (!TextUtils.isEmpty(userStepEntity.getCollStartPointData())) { | |
| 62 | + startPoint = GsonUtil.GsonToBean(userStepEntity.getCollStartPointData(), CollectPoint.class); | |
| 63 | + } | |
| 64 | + CollectPoint endPoint = null; | |
| 65 | + if (!TextUtils.isEmpty(userStepEntity.getCollEndPointData())) { | |
| 66 | + endPoint = GsonUtil.GsonToBean(userStepEntity.getCollEndPointData(), CollectPoint.class); | |
| 67 | + } | |
| 68 | + if (null != startPoint) { | |
| 69 | + collectPoints.add(0, startPoint); | |
| 70 | + //起点 | |
| 71 | + paramsMap.put("startLocation", startPoint.getPointName()); | |
| 72 | + } | |
| 73 | + if (null != endPoint) { | |
| 74 | + collectPoints.add(endPoint); | |
| 75 | + // 终点 | |
| 76 | + paramsMap.put("endLocation", endPoint.getPointName()); | |
| 77 | + | |
| 78 | + } | |
| 79 | + // 经纬度 | |
| 80 | + paramsMap.put("latLongitude", GsonUtil.GsonString(collectPoints)); | |
| 81 | + } | |
| 82 | + } | |
| 83 | + //全程里数 mileage | |
| 84 | + if (!TextUtils.isEmpty(userStepEntity.getStepCount())) { | |
| 85 | + double mileage = CollStepUtil.getWalkDistanceKM(Long.parseLong(userStepEntity.getStepCount())); | |
| 86 | + paramsMap.put("mileage", mileage + ""); | |
| 87 | + } | |
| 88 | + //开始时间 | |
| 89 | + if (0 != userStepEntity.getStartTimeStamp()) { | |
| 90 | + paramsMap.put("startTime", userStepEntity.getStartTimeStamp() + ""); | |
| 91 | + } | |
| 92 | + //结束时间 | |
| 93 | + if (0 != userStepEntity.getFinishTimeStamp()) { | |
| 94 | + paramsMap.put("endTime", userStepEntity.getFinishTimeStamp() + ""); | |
| 95 | + } | |
| 96 | + //实体名称 | |
| 97 | + paramsMap.put("entityName", CollCommonInfo.getUserId(context)); | |
| 98 | + | |
| 99 | + Logic.create(paramsMap).action(new Logic.Action<Map<String, String>, BaseInfo>() { | |
| 100 | + @Override | |
| 101 | + public Disposable action(Map<String, String> stringStringMap, DataCallback<BaseInfo> dataCallback) { | |
| 102 | + return SubscriptionRequest.service(ApiServiceRunLin.class, api -> api.collSaveShoeLine(stringStringMap)).subscribe(context, dataCallback); | |
| 103 | + } | |
| 104 | + }).<BaseInfo>event() | |
| 105 | + .setFailureCallback(new FailureCallback() { | |
| 106 | + @Override | |
| 107 | + public void onFailure(int code, String message) { | |
| 108 | + if (getView() == null) { | |
| 109 | + return; | |
| 110 | + } | |
| 111 | + QMUITipDialogUtil.dismessDialog(); | |
| 112 | + SelectDialog selectDialog = new SelectDialog(context, "数据上传失败,是否重试?", "取消", new SelectDialog.DialogInterface() { | |
| 113 | + @Override | |
| 114 | + public void onClick(SelectDialog dialog) { | |
| 115 | + dialog.dismiss(); | |
| 116 | + } | |
| 117 | + }, "重试", new SelectDialog.DialogInterface() { | |
| 118 | + @Override | |
| 119 | + public void onClick(SelectDialog dialog) { | |
| 120 | + dialog.dismiss(); | |
| 121 | + uploadTraceDateToServer(context, userStepEntity, roadmap); | |
| 122 | + } | |
| 123 | + }); | |
| 124 | + selectDialog.setCancelable(false); | |
| 125 | + selectDialog.setCanceledOnTouchOutside(false); | |
| 126 | + if (!selectDialog.isShowing()) { | |
| 127 | + selectDialog.show(); | |
| 128 | + } | |
| 129 | + } | |
| 130 | + }).setSuccessCallback(new SuccessCallback<BaseInfo>() { | |
| 131 | + @Override | |
| 132 | + public void onSuccess(BaseInfo baseInfo) { | |
| 133 | + if (getView() == null) { | |
| 134 | + return; | |
| 135 | + } | |
| 136 | + QMUITipDialogUtil.dismessDialog(); | |
| 137 | + QMUITipDialogUtil.successDialog(context, "数据上传成功", 1); | |
| 138 | + //清空数据 | |
| 139 | + CollStepUtil.clearRunData(context, CollCommonInfo.getUserId(context)); | |
| 140 | + CollCommonInfo.reset(context); | |
| 141 | + new Handler().postDelayed(new Runnable() { | |
| 142 | + @Override | |
| 143 | + public void run() { | |
| 144 | + if (null != context) { | |
| 145 | + context.finish(); | |
| 146 | + } | |
| 147 | + } | |
| 148 | + }, 1000); | |
| 149 | + } | |
| 150 | + }).start(); | |
| 151 | + } | |
| 7 | 152 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunningFinishFragmentView.java
| ... | ... | @@ -3,9 +3,13 @@ package com.cnlive.moudle.collectionTrace.frame.view; |
| 3 | 3 | import android.content.Context; |
| 4 | 4 | import android.graphics.Bitmap; |
| 5 | 5 | import android.graphics.BitmapFactory; |
| 6 | +import android.os.Handler; | |
| 6 | 7 | import android.support.v7.widget.LinearLayoutManager; |
| 7 | 8 | import android.text.TextUtils; |
| 9 | +import android.util.Log; | |
| 10 | +import android.view.MotionEvent; | |
| 8 | 11 | import android.view.View; |
| 12 | +import android.widget.Toast; | |
| 9 | 13 | |
| 10 | 14 | import com.baidu.location.LocationClient; |
| 11 | 15 | import com.baidu.location.LocationClientOption; |
| ... | ... | @@ -17,27 +21,55 @@ import com.baidu.mapapi.map.Overlay; |
| 17 | 21 | import com.baidu.mapapi.map.UiSettings; |
| 18 | 22 | import com.baidu.mapapi.model.LatLng; |
| 19 | 23 | import com.baidu.trace.LBSTraceClient; |
| 24 | +import com.baidu.trace.api.fence.AddMonitoredPersonResponse; | |
| 25 | +import com.baidu.trace.api.fence.CreateFenceRequest; | |
| 26 | +import com.baidu.trace.api.fence.CreateFenceResponse; | |
| 27 | +import com.baidu.trace.api.fence.DeleteFenceResponse; | |
| 28 | +import com.baidu.trace.api.fence.DeleteMonitoredPersonResponse; | |
| 29 | +import com.baidu.trace.api.fence.FenceListResponse; | |
| 30 | +import com.baidu.trace.api.fence.HistoryAlarmResponse; | |
| 31 | +import com.baidu.trace.api.fence.ListMonitoredPersonResponse; | |
| 32 | +import com.baidu.trace.api.fence.MonitoredStatusByLocationResponse; | |
| 33 | +import com.baidu.trace.api.fence.MonitoredStatusResponse; | |
| 34 | +import com.baidu.trace.api.fence.OnFenceListener; | |
| 35 | +import com.baidu.trace.api.fence.UpdateFenceResponse; | |
| 36 | +import com.baidu.trace.model.CoordType; | |
| 20 | 37 | import com.baidu.trace.model.SortType; |
| 38 | +import com.cnlive.libs.base.logic.Event; | |
| 39 | +import com.cnlive.libs.base.logic.callback.FailureCallback; | |
| 40 | +import com.cnlive.libs.base.logic.callback.SuccessCallback; | |
| 41 | +import com.cnlive.moudle.collectionTrace.commonInfo.CollCommonInfo; | |
| 21 | 42 | import com.cnlive.moudle.collectionTrace.model.CollectPoint; |
| 22 | 43 | import com.cnlive.moudle.collectionTrace.ui.adapter.CollFinishDetaiAdapter; |
| 23 | 44 | import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunningFinishFragment; |
| 24 | 45 | import com.cnlive.moudle.collectionTrace.utils.CollStepUtil; |
| 25 | 46 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 47 | +import com.cnlive.moudle.pedometer.model.Constant; | |
| 26 | 48 | import com.cnlive.moudle.pedometer.model.RunningFinishBean; |
| 27 | 49 | import com.cnlive.moudle.pedometer.sql.entity.CollUserStepEntity; |
| 28 | 50 | import com.cnlive.moudle.pedometer.ui.fragment.RunningFinishFragment; |
| 51 | +import com.cnlive.moudle.pedometer.ui.widget.SelectDialog; | |
| 52 | +import com.cnlive.moudle.pedometer.upload.UploadLogic; | |
| 29 | 53 | import com.cnlive.moudle.pedometer.utils.BitmapUtil; |
| 30 | 54 | import com.cnlive.moudle.pedometer.utils.GsonUtil; |
| 31 | 55 | import com.cnlive.moudle.pedometer.utils.MyMapUtil; |
| 56 | +import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil; | |
| 57 | +import com.cnlive.moudle.pedometer.utils.ScreenUtil; | |
| 32 | 58 | import com.cnlive.moudle.pedometer.utils.TimeUtil; |
| 33 | 59 | import com.cnlive.strike.application.GlideApp; |
| 34 | 60 | import com.example.moudle_pedometer.R; |
| 35 | 61 | import com.hannesdorfmann.mosby3.mvp.MvpView; |
| 62 | +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog; | |
| 63 | +import com.sothree.slidinguppanel.SlidingUpPanelLayout; | |
| 36 | 64 | |
| 65 | +import java.io.File; | |
| 66 | +import java.io.FileOutputStream; | |
| 67 | +import java.text.SimpleDateFormat; | |
| 37 | 68 | import java.util.ArrayList; |
| 69 | +import java.util.Date; | |
| 38 | 70 | import java.util.List; |
| 39 | 71 | |
| 40 | -public class CollRunningFinishFragmentView implements MvpView { | |
| 72 | +public class CollRunningFinishFragmentView implements MvpView, OnFenceListener { | |
| 41 | 73 | private CollRunningFinishFragment fragment; |
| 42 | 74 | private CollFinishDetaiAdapter adapter; |
| 43 | 75 | public BaiduMap baiduMap; |
| ... | ... | @@ -45,6 +77,9 @@ public class CollRunningFinishFragmentView implements MvpView { |
| 45 | 77 | private UiSettings mUiSettings; |
| 46 | 78 | private LBSTraceClient mClient = null; |
| 47 | 79 | private List<Overlay> allMapOverlays; |
| 80 | + private List<LatLng> queryResultPoints; | |
| 81 | + private List<com.baidu.trace.model.LatLng> collectLatLngs; | |
| 82 | + private CollUserStepEntity collUserStepEntity; | |
| 48 | 83 | |
| 49 | 84 | public CollRunningFinishFragmentView(CollRunningFinishFragment fragment) { |
| 50 | 85 | this.fragment = fragment; |
| ... | ... | @@ -55,21 +90,25 @@ public class CollRunningFinishFragmentView implements MvpView { |
| 55 | 90 | } |
| 56 | 91 | |
| 57 | 92 | public void initView(CollUserStepEntity collUserStepEntity) { |
| 93 | + this.collUserStepEntity = collUserStepEntity; | |
| 58 | 94 | allMapOverlays = new ArrayList<>(); |
| 95 | + //设置滑动卡片 | |
| 96 | +// fragment.binding.slidingLayout.set | |
| 97 | + //添加起点 | |
| 98 | + CollectPoint startPoint = null; | |
| 99 | + if (!TextUtils.isEmpty(collUserStepEntity.getCollStartPointData())) { | |
| 100 | + startPoint = GsonUtil.GsonToBean(collUserStepEntity.getCollStartPointData(), CollectPoint.class); | |
| 101 | + } | |
| 102 | + CollectPoint endPoint = null; | |
| 103 | + if (!TextUtils.isEmpty(collUserStepEntity.getCollEndPointData())) { | |
| 104 | + endPoint = GsonUtil.GsonToBean(collUserStepEntity.getCollEndPointData(), CollectPoint.class); | |
| 105 | + } | |
| 59 | 106 | //查询用户历史轨迹 |
| 60 | 107 | if (0 != collUserStepEntity.getStartTimeStamp() && 0 != collUserStepEntity.getFinishTimeStamp()) { |
| 61 | 108 | long startTime = collUserStepEntity.getStartTimeStamp(); |
| 62 | 109 | long endTime = collUserStepEntity.getFinishTimeStamp(); |
| 63 | 110 | //开始查询 |
| 64 | - MyMapUtil.queryHistoryTrace(getContext(), mClient, CommonInfo.getUserId(getContext()), startTime, endTime, new MyMapUtil.CallBack() { | |
| 65 | - @Override | |
| 66 | - public void success(List<LatLng> resultPoints) { | |
| 67 | - if (null != resultPoints && resultPoints.size() > 1) { | |
| 68 | - //绘制轨迹 | |
| 69 | - MyMapUtil.drawHistoryTrack(getContext(), baiduMap, resultPoints, SortType.asc, R.color.green_round, R.drawable.icon_start, R.drawable.icon_end); | |
| 70 | - } | |
| 71 | - } | |
| 72 | - }); | |
| 111 | + queryWalkTrace(startTime, endTime); | |
| 73 | 112 | if (!TextUtils.isEmpty(collUserStepEntity.getImportPoint())) { |
| 74 | 113 | List<CollectPoint> collectPoints = GsonUtil.jsonToList(collUserStepEntity.getImportPoint(), CollectPoint.class); |
| 75 | 114 | //绘制运营打的点 |
| ... | ... | @@ -114,15 +153,6 @@ public class CollRunningFinishFragmentView implements MvpView { |
| 114 | 153 | //设置适配器 |
| 115 | 154 | if (!TextUtils.isEmpty(collUserStepEntity.getImportPoint())) { |
| 116 | 155 | List<CollectPoint> collectPoints = GsonUtil.jsonToList(collUserStepEntity.getImportPoint(), CollectPoint.class); |
| 117 | - //添加起点 | |
| 118 | - CollectPoint startPoint = null; | |
| 119 | - if (!TextUtils.isEmpty(collUserStepEntity.getCollStartPointData())) { | |
| 120 | - startPoint = GsonUtil.GsonToBean(collUserStepEntity.getCollStartPointData(), CollectPoint.class); | |
| 121 | - } | |
| 122 | - CollectPoint endPoint = null; | |
| 123 | - if (!TextUtils.isEmpty(collUserStepEntity.getCollEndPointData())) { | |
| 124 | - endPoint = GsonUtil.GsonToBean(collUserStepEntity.getCollEndPointData(), CollectPoint.class); | |
| 125 | - } | |
| 126 | 156 | if (null == collectPoints) { |
| 127 | 157 | collectPoints = new ArrayList<>(); |
| 128 | 158 | } |
| ... | ... | @@ -132,7 +162,11 @@ public class CollRunningFinishFragmentView implements MvpView { |
| 132 | 162 | if (null != endPoint) { |
| 133 | 163 | collectPoints.add(endPoint); |
| 134 | 164 | } |
| 135 | - | |
| 165 | + //格式化打的点 | |
| 166 | + collectLatLngs = new ArrayList<>(); | |
| 167 | + for (CollectPoint collectPoint : collectPoints) { | |
| 168 | + collectLatLngs.add(new com.baidu.trace.model.LatLng(collectPoint.getLatitude(), collectPoint.getLongitude())); | |
| 169 | + } | |
| 136 | 170 | adapter = new CollFinishDetaiAdapter(fragment.getActivity(), collectPoints); |
| 137 | 171 | //设置 |
| 138 | 172 | fragment.binding.includeFinishUserInfo.rvList.setLayoutManager(new LinearLayoutManager(fragment.getActivity())); |
| ... | ... | @@ -148,9 +182,262 @@ public class CollRunningFinishFragmentView implements MvpView { |
| 148 | 182 | fragment.getActivity().finish(); |
| 149 | 183 | } |
| 150 | 184 | }); |
| 185 | + fragment.binding.rlScrollViewStartBtn.setOnTouchListener(new View.OnTouchListener() { | |
| 186 | + @Override | |
| 187 | + public boolean onTouch(View view, MotionEvent motionEvent) { | |
| 188 | + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { | |
| 189 | + //判断是否成功查询到轨迹点 | |
| 190 | + if (null == queryResultPoints) { | |
| 191 | + QMUITipDialogUtil.textDialog(getContext(), "正在获取轨迹信息,请稍后...", 1); | |
| 192 | + } else { | |
| 193 | + //隐藏面板视图 | |
| 194 | +// fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN); | |
| 195 | + fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 100)); | |
| 196 | + fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); | |
| 197 | + //让运营选择最佳的截图 | |
| 198 | + SelectDialog selectDialog = new SelectDialog(getContext(), "当前赛事图是否\n已经调整到最佳效果?", "否", new SelectDialog.DialogInterface() { | |
| 199 | + @Override | |
| 200 | + public void onClick(SelectDialog dialog) { | |
| 201 | + dialog.dismiss(); | |
| 202 | + } | |
| 203 | + }, "是", new SelectDialog.DialogInterface() { | |
| 204 | + @Override | |
| 205 | + public void onClick(SelectDialog dialog) { | |
| 206 | + if (null != allMapOverlays) { | |
| 207 | + for (Overlay overlay : allMapOverlays) { | |
| 208 | + overlay.remove(); | |
| 209 | + } | |
| 210 | + } | |
| 211 | + dialog.dismiss(); | |
| 212 | + QMUITipDialogUtil.loadingDialog(getContext(), "正在截取赛事图片,请稍后", false); | |
| 213 | + //延迟一秒进行截图,以免把打的点都截取到 | |
| 214 | + new Handler().postDelayed(new Runnable() { | |
| 215 | + @Override | |
| 216 | + public void run() { | |
| 217 | + if (null != collectLatLngs && collectLatLngs.size() > 1) { | |
| 218 | + getBaiDuSnap(); | |
| 219 | + } | |
| 220 | + } | |
| 221 | + }, 1000); | |
| 222 | + } | |
| 223 | + }); | |
| 224 | + selectDialog.setCanceledOnTouchOutside(false); | |
| 225 | + selectDialog.setCancelable(false); | |
| 226 | + selectDialog.show(); | |
| 227 | + } | |
| 228 | + } | |
| 229 | + return false; | |
| 230 | + } | |
| 231 | + }); | |
| 232 | +// //确定轨迹按钮点击事件 | |
| 233 | +// fragment.binding.rlScrollViewStartBtn.setOnClickListener(new View.OnClickListener() { | |
| 234 | +// @Override | |
| 235 | +// public void onClick(View view) { | |
| 236 | +// Log.e("aaa", "onClick: "); | |
| 237 | +// //开始整合数据 | |
| 238 | +// //判断是否成功查询到轨迹点 | |
| 239 | +// if (null == queryResultPoints) { | |
| 240 | +// QMUITipDialogUtil.textDialog(getContext(), "正在获取轨迹信息,请稍后...", 1); | |
| 241 | +// } else { | |
| 242 | +// //隐藏面板视图 | |
| 243 | +//// fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN); | |
| 244 | +// fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(),100)); | |
| 245 | +// fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); | |
| 246 | +// //让运营选择最佳的截图 | |
| 247 | +// SelectDialog selectDialog = new SelectDialog(getContext(), "当前赛事图是否\n已经调整到最佳效果?", "否", new SelectDialog.DialogInterface() { | |
| 248 | +// @Override | |
| 249 | +// public void onClick(SelectDialog dialog) { | |
| 250 | +// dialog.dismiss(); | |
| 251 | +// } | |
| 252 | +// }, "是", new SelectDialog.DialogInterface() { | |
| 253 | +// @Override | |
| 254 | +// public void onClick(SelectDialog dialog) { | |
| 255 | +// if (null != allMapOverlays) { | |
| 256 | +// for (Overlay overlay : allMapOverlays) { | |
| 257 | +// overlay.remove(); | |
| 258 | +// } | |
| 259 | +// } | |
| 260 | +// dialog.dismiss(); | |
| 261 | +// QMUITipDialogUtil.textDialog(getContext(), "正在截取赛事图片,请稍后", 1); | |
| 262 | +// //延迟一秒进行截图,以免把打的点都截取到 | |
| 263 | +// new Handler().postDelayed(new Runnable() { | |
| 264 | +// @Override | |
| 265 | +// public void run() { | |
| 266 | +// baiduMap.snapshot(new BaiduMap.SnapshotReadyCallback() { | |
| 267 | +// @Override | |
| 268 | +// public void onSnapshotReady(Bitmap bitmap) { | |
| 269 | +// if (null == bitmap) { | |
| 270 | +// QMUITipDialogUtil.dismessDialog(); | |
| 271 | +// QMUITipDialogUtil.failedDialog(getContext(), "赛事图片截取失败,请重试", 2); | |
| 272 | +// return; | |
| 273 | +// } | |
| 274 | +// | |
| 275 | +// //开始保存截屏 | |
| 276 | +// try { | |
| 277 | +// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); | |
| 278 | +// File image = new File(getContext().getExternalCacheDir() + "/location_screenshot_" + sdf.format(new Date()) + ".jpeg"); | |
| 279 | +// FileOutputStream fos = new FileOutputStream(当前赛事图是否 | |
| 280 | +//已经调整到最佳效果?image); | |
| 281 | +// boolean b = bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos); | |
| 282 | +// fos.flush(); | |
| 283 | +// fos.close(); | |
| 284 | +// //获取保存截图地址 | |
| 285 | +//// image.getAbsolutePath() | |
| 286 | +// } catch (Exception e) { | |
| 287 | +// QMUITipDialogUtil.dismessDialog(); | |
| 288 | +// QMUITipDialogUtil.failedDialog(getContext(), "赛事图片截取失败,请重试", 2); | |
| 289 | +// e.printStackTrace(); | |
| 290 | +// } | |
| 291 | +// } | |
| 292 | +// }); | |
| 293 | +// } | |
| 294 | +// }, 1000); | |
| 295 | +// } | |
| 296 | +// }); | |
| 297 | +// selectDialog.setCanceledOnTouchOutside(false); | |
| 298 | +// selectDialog.setCancelable(false); | |
| 299 | +// selectDialog.show(); | |
| 300 | +// } | |
| 301 | +// } | |
| 302 | +// }); | |
| 303 | + | |
| 151 | 304 | } |
| 152 | 305 | |
| 306 | + private void queryWalkTrace(long startTime, long endTime) { | |
| 307 | + MyMapUtil.queryHistoryTrace(getContext(), mClient, CommonInfo.getUserId(getContext()), startTime, endTime, new MyMapUtil.CallBack() { | |
| 308 | + @Override | |
| 309 | + public void success(List<LatLng> resultPoints) { | |
| 310 | + queryResultPoints = resultPoints; | |
| 311 | + if (null != resultPoints) { | |
| 312 | + //绘制轨迹 | |
| 313 | + MyMapUtil.drawHistoryTrack(getContext(), baiduMap, resultPoints, SortType.asc, R.color.green_round, R.drawable.icon_start, R.drawable.icon_end); | |
| 314 | + }else { | |
| 315 | + SelectDialog selectDialog = new SelectDialog(getContext(), "轨迹获取失败,是否重试?", "取消", new SelectDialog.DialogInterface() { | |
| 316 | + @Override | |
| 317 | + public void onClick(SelectDialog dialog) { | |
| 318 | + dialog.dismiss(); | |
| 319 | + } | |
| 320 | + }, "重试", new SelectDialog.DialogInterface() { | |
| 321 | + @Override | |
| 322 | + public void onClick(SelectDialog dialog) { | |
| 323 | + dialog.dismiss(); | |
| 324 | + queryWalkTrace(startTime,endTime); | |
| 325 | + } | |
| 326 | + }); | |
| 327 | + selectDialog.setCancelable(false); | |
| 328 | + selectDialog.setCanceledOnTouchOutside(false); | |
| 329 | + if (!selectDialog.isShowing()) { | |
| 330 | + selectDialog.show(); | |
| 331 | + } | |
| 332 | + } | |
| 333 | + } | |
| 334 | + }); | |
| 335 | + } | |
| 336 | + | |
| 337 | + private void getBaiDuSnap() { | |
| 338 | + baiduMap.snapshot(new BaiduMap.SnapshotReadyCallback() { | |
| 339 | + @Override | |
| 340 | + public void onSnapshotReady(Bitmap bitmap) { | |
| 341 | + QMUITipDialogUtil.dismessDialog(); | |
| 342 | + if (null == bitmap) { | |
| 343 | + QMUITipDialogUtil.failedDialog(getContext(), "赛事图片截取失败,请重试", 2); | |
| 344 | + return; | |
| 345 | + } | |
| 346 | + //开始保存截屏 | |
| 347 | + try { | |
| 348 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); | |
| 349 | + File image = new File(getContext().getExternalCacheDir() + "/location_screenshot_" + sdf.format(new Date()) + ".jpeg"); | |
| 350 | + FileOutputStream fos = new FileOutputStream(image); | |
| 351 | + boolean b = bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos); | |
| 352 | + fos.flush(); | |
| 353 | + fos.close(); | |
| 354 | + //获取保存截图地址 | |
| 355 | + String roadMapPath = image.getAbsolutePath(); | |
| 356 | + //开始上传 | |
| 357 | + uploadRoadMapPic(roadMapPath); | |
| 358 | + } catch (Exception e) { | |
| 359 | + QMUITipDialogUtil.dismessDialog(); | |
| 360 | + QMUITipDialogUtil.failedDialog(getContext(), "赛事图片截取失败,请重试", 2); | |
| 361 | + e.printStackTrace(); | |
| 362 | + } | |
| 363 | + } | |
| 364 | + }); | |
| 365 | + } | |
| 366 | + | |
| 367 | + /** | |
| 368 | + * 上传赛事图片 | |
| 369 | + * | |
| 370 | + * @param roadMapPath | |
| 371 | + */ | |
| 372 | + private void uploadRoadMapPic(String roadMapPath) { | |
| 373 | + if (!TextUtils.isEmpty(roadMapPath)) { | |
| 374 | + QMUITipDialogUtil.loadingDialog(getContext(), "正在上传赛事图片,请稍后", false); | |
| 375 | + List<String> imagePaths = new ArrayList<>(); | |
| 376 | + imagePaths.add(roadMapPath); | |
| 377 | + UploadLogic.uploadAddressPicInfo(getContext(), imagePaths, new Event<String>() | |
| 378 | + .setFailureCallback(new FailureCallback() { | |
| 379 | + @Override | |
| 380 | + public void onFailure(int i, String s) { | |
| 381 | + QMUITipDialogUtil.dismessDialog(); | |
| 382 | + SelectDialog selectDialog = new SelectDialog(getContext(), "赛事图片上传失败,是否重试?", "取消", new SelectDialog.DialogInterface() { | |
| 383 | + @Override | |
| 384 | + public void onClick(SelectDialog dialog) { | |
| 385 | + dialog.dismiss(); | |
| 386 | + } | |
| 387 | + }, "重试", new SelectDialog.DialogInterface() { | |
| 388 | + @Override | |
| 389 | + public void onClick(SelectDialog dialog) { | |
| 390 | + dialog.dismiss(); | |
| 391 | + uploadRoadMapPic(roadMapPath); | |
| 392 | + } | |
| 393 | + }); | |
| 394 | + selectDialog.setCancelable(false); | |
| 395 | + selectDialog.setCanceledOnTouchOutside(false); | |
| 396 | + if (!selectDialog.isShowing()) { | |
| 397 | + selectDialog.show(); | |
| 398 | + } | |
| 399 | + | |
| 400 | + } | |
| 401 | + }) | |
| 402 | + .setSuccessCallback(new SuccessCallback<String>() { | |
| 403 | + @Override | |
| 404 | + public void onSuccess(String data) { | |
| 405 | + QMUITipDialogUtil.dismessDialog(); | |
| 406 | + //开始把数据传到服务端 | |
| 407 | + collUserStepEntity = CollStepUtil.getCollUserStepData(getContext(), CollCommonInfo.getUserId(getContext())); | |
| 408 | + if (null != fragment.getPresenter() || null == fragment.getActivity() || null == collUserStepEntity || TextUtils.isEmpty(data)) { | |
| 409 | + fragment.getPresenter().uploadTraceDateToServer(fragment.getActivity(), collUserStepEntity, data); | |
| 410 | + } | |
| 411 | + } | |
| 412 | + }) | |
| 413 | + ); | |
| 414 | + // | |
| 415 | + } | |
| 416 | + } | |
| 153 | 417 | |
| 418 | + // //判断地理围栏是否创建成功 | |
| 419 | +// if (null != collUserStepEntity) { | |
| 420 | +// if (TextUtils.isEmpty(collUserStepEntity.getFenceId())) { | |
| 421 | +// //开始创建地理围栏 | |
| 422 | +// QMUITipDialogUtil.loadingDialog(getContext(), "正在创建地理围栏", false); | |
| 423 | +// CreateFenceRequest createFenceRequest = null; | |
| 424 | +// int offset = Constant.FENCE_OFFSET;// 偏离距离 | |
| 425 | +// int denoise = Constant.FENCE_DENOISE; //围栏去噪精度 | |
| 426 | +// if (null != collUserStepEntity) { | |
| 427 | +// //赛事标题作为围栏名称 | |
| 428 | +// String fenceName = collUserStepEntity.getStreetTitle(); | |
| 429 | +// if (mClient != null && !TextUtils.isEmpty(fenceName) && null != collectLatLngs) { | |
| 430 | +// if (createFenceRequest == null) { | |
| 431 | +// createFenceRequest = CreateFenceRequest.buildServerPolylineRequest(Constant.TAG, Constant.SERVICE_ID, fenceName, "", collectLatLngs, offset, denoise, CoordType.gcj02); | |
| 432 | +// mClient.createFence(createFenceRequest, CollRunningFinishFragmentView.this); | |
| 433 | +// } | |
| 434 | +// } | |
| 435 | +// } | |
| 436 | +// } else { | |
| 437 | +// //已经存在地理围栏(直接将数据传给服务器) | |
| 438 | +// | |
| 439 | +// } | |
| 440 | +// } | |
| 154 | 441 | public void initMap() { |
| 155 | 442 | this.mMapView = fragment.binding.mapView; |
| 156 | 443 | if (baiduMap == null) { |
| ... | ... | @@ -231,4 +518,79 @@ public class CollRunningFinishFragmentView implements MvpView { |
| 231 | 518 | mMapView = null; |
| 232 | 519 | } |
| 233 | 520 | } |
| 521 | + | |
| 522 | + /** | |
| 523 | + * 常见围栏成功回调 | |
| 524 | + * | |
| 525 | + * @param createFenceResponse | |
| 526 | + */ | |
| 527 | + @Override | |
| 528 | + public void onCreateFenceCallback(CreateFenceResponse createFenceResponse) { | |
| 529 | + if (null == getContext() || null == createFenceResponse) { | |
| 530 | + return; | |
| 531 | + } | |
| 532 | + Log.e("地理围栏", "状态: " + createFenceResponse.getStatus() + ",返回信息:" + createFenceResponse.getMessage()); | |
| 533 | + //关闭提示框 | |
| 534 | + QMUITipDialogUtil.dismessDialog(); | |
| 535 | + //判断是否成功 | |
| 536 | + if (0 == createFenceResponse.getStatus()) { | |
| 537 | + //获取围栏id | |
| 538 | + long fenceId = createFenceResponse.getFenceId(); | |
| 539 | + Log.e("地理围栏", "创建围栏成功ID: " + fenceId + ",围栏名称" + createFenceResponse.getFenceName()); | |
| 540 | + //保存到数据库中 | |
| 541 | + CollStepUtil.setFenceId(getContext(), CollCommonInfo.getUserId(getContext()), fenceId + ""); | |
| 542 | + //提交到后台 | |
| 543 | + | |
| 544 | + } else { | |
| 545 | + //创建围栏失败 | |
| 546 | + //创建提示信息 | |
| 547 | + QMUITipDialogUtil.failedDialog(getContext(), createFenceResponse.getMessage(), 2); | |
| 548 | + } | |
| 549 | + | |
| 550 | + } | |
| 551 | + | |
| 552 | + @Override | |
| 553 | + public void onUpdateFenceCallback(UpdateFenceResponse updateFenceResponse) { | |
| 554 | + | |
| 555 | + } | |
| 556 | + | |
| 557 | + @Override | |
| 558 | + public void onDeleteFenceCallback(DeleteFenceResponse deleteFenceResponse) { | |
| 559 | + | |
| 560 | + } | |
| 561 | + | |
| 562 | + @Override | |
| 563 | + public void onFenceListCallback(FenceListResponse fenceListResponse) { | |
| 564 | + | |
| 565 | + } | |
| 566 | + | |
| 567 | + @Override | |
| 568 | + public void onMonitoredStatusCallback(MonitoredStatusResponse monitoredStatusResponse) { | |
| 569 | + | |
| 570 | + } | |
| 571 | + | |
| 572 | + @Override | |
| 573 | + public void onMonitoredStatusByLocationCallback(MonitoredStatusByLocationResponse monitoredStatusByLocationResponse) { | |
| 574 | + | |
| 575 | + } | |
| 576 | + | |
| 577 | + @Override | |
| 578 | + public void onHistoryAlarmCallback(HistoryAlarmResponse historyAlarmResponse) { | |
| 579 | + | |
| 580 | + } | |
| 581 | + | |
| 582 | + @Override | |
| 583 | + public void onAddMonitoredPersonCallback(AddMonitoredPersonResponse addMonitoredPersonResponse) { | |
| 584 | + | |
| 585 | + } | |
| 586 | + | |
| 587 | + @Override | |
| 588 | + public void onDeleteMonitoredPersonCallback(DeleteMonitoredPersonResponse deleteMonitoredPersonResponse) { | |
| 589 | + | |
| 590 | + } | |
| 591 | + | |
| 592 | + @Override | |
| 593 | + public void onListMonitoredPersonCallback(ListMonitoredPersonResponse listMonitoredPersonResponse) { | |
| 594 | + | |
| 595 | + } | |
| 234 | 596 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunningMapFragmentView.java
| ... | ... | @@ -535,7 +535,6 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener |
| 535 | 535 | if (location == null || mMapView == null || getContext() == null) { |
| 536 | 536 | return; |
| 537 | 537 | } |
| 538 | - Log.e(TAG, "onReceiveLocation: 定位地点" + location.getAddress().address); | |
| 539 | 538 | |
| 540 | 539 | mCurrentAccracy = location.getRadius(); |
| 541 | 540 | followMyLocation = new MyLocationData.Builder() |
| ... | ... | @@ -551,14 +550,12 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener |
| 551 | 550 | if (isFirstLoc) { |
| 552 | 551 | isFirstLoc = false; |
| 553 | 552 | if (location.getRadius() > Constant.LOCA_ACCURACY) { |
| 554 | - Toast.makeText(getContext(), "当前定位精度为:" + location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show(); | |
| 555 | 553 | } |
| 556 | 554 | baiduMap.setMyLocationData(followMyLocation); |
| 557 | 555 | builder.target(new LatLng(followMyLocation.latitude, followMyLocation.longitude)).zoom(DEFULT_ZOOM); |
| 558 | 556 | baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); |
| 559 | 557 | } else { |
| 560 | 558 | //不是第一次定位状态 |
| 561 | - Log.e(TAG, "onReceiveLocation: 当前精度" + location.getRadius()); | |
| 562 | 559 | //过滤定位精度 |
| 563 | 560 | if (location.getRadius() > Constant.LOCA_ACCURACY) { |
| 564 | 561 | return; | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/activity/CollPedometerMainActivity.java
| ... | ... | @@ -68,9 +68,7 @@ public class CollPedometerMainActivity extends QMUIFragmentActivity { |
| 68 | 68 | notificationManagerCompat = NotificationManagerCompat.from(this); |
| 69 | 69 | isOpen = notificationManagerCompat.areNotificationsEnabled(); |
| 70 | 70 | if (isOpen) { |
| 71 | - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |
| 72 | -// ContextCompat.startForegroundService(CollPedometerMainActivity.this, new Intent(CollPedometerMainActivity.this, CollStepService.class)); | |
| 73 | - } | |
| 71 | + getPermissionsWithTip(); | |
| 74 | 72 | } else { |
| 75 | 73 | goToSettingNo(); |
| 76 | 74 | } |
| ... | ... | @@ -118,7 +116,7 @@ public class CollPedometerMainActivity extends QMUIFragmentActivity { |
| 118 | 116 | protected void onResume() { |
| 119 | 117 | super.onResume(); |
| 120 | 118 | check(); |
| 121 | - getPermissionsWithTip(); | |
| 119 | + | |
| 122 | 120 | } |
| 123 | 121 | |
| 124 | 122 | private void addFragment(RunRaceDetailInfo runRaceDetailInfo) { | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/activity/StartCollectTraceActivity.java
| 1 | 1 | package com.cnlive.moudle.collectionTrace.ui.activity; |
| 2 | 2 | |
| 3 | +import android.Manifest; | |
| 3 | 4 | import android.app.Activity; |
| 4 | 5 | import android.content.Context; |
| 5 | 6 | import android.content.Intent; |
| 6 | 7 | import android.os.Bundle; |
| 8 | +import android.provider.Settings; | |
| 9 | +import android.support.annotation.NonNull; | |
| 10 | +import android.util.Log; | |
| 11 | +import android.widget.Toast; | |
| 7 | 12 | |
| 8 | 13 | import com.cnlive.libs.base.ui.QMUIFragment; |
| 9 | 14 | import com.cnlive.libs.base.ui.QMUIFragmentActivity; |
| ... | ... | @@ -11,10 +16,15 @@ import com.cnlive.libs.base.util.StatusBarUtil; |
| 11 | 16 | import com.cnlive.libs.base.util.StatusBarUtil2; |
| 12 | 17 | import com.cnlive.moudle.collectionTrace.ui.fragment.StartTraceFragment; |
| 13 | 18 | import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo; |
| 19 | +import com.cnlive.moudle.pedometer.utils.MyMapUtil; | |
| 20 | +import com.cnlive.moudle.pedometer.utils.lib_permisshelper.PermissionsListener; | |
| 21 | +import com.cnlive.moudle.pedometer.utils.lib_permisshelper.PermissionsUtils; | |
| 14 | 22 | import com.example.moudle_pedometer.R; |
| 15 | 23 | |
| 16 | 24 | public class StartCollectTraceActivity extends QMUIFragmentActivity { |
| 17 | 25 | |
| 26 | + private PermissionsUtils mPermissionsUtils;//权限申请 | |
| 27 | + private RunRaceDetailInfo runRaceDetailInfo; | |
| 18 | 28 | |
| 19 | 29 | public static void newInstance(Context context, String eventId) { |
| 20 | 30 | Intent intent = new Intent(context, StartCollectTraceActivity.class); |
| ... | ... | @@ -30,13 +40,18 @@ public class StartCollectTraceActivity extends QMUIFragmentActivity { |
| 30 | 40 | @Override |
| 31 | 41 | protected void onCreate(Bundle savedInstanceState) { |
| 32 | 42 | super.onCreate(savedInstanceState); |
| 43 | + mPermissionsUtils = new PermissionsUtils(); | |
| 33 | 44 | StatusBarUtil.setStatusBarWrite(this); |
| 34 | 45 | StatusBarUtil2.setColor(this, getResources().getColor(R.color.white), 0); |
| 35 | - RunRaceDetailInfo runRaceDetailInfo = (RunRaceDetailInfo) getIntent().getExtras().getSerializable("runRaceDetailInfo"); | |
| 36 | - if (null != runRaceDetailInfo) { | |
| 37 | - addFragment(StartTraceFragment.newInstance(runRaceDetailInfo)); | |
| 38 | - } | |
| 46 | + runRaceDetailInfo = (RunRaceDetailInfo) getIntent().getExtras().getSerializable("runRaceDetailInfo"); | |
| 39 | 47 | |
| 48 | + | |
| 49 | + } | |
| 50 | + | |
| 51 | + @Override | |
| 52 | + protected void onResume() { | |
| 53 | + super.onResume(); | |
| 54 | + getPermissionsWithTip(); | |
| 40 | 55 | } |
| 41 | 56 | |
| 42 | 57 | private void addFragment(QMUIFragment fragment) { |
| ... | ... | @@ -51,4 +66,69 @@ public class StartCollectTraceActivity extends QMUIFragmentActivity { |
| 51 | 66 | intent.putExtra("runRaceDetailInfo", runRaceDetailInfo); |
| 52 | 67 | activity.startActivity(intent); |
| 53 | 68 | } |
| 69 | + | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * 一次申请一组权限(使用拒绝弹框)点击事件 | |
| 73 | + */ | |
| 74 | + public void getPermissionsWithTip() { | |
| 75 | + mPermissionsUtils | |
| 76 | + .setPermissionsListener(new PermissionsListener() { | |
| 77 | + @Override | |
| 78 | + public void onDenied(String[] deniedPermissions) { | |
| 79 | + getPermissionsWithTip(); | |
| 80 | + } | |
| 81 | + | |
| 82 | + @Override | |
| 83 | + public void onGranted() { | |
| 84 | + | |
| 85 | + //判断GPS是否开启 | |
| 86 | + if (!MyMapUtil.isOPenGps(getApplicationContext())) { | |
| 87 | + //开启GPS | |
| 88 | + Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); | |
| 89 | + startActivityForResult(intent, 10); | |
| 90 | + Toast.makeText(getApplicationContext(), getString(R.string.open_gps_tip), Toast.LENGTH_LONG).show(); | |
| 91 | + } else { | |
| 92 | + if (getCurrentFragment() == null) { | |
| 93 | + if (null != runRaceDetailInfo) { | |
| 94 | + addFragment(StartTraceFragment.newInstance(runRaceDetailInfo)); | |
| 95 | + } | |
| 96 | + } | |
| 97 | + } | |
| 98 | + } | |
| 99 | + }) | |
| 100 | + .withActivity(StartCollectTraceActivity.this) | |
| 101 | + .getPermissions(StartCollectTraceActivity.this | |
| 102 | + , 100 | |
| 103 | + , Manifest.permission.INTERNET | |
| 104 | + , Manifest.permission.READ_EXTERNAL_STORAGE | |
| 105 | + , Manifest.permission.WRITE_EXTERNAL_STORAGE | |
| 106 | + , Manifest.permission.ACCESS_FINE_LOCATION | |
| 107 | + , Manifest.permission.ACCESS_COARSE_LOCATION | |
| 108 | + ); | |
| 109 | +// .getPermissionsWithTips(MainActivity.this | |
| 110 | +// ,100 | |
| 111 | +// , new String[]{"人家要录音","我们需要读取你的信息,磨磨唧唧的","我要上网","我要读内存卡","我要看日历","我要定位"} | |
| 112 | +// , Manifest.permission.RECORD_AUDIO | |
| 113 | +// , Manifest.permission.READ_SMS | |
| 114 | +// , Manifest.permission.INTERNET | |
| 115 | +// , Manifest.permission.READ_EXTERNAL_STORAGE | |
| 116 | +// , Manifest.permission.READ_CALENDAR | |
| 117 | +// , Manifest.permission.ACCESS_FINE_LOCATION); | |
| 118 | + } | |
| 119 | + | |
| 120 | + | |
| 121 | + /** | |
| 122 | + * 权限回调 | |
| 123 | + * | |
| 124 | + * @param requestCode | |
| 125 | + * @param permissions | |
| 126 | + * @param grantResults | |
| 127 | + */ | |
| 128 | + @Override | |
| 129 | + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, | |
| 130 | + @NonNull int[] grantResults) { | |
| 131 | + super.onRequestPermissionsResult(requestCode, permissions, grantResults); | |
| 132 | + mPermissionsUtils.dealResult(requestCode, permissions, grantResults); | |
| 133 | + } | |
| 54 | 134 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/adapter/CollFinishDetaiAdapter.java
| ... | ... | @@ -44,12 +44,15 @@ public class CollFinishDetaiAdapter extends RecyclerView.Adapter<CollFinishDetai |
| 44 | 44 | //起点 |
| 45 | 45 | myViewHolder.view_circle.setBackground(context.getResources().getDrawable(R.drawable.shape_circle_green)); |
| 46 | 46 | myViewHolder.tv_point_type_tip.setText(context.getResources().getString(R.string.layout_street_start_point)); |
| 47 | + myViewHolder.view_line.setVisibility(View.VISIBLE); | |
| 48 | + | |
| 47 | 49 | } else if (list.size() - 1 == i) { |
| 48 | 50 | //终点 |
| 49 | 51 | myViewHolder.view_circle.setBackground(context.getResources().getDrawable(R.drawable.shape_circle_red)); |
| 50 | 52 | myViewHolder.tv_point_type_tip.setText(context.getResources().getString(R.string.layout_street_end_point)); |
| 51 | 53 | myViewHolder.view_line.setVisibility(View.GONE); |
| 52 | 54 | } else { |
| 55 | + myViewHolder.view_line.setVisibility(View.VISIBLE); | |
| 53 | 56 | //打点 |
| 54 | 57 | myViewHolder.view_circle.setBackground(context.getResources().getDrawable(R.drawable.shape_circle_gray)); |
| 55 | 58 | // myViewHolder.tv_point_type_tip.setText(context.getResources().getString(R.string.layout_coll_take_point_text)); | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/fragment/CollRunRaceDetailFragment.java
| ... | ... | @@ -9,8 +9,10 @@ import android.view.View; |
| 9 | 9 | import android.widget.Button; |
| 10 | 10 | |
| 11 | 11 | import com.cnlive.libs.base.ui.QMUIFragment; |
| 12 | +import com.cnlive.moudle.collectionTrace.commonInfo.CollCommonInfo; | |
| 12 | 13 | import com.cnlive.moudle.collectionTrace.frame.presenter.CollRunRaceDetailFragmentPresenter; |
| 13 | 14 | import com.cnlive.moudle.collectionTrace.frame.view.CollRunRaceDetailFragmentView; |
| 15 | +import com.cnlive.moudle.collectionTrace.ui.activity.RaceNameListActivity; | |
| 14 | 16 | import com.cnlive.moudle.collectionTrace.ui.activity.StartCollectTraceActivity; |
| 15 | 17 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 16 | 18 | import com.cnlive.moudle.pedometer.model.Constant; |
| ... | ... | @@ -60,8 +62,7 @@ public class CollRunRaceDetailFragment extends QMUIFragment<CollRunRaceDetailFra |
| 60 | 62 | @Override |
| 61 | 63 | public void onClick(View view) { |
| 62 | 64 | //todo 自己测试用 |
| 63 | - getActivity().finish(); | |
| 64 | - RunLineActivity.newInstance(getActivity(),null,null,null,null); | |
| 65 | + RaceNameListActivity.newInstance(getActivity(), CollCommonInfo.getStreetId(getActivity())); | |
| 65 | 66 | } |
| 66 | 67 | }); |
| 67 | 68 | } |
| ... | ... | @@ -177,5 +178,4 @@ public class CollRunRaceDetailFragment extends QMUIFragment<CollRunRaceDetailFra |
| 177 | 178 | // } |
| 178 | 179 | |
| 179 | 180 | |
| 180 | - | |
| 181 | 181 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/utils/CollStepUtil.java
| ... | ... | @@ -34,6 +34,26 @@ public class CollStepUtil { |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | + * 设置围栏id | |
| 38 | + * | |
| 39 | + * @param context | |
| 40 | + * @param uid | |
| 41 | + * @param fenceID | |
| 42 | + */ | |
| 43 | + public static void setFenceId(Context context, String uid, String fenceID) { | |
| 44 | + //先获取有没有 | |
| 45 | + if (getCollUserStepData(context, uid) != null) { | |
| 46 | + CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 47 | + if (null != entity) { | |
| 48 | + //设置围栏id | |
| 49 | + entity.setFenceId(fenceID); | |
| 50 | + //更新数据 | |
| 51 | + updateCollStepData(context, entity); | |
| 52 | + } | |
| 53 | + } | |
| 54 | + } | |
| 55 | + | |
| 56 | + /** | |
| 37 | 57 | * 设置用户整个赛事用时 |
| 38 | 58 | * |
| 39 | 59 | * @param context | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/model/Constant.java
| ... | ... | @@ -30,5 +30,7 @@ public class Constant { |
| 30 | 30 | public static final int LOCA_ACCURACY = 20;//定位过滤精度 |
| 31 | 31 | public static final int LOCA_END_POINT_ACCURACY = 20;//终点位置比较精度 |
| 32 | 32 | public static final int LOCA_START_POINT_ACCURACY = 200;//起点位置比较精度 |
| 33 | + public static final int FENCE_OFFSET=70;//围栏偏离距离 | |
| 34 | + public static final int FENCE_DENOISE=70;//围栏去噪精度 | |
| 33 | 35 | |
| 34 | 36 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/net/ApiServiceRunLin.java
| ... | ... | @@ -66,6 +66,15 @@ public interface ApiServiceRunLin { |
| 66 | 66 | @POST("Daren/event/getRouteRecordList.action") |
| 67 | 67 | Observable<Result<BaseInfo<SelfRecordInfo>>> getSelfRecordInfo(@QueryMap() Map<String, String> maps); |
| 68 | 68 | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * 保存个人约跑路线记录 | |
| 72 | + */ | |
| 73 | + @POST("Daren/event/routeRecord.action") | |
| 74 | + Observable<Result<BaseInfo>> saveRouteData(@QueryMap() Map<String, String> maps); | |
| 75 | + | |
| 76 | + | |
| 77 | +/***********************************************运营人员接口*****************************************************************/ | |
| 69 | 78 | /** |
| 70 | 79 | * 踩点轨迹列表 |
| 71 | 80 | */ |
| ... | ... | @@ -84,15 +93,11 @@ public interface ApiServiceRunLin { |
| 84 | 93 | @POST("Daren/event/bindingShoeLine.action") |
| 85 | 94 | Observable<Result<BaseInfo>> bindingShoeLineInfo(@QueryMap() Map<String, String> maps); |
| 86 | 95 | |
| 87 | - | |
| 88 | 96 | /** |
| 89 | - * 保存个人约跑路线记录 | |
| 97 | + * http://apiwjjtest.cnlive.com/Daren/event/saveShoeLine.action | |
| 98 | + * 运营路线踩点 | |
| 90 | 99 | */ |
| 91 | - @POST("Daren/event/routeRecord.action") | |
| 92 | - Observable<Result<BaseInfo>> saveRouteData(@QueryMap() Map<String, String> maps); | |
| 93 | - | |
| 94 | - | |
| 95 | - | |
| 96 | - | |
| 100 | + @POST("Daren/event/saveShoeLine.action") | |
| 101 | + Observable<Result<BaseInfo>> collSaveShoeLine(@QueryMap() Map<String, String> maps); | |
| 97 | 102 | } |
| 98 | 103 | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/CollUserStepEntityDao.java
| ... | ... | @@ -40,7 +40,7 @@ public class CollUserStepEntityDao extends AbstractDao<CollUserStepEntity, Strin |
| 40 | 40 | public final static Property QueryTraceEndTime = new Property(13, long.class, "queryTraceEndTime", false, "QUERY_TRACE_END_TIME"); |
| 41 | 41 | public final static Property QueryEntityName = new Property(14, String.class, "queryEntityName", false, "QUERY_ENTITY_NAME"); |
| 42 | 42 | public final static Property ContinueTime = new Property(15, long.class, "continueTime", false, "CONTINUE_TIME"); |
| 43 | - public final static Property FenceId = new Property(16, long.class, "fenceId", false, "FENCE_ID"); | |
| 43 | + public final static Property FenceId = new Property(16, String.class, "fenceId", false, "FENCE_ID"); | |
| 44 | 44 | public final static Property ImportPoint = new Property(17, String.class, "importPoint", false, "IMPORT_POINT"); |
| 45 | 45 | public final static Property StreetTitle = new Property(18, String.class, "streetTitle", false, "STREET_TITLE"); |
| 46 | 46 | public final static Property EndLatLng = new Property(19, String.class, "endLatLng", false, "END_LAT_LNG"); |
| ... | ... | @@ -79,7 +79,7 @@ public class CollUserStepEntityDao extends AbstractDao<CollUserStepEntity, Strin |
| 79 | 79 | "\"QUERY_TRACE_END_TIME\" INTEGER NOT NULL ," + // 13: queryTraceEndTime |
| 80 | 80 | "\"QUERY_ENTITY_NAME\" TEXT," + // 14: queryEntityName |
| 81 | 81 | "\"CONTINUE_TIME\" INTEGER NOT NULL ," + // 15: continueTime |
| 82 | - "\"FENCE_ID\" INTEGER NOT NULL ," + // 16: fenceId | |
| 82 | + "\"FENCE_ID\" TEXT," + // 16: fenceId | |
| 83 | 83 | "\"IMPORT_POINT\" TEXT," + // 17: importPoint |
| 84 | 84 | "\"STREET_TITLE\" TEXT," + // 18: streetTitle |
| 85 | 85 | "\"END_LAT_LNG\" TEXT," + // 19: endLatLng |
| ... | ... | @@ -138,7 +138,11 @@ public class CollUserStepEntityDao extends AbstractDao<CollUserStepEntity, Strin |
| 138 | 138 | stmt.bindString(15, queryEntityName); |
| 139 | 139 | } |
| 140 | 140 | stmt.bindLong(16, entity.getContinueTime()); |
| 141 | - stmt.bindLong(17, entity.getFenceId()); | |
| 141 | + | |
| 142 | + String fenceId = entity.getFenceId(); | |
| 143 | + if (fenceId != null) { | |
| 144 | + stmt.bindString(17, fenceId); | |
| 145 | + } | |
| 142 | 146 | |
| 143 | 147 | String importPoint = entity.getImportPoint(); |
| 144 | 148 | if (importPoint != null) { |
| ... | ... | @@ -215,7 +219,11 @@ public class CollUserStepEntityDao extends AbstractDao<CollUserStepEntity, Strin |
| 215 | 219 | stmt.bindString(15, queryEntityName); |
| 216 | 220 | } |
| 217 | 221 | stmt.bindLong(16, entity.getContinueTime()); |
| 218 | - stmt.bindLong(17, entity.getFenceId()); | |
| 222 | + | |
| 223 | + String fenceId = entity.getFenceId(); | |
| 224 | + if (fenceId != null) { | |
| 225 | + stmt.bindString(17, fenceId); | |
| 226 | + } | |
| 219 | 227 | |
| 220 | 228 | String importPoint = entity.getImportPoint(); |
| 221 | 229 | if (importPoint != null) { |
| ... | ... | @@ -273,7 +281,7 @@ public class CollUserStepEntityDao extends AbstractDao<CollUserStepEntity, Strin |
| 273 | 281 | cursor.getLong(offset + 13), // queryTraceEndTime |
| 274 | 282 | cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // queryEntityName |
| 275 | 283 | cursor.getLong(offset + 15), // continueTime |
| 276 | - cursor.getLong(offset + 16), // fenceId | |
| 284 | + cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // fenceId | |
| 277 | 285 | cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // importPoint |
| 278 | 286 | cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // streetTitle |
| 279 | 287 | cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // endLatLng |
| ... | ... | @@ -303,7 +311,7 @@ public class CollUserStepEntityDao extends AbstractDao<CollUserStepEntity, Strin |
| 303 | 311 | entity.setQueryTraceEndTime(cursor.getLong(offset + 13)); |
| 304 | 312 | entity.setQueryEntityName(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14)); |
| 305 | 313 | entity.setContinueTime(cursor.getLong(offset + 15)); |
| 306 | - entity.setFenceId(cursor.getLong(offset + 16)); | |
| 314 | + entity.setFenceId(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16)); | |
| 307 | 315 | entity.setImportPoint(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17)); |
| 308 | 316 | entity.setStreetTitle(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); |
| 309 | 317 | entity.setEndLatLng(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/entity/CollUserStepEntity.java
| ... | ... | @@ -23,7 +23,7 @@ public class CollUserStepEntity { |
| 23 | 23 | private long queryTraceEndTime;//从服务器获取的结束时间呢 |
| 24 | 24 | private String queryEntityName;//从服务器获取的运营人员的实体名称 |
| 25 | 25 | private long continueTime;//继续运动时间 |
| 26 | - private long fenceId;//围栏id | |
| 26 | + private String fenceId;//围栏id | |
| 27 | 27 | private String importPoint;//关键点 |
| 28 | 28 | private String streetTitle;//赛事标题 |
| 29 | 29 | private String endLatLng;//终点坐标 |
| ... | ... | @@ -32,11 +32,11 @@ public class CollUserStepEntity { |
| 32 | 32 | private String collEndPointData;//运营结束打点名称和经纬度 |
| 33 | 33 | private String employTime;//用时时间戳 |
| 34 | 34 | |
| 35 | - @Generated(hash = 148375276) | |
| 36 | - public CollUserStepEntity(String userId, String date, String stepCount, long recordTime, double caloriesCount, String serverTraceData, | |
| 37 | - long startTimeStamp, long finishTimeStamp, String streetId, int pauseCount, long userPauseTimeStamp, long chronometerBase, | |
| 38 | - long queryTraceStartTime, long queryTraceEndTime, String queryEntityName, long continueTime, long fenceId, String importPoint, | |
| 39 | - String streetTitle, String endLatLng, boolean isArriveEndPoint, String collStartPointData, String collEndPointData, String employTime) { | |
| 35 | + @Generated(hash = 297618082) | |
| 36 | + public CollUserStepEntity(String userId, String date, String stepCount, long recordTime, double caloriesCount, String serverTraceData, long startTimeStamp, | |
| 37 | + long finishTimeStamp, String streetId, int pauseCount, long userPauseTimeStamp, long chronometerBase, long queryTraceStartTime, long queryTraceEndTime, | |
| 38 | + String queryEntityName, long continueTime, String fenceId, String importPoint, String streetTitle, String endLatLng, boolean isArriveEndPoint, | |
| 39 | + String collStartPointData, String collEndPointData, String employTime) { | |
| 40 | 40 | this.userId = userId; |
| 41 | 41 | this.date = date; |
| 42 | 42 | this.stepCount = stepCount; |
| ... | ... | @@ -196,13 +196,6 @@ public class CollUserStepEntity { |
| 196 | 196 | this.continueTime = continueTime; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - public long getFenceId() { | |
| 200 | - return this.fenceId; | |
| 201 | - } | |
| 202 | - | |
| 203 | - public void setFenceId(long fenceId) { | |
| 204 | - this.fenceId = fenceId; | |
| 205 | - } | |
| 206 | 199 | |
| 207 | 200 | public String getImportPoint() { |
| 208 | 201 | return this.importPoint; |
| ... | ... | @@ -261,5 +254,13 @@ public class CollUserStepEntity { |
| 261 | 254 | this.employTime = employTime; |
| 262 | 255 | } |
| 263 | 256 | |
| 257 | + public String getFenceId() { | |
| 258 | + return this.fenceId; | |
| 259 | + } | |
| 260 | + | |
| 261 | + public void setFenceId(String fenceId) { | |
| 262 | + this.fenceId = fenceId; | |
| 263 | + } | |
| 264 | + | |
| 264 | 265 | |
| 265 | 266 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/MyMapUtil.java
| ... | ... | @@ -71,7 +71,10 @@ public class MyMapUtil { |
| 71 | 71 | Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), startIconRes), 17, 30); |
| 72 | 72 | OverlayOptions startOptions = null; |
| 73 | 73 | if (pointBitmap != null) { |
| 74 | - startOptions = new MarkerOptions().position(startLatLng).icon(BitmapDescriptorFactory.fromBitmap(pointBitmap)); | |
| 74 | + startOptions = new MarkerOptions() | |
| 75 | + .position(startLatLng) | |
| 76 | + .icon(BitmapDescriptorFactory.fromBitmap(pointBitmap)) | |
| 77 | + .animateType(MarkerOptions.MarkerAnimateType.grow); | |
| 75 | 78 | } |
| 76 | 79 | |
| 77 | 80 | if (startOptions != null) { |
| ... | ... | @@ -104,7 +107,10 @@ public class MyMapUtil { |
| 104 | 107 | Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), startIconRes), 24, 30); |
| 105 | 108 | OverlayOptions startOptions = null; |
| 106 | 109 | if (pointBitmap != null) { |
| 107 | - startOptions = new MarkerOptions().position(startLatLng).icon(BitmapDescriptorFactory.fromBitmap(pointBitmap)); | |
| 110 | + startOptions = new MarkerOptions() | |
| 111 | + .position(startLatLng) | |
| 112 | + .icon(BitmapDescriptorFactory.fromBitmap(pointBitmap)) | |
| 113 | + .animateType(MarkerOptions.MarkerAnimateType.grow); | |
| 108 | 114 | } |
| 109 | 115 | |
| 110 | 116 | // 添加圆形范围 | ... | ... |
moudle_pedometer/src/main/res/layout/fragment_coll_finish_run_map.xml
| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | sothree:umanoDragView="@+id/dragView" |
| 15 | 15 | sothree:umanoFadeColor="@color/black_20" |
| 16 | 16 | sothree:umanoOverlay="true" |
| 17 | - sothree:umanoPanelHeight="310dp" | |
| 17 | + sothree:umanoPanelHeight="250dp" | |
| 18 | 18 | sothree:umanoParallaxOffset="0dp" |
| 19 | 19 | sothree:umanoScrollableView="@+id/rv_list" |
| 20 | 20 | sothree:umanoShadowHeight="0dp"> |
| ... | ... | @@ -105,6 +105,9 @@ |
| 105 | 105 | android:layout_width="match_parent" |
| 106 | 106 | android:layout_height="40sp" |
| 107 | 107 | android:layout_gravity="bottom" |
| 108 | + android:focusable="true" | |
| 109 | + android:clickable="true" | |
| 110 | + android:focusableInTouchMode="true" | |
| 108 | 111 | android:background="@color/green_round" |
| 109 | 112 | android:gravity="center" |
| 110 | 113 | android:tag="0"> |
| ... | ... | @@ -117,6 +120,7 @@ |
| 117 | 120 | android:layout_centerInParent="true" |
| 118 | 121 | android:layout_marginLeft="5dp" |
| 119 | 122 | android:clickable="false" |
| 123 | + android:focusable="false" | |
| 120 | 124 | android:focusableInTouchMode="false" |
| 121 | 125 | android:tag="0" |
| 122 | 126 | android:text="确定轨迹" | ... | ... |