Commit 4f7740e139b55ce1c86b03281efa303363328ebb
1 parent
a7cac7d9
Merge branch 'master' of http://bj.gitlab.cnlive.com/cnlive-team/ModulePedometer
# Conflicts: # moudle_pedometer/src/main/res/layout/line_up__item_view.xml
Showing
41 changed files
with
852 additions
and
532 deletions
.idea/gradle.xml
| ... | ... | @@ -3,9 +3,6 @@ |
| 3 | 3 | <component name="GradleSettings"> |
| 4 | 4 | <option name="linkedExternalProjectsSettings"> |
| 5 | 5 | <GradleProjectSettings> |
| 6 | - <compositeConfiguration> | |
| 7 | - <compositeBuild compositeDefinitionSource="SCRIPT" /> | |
| 8 | - </compositeConfiguration> | |
| 9 | 6 | <option name="distributionType" value="DEFAULT_WRAPPED" /> |
| 10 | 7 | <option name="externalProjectPath" value="$PROJECT_DIR$" /> |
| 11 | 8 | <option name="modules"> | ... | ... |
app/src/main/java/com/example/modulepedometer/MainActivity.java
| ... | ... | @@ -10,6 +10,7 @@ import com.cnlive.moudle.collectionTrace.ui.activity.RaceListActivity; |
| 10 | 10 | import com.cnlive.moudle.collectionTrace.ui.activity.RaceNameListActivity; |
| 11 | 11 | import com.cnlive.moudle.pedometer.ui.activity.MyRecordActivity; |
| 12 | 12 | import com.cnlive.moudle.pedometer.ui.activity.RunLineActivity; |
| 13 | +import com.cnlive.moudle.pedometer.ui.activity.SelfRecordActivity; | |
| 13 | 14 | |
| 14 | 15 | |
| 15 | 16 | public class MainActivity extends AppCompatActivity { |
| ... | ... | @@ -33,6 +34,13 @@ public class MainActivity extends AppCompatActivity { |
| 33 | 34 | startActivity(intent); |
| 34 | 35 | } |
| 35 | 36 | }); |
| 37 | + findViewById(R.id.tool2).setOnClickListener(new View.OnClickListener() { | |
| 38 | + @Override | |
| 39 | + public void onClick(View v) { | |
| 40 | + SelfRecordActivity.newInstance(MainActivity.this, "10513196",null,null,null); | |
| 41 | +// startActivity(intent); | |
| 42 | + } | |
| 43 | + }); | |
| 36 | 44 | |
| 37 | 45 | // RunLineActivity.newInstance(this,null,null,null); |
| 38 | 46 | // Intent intent = new Intent(this, CollRunRaceDetailActivity.class); | ... | ... |
app/src/main/res/layout/activity_main.xml
| ... | ... | @@ -12,15 +12,19 @@ |
| 12 | 12 | android:layout_width="match_parent" |
| 13 | 13 | android:layout_height="wrap_content" |
| 14 | 14 | android:layout_margin="10dp" |
| 15 | - android:text="体育活动" | |
| 16 | - /> | |
| 15 | + android:text="体育活动" /> | |
| 17 | 16 | |
| 18 | 17 | <Button |
| 19 | 18 | android:id="@+id/tooll" |
| 20 | 19 | android:layout_width="match_parent" |
| 21 | 20 | android:layout_height="wrap_content" |
| 22 | 21 | android:layout_margin="10dp" |
| 23 | - android:text="路径工具" | |
| 24 | - /> | |
| 22 | + android:text="路径工具" /> | |
| 25 | 23 | |
| 24 | + <Button | |
| 25 | + android:id="@+id/tool2" | |
| 26 | + android:layout_width="match_parent" | |
| 27 | + android:layout_height="wrap_content" | |
| 28 | + android:layout_margin="10dp" | |
| 29 | + android:text="我的记录" /> | |
| 26 | 30 | </LinearLayout> |
| 27 | 31 | \ No newline at end of file | ... | ... |
moudle_pedometer/src/main/AndroidManifest.xml
| ... | ... | @@ -131,7 +131,13 @@ |
| 131 | 131 | android:process=":step" /> |
| 132 | 132 | <activity |
| 133 | 133 | android:name="com.cnlive.moudle.pedometer.ui.activity.RunningFinishActivity" |
| 134 | - android:process=":step" /> <!-- 路径工具 --> | |
| 134 | + android:launchMode="singleTask" | |
| 135 | + android:process=":step" /> | |
| 136 | + <activity | |
| 137 | + android:name="com.cnlive.moudle.pedometer.ui.activity.UploadFailDetailActivity" | |
| 138 | + android:launchMode="singleTask" | |
| 139 | + android:process=":step" /> | |
| 140 | + <!--************************************************路径工具**********************************************--> | |
| 135 | 141 | <service |
| 136 | 142 | android:name="com.cnlive.moudle.collectionTrace.service.CollKeepLiveService" |
| 137 | 143 | android:enabled="true" | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/commonInfo/CommonInfo.java
| ... | ... | @@ -25,23 +25,6 @@ public class CommonInfo { |
| 25 | 25 | // return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getLong("stepStartTime", 0); |
| 26 | 26 | // } |
| 27 | 27 | |
| 28 | - /** | |
| 29 | - * 设置计步完成时间 | |
| 30 | - * | |
| 31 | - * @param context | |
| 32 | - */ | |
| 33 | - public static void setStepEndTime(Context context, long currentTime) { | |
| 34 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putLong("stepEndTime", currentTime); | |
| 35 | - } | |
| 36 | - | |
| 37 | - /** | |
| 38 | - * 获取计步完成时间 | |
| 39 | - * | |
| 40 | - * @param context | |
| 41 | - */ | |
| 42 | - public static long getStepEndTime(Context context) { | |
| 43 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getLong("stepEndTime", 0); | |
| 44 | - } | |
| 45 | 28 | |
| 46 | 29 | /** |
| 47 | 30 | * 是否允许写入步数 |
| ... | ... | @@ -295,88 +278,10 @@ public class CommonInfo { |
| 295 | 278 | return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("runIsPauseState", false); |
| 296 | 279 | } |
| 297 | 280 | |
| 298 | - /** | |
| 299 | - * 设置轨迹查询开始时间 | |
| 300 | - * | |
| 301 | - * @param context | |
| 302 | - * @param startTime | |
| 303 | - */ | |
| 304 | - public static void setQueryTraceStartTime(Context context, long startTime) { | |
| 305 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putLong("runQueryTraceStartTime", startTime); | |
| 306 | - | |
| 307 | - } | |
| 308 | - | |
| 309 | - /** | |
| 310 | - * 互殴轨迹查询开始时间 | |
| 311 | - * | |
| 312 | - * @param context | |
| 313 | - */ | |
| 314 | - public static long getQueryTraceStartTime(Context context) { | |
| 315 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getLong("runQueryTraceStartTime", 0); | |
| 316 | 281 | |
| 317 | - } | |
| 318 | 282 | |
| 319 | - /** | |
| 320 | - * 设置轨迹查询结束时间 | |
| 321 | - * | |
| 322 | - * @param context | |
| 323 | - * @param startTime | |
| 324 | - */ | |
| 325 | - public static void setQueryTraceEndTime(Context context, long startTime) { | |
| 326 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putLong("runQueryTraceEndTime", startTime); | |
| 327 | 283 | |
| 328 | - } | |
| 329 | 284 | |
| 330 | - /** | |
| 331 | - * 互殴轨迹查询开始时间 | |
| 332 | - * | |
| 333 | - * @param context | |
| 334 | - */ | |
| 335 | - public static long getQueryTraceEndTime(Context context) { | |
| 336 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getLong("runQueryTraceEndTime", 0); | |
| 337 | - | |
| 338 | - } | |
| 339 | - | |
| 340 | - /** | |
| 341 | - * 设置轨迹查询实体名称 | |
| 342 | - * | |
| 343 | - * @param context | |
| 344 | - */ | |
| 345 | - public static void setQueryEntityName(Context context, String entityName) { | |
| 346 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString("runQueryEntityName", entityName); | |
| 347 | - | |
| 348 | - } | |
| 349 | - | |
| 350 | - /** | |
| 351 | - * 互殴轨迹查询\的实体名称 | |
| 352 | - * | |
| 353 | - * @param context | |
| 354 | - */ | |
| 355 | - public static String getQueryQueryEntityName(Context context) { | |
| 356 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString("runQueryEntityName", ""); | |
| 357 | - | |
| 358 | - } | |
| 359 | - | |
| 360 | - | |
| 361 | - /** | |
| 362 | - * 设置赛事标题 | |
| 363 | - * | |
| 364 | - * @param context | |
| 365 | - */ | |
| 366 | - public static void setStreetTitle(Context context, String streetTitle) { | |
| 367 | - MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putString("runStreetTitle", streetTitle); | |
| 368 | - | |
| 369 | - } | |
| 370 | - | |
| 371 | - /** | |
| 372 | - * 互殴轨迹查询\的实体名称 | |
| 373 | - * | |
| 374 | - * @param context | |
| 375 | - */ | |
| 376 | - public static String getStreetTitle(Context context) { | |
| 377 | - return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getString("runStreetTitle", ""); | |
| 378 | - | |
| 379 | - } | |
| 380 | 285 | |
| 381 | 286 | |
| 382 | 287 | /*重置 |
| ... | ... | @@ -395,9 +300,6 @@ public class CommonInfo { |
| 395 | 300 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("IsFirstShowTimeTip"); |
| 396 | 301 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("runIsPauseState"); |
| 397 | 302 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("runStreetTitle"); |
| 398 | -// MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("runQueryTraceStartTime"); | |
| 399 | -// MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("runQueryTraceEndTime"); | |
| 400 | -// MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("runQueryEntityName"); | |
| 401 | 303 | |
| 402 | 304 | |
| 403 | 305 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/presenter/RunningFinishFragmetPresenter.java
| ... | ... | @@ -22,6 +22,7 @@ import com.cnlive.libs.base.logic.callback.SuccessCallback; |
| 22 | 22 | import com.cnlive.libs.base.util.ToastUtil; |
| 23 | 23 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 24 | 24 | import com.cnlive.moudle.pedometer.frame.view.RunningFinishFragmentView; |
| 25 | +import com.cnlive.moudle.pedometer.model.Constant; | |
| 25 | 26 | import com.cnlive.moudle.pedometer.model.RunningFinishBean; |
| 26 | 27 | import com.cnlive.moudle.pedometer.net.ApiServiceRunLin; |
| 27 | 28 | import com.cnlive.moudle.pedometer.net.SubscriptionRequest; |
| ... | ... | @@ -59,8 +60,11 @@ import static com.cnlive.libs.base.logic.Config.STATE_LOAD; |
| 59 | 60 | public class RunningFinishFragmetPresenter extends MvpBasePresenter<RunningFinishFragmentView> { |
| 60 | 61 | private LBSTraceClient mClient = null; |
| 61 | 62 | private List<LatLng> importPoints; |
| 63 | + private SelectDialog uploadFailDialog; | |
| 64 | + private SelectDialog failTraceDialog; | |
| 62 | 65 | |
| 63 | 66 | public void saveRouteData(Activity context, UserStepEntity userStepEntity, RunningFinishBean runningFinishBean) { |
| 67 | + QMUITipDialogUtil.loadingDialog(context, "正在上传数据", false); | |
| 64 | 68 | // 赛事id |
| 65 | 69 | String eventId = userStepEntity.getStreetId(); |
| 66 | 70 | //用户ID |
| ... | ... | @@ -83,6 +87,7 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter<RunningFinis |
| 83 | 87 | } |
| 84 | 88 | // 路线图 |
| 85 | 89 | String roadmap = runningFinishBean.getRoadmap(); |
| 90 | + roadmap = ""; | |
| 86 | 91 | //经纬度 |
| 87 | 92 | String latLongitude = ""; |
| 88 | 93 | // 开始时间 |
| ... | ... | @@ -127,18 +132,41 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter<RunningFinis |
| 127 | 132 | .setFailureCallback(new FailureCallback() { |
| 128 | 133 | @Override |
| 129 | 134 | public void onFailure(int code, String message) { |
| 130 | - QMUITipDialogUtil.dismessDialog(); | |
| 131 | 135 | if (getView() == null) { |
| 132 | 136 | return; |
| 133 | 137 | } |
| 134 | 138 | Log.e("saveRouteData", "onFailure: " + message); |
| 135 | -// getView().hideLoadingView(); | |
| 136 | -// getView().showRetryView(code, new View.OnClickListener() { | |
| 137 | -// @Override | |
| 138 | -// public void onClick(View view) { | |
| 139 | -// getRunRaceDetailInfo(context, id, userId,state); | |
| 140 | -// } | |
| 141 | -// }); | |
| 139 | + QMUITipDialogUtil.dismessDialog(); | |
| 140 | + if (uploadFailDialog == null) { | |
| 141 | + uploadFailDialog = new SelectDialog(context, "上传数据失败,是否重试?", "重试", new SelectDialog.DialogInterface() { | |
| 142 | + @Override | |
| 143 | + public void onClick(SelectDialog dialog) { | |
| 144 | + dialog.dismiss(); | |
| 145 | + saveRouteData(context, userStepEntity, runningFinishBean); | |
| 146 | + } | |
| 147 | + }, "暂存", new SelectDialog.DialogInterface() { | |
| 148 | + @Override | |
| 149 | + public void onClick(SelectDialog dialog) { | |
| 150 | + dialog.dismiss(); | |
| 151 | + StepUtil.clearRunData(context, CommonInfo.getUserId(context)); | |
| 152 | + CommonInfo.reset(context); | |
| 153 | + //跳转到上传失败列表 | |
| 154 | + LineUpAgainActivity.newInstance(context); | |
| 155 | + //关闭当前窗口 | |
| 156 | + context.finish(); | |
| 157 | + | |
| 158 | + } | |
| 159 | + }); | |
| 160 | + uploadFailDialog.setCanceledOnTouchOutside(false); | |
| 161 | + uploadFailDialog.setCancelable(false); | |
| 162 | + if (!uploadFailDialog.isShowing()) { | |
| 163 | + uploadFailDialog.show(); | |
| 164 | + } | |
| 165 | + } else { | |
| 166 | + if (!uploadFailDialog.isShowing()) { | |
| 167 | + uploadFailDialog.show(); | |
| 168 | + } | |
| 169 | + } | |
| 142 | 170 | } |
| 143 | 171 | }).setSuccessCallback(new SuccessCallback<BaseInfo>() { |
| 144 | 172 | @Override |
| ... | ... | @@ -146,10 +174,15 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter<RunningFinis |
| 146 | 174 | if (getView() == null) { |
| 147 | 175 | return; |
| 148 | 176 | } |
| 149 | - Log.e("saveRouteData", "onSuccess: "); | |
| 150 | - | |
| 151 | 177 | QMUITipDialogUtil.dismessDialog(); |
| 152 | 178 | getView().updataIsFinish(runningFinishBean); |
| 179 | + //删除暂存数据 | |
| 180 | + FailedEntity entity = StepUtil.getTempSaveFailData(context, CommonInfo.getUserId(context), userStepEntity.getStartTimeStamp()); | |
| 181 | + if (entity != null) { | |
| 182 | + //删除 | |
| 183 | + StepUtil.deleteTempSaveFailData(context, entity); | |
| 184 | + } | |
| 185 | + //删除当前跑步数据 | |
| 153 | 186 | StepUtil.clearRunData(context, CommonInfo.getUserId(context)); |
| 154 | 187 | CommonInfo.reset(context); |
| 155 | 188 | |
| ... | ... | @@ -161,6 +194,7 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter<RunningFinis |
| 161 | 194 | * 查询当前用户历史轨迹 |
| 162 | 195 | */ |
| 163 | 196 | public void queryHistoryTrace(Activity context, UserStepEntity userStepEntity, RunningFinishBean runningFinishBean) { |
| 197 | + QMUITipDialogUtil.loadingDialog(context, "正在获取轨迹信息,请稍后", false); | |
| 164 | 198 | //查询当前用户的历史轨迹 |
| 165 | 199 | long startTime = userStepEntity.getStartTimeStamp(); |
| 166 | 200 | //获取当前的时间戳(秒) |
| ... | ... | @@ -179,10 +213,11 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter<RunningFinis |
| 179 | 213 | @Override |
| 180 | 214 | public void success(List<LatLng> resultPoints) { |
| 181 | 215 | if (resultPoints != null) { |
| 182 | - if (getView() != null && resultPoints != null) { | |
| 183 | - if (importPoints != null && resultPoints != null) { | |
| 216 | + if (getView() != null) { | |
| 217 | + QMUITipDialogUtil.dismessDialog(); | |
| 218 | + if (importPoints != null) { | |
| 184 | 219 | //判断是否完成 |
| 185 | - boolean isFinish = MyMapUtil.checkIsFinishTrace(importPoints, resultPoints, 0.6); | |
| 220 | + boolean isFinish = MyMapUtil.checkIsFinishTrace(importPoints, resultPoints, Constant.PASS_RATE); | |
| 186 | 221 | if (isFinish) { |
| 187 | 222 | Toast.makeText(context, "完成", Toast.LENGTH_LONG).show(); |
| 188 | 223 | runningFinishBean.setIsFinish("1"); |
| ... | ... | @@ -191,161 +226,50 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter<RunningFinis |
| 191 | 226 | runningFinishBean.setIsFinish("0"); |
| 192 | 227 | } |
| 193 | 228 | MyMapUtil.drawHistoryTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, R.drawable.icon_start, R.drawable.icon_end); |
| 194 | - new Handler().postDelayed(new Runnable() { | |
| 195 | - @Override | |
| 196 | - public void run() { | |
| 197 | - //开始截图 | |
| 198 | - getView().baiduMap.snapshot(new BaiduMap.SnapshotReadyCallback() { | |
| 199 | - @Override | |
| 200 | - public void onSnapshotReady(Bitmap bitmap) { | |
| 201 | - if (context == null) { | |
| 202 | - return; | |
| 203 | - } | |
| 204 | - if (null == bitmap) { | |
| 205 | - return; | |
| 206 | - } | |
| 207 | - //开始保存截屏 | |
| 208 | - try { | |
| 209 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); | |
| 210 | - File image = new File(context.getExternalCacheDir() + "/location_screenshot_" + sdf.format(new Date()) + ".jpeg"); | |
| 211 | - FileOutputStream fos = new FileOutputStream(image); | |
| 212 | - boolean b = bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos); | |
| 213 | - fos.flush(); | |
| 214 | - fos.close(); | |
| 215 | - String mapImagePath = image.getAbsolutePath(); | |
| 216 | - if (!TextUtils.isEmpty(mapImagePath)) { | |
| 217 | - QMUITipDialogUtil.loadingDialog(context, "正在上传数据", false); | |
| 218 | - //开始上传7牛 | |
| 219 | - List<String> imagePaths = new ArrayList<>(); | |
| 220 | - imagePaths.add(mapImagePath); | |
| 221 | - UploadLogic.uploadAddressPicInfo(getView().getContext(), imagePaths, new Event<String>() | |
| 222 | - .setFailureCallback(new FailureCallback() { | |
| 223 | - @Override | |
| 224 | - public void onFailure(int i, String s) { | |
| 225 | - QMUITipDialogUtil.dismessDialog(); | |
| 226 | - } | |
| 227 | - }) | |
| 228 | - .setSuccessCallback(new SuccessCallback<String>() { | |
| 229 | - @Override | |
| 230 | - public void onSuccess(String data) { | |
| 231 | - //设置截图 | |
| 232 | - runningFinishBean.setRoadmap(data); | |
| 233 | - //开始向服务器传数据 | |
| 234 | - saveRouteData(context, userStepEntity, runningFinishBean); | |
| 235 | - } | |
| 236 | - }) | |
| 237 | - ); | |
| 238 | - } | |
| 239 | - } catch (Exception e) { | |
| 240 | - e.printStackTrace(); | |
| 241 | - } | |
| 242 | - } | |
| 243 | - }); | |
| 244 | -// | |
| 245 | - } | |
| 246 | - }, 2000); | |
| 247 | - // | |
| 229 | + saveRouteData(context, userStepEntity, runningFinishBean); | |
| 248 | 230 | } |
| 249 | 231 | } |
| 250 | 232 | } |
| 251 | 233 | //查询失败 |
| 252 | 234 | else { |
| 253 | 235 | QMUITipDialogUtil.dismessDialog(); |
| 254 | - SelectDialog selectDialog = new SelectDialog(context, "获取轨迹失败,是否重试?", "重试", new SelectDialog.DialogInterface() { | |
| 255 | - @Override | |
| 256 | - public void onClick(SelectDialog dialog) { | |
| 257 | - dialog.dismiss(); | |
| 258 | - queryHistoryTrace(context, userStepEntity, runningFinishBean); | |
| 236 | + if (failTraceDialog == null) { | |
| 237 | + failTraceDialog = new SelectDialog(context, "获取轨迹失败,是否重试?", "重试", new SelectDialog.DialogInterface() { | |
| 238 | + @Override | |
| 239 | + public void onClick(SelectDialog dialog) { | |
| 240 | + dialog.dismiss(); | |
| 241 | + queryHistoryTrace(context, userStepEntity, runningFinishBean); | |
| 242 | + } | |
| 243 | + }, "暂存", new SelectDialog.DialogInterface() { | |
| 244 | + @Override | |
| 245 | + public void onClick(SelectDialog dialog) { | |
| 246 | + dialog.dismiss(); | |
| 247 | + StepUtil.clearRunData(context, CommonInfo.getUserId(context)); | |
| 248 | + CommonInfo.reset(context); | |
| 249 | + //跳转到上传失败列表 | |
| 250 | + LineUpAgainActivity.newInstance(context); | |
| 251 | + //关闭当前窗口 | |
| 252 | + context.finish(); | |
| 253 | + | |
| 254 | + } | |
| 255 | + }); | |
| 256 | + failTraceDialog.setCanceledOnTouchOutside(false); | |
| 257 | + failTraceDialog.setCancelable(false); | |
| 258 | + if (!failTraceDialog.isShowing()) { | |
| 259 | + failTraceDialog.show(); | |
| 259 | 260 | } |
| 260 | - }, "暂存", new SelectDialog.DialogInterface() { | |
| 261 | - @Override | |
| 262 | - public void onClick(SelectDialog dialog) { | |
| 263 | - setFailData(context, userStepEntity, runningFinishBean); | |
| 264 | 261 | |
| 265 | - dialog.dismiss(); | |
| 262 | + } else { | |
| 263 | + if (!failTraceDialog.isShowing()) { | |
| 264 | + failTraceDialog.show(); | |
| 266 | 265 | } |
| 267 | - }); | |
| 268 | - selectDialog.setCanceledOnTouchOutside(false); | |
| 269 | - selectDialog.setCancelable(false); | |
| 270 | - selectDialog.show(); | |
| 266 | + } | |
| 271 | 267 | } |
| 272 | 268 | } |
| 273 | 269 | }); |
| 274 | 270 | |
| 275 | 271 | } |
| 276 | 272 | |
| 277 | - public void setFailData(Activity activity, UserStepEntity userStepEntity, RunningFinishBean runningFinishBean) { | |
| 278 | - if (userStepEntity == null || runningFinishBean == null || activity == null) { | |
| 279 | - return; | |
| 280 | - } | |
| 281 | - //设置数据 | |
| 282 | - FailedEntity failedEntity = new FailedEntity(); | |
| 283 | - //设置主键 | |
| 284 | - failedEntity.setUuid(StepUtil.getUUID()); | |
| 285 | - //设置用户id | |
| 286 | - failedEntity.setUid(userStepEntity.getUserId()); | |
| 287 | - //设置当前数据创建时间戳 | |
| 288 | - failedEntity.setCreatTimeStamp(TimeUtil.getNowTimeStamp()); | |
| 289 | - //设置是否暂停 | |
| 290 | - if (userStepEntity.getPauseCount() > 1) { | |
| 291 | - failedEntity.setIsPause(true); | |
| 292 | - //设置暂停时间 | |
| 293 | - failedEntity.setUserPauseTime(userStepEntity.getUserPauseTimeStamp()); | |
| 294 | - //设置继续时间戳 | |
| 295 | - failedEntity.setUsrContinueTime(userStepEntity.getContinueTime()); | |
| 296 | - } else { | |
| 297 | - failedEntity.setIsPause(false); | |
| 298 | - } | |
| 299 | - //设置用时 | |
| 300 | - failedEntity.setTime(runningFinishBean.getEmployTime()); | |
| 301 | - //设置配速 | |
| 302 | - if ("--".equals(runningFinishBean.getSpeed())) { | |
| 303 | - failedEntity.setSpeed("0"); | |
| 304 | - } else { | |
| 305 | - failedEntity.setSpeed(runningFinishBean.getSpeed()); | |
| 306 | - } | |
| 307 | - //设置步数 | |
| 308 | - if ("--".equals(runningFinishBean.getStep())) { | |
| 309 | - failedEntity.setStep("0"); | |
| 310 | - } else { | |
| 311 | - failedEntity.setStep(runningFinishBean.getStep()); | |
| 312 | - } | |
| 313 | - //设置距离 | |
| 314 | - if ("--".equals(runningFinishBean.getRunDistance())) { | |
| 315 | - failedEntity.setDistance("0"); | |
| 316 | - } else { | |
| 317 | - failedEntity.setDistance(runningFinishBean.getRunDistance()); | |
| 318 | - } | |
| 319 | - //设置开始地点 | |
| 320 | - failedEntity.setStartPoint(userStepEntity.getStartPoint()); | |
| 321 | - //设置结束地点 | |
| 322 | - failedEntity.setEndPoint(userStepEntity.getEndPoint()); | |
| 323 | - //设置赛道开始时间 | |
| 324 | - failedEntity.setStreetTraceStartTime(userStepEntity.getQueryTraceStartTime()); | |
| 325 | - //设置赛道结束时间 | |
| 326 | - failedEntity.setStreetTraceEndTime(userStepEntity.getQueryTraceEndTime()); | |
| 327 | - //设置赛道查询实体 | |
| 328 | - failedEntity.setEntityName(userStepEntity.getQueryEntityName()); | |
| 329 | - //设置用户开始时间 | |
| 330 | - failedEntity.setUserStartTime(userStepEntity.getStartTimeStamp()); | |
| 331 | - //设置用户完成时间 | |
| 332 | - failedEntity.setUserEndTime(userStepEntity.getFinishTimeStamp()); | |
| 333 | - //设置关键点 | |
| 334 | - failedEntity.setImportPoint(userStepEntity.getImportPoint()); | |
| 335 | - //设置赛事id | |
| 336 | - failedEntity.setStreetId(userStepEntity.getStreetId()); | |
| 337 | - //设置赛事标题 | |
| 338 | - failedEntity.setStreetTitle(userStepEntity.getStreetTitle()); | |
| 339 | - //设置数据 | |
| 340 | - StepUtil.setFailData(activity, failedEntity); | |
| 341 | - //跳转到上传失败列表 | |
| 342 | - LineUpAgainActivity.newInstance(activity); | |
| 343 | - StepUtil.clearRunData(activity, CommonInfo.getUserId(activity)); | |
| 344 | - CommonInfo.reset(activity); | |
| 345 | - //关闭当前窗口 | |
| 346 | - activity.finish(); | |
| 347 | - | |
| 348 | - } | |
| 349 | 273 | |
| 350 | 274 | /** |
| 351 | 275 | * 查询运营人员踩得轨迹 |
| ... | ... | @@ -377,4 +301,60 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter<RunningFinis |
| 377 | 301 | } |
| 378 | 302 | |
| 379 | 303 | } |
| 304 | + | |
| 305 | + | |
| 306 | +// new Handler().postDelayed(new Runnable() { | |
| 307 | +// @Override | |
| 308 | +// public void run() { | |
| 309 | +// //开始截图 | |
| 310 | +// getView().baiduMap.snapshot(new BaiduMap.SnapshotReadyCallback() { | |
| 311 | +// @Override | |
| 312 | +// public void onSnapshotReady(Bitmap bitmap) { | |
| 313 | +// if (context == null) { | |
| 314 | +// return; | |
| 315 | +// } | |
| 316 | +// if (null == bitmap) { | |
| 317 | +// return; | |
| 318 | +// } | |
| 319 | +// //开始保存截屏 | |
| 320 | +// try { | |
| 321 | +// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); | |
| 322 | +// File image = new File(context.getExternalCacheDir() + "/location_screenshot_" + sdf.format(new Date()) + ".jpeg"); | |
| 323 | +// FileOutputStream fos = new FileOutputStream(image); | |
| 324 | +// boolean b = bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos); | |
| 325 | +// fos.flush(); | |
| 326 | +// fos.close(); | |
| 327 | +// String mapImagePath = image.getAbsolutePath(); | |
| 328 | +// if (!TextUtils.isEmpty(mapImagePath)) { | |
| 329 | +// QMUITipDialogUtil.loadingDialog(context, "正在上传数据", false); | |
| 330 | +// //开始上传7牛 | |
| 331 | +// List<String> imagePaths = new ArrayList<>(); | |
| 332 | +// imagePaths.add(mapImagePath); | |
| 333 | +// UploadLogic.uploadAddressPicInfo(getView().getContext(), imagePaths, new Event<String>() | |
| 334 | +// .setFailureCallback(new FailureCallback() { | |
| 335 | +// @Override | |
| 336 | +// public void onFailure(int i, String s) { | |
| 337 | +// QMUITipDialogUtil.dismessDialog(); | |
| 338 | +// } | |
| 339 | +// }) | |
| 340 | +// .setSuccessCallback(new SuccessCallback<String>() { | |
| 341 | +// @Override | |
| 342 | +// public void onSuccess(String data) { | |
| 343 | +// //设置截图 | |
| 344 | +// runningFinishBean.setRoadmap(data); | |
| 345 | +// //开始向服务器传数据 | |
| 346 | +// saveRouteData(context, userStepEntity, runningFinishBean); | |
| 347 | +// } | |
| 348 | +// }) | |
| 349 | +// ); | |
| 350 | +// } | |
| 351 | +// } catch (Exception e) { | |
| 352 | +// e.printStackTrace(); | |
| 353 | +// } | |
| 354 | +// } | |
| 355 | +// }); | |
| 356 | +//// | |
| 357 | +// } | |
| 358 | +// }, 2000); | |
| 359 | + // | |
| 380 | 360 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/presenter/UploadFailDetailFragmentPresenter.java
0 → 100644
| 1 | +package com.cnlive.moudle.pedometer.frame.presenter; | |
| 2 | + | |
| 3 | +import com.cnlive.moudle.pedometer.frame.view.UploadFailDetailFragmentView; | |
| 4 | +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; | |
| 5 | + | |
| 6 | +public class UploadFailDetailFragmentPresenter extends MvpBasePresenter<UploadFailDetailFragmentView> { | |
| 7 | +} | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/LineUpAgainView.java
| 1 | 1 | package com.cnlive.moudle.pedometer.frame.view; |
| 2 | 2 | |
| 3 | 3 | import android.support.v7.widget.LinearLayoutManager; |
| 4 | +import android.view.View; | |
| 4 | 5 | |
| 5 | 6 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 6 | 7 | import com.cnlive.moudle.pedometer.sql.entity.FailedEntity; |
| 8 | +import com.cnlive.moudle.pedometer.ui.activity.UploadFailDetailActivity; | |
| 7 | 9 | import com.cnlive.moudle.pedometer.ui.adapter.LineUpAgainAdapter; |
| 8 | 10 | import com.cnlive.moudle.pedometer.ui.fragment.LineUpAgainFragment; |
| 9 | 11 | import com.cnlive.moudle.pedometer.utils.StepUtil; |
| ... | ... | @@ -34,19 +36,19 @@ public class LineUpAgainView implements MvpView { |
| 34 | 36 | }); |
| 35 | 37 | fragment.binding.topbar.setTitle("重新上传"); |
| 36 | 38 | //获取上传失败的数据 |
| 37 | - List<FailedEntity> failedEntities = StepUtil.getFailListData(fragment.getContext(), CommonInfo.getUserId(fragment.getContext())); | |
| 38 | - //没有失败数据 | |
| 39 | - if (failedEntities == null) { | |
| 40 | - | |
| 41 | - } | |
| 42 | - //有失败数据 | |
| 43 | - else { | |
| 44 | - againAdapter = new LineUpAgainAdapter(failedEntities, fragment.getActivity()); | |
| 45 | - fragment.binding.recycler.setAdapter(againAdapter); | |
| 46 | - } | |
| 47 | 39 | // fragment.binding.refreshLayout.setRefreshHeader(new ClassicsHeader(fragment.getActivity())); |
| 48 | 40 | // fragment.binding.refreshLayout.setRefreshFooter(new ClassicsFooter(fragment.getActivity())); |
| 49 | 41 | fragment.binding.recycler.setLayoutManager(new LinearLayoutManager(fragment.getActivity())); |
| 50 | 42 | } |
| 51 | 43 | |
| 44 | + public void setData(List<FailedEntity> failedEntities) { | |
| 45 | + againAdapter = new LineUpAgainAdapter(failedEntities, fragment.getActivity()); | |
| 46 | + fragment.binding.recycler.setAdapter(againAdapter); | |
| 47 | + againAdapter.setOnClickListener(new LineUpAgainAdapter.OnClickListener() { | |
| 48 | + @Override | |
| 49 | + public void onClickListener(FailedEntity bean, int position) { | |
| 50 | + UploadFailDetailActivity.startActivity(fragment.getActivity(), bean); | |
| 51 | + } | |
| 52 | + }); | |
| 53 | + } | |
| 52 | 54 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunMainFragmentView.java
| 1 | 1 | package com.cnlive.moudle.pedometer.frame.view; |
| 2 | 2 | |
| 3 | +import android.app.Activity; | |
| 3 | 4 | import android.content.Context; |
| 4 | 5 | import android.content.Intent; |
| 5 | 6 | import android.os.Handler; |
| ... | ... | @@ -25,9 +26,12 @@ import com.cnlive.moudle.pedometer.model.RunningFinishBean; |
| 25 | 26 | import com.cnlive.moudle.pedometer.model.RunningMapBean; |
| 26 | 27 | import com.cnlive.moudle.pedometer.model.Constant; |
| 27 | 28 | import com.cnlive.moudle.pedometer.model.MessageEvent; |
| 29 | +import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo; | |
| 28 | 30 | import com.cnlive.moudle.pedometer.service.KeepLiveService; |
| 29 | 31 | import com.cnlive.moudle.pedometer.service.StepService; |
| 32 | +import com.cnlive.moudle.pedometer.sql.entity.FailedEntity; | |
| 30 | 33 | import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; |
| 34 | +import com.cnlive.moudle.pedometer.ui.activity.LineUpAgainActivity; | |
| 31 | 35 | import com.cnlive.moudle.pedometer.ui.activity.RunRaceDetailActivity; |
| 32 | 36 | import com.cnlive.moudle.pedometer.ui.activity.RunningFinishActivity; |
| 33 | 37 | import com.cnlive.moudle.pedometer.ui.activity.RunningMapActivity; |
| ... | ... | @@ -117,10 +121,27 @@ public class RunMainFragmentView implements MvpView { |
| 117 | 121 | /** |
| 118 | 122 | * 初始化相关视图 |
| 119 | 123 | */ |
| 120 | - public void initView() { | |
| 124 | + public void initView(RunRaceDetailInfo runRaceDetailInfo) { | |
| 121 | 125 | Log.e(TAG, "initView: +时间" + SystemClock.elapsedRealtime()); |
| 122 | 126 | uid = CommonInfo.getUserId(getContext()); |
| 123 | 127 | userStepEntity = StepUtil.getUserStepData(getContext(), uid); |
| 128 | + //设置数据 | |
| 129 | + if (userStepEntity != null) { | |
| 130 | + //设置赛事标题 | |
| 131 | + if (TextUtils.isEmpty(userStepEntity.getStreetTitle())) { | |
| 132 | + StepUtil.setStreetTitle(getContext(), CommonInfo.getUserId(getContext()), runRaceDetailInfo.getTitle()); | |
| 133 | + } | |
| 134 | + //设置实体名字 | |
| 135 | + if (TextUtils.isEmpty(userStepEntity.getQueryEntityName())) { | |
| 136 | + long startTime = Long.parseLong(runRaceDetailInfo.getStartTime()); | |
| 137 | + long endTime = Long.parseLong(runRaceDetailInfo.getEndTime()); | |
| 138 | + StepUtil.setQueryTraceTime(getContext(), CommonInfo.getUserId(getContext()), startTime, endTime, runRaceDetailInfo.getEntityName()); | |
| 139 | + } | |
| 140 | + //设置重要点 | |
| 141 | + if (TextUtils.isEmpty(userStepEntity.getImportPoint())){ | |
| 142 | + StepUtil.setImportPoints(getContext(),CommonInfo.getUserId(getContext()),runRaceDetailInfo.getLatLongitude()); | |
| 143 | + } | |
| 144 | + } | |
| 124 | 145 | initLocationClient(); |
| 125 | 146 | fragment.binding.llRunMainRoot.setVisibility(View.GONE); |
| 126 | 147 | ButtonAnimUtil.startAnimation(fragment.binding.llStartTimeTip, false); |
| ... | ... | @@ -183,6 +204,7 @@ public class RunMainFragmentView implements MvpView { |
| 183 | 204 | |
| 184 | 205 | } |
| 185 | 206 | }); |
| 207 | + | |
| 186 | 208 | boolean isFirstShowTime = CommonInfo.getIsFirstShowTimeTip(getContext()); |
| 187 | 209 | //当前用户已经在运动 |
| 188 | 210 | if (isFirstShowTime) { |
| ... | ... | @@ -338,7 +360,6 @@ public class RunMainFragmentView implements MvpView { |
| 338 | 360 | setStopStartFlag(); |
| 339 | 361 | //设置运动结束时间戳 |
| 340 | 362 | StepUtil.setUserFinishTimeStamp(getContext(), uid); |
| 341 | - CommonInfo.setStepEndTime(getContext(), TimeUtil.getNowTimeStamp()); | |
| 342 | 363 | fragment.binding.cpCurrent.setVisibility(View.GONE); |
| 343 | 364 | ButtonAnimUtil.setViewDefault(fragment.binding.flStop); |
| 344 | 365 | dialog.dismiss(); |
| ... | ... | @@ -349,11 +370,20 @@ public class RunMainFragmentView implements MvpView { |
| 349 | 370 | runningFinishBean.setSpeed(fragment.binding.tvSpeed.getText().toString()); |
| 350 | 371 | runningFinishBean.setStep(fragment.binding.tvStepCount.getText().toString()); |
| 351 | 372 | runningFinishBean.setTime(fragment.binding.chronometer.getText().toString()); |
| 352 | - runningFinishBean.setDate(TimeUtil.getFormatNowTime()); | |
| 373 | + runningFinishBean.setDate(TimeUtil.getStampToTime(userStepEntity.getFinishTimeStamp()*1000,"yyyy/MM/dd HH:mm")); | |
| 374 | + runningFinishBean.setStreetTitle(userStepEntity.getStreetTitle()); | |
| 353 | 375 | //设置用时 |
| 354 | 376 | runningFinishBean.setEmployTime(employTime); |
| 355 | - RunningFinishActivity.startActivity(fragment.getActivity(), runningFinishBean); | |
| 356 | - fragment.getActivity().finish(); | |
| 377 | + | |
| 378 | + //先将失败数据保存起来 | |
| 379 | + if (runningFinishBean != null && userStepEntity != null) { | |
| 380 | + setFailData(getContext(), userStepEntity, runningFinishBean); | |
| 381 | + } | |
| 382 | + FailedEntity failedEntity = StepUtil.getTempSaveFailData(getContext(), CommonInfo.getUserId(getContext()), userStepEntity.getStartTimeStamp()); | |
| 383 | + if (failedEntity != null) { | |
| 384 | + RunningFinishActivity.startActivity(fragment.getActivity(), runningFinishBean); | |
| 385 | + fragment.getActivity().finish(); | |
| 386 | + } | |
| 357 | 387 | } |
| 358 | 388 | }, "取消", new SelectDialog.DialogInterface() { |
| 359 | 389 | @Override |
| ... | ... | @@ -486,6 +516,8 @@ public class RunMainFragmentView implements MvpView { |
| 486 | 516 | * 暂停按钮 |
| 487 | 517 | */ |
| 488 | 518 | public void onBtnPause() { |
| 519 | + //暂停计步 | |
| 520 | + EventBus.getDefault().post(new MessageEvent(Constant.SERVICE_STEP_COUNT_PAUSE, "")); | |
| 489 | 521 | //将当前计时器时间戳写入数据库 |
| 490 | 522 | setSQLPauseTime(uid); |
| 491 | 523 | //设置暂停标志 |
| ... | ... | @@ -537,8 +569,7 @@ public class RunMainFragmentView implements MvpView { |
| 537 | 569 | //停止计时 |
| 538 | 570 | fragment.binding.chronometer.stop(); |
| 539 | 571 | mRecordTime = SystemClock.elapsedRealtime(); |
| 540 | - //暂停计步 | |
| 541 | - EventBus.getDefault().post(new MessageEvent(Constant.SERVICE_STEP_COUNT_PAUSE, "")); | |
| 572 | + | |
| 542 | 573 | } |
| 543 | 574 | } |
| 544 | 575 | |
| ... | ... | @@ -692,6 +723,80 @@ public class RunMainFragmentView implements MvpView { |
| 692 | 723 | mLocClient.stop(); |
| 693 | 724 | } |
| 694 | 725 | } |
| 726 | + | |
| 727 | + /** | |
| 728 | + * 暂存失败数据 | |
| 729 | + * | |
| 730 | + * @param context | |
| 731 | + * @param userStepEntity | |
| 732 | + * @param runningFinishBean | |
| 733 | + */ | |
| 734 | + public void setFailData(Context context, UserStepEntity userStepEntity, RunningFinishBean runningFinishBean) { | |
| 735 | + if (userStepEntity == null || runningFinishBean == null || context == null) { | |
| 736 | + return; | |
| 737 | + } | |
| 738 | + //设置数据 | |
| 739 | + FailedEntity failedEntity = new FailedEntity(); | |
| 740 | + //设置主键 | |
| 741 | + failedEntity.setUuid(StepUtil.getUUID()); | |
| 742 | + //设置用户id | |
| 743 | + failedEntity.setUid(userStepEntity.getUserId()); | |
| 744 | + //设置当前数据创建时间戳 | |
| 745 | + failedEntity.setCreatTimeStamp(TimeUtil.getNowTimeStamp()); | |
| 746 | + //设置是否暂停 | |
| 747 | + if (userStepEntity.getPauseCount() > 1) { | |
| 748 | + failedEntity.setIsPause(true); | |
| 749 | + //设置暂停时间 | |
| 750 | + failedEntity.setUserPauseTime(userStepEntity.getUserPauseTimeStamp()); | |
| 751 | + //设置继续时间戳 | |
| 752 | + failedEntity.setUsrContinueTime(userStepEntity.getContinueTime()); | |
| 753 | + } else { | |
| 754 | + failedEntity.setIsPause(false); | |
| 755 | + } | |
| 756 | + //设置用时 | |
| 757 | + failedEntity.setTime(runningFinishBean.getEmployTime()); | |
| 758 | + //设置配速 | |
| 759 | + if ("--".equals(runningFinishBean.getSpeed())) { | |
| 760 | + failedEntity.setSpeed("0"); | |
| 761 | + } else { | |
| 762 | + failedEntity.setSpeed(runningFinishBean.getSpeed()); | |
| 763 | + } | |
| 764 | + //设置步数 | |
| 765 | + if ("--".equals(runningFinishBean.getStep())) { | |
| 766 | + failedEntity.setStep("0"); | |
| 767 | + } else { | |
| 768 | + failedEntity.setStep(runningFinishBean.getStep()); | |
| 769 | + } | |
| 770 | + //设置距离 | |
| 771 | + if ("--".equals(runningFinishBean.getRunDistance())) { | |
| 772 | + failedEntity.setDistance("0"); | |
| 773 | + } else { | |
| 774 | + failedEntity.setDistance(runningFinishBean.getRunDistance()); | |
| 775 | + } | |
| 776 | + //设置开始地点 | |
| 777 | + failedEntity.setStartPoint(userStepEntity.getStartPoint()); | |
| 778 | + //设置结束地点 | |
| 779 | + failedEntity.setEndPoint(userStepEntity.getEndPoint()); | |
| 780 | + //设置赛道开始时间 | |
| 781 | + failedEntity.setStreetTraceStartTime(userStepEntity.getQueryTraceStartTime()); | |
| 782 | + //设置赛道结束时间 | |
| 783 | + failedEntity.setStreetTraceEndTime(userStepEntity.getQueryTraceEndTime()); | |
| 784 | + //设置赛道查询实体 | |
| 785 | + failedEntity.setEntityName(userStepEntity.getQueryEntityName()); | |
| 786 | + //设置用户开始时间 | |
| 787 | + failedEntity.setUserStartTime(userStepEntity.getStartTimeStamp()); | |
| 788 | + //设置用户完成时间 | |
| 789 | + failedEntity.setUserEndTime(userStepEntity.getFinishTimeStamp()); | |
| 790 | + //设置关键点 | |
| 791 | + failedEntity.setImportPoint(userStepEntity.getImportPoint()); | |
| 792 | + //设置赛事id | |
| 793 | + failedEntity.setStreetId(userStepEntity.getStreetId()); | |
| 794 | + //设置赛事标题 | |
| 795 | + failedEntity.setStreetTitle(userStepEntity.getStreetTitle()); | |
| 796 | + //设置数据 | |
| 797 | + StepUtil.setFailData(context, failedEntity); | |
| 798 | + | |
| 799 | + } | |
| 695 | 800 | } |
| 696 | 801 | |
| 697 | 802 | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
| ... | ... | @@ -131,7 +131,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 131 | 131 | // 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}]"; |
| 132 | 132 | private LinkedList<LatLng> importLatLngs;//关键点 |
| 133 | 133 | private LatLng startLatLng = new LatLng(39.934733, 116.308646);//起始点 |
| 134 | - private RunRaceDetailInfo runRaceDetailInfo; | |
| 134 | + public RunRaceDetailInfo runRaceDetailInfo; | |
| 135 | 135 | private UserStepEntity userStepEntity; |
| 136 | 136 | private boolean isDifferentStreet = false; |
| 137 | 137 | private LBSTraceClient mClient = null; |
| ... | ... | @@ -212,12 +212,6 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 212 | 212 | startTime = Long.parseLong(runRaceDetailInfo.getStartTime()); |
| 213 | 213 | endTime = Long.parseLong(runRaceDetailInfo.getEndTime()); |
| 214 | 214 | //todo 注意后续查询历史轨迹的时候,必须查数据库中的时间,因为涉及到历史运动恢复,所以不能用这个sp文件中的,这里设置,只是为了在服务启动成功后, |
| 215 | - //设置轨迹查询实体名称 | |
| 216 | - CommonInfo.setQueryEntityName(getContext(), runRaceDetailInfo.getEntityName()); | |
| 217 | - //设置轨迹查询开始时间 | |
| 218 | - CommonInfo.setQueryTraceStartTime(getContext(), startTime); | |
| 219 | - //设置轨迹查询结束时间 | |
| 220 | - CommonInfo.setQueryTraceEndTime(getContext(), endTime); | |
| 221 | 215 | |
| 222 | 216 | mClient = new LBSTraceClient(getContext()); |
| 223 | 217 | //获取轨迹 |
| ... | ... | @@ -307,7 +301,6 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 307 | 301 | } |
| 308 | 302 | //设置标题 |
| 309 | 303 | if (!TextUtils.isEmpty(runRaceDetailInfo.getTitle())) { |
| 310 | - CommonInfo.setStreetTitle(getContext(), runRaceDetailInfo.getTitle()); | |
| 311 | 304 | fragment.binding.includeStreet.tvRaceTitle.setText(runRaceDetailInfo.getTitle()); |
| 312 | 305 | //根据标题字数动态设置卡片高度 |
| 313 | 306 | if (runRaceDetailInfo.getTitle().length() > 19) { |
| ... | ... | @@ -574,10 +567,10 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 574 | 567 | stopStepService(); |
| 575 | 568 | startStepService(getContext()); |
| 576 | 569 | } else { |
| 577 | - PedometerMainActivity.startActivity(fragment.getActivity(), runRaceDetailInfo.getStartLocation(), runRaceDetailInfo.getEndLocation(), importStreetPoints); | |
| 570 | + PedometerMainActivity.startActivity(fragment.getActivity(), runRaceDetailInfo); | |
| 578 | 571 | } |
| 579 | 572 | } else { |
| 580 | - PedometerMainActivity.startActivity(fragment.getActivity(), runRaceDetailInfo.getStartLocation(), runRaceDetailInfo.getEndLocation(), importStreetPoints); | |
| 573 | + PedometerMainActivity.startActivity(fragment.getActivity(), runRaceDetailInfo); | |
| 581 | 574 | } |
| 582 | 575 | } |
| 583 | 576 | |
| ... | ... | @@ -913,19 +906,9 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 913 | 906 | } |
| 914 | 907 | //todo 防止停止后,再次开始,无法获取到赛道的轨迹 |
| 915 | 908 | if (runRaceDetailInfo != null) { |
| 916 | - if (!TextUtils.isEmpty(runRaceDetailInfo.getStartTime()) && !TextUtils.isEmpty(runRaceDetailInfo.getEndTime()) && !TextUtils.isEmpty(runRaceDetailInfo.getEntityName())) { | |
| 917 | - long startTime = Long.parseLong(runRaceDetailInfo.getStartTime()); | |
| 918 | - long endTime = Long.parseLong(runRaceDetailInfo.getEndTime()); | |
| 919 | - //todo 注意后续查询历史轨迹的时候,必须查数据库中的时间,因为涉及到历史运动恢复,所以不能用这个sp文件中的,这里设置,只是为了在服务启动成功后, | |
| 920 | - //设置轨迹查询实体名称 | |
| 921 | - CommonInfo.setQueryEntityName(getContext(), runRaceDetailInfo.getEntityName()); | |
| 922 | - //设置轨迹查询开始时间 | |
| 923 | - CommonInfo.setQueryTraceStartTime(getContext(), startTime); | |
| 924 | - //设置轨迹查询结束时间 | |
| 925 | - CommonInfo.setQueryTraceEndTime(getContext(), endTime); | |
| 926 | - } | |
| 927 | - if (!TextUtils.isEmpty(runRaceDetailInfo.getTitle())) { | |
| 928 | - CommonInfo.setStreetTitle(getContext(), runRaceDetailInfo.getTitle()); | |
| 909 | + if (runRaceDetailInfo.getFenceId() != null) { | |
| 910 | + //设置围栏ID | |
| 911 | + CommonInfo.setFenceId(getContext(), Integer.parseInt(runRaceDetailInfo.getFenceId())); | |
| 929 | 912 | } |
| 930 | 913 | } |
| 931 | 914 | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunningFinishFragmentView.java
| ... | ... | @@ -42,6 +42,10 @@ public class RunningFinishFragmentView implements MvpView { |
| 42 | 42 | public void initView(RunningFinishBean runningFinishBean) { |
| 43 | 43 | this.mMapView = fragment.binding.mapView; |
| 44 | 44 | initMap(); |
| 45 | + //设置赛事标题 | |
| 46 | + if (!TextUtils.isEmpty(runningFinishBean.getStreetTitle())) { | |
| 47 | + fragment.binding.includeFinishUserInfo.tvStreetName.setText(runningFinishBean.getStreetTitle()); | |
| 48 | + } | |
| 45 | 49 | //设置用户头像 |
| 46 | 50 | String faceUrl = CommonInfo.getUserIcon(getContext()); |
| 47 | 51 | if (!TextUtils.isEmpty(faceUrl)) { | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/UploadFailDetailFragmentView.java
0 → 100644
| 1 | +package com.cnlive.moudle.pedometer.frame.view; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.text.TextUtils; | |
| 5 | +import android.view.View; | |
| 6 | + | |
| 7 | +import com.bumptech.glide.Glide; | |
| 8 | +import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; | |
| 9 | +import com.cnlive.moudle.pedometer.sql.entity.FailedEntity; | |
| 10 | +import com.cnlive.moudle.pedometer.ui.fragment.UploadFailDetailFragment; | |
| 11 | +import com.cnlive.moudle.pedometer.utils.TimeUtil; | |
| 12 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | |
| 13 | + | |
| 14 | +public class UploadFailDetailFragmentView implements MvpView { | |
| 15 | + private UploadFailDetailFragment fragment; | |
| 16 | + private FailedEntity failedEntity; | |
| 17 | + | |
| 18 | + public UploadFailDetailFragmentView(UploadFailDetailFragment fragment) { | |
| 19 | + this.fragment = fragment; | |
| 20 | + } | |
| 21 | + | |
| 22 | + public Context getContext() { | |
| 23 | + return fragment == null ? null : fragment.getActivity(); | |
| 24 | + } | |
| 25 | + | |
| 26 | + public void initView(FailedEntity failedEntity) { | |
| 27 | + if (getContext() == null) { | |
| 28 | + return; | |
| 29 | + } | |
| 30 | + if (failedEntity == null) { | |
| 31 | + return; | |
| 32 | + } | |
| 33 | + this.failedEntity = failedEntity; | |
| 34 | + //隐藏loading | |
| 35 | + fragment.binding.loading.setVisibility(View.GONE); | |
| 36 | + //设置提示文字为重新上传 | |
| 37 | + fragment.binding.tvRunNow.setText("重新上传"); | |
| 38 | + fragment.binding.rlScrollViewStartBtn.setTag("0"); | |
| 39 | + //初始化相关数据 | |
| 40 | + //设置用户昵称 | |
| 41 | + String nickName = CommonInfo.getUserNickName(getContext()); | |
| 42 | + if (!TextUtils.isEmpty(nickName)) { | |
| 43 | + fragment.binding.includeFinishUserInfo.tvUserNickName.setText(nickName); | |
| 44 | + } | |
| 45 | + //设置用户头像 | |
| 46 | + String faceUrl = CommonInfo.getUserIcon(getContext()); | |
| 47 | + if (!TextUtils.isEmpty(faceUrl)) { | |
| 48 | + Glide.with(getContext()).load(faceUrl).into(fragment.binding.includeFinishUserInfo.qmIvIcon); | |
| 49 | + } | |
| 50 | + //设置赛事标题 | |
| 51 | + if (!TextUtils.isEmpty(failedEntity.getStreetTitle())) { | |
| 52 | + fragment.binding.includeFinishUserInfo.tvStreetName.setText(failedEntity.getStreetTitle()); | |
| 53 | + } | |
| 54 | + //设置距离 | |
| 55 | + fragment.binding.includeFinishUserInfo.tvDistance.setText(failedEntity.getDistance()); | |
| 56 | + //设置配速 | |
| 57 | + if ("--".equals(failedEntity.getSpeed())) { | |
| 58 | + fragment.binding.includeFinishUserInfo.tvSpeed.setText("0"); | |
| 59 | + } else { | |
| 60 | + fragment.binding.includeFinishUserInfo.tvSpeed.setText(failedEntity.getSpeed()); | |
| 61 | + } | |
| 62 | + //设置用时 | |
| 63 | + fragment.binding.includeFinishUserInfo.tvTimer.setText(TimeUtil.stampToChronometer(Long.parseLong(failedEntity.getTime()))); | |
| 64 | + //设置日期 | |
| 65 | + fragment.binding.includeFinishUserInfo.tvDate.setText(TimeUtil.getStampToTime(failedEntity.getUserEndTime() * 1000, "yyyy/MM/dd HH:mm")); | |
| 66 | + //设置步数 | |
| 67 | + if ("--".equals(failedEntity.getStep())) { | |
| 68 | + fragment.binding.includeFinishStep.tvStep.setText("0"); | |
| 69 | + } else { | |
| 70 | + fragment.binding.includeFinishStep.tvStep.setText(failedEntity.getStep()); | |
| 71 | + } | |
| 72 | + //设置起点位置 | |
| 73 | + fragment.binding.includeFinishRunRoute.tvStartPoint.setText(failedEntity.getStartPoint()); | |
| 74 | + //设置终点位置 | |
| 75 | + fragment.binding.includeFinishRunRoute.tvEndPoint.setText(failedEntity.getEndPoint()); | |
| 76 | + //设置时间 | |
| 77 | + fragment.binding.includeFinishRunRoute.tvTimer.setText(TimeUtil.stampToChronometer(Long.parseLong(failedEntity.getTime()))); | |
| 78 | + //返回按钮点击事件 | |
| 79 | + fragment.binding.flBack.setOnClickListener(new View.OnClickListener() { | |
| 80 | + @Override | |
| 81 | + public void onClick(View view) { | |
| 82 | + if (fragment.getActivity() != null) { | |
| 83 | + fragment.getActivity().finish(); | |
| 84 | + } | |
| 85 | + } | |
| 86 | + }); | |
| 87 | + //重新上传按钮点击事件 | |
| 88 | + fragment.binding.rlScrollViewStartBtn.setOnClickListener(new View.OnClickListener() { | |
| 89 | + @Override | |
| 90 | + public void onClick(View view) { | |
| 91 | + | |
| 92 | + } | |
| 93 | + }); | |
| 94 | + } | |
| 95 | +} | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/model/Constant.java
| ... | ... | @@ -3,7 +3,7 @@ package com.cnlive.moudle.pedometer.model; |
| 3 | 3 | public class Constant { |
| 4 | 4 | public static final long SERVICE_ID = 213511; |
| 5 | 5 | public static final int TAG = 1; |
| 6 | - public static final int GATHER_INTERVAL =2;//位置采集周期 | |
| 6 | + public static final int GATHER_INTERVAL = 2;//位置采集周期 | |
| 7 | 7 | public static final int PACK_INTERVAL = 10;//位置采集周期 |
| 8 | 8 | |
| 9 | 9 | public static final int SERVICE_STEP_COUNT_UPDATE = 0;//步数更新 |
| ... | ... | @@ -18,5 +18,6 @@ public class Constant { |
| 18 | 18 | public static final int START_TRACE_GATHER_SUCCESS = 9;//启动轨迹服务成功(用户) |
| 19 | 19 | public static final int START_TRACE_GATHER_FAIL = 10;//启动轨迹服务失败(用户) |
| 20 | 20 | public static final int REGISTRATION_SUCCESS = 11;//用户报名成功 |
| 21 | - | |
| 21 | + public static final double PASS_RATE = 0.7;//通过率70% | |
| 22 | + public static final int CHECK_ACCURACY = 50;//判断用户是否完成的精度范围 | |
| 22 | 23 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/model/RunningFinishBean.java
| ... | ... | @@ -20,6 +20,15 @@ public class RunningFinishBean implements Serializable { |
| 20 | 20 | private String employTime; |
| 21 | 21 | private String isFinish; |
| 22 | 22 | private String roadmap; |
| 23 | + private String streetTitle; | |
| 24 | + | |
| 25 | + public String getStreetTitle() { | |
| 26 | + return streetTitle; | |
| 27 | + } | |
| 28 | + | |
| 29 | + public void setStreetTitle(String streetTitle) { | |
| 30 | + this.streetTitle = streetTitle; | |
| 31 | + } | |
| 23 | 32 | |
| 24 | 33 | public String getRoadmap() { |
| 25 | 34 | return roadmap; | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/net/bean/RunRaceDetailInfo.java
| 1 | 1 | package com.cnlive.moudle.pedometer.net.bean; |
| 2 | 2 | |
| 3 | +import java.io.Serializable; | |
| 3 | 4 | import java.util.List; |
| 4 | 5 | |
| 5 | 6 | /** |
| ... | ... | @@ -7,7 +8,7 @@ import java.util.List; |
| 7 | 8 | * |
| 8 | 9 | * @author ShinnyYang |
| 9 | 10 | */ |
| 10 | -public class RunRaceDetailInfo { | |
| 11 | +public class RunRaceDetailInfo implements Serializable { | |
| 11 | 12 | |
| 12 | 13 | |
| 13 | 14 | /** | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/StepService.java
| ... | ... | @@ -104,11 +104,11 @@ public class StepService extends Service implements SensorEventListener { |
| 104 | 104 | /** |
| 105 | 105 | * 保存记步计时器 |
| 106 | 106 | */ |
| 107 | - private TimeCount time; | |
| 107 | + private static TimeCount time; | |
| 108 | 108 | /** |
| 109 | 109 | * 当前所走的步数 |
| 110 | 110 | */ |
| 111 | - private int CURRENT_STEP; | |
| 111 | + private int CURRENT_STEP = 0; | |
| 112 | 112 | /** |
| 113 | 113 | * 计步传感器类型 Sensor.TYPE_STEP_COUNTER或者Sensor.TYPE_STEP_DETECTOR |
| 114 | 114 | */ |
| ... | ... | @@ -137,7 +137,7 @@ public class StepService extends Service implements SensorEventListener { |
| 137 | 137 | private Handler handler; |
| 138 | 138 | private Runnable speedRunnable; |
| 139 | 139 | private final int NOTIFICATION_ID = 100; |
| 140 | - private static int tempStep;//计步器临时保存步数 | |
| 140 | + // private static int tempStep;//计步器临时保存步数 | |
| 141 | 141 | private static boolean pauseFlag;//是否暂停 |
| 142 | 142 | private static int speedCurrentStep;//用于检测速度步数 |
| 143 | 143 | private boolean updateSpeedStepFlag;//是否是已经更新速度 |
| ... | ... | @@ -255,18 +255,12 @@ public class StepService extends Service implements SensorEventListener { |
| 255 | 255 | if (userStepEntity == null) { |
| 256 | 256 | StepUtil.setStepStartData(getApplicationContext(), userId, TimeUtil.getNowTimeStamp(), CommonInfo.getStreetId(getApplicationContext())); |
| 257 | 257 | //设置从服务器获取的时间(后续查询历史轨迹的时间,要从数据库中获取,因为涉及到现有运动恢复问题) |
| 258 | - StepUtil.setQueryTraceTime(getApplicationContext(), userId, CommonInfo.getQueryTraceStartTime(getApplicationContext()), CommonInfo.getQueryTraceEndTime(getApplicationContext()), CommonInfo.getQueryQueryEntityName(getApplicationContext())); | |
| 259 | 258 | int fenceId = CommonInfo.getFenceId(getApplicationContext()); |
| 259 | + Log.e(TAG, "onStartTraceCallback: 保存的围栏id" + fenceId); | |
| 260 | 260 | //设置围栏id |
| 261 | 261 | StepUtil.setFenceId(getApplicationContext(), CommonInfo.getUserId(getApplicationContext()), fenceId); |
| 262 | - //设置赛事标题 | |
| 263 | - StepUtil.setStreetTitle(getApplicationContext(), CommonInfo.getUserId(getApplicationContext()), CommonInfo.getStreetTitle(getApplicationContext())); | |
| 264 | 262 | //清空临时保存的时间 |
| 265 | - CommonInfo.setQueryTraceEndTime(getApplicationContext(), 0); | |
| 266 | - CommonInfo.setQueryTraceStartTime(getApplicationContext(), 0); | |
| 267 | - CommonInfo.setQueryEntityName(getApplicationContext(), ""); | |
| 268 | 263 | CommonInfo.setFenceId(getApplicationContext(), -1); |
| 269 | - CommonInfo.setStreetTitle(getApplicationContext(), ""); | |
| 270 | 264 | |
| 271 | 265 | } |
| 272 | 266 | //开始设置围栏报警 |
| ... | ... | @@ -632,7 +626,15 @@ public class StepService extends Service implements SensorEventListener { |
| 632 | 626 | if (speedRunnable != null) { |
| 633 | 627 | handler.removeCallbacks(speedRunnable); |
| 634 | 628 | } |
| 635 | - Log.e("杀死", "MyTestService"); | |
| 629 | +// Log.e("杀死", "MyTestService"); | |
| 630 | + lastStep=0; | |
| 631 | + hasStepCount = 0; | |
| 632 | + hasRecord = false; | |
| 633 | + CURRENT_STEP = 0; | |
| 634 | + previousStepCount = 0; | |
| 635 | + sensorManager = null; | |
| 636 | + stepSensorType = -1; | |
| 637 | + time=null; | |
| 636 | 638 | } |
| 637 | 639 | |
| 638 | 640 | //接收事件 |
| ... | ... | @@ -703,6 +705,7 @@ public class StepService extends Service implements SensorEventListener { |
| 703 | 705 | CURRENT_STEP = Integer.parseInt(userStepEntity.getStepCount()); |
| 704 | 706 | } |
| 705 | 707 | } |
| 708 | + Log.e(TAG, "initTodayData: 初始化当前步数" + CURRENT_STEP); | |
| 706 | 709 | if (mStepCount != null) { |
| 707 | 710 | mStepCount.setSteps(CURRENT_STEP); |
| 708 | 711 | } |
| ... | ... | @@ -710,6 +713,7 @@ public class StepService extends Service implements SensorEventListener { |
| 710 | 713 | } |
| 711 | 714 | |
| 712 | 715 | private void updateNotification() { |
| 716 | + Log.e(TAG, "updateNotification: 当前步数:" + CURRENT_STEP); | |
| 713 | 717 | EventBus.getDefault().post(new MessageEvent(Constant.SERVICE_STEP_COUNT_UPDATE, CURRENT_STEP)); |
| 714 | 718 | updateSpeedStepFlag = false; |
| 715 | 719 | // remoteViews = new RemoteViews(getPackageName(), R.layout.custom_step_notification); |
| ... | ... | @@ -1005,29 +1009,45 @@ public class StepService extends Service implements SensorEventListener { |
| 1005 | 1009 | * |
| 1006 | 1010 | * @param event |
| 1007 | 1011 | */ |
| 1012 | + private static int lastStep = 0;//有时候获取的是一样的 | |
| 1013 | + | |
| 1008 | 1014 | @Override |
| 1009 | 1015 | public void onSensorChanged(SensorEvent event) { |
| 1010 | 1016 | //没有暂停 |
| 1011 | 1017 | if (stepSensorType == Sensor.TYPE_STEP_COUNTER) { |
| 1012 | 1018 | //获取当前传感器返回的临时步数 |
| 1013 | - tempStep = (int) event.values[0]; | |
| 1019 | + int tempStep = (int) event.values[0]; | |
| 1020 | + Log.e(TAG, "onSensorChanged: 第一次,tempStep:" + tempStep + "lastStep:" + lastStep + ",previousStepCount" + previousStepCount + ",CURRENT_STEP" + CURRENT_STEP); | |
| 1014 | 1021 | //首次如果没有获取手机系统中已有的步数则获取一次系统中APP还未开始记步的步数 |
| 1015 | 1022 | if (!hasRecord) { |
| 1016 | 1023 | hasRecord = true; |
| 1017 | 1024 | hasStepCount = tempStep; |
| 1025 | + previousStepCount = 0; | |
| 1018 | 1026 | } else { |
| 1019 | - //获取APP打开到现在的总步数=本次系统回调的总步数-APP打开之前已有的步数 | |
| 1020 | - int thisStepCount = tempStep - hasStepCount; | |
| 1021 | - //本次有效步数=(APP打开后所记录的总步数-上一次APP打开后所记录的总步数) | |
| 1022 | - int thisStep = thisStepCount - previousStepCount; | |
| 1023 | - //当用户点击暂停了 | |
| 1024 | - if (pauseFlag) { | |
| 1025 | - thisStep = 0; | |
| 1027 | + if (tempStep > lastStep) { | |
| 1028 | + //获取APP打开到现在的总步数=本次系统回调的总步数-APP打开之前已有的步数 | |
| 1029 | + Log.e(TAG, "tempStep: " + tempStep + ",hasStepCount:" + hasStepCount); | |
| 1030 | + int thisStepCount = tempStep - hasStepCount; | |
| 1031 | + Log.e(TAG, "onSensorChanged: thisStepCount" + thisStepCount); | |
| 1032 | + //本次有效步数=(APP打开后所记录的总步数-上一次APP打开后所记录的总步数) | |
| 1033 | + int thisStep = thisStepCount - previousStepCount; | |
| 1034 | + //记录最后一次APP打开到现在的总步数 | |
| 1035 | + previousStepCount = thisStepCount; | |
| 1036 | + Log.e(TAG, "本次有效步数: thisStep" + thisStep + ",previousStepCount:" + previousStepCount); | |
| 1037 | + //当用户点击暂停了 | |
| 1038 | + if (pauseFlag) { | |
| 1039 | + thisStep = 0; | |
| 1040 | + Log.e(TAG, "修改: thisStepCount" + thisStep); | |
| 1041 | + } | |
| 1042 | + Log.e(TAG, "onSensorChanged: CURRENT_STEP" + CURRENT_STEP); | |
| 1043 | + if (CURRENT_STEP < 0) { | |
| 1044 | + CURRENT_STEP = -CURRENT_STEP; | |
| 1045 | + } | |
| 1046 | + //总步数=现有的步数+本次有效步数 | |
| 1047 | + CURRENT_STEP += (thisStep); | |
| 1048 | + Log.e(TAG, "onSensorChanged: 加了以后" + CURRENT_STEP); | |
| 1049 | + lastStep = tempStep; | |
| 1026 | 1050 | } |
| 1027 | - //总步数=现有的步数+本次有效步数 | |
| 1028 | - CURRENT_STEP += (thisStep); | |
| 1029 | - //记录最后一次APP打开到现在的总步数 | |
| 1030 | - previousStepCount = thisStepCount; | |
| 1031 | 1051 | } |
| 1032 | 1052 | } else if (stepSensorType == Sensor.TYPE_STEP_DETECTOR) { |
| 1033 | 1053 | if (event.values[0] == 1.0) { |
| ... | ... | @@ -1053,10 +1073,10 @@ public class StepService extends Service implements SensorEventListener { |
| 1053 | 1073 | * 保存记步数据 |
| 1054 | 1074 | */ |
| 1055 | 1075 | private void save() { |
| 1056 | - boolean isWriteUserStep = CommonInfo.getIsWriteUserStep(getApplicationContext()); | |
| 1057 | - if (!isWriteUserStep) { | |
| 1058 | - return; | |
| 1059 | - } | |
| 1076 | +// boolean isWriteUserStep = CommonInfo.getIsWriteUserStep(getApplicationContext()); | |
| 1077 | +// if (!isWriteUserStep) { | |
| 1078 | +// return; | |
| 1079 | +// } | |
| 1060 | 1080 | int tempStep = CURRENT_STEP; |
| 1061 | 1081 | UserStepEntity userStepEntity = StepUtil.getUserStepData(getApplicationContext(), CommonInfo.getUserId(getApplicationContext())); |
| 1062 | 1082 | if (userStepEntity == null) { | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/DaoMaster.java
| ... | ... | @@ -22,15 +22,15 @@ public class DaoMaster extends AbstractDaoMaster { |
| 22 | 22 | /** Creates underlying database table using DAOs. */ |
| 23 | 23 | public static void createAllTables(Database db, boolean ifNotExists) { |
| 24 | 24 | CollUserStepEntityDao.createTable(db, ifNotExists); |
| 25 | - UserStepEntityDao.createTable(db, ifNotExists); | |
| 26 | 25 | FailedEntityDao.createTable(db, ifNotExists); |
| 26 | + UserStepEntityDao.createTable(db, ifNotExists); | |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** Drops underlying database table using DAOs. */ |
| 30 | 30 | public static void dropAllTables(Database db, boolean ifExists) { |
| 31 | 31 | CollUserStepEntityDao.dropTable(db, ifExists); |
| 32 | - UserStepEntityDao.dropTable(db, ifExists); | |
| 33 | 32 | FailedEntityDao.dropTable(db, ifExists); |
| 33 | + UserStepEntityDao.dropTable(db, ifExists); | |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
| ... | ... | @@ -50,8 +50,8 @@ public class DaoMaster extends AbstractDaoMaster { |
| 50 | 50 | public DaoMaster(Database db) { |
| 51 | 51 | super(db, SCHEMA_VERSION); |
| 52 | 52 | registerDaoClass(CollUserStepEntityDao.class); |
| 53 | - registerDaoClass(UserStepEntityDao.class); | |
| 54 | 53 | registerDaoClass(FailedEntityDao.class); |
| 54 | + registerDaoClass(UserStepEntityDao.class); | |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | public DaoSession newSession() { | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/DaoSession.java
| ... | ... | @@ -9,12 +9,12 @@ import org.greenrobot.greendao.identityscope.IdentityScopeType; |
| 9 | 9 | import org.greenrobot.greendao.internal.DaoConfig; |
| 10 | 10 | |
| 11 | 11 | import com.cnlive.moudle.pedometer.sql.entity.CollUserStepEntity; |
| 12 | -import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; | |
| 13 | 12 | import com.cnlive.moudle.pedometer.sql.entity.FailedEntity; |
| 13 | +import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; | |
| 14 | 14 | |
| 15 | 15 | import com.cnlive.moudle.pedometer.sql.dao.CollUserStepEntityDao; |
| 16 | -import com.cnlive.moudle.pedometer.sql.dao.UserStepEntityDao; | |
| 17 | 16 | import com.cnlive.moudle.pedometer.sql.dao.FailedEntityDao; |
| 17 | +import com.cnlive.moudle.pedometer.sql.dao.UserStepEntityDao; | |
| 18 | 18 | |
| 19 | 19 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. |
| 20 | 20 | |
| ... | ... | @@ -26,12 +26,12 @@ import com.cnlive.moudle.pedometer.sql.dao.FailedEntityDao; |
| 26 | 26 | public class DaoSession extends AbstractDaoSession { |
| 27 | 27 | |
| 28 | 28 | private final DaoConfig collUserStepEntityDaoConfig; |
| 29 | - private final DaoConfig userStepEntityDaoConfig; | |
| 30 | 29 | private final DaoConfig failedEntityDaoConfig; |
| 30 | + private final DaoConfig userStepEntityDaoConfig; | |
| 31 | 31 | |
| 32 | 32 | private final CollUserStepEntityDao collUserStepEntityDao; |
| 33 | - private final UserStepEntityDao userStepEntityDao; | |
| 34 | 33 | private final FailedEntityDao failedEntityDao; |
| 34 | + private final UserStepEntityDao userStepEntityDao; | |
| 35 | 35 | |
| 36 | 36 | public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> |
| 37 | 37 | daoConfigMap) { |
| ... | ... | @@ -40,37 +40,37 @@ public class DaoSession extends AbstractDaoSession { |
| 40 | 40 | collUserStepEntityDaoConfig = daoConfigMap.get(CollUserStepEntityDao.class).clone(); |
| 41 | 41 | collUserStepEntityDaoConfig.initIdentityScope(type); |
| 42 | 42 | |
| 43 | - userStepEntityDaoConfig = daoConfigMap.get(UserStepEntityDao.class).clone(); | |
| 44 | - userStepEntityDaoConfig.initIdentityScope(type); | |
| 45 | - | |
| 46 | 43 | failedEntityDaoConfig = daoConfigMap.get(FailedEntityDao.class).clone(); |
| 47 | 44 | failedEntityDaoConfig.initIdentityScope(type); |
| 48 | 45 | |
| 46 | + userStepEntityDaoConfig = daoConfigMap.get(UserStepEntityDao.class).clone(); | |
| 47 | + userStepEntityDaoConfig.initIdentityScope(type); | |
| 48 | + | |
| 49 | 49 | collUserStepEntityDao = new CollUserStepEntityDao(collUserStepEntityDaoConfig, this); |
| 50 | - userStepEntityDao = new UserStepEntityDao(userStepEntityDaoConfig, this); | |
| 51 | 50 | failedEntityDao = new FailedEntityDao(failedEntityDaoConfig, this); |
| 51 | + userStepEntityDao = new UserStepEntityDao(userStepEntityDaoConfig, this); | |
| 52 | 52 | |
| 53 | 53 | registerDao(CollUserStepEntity.class, collUserStepEntityDao); |
| 54 | - registerDao(UserStepEntity.class, userStepEntityDao); | |
| 55 | 54 | registerDao(FailedEntity.class, failedEntityDao); |
| 55 | + registerDao(UserStepEntity.class, userStepEntityDao); | |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | public void clear() { |
| 59 | 59 | collUserStepEntityDaoConfig.clearIdentityScope(); |
| 60 | - userStepEntityDaoConfig.clearIdentityScope(); | |
| 61 | 60 | failedEntityDaoConfig.clearIdentityScope(); |
| 61 | + userStepEntityDaoConfig.clearIdentityScope(); | |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | public CollUserStepEntityDao getCollUserStepEntityDao() { |
| 65 | 65 | return collUserStepEntityDao; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - public UserStepEntityDao getUserStepEntityDao() { | |
| 69 | - return userStepEntityDao; | |
| 70 | - } | |
| 71 | - | |
| 72 | 68 | public FailedEntityDao getFailedEntityDao() { |
| 73 | 69 | return failedEntityDao; |
| 74 | 70 | } |
| 75 | 71 | |
| 72 | + public UserStepEntityDao getUserStepEntityDao() { | |
| 73 | + return userStepEntityDao; | |
| 74 | + } | |
| 75 | + | |
| 76 | 76 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/entity/FailedEntity.java
| ... | ... | @@ -4,13 +4,16 @@ import org.greenrobot.greendao.annotation.Entity; |
| 4 | 4 | import org.greenrobot.greendao.annotation.Id; |
| 5 | 5 | import org.greenrobot.greendao.annotation.Generated; |
| 6 | 6 | |
| 7 | +import java.io.Serializable; | |
| 8 | + | |
| 7 | 9 | /** |
| 8 | 10 | * 上传失败列表 |
| 9 | 11 | * |
| 10 | 12 | * @author ShinnyYang |
| 11 | 13 | */ |
| 12 | 14 | @Entity |
| 13 | -public class FailedEntity { | |
| 15 | +public class FailedEntity implements Serializable { | |
| 16 | + static final long serialVersionUID = 01L; | |
| 14 | 17 | @Id |
| 15 | 18 | private String uuid;//主键 |
| 16 | 19 | private String uid;//用户id | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/PedometerMainActivity.java
| ... | ... | @@ -2,31 +2,20 @@ package com.cnlive.moudle.pedometer.ui.activity; |
| 2 | 2 | |
| 3 | 3 | import android.Manifest; |
| 4 | 4 | import android.app.Activity; |
| 5 | -import android.content.Context; | |
| 6 | 5 | import android.content.Intent; |
| 7 | -import android.content.pm.PackageInfo; | |
| 8 | -import android.content.pm.PackageManager; | |
| 9 | -import android.location.LocationManager; | |
| 10 | 6 | import android.os.Build; |
| 11 | 7 | import android.provider.Settings; |
| 12 | 8 | import android.os.Bundle; |
| 13 | 9 | import android.support.annotation.NonNull; |
| 14 | 10 | import android.support.v4.app.NotificationManagerCompat; |
| 15 | -import android.support.v4.content.ContextCompat; | |
| 16 | 11 | import android.text.TextUtils; |
| 17 | 12 | import android.util.Log; |
| 18 | -import android.view.KeyEvent; | |
| 19 | 13 | import android.widget.Toast; |
| 20 | 14 | |
| 21 | 15 | import com.alibaba.android.arouter.facade.annotation.Route; |
| 22 | -import com.baidu.mapapi.CoordType; | |
| 23 | -import com.baidu.mapapi.SDKInitializer; | |
| 24 | 16 | import com.baidu.mapapi.model.LatLng; |
| 25 | -import com.cnlive.libs.base.ui.QMUIFragment; | |
| 26 | 17 | import com.cnlive.libs.base.ui.QMUIFragmentActivity; |
| 27 | -import com.cnlive.libs.base.util.StatusBarUtil; | |
| 28 | -import com.cnlive.libs.base.util.StatusBarUtil2; | |
| 29 | -import com.cnlive.moudle.collectionTrace.ui.activity.CollPedometerMainActivity; | |
| 18 | +import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo; | |
| 30 | 19 | import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment; |
| 31 | 20 | import com.cnlive.moudle.pedometer.utils.MyMapUtil; |
| 32 | 21 | import com.cnlive.moudle.pedometer.utils.lib_permisshelper.PermissionsListener; |
| ... | ... | @@ -47,13 +36,11 @@ import static android.provider.Settings.EXTRA_APP_PACKAGE; |
| 47 | 36 | public class PedometerMainActivity extends QMUIFragmentActivity { |
| 48 | 37 | private static final String TAG = "PedometerMainActivity"; |
| 49 | 38 | |
| 50 | - private NotificationManagerCompat notificationManagerCompat; | |
| 51 | - private boolean isOpen; | |
| 39 | + | |
| 52 | 40 | private PermissionsUtils mPermissionsUtils = new PermissionsUtils();//权限申请 |
| 53 | 41 | private RunMainFragment fragment; |
| 54 | - private String startPointAdd; | |
| 55 | - private String endPointAdd; | |
| 56 | 42 | private List<LatLng> importStreetPoints; |
| 43 | + private RunRaceDetailInfo runRaceDetailInfo; | |
| 57 | 44 | |
| 58 | 45 | @Override |
| 59 | 46 | protected int getContextViewId() { |
| ... | ... | @@ -63,9 +50,7 @@ public class PedometerMainActivity extends QMUIFragmentActivity { |
| 63 | 50 | @Override |
| 64 | 51 | protected void onCreate(Bundle savedInstanceState) { |
| 65 | 52 | super.onCreate(savedInstanceState); |
| 66 | - startPointAdd = getIntent().getExtras().getString("startPointAdd"); | |
| 67 | - endPointAdd = getIntent().getExtras().getString("endPointAdd"); | |
| 68 | - importStreetPoints = (List<LatLng>) getIntent().getExtras().getSerializable("importStreetPoints"); | |
| 53 | + runRaceDetailInfo = (RunRaceDetailInfo) getIntent().getExtras().get("runRaceDetailInfo"); | |
| 69 | 54 | } |
| 70 | 55 | |
| 71 | 56 | |
| ... | ... | @@ -74,51 +59,10 @@ public class PedometerMainActivity extends QMUIFragmentActivity { |
| 74 | 59 | super.onDestroy(); |
| 75 | 60 | } |
| 76 | 61 | |
| 77 | - private void check() { | |
| 78 | - | |
| 79 | - //监测通知权限是否打开 | |
| 80 | - notificationManagerCompat = NotificationManagerCompat.from(this); | |
| 81 | - isOpen = notificationManagerCompat.areNotificationsEnabled(); | |
| 82 | - if (isOpen) { | |
| 83 | - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |
| 84 | -// ContextCompat.startForegroundService(CollPedometerMainActivity.this, new Intent(CollPedometerMainActivity.this, CollStepService.class)); | |
| 85 | - } | |
| 86 | - } else { | |
| 87 | - goToSettingNo(); | |
| 88 | - } | |
| 62 | + private void checkIsOpenNotifiction() { | |
| 63 | + getPermissionsWithTip(); | |
| 89 | 64 | } |
| 90 | 65 | |
| 91 | - private void goToSettingNo() { | |
| 92 | - Intent intent1 = new Intent(); | |
| 93 | - try { | |
| 94 | - // 根据isOpened结果,判断是否需要提醒用户跳转AppInfo页面,去打开App通知权限 | |
| 95 | - intent1.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS); | |
| 96 | - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |
| 97 | - //这种方案适用于 API 26, 即8.0(含8.0)以上可以用 | |
| 98 | - intent1.putExtra(EXTRA_APP_PACKAGE, getPackageName()); | |
| 99 | - intent1.putExtra(EXTRA_CHANNEL_ID, getApplicationInfo().uid); | |
| 100 | - } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | |
| 101 | - //这种方案适用于 API21——25,即 5.0——7.1 之间的版本可以使用 | |
| 102 | - intent1.putExtra("app_package", getPackageName()); | |
| 103 | - intent1.putExtra("app_uid", getApplicationInfo().uid); | |
| 104 | - } | |
| 105 | - | |
| 106 | - // 小米6 -MIUI9.6-8.0.0系统,是个特例,通知设置界面只能控制"允许使用通知圆点"——然而这个玩意并没有卵用,我想对雷布斯说:I'm not ok!!! | |
| 107 | - // if ("MI 6".equals(Build.MODEL)) { | |
| 108 | - // intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); | |
| 109 | - // Uri uri = Uri.fromParts("package", getPackageName(), null); | |
| 110 | - // intent.setData(uri); | |
| 111 | - // // intent.setAction("com.android.settings/.SubSettings"); | |
| 112 | - // } | |
| 113 | - startActivity(intent1); | |
| 114 | - } catch (Exception e) { | |
| 115 | - //其他低版本或者异常情况,走该节点。进入APP设置界面 | |
| 116 | - intent1.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); | |
| 117 | - intent1.putExtra("package", getPackageName()); | |
| 118 | - startActivity(intent1); | |
| 119 | - } | |
| 120 | - Toast.makeText(getApplicationContext(), "您尚未开启通知权限,无法进行计步", Toast.LENGTH_LONG).show(); | |
| 121 | - } | |
| 122 | 66 | |
| 123 | 67 | @Override |
| 124 | 68 | protected void onRestart() { |
| ... | ... | @@ -129,12 +73,11 @@ public class PedometerMainActivity extends QMUIFragmentActivity { |
| 129 | 73 | @Override |
| 130 | 74 | protected void onResume() { |
| 131 | 75 | super.onResume(); |
| 132 | - check(); | |
| 133 | - getPermissionsWithTip(); | |
| 76 | + checkIsOpenNotifiction(); | |
| 134 | 77 | } |
| 135 | 78 | |
| 136 | - private void addFragment(String startPointAdd, String endPointAdd, List<LatLng> importStreetPoints) { | |
| 137 | - fragment = RunMainFragment.newInstance(startPointAdd, endPointAdd, importStreetPoints); | |
| 79 | + private void addFragment(RunRaceDetailInfo runRaceDetailInfo) { | |
| 80 | + fragment = RunMainFragment.newInstance(runRaceDetailInfo); | |
| 138 | 81 | getSupportFragmentManager().beginTransaction() |
| 139 | 82 | .add(getContextViewId(), fragment, fragment.getClass().getSimpleName()) |
| 140 | 83 | .addToBackStack(fragment.getClass().getSimpleName()) |
| ... | ... | @@ -165,8 +108,8 @@ public class PedometerMainActivity extends QMUIFragmentActivity { |
| 165 | 108 | Toast.makeText(getApplicationContext(), getString(R.string.open_gps_tip), Toast.LENGTH_LONG).show(); |
| 166 | 109 | } else { |
| 167 | 110 | if (getCurrentFragment() == null) { |
| 168 | - if (!TextUtils.isEmpty(startPointAdd) && !TextUtils.isEmpty(endPointAdd) && importStreetPoints != null) { | |
| 169 | - addFragment(startPointAdd, endPointAdd, importStreetPoints); | |
| 111 | + if (runRaceDetailInfo != null) { | |
| 112 | + addFragment(runRaceDetailInfo); | |
| 170 | 113 | } |
| 171 | 114 | } |
| 172 | 115 | } |
| ... | ... | @@ -213,11 +156,9 @@ public class PedometerMainActivity extends QMUIFragmentActivity { |
| 213 | 156 | return; |
| 214 | 157 | } |
| 215 | 158 | |
| 216 | - public static void startActivity(Activity activity, String startPointAdd, String endPointAdd, List<LatLng> importStreetPoints) { | |
| 159 | + public static void startActivity(Activity activity, RunRaceDetailInfo runRaceDetailInfo) { | |
| 217 | 160 | Intent intent = new Intent(activity, PedometerMainActivity.class); |
| 218 | - intent.putExtra("startPointAdd", startPointAdd); | |
| 219 | - intent.putExtra("endPointAdd", endPointAdd); | |
| 220 | - intent.putExtra("importStreetPoints", (Serializable) importStreetPoints); | |
| 161 | + intent.putExtra("runRaceDetailInfo", (Serializable) runRaceDetailInfo); | |
| 221 | 162 | activity.startActivity(intent); |
| 222 | 163 | } |
| 223 | 164 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/RunRaceDetailActivity.java
| ... | ... | @@ -30,6 +30,7 @@ import com.cnlive.moudle.pedometer.ui.fragment.RunRaceDetailFragment; |
| 30 | 30 | import com.cnlive.moudle.pedometer.ui.fragment.RunningMapFragment; |
| 31 | 31 | import com.cnlive.moudle.pedometer.ui.widget.FivePersonIconView; |
| 32 | 32 | import com.cnlive.moudle.pedometer.utils.MyMapUtil; |
| 33 | +import com.cnlive.moudle.pedometer.utils.NotificationUtil; | |
| 33 | 34 | import com.cnlive.moudle.pedometer.utils.StepUtil; |
| 34 | 35 | import com.cnlive.moudle.pedometer.utils.lib_permisshelper.PermissionsListener; |
| 35 | 36 | import com.cnlive.moudle.pedometer.utils.lib_permisshelper.PermissionsUtils; |
| ... | ... | @@ -47,6 +48,7 @@ import java.util.List; |
| 47 | 48 | public class RunRaceDetailActivity extends QMUIFragmentActivity { |
| 48 | 49 | private QMUIFragment fragment; |
| 49 | 50 | private PermissionsUtils mPermissionsUtils = new PermissionsUtils();//权限申请 |
| 51 | + private String eventId;//赛道id | |
| 50 | 52 | |
| 51 | 53 | public static void startActivity(Activity activity, String eventId, String userId, String userIcon, String userName, String userPhone) { |
| 52 | 54 | Intent intent = new Intent(activity, RunRaceDetailActivity.class); |
| ... | ... | @@ -55,7 +57,6 @@ public class RunRaceDetailActivity extends QMUIFragmentActivity { |
| 55 | 57 | intent.putExtra("userIcon", userIcon); |
| 56 | 58 | intent.putExtra("userName", userName); |
| 57 | 59 | intent.putExtra("userPhone", userPhone); |
| 58 | - CommonInfo.setStreetId(activity, eventId); | |
| 59 | 60 | activity.startActivity(intent); |
| 60 | 61 | } |
| 61 | 62 | |
| ... | ... | @@ -67,12 +68,15 @@ public class RunRaceDetailActivity extends QMUIFragmentActivity { |
| 67 | 68 | @Override |
| 68 | 69 | protected void onCreate(Bundle savedInstanceState) { |
| 69 | 70 | super.onCreate(savedInstanceState); |
| 70 | - | |
| 71 | + if (getIntent().getStringExtra("eventId") != null) { | |
| 72 | + eventId = getIntent().getStringExtra("eventId"); | |
| 73 | + } | |
| 71 | 74 | if (getIntent().getStringExtra("userId") != null) { |
| 72 | 75 | CommonInfo.setUserId(this, getIntent().getStringExtra("userId")); |
| 73 | 76 | CommonInfo.setUserNickName(this, getIntent().getStringExtra("userName")); |
| 74 | 77 | CommonInfo.setUserIcon(this, getIntent().getStringExtra("userIcon")); |
| 75 | 78 | CommonInfo.setUserPhone(this, getIntent().getStringExtra("userPhone")); |
| 79 | + | |
| 76 | 80 | } |
| 77 | 81 | //判断用户是否结束运动 |
| 78 | 82 | // boolean isRunStep = CommonInfo.getIsRunStepService(this); |
| ... | ... | @@ -90,7 +94,23 @@ public class RunRaceDetailActivity extends QMUIFragmentActivity { |
| 90 | 94 | @Override |
| 91 | 95 | protected void onResume() { |
| 92 | 96 | super.onResume(); |
| 93 | - getPermissionsWithTip(); | |
| 97 | + if (eventId != null) { | |
| 98 | + CommonInfo.setStreetId(this, eventId); | |
| 99 | + Log.e("设置全局eventId", "onResume: " + eventId); | |
| 100 | + } | |
| 101 | + boolean isOpen = NotificationUtil.isOpenNotification(this); | |
| 102 | + if (isOpen) { | |
| 103 | + //判断GPS是否开启 | |
| 104 | + if (!MyMapUtil.isOPenGps(getApplicationContext())) { | |
| 105 | + Toast.makeText(getApplicationContext(), getString(R.string.open_gps_tip), Toast.LENGTH_LONG).show(); | |
| 106 | + //开启GPS | |
| 107 | + Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); | |
| 108 | + startActivityForResult(intent, 10); | |
| 109 | + } else { | |
| 110 | + getPermissionsWithTip(); | |
| 111 | + } | |
| 112 | + } | |
| 113 | + | |
| 94 | 114 | } |
| 95 | 115 | |
| 96 | 116 | private void addFragment(QMUIFragment fragment) { |
| ... | ... | @@ -123,17 +143,9 @@ public class RunRaceDetailActivity extends QMUIFragmentActivity { |
| 123 | 143 | |
| 124 | 144 | @Override |
| 125 | 145 | public void onGranted() { |
| 126 | - //判断GPS是否开启 | |
| 127 | - if (!MyMapUtil.isOPenGps(getApplicationContext())) { | |
| 128 | - //开启GPS | |
| 129 | - Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); | |
| 130 | - startActivityForResult(intent, 10); | |
| 131 | - Toast.makeText(getApplicationContext(), getString(R.string.open_gps_tip), Toast.LENGTH_LONG).show(); | |
| 132 | - } else { | |
| 133 | - if (getCurrentFragment() == null) { | |
| 134 | - if (fragment != null) { | |
| 135 | - addFragment(fragment); | |
| 136 | - } | |
| 146 | + if (getCurrentFragment() == null) { | |
| 147 | + if (fragment != null) { | |
| 148 | + addFragment(fragment); | |
| 137 | 149 | } |
| 138 | 150 | } |
| 139 | 151 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/UploadFailDetailActivity.java
0 → 100644
| 1 | +package com.cnlive.moudle.pedometer.ui.activity; | |
| 2 | + | |
| 3 | +import android.app.Activity; | |
| 4 | +import android.content.Intent; | |
| 5 | +import android.os.Bundle; | |
| 6 | + | |
| 7 | +import com.cnlive.libs.base.ui.QMUIFragment; | |
| 8 | +import com.cnlive.libs.base.ui.QMUIFragmentActivity; | |
| 9 | +import com.cnlive.moudle.pedometer.sql.entity.FailedEntity; | |
| 10 | +import com.cnlive.moudle.pedometer.ui.fragment.UploadFailDetailFragment; | |
| 11 | +import com.example.moudle_pedometer.R; | |
| 12 | + | |
| 13 | +import java.io.Serializable; | |
| 14 | + | |
| 15 | +public class UploadFailDetailActivity extends QMUIFragmentActivity { | |
| 16 | + @Override | |
| 17 | + protected int getContextViewId() { | |
| 18 | + return R.id.fragment_upload_fail; | |
| 19 | + } | |
| 20 | + | |
| 21 | + @Override | |
| 22 | + protected void onCreate(Bundle savedInstanceState) { | |
| 23 | + super.onCreate(savedInstanceState); | |
| 24 | + FailedEntity failedEntity = (FailedEntity) getIntent().getExtras().getSerializable("failedEntity"); | |
| 25 | + if (failedEntity != null) { | |
| 26 | + addFragment(UploadFailDetailFragment.newInstance(failedEntity)); | |
| 27 | + } | |
| 28 | + } | |
| 29 | + private void addFragment(QMUIFragment fragment) { | |
| 30 | + getSupportFragmentManager().beginTransaction() | |
| 31 | + .add(getContextViewId(), fragment, fragment.getClass().getSimpleName()) | |
| 32 | + .addToBackStack(fragment.getClass().getSimpleName()) | |
| 33 | + .commit(); | |
| 34 | + } | |
| 35 | + public static void startActivity(Activity activity, FailedEntity failedEntity) { | |
| 36 | + Intent intent = new Intent(activity, UploadFailDetailActivity.class); | |
| 37 | + intent.putExtra("failedEntity", (Serializable) failedEntity); | |
| 38 | + activity.startActivity(intent); | |
| 39 | + } | |
| 40 | +} | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/adapter/LineUpAgainAdapter.java
| ... | ... | @@ -60,7 +60,6 @@ public class LineUpAgainAdapter extends RecyclerView.Adapter<LineUpAgainAdapter. |
| 60 | 60 | myHolder.up_item_title.setText(list.get(i).getStreetTitle()); |
| 61 | 61 | //设置公里 |
| 62 | 62 | myHolder.up_kilometer_num.setText(list.get(i).getDistance()); |
| 63 | - Log.e("时间", "onBindViewHolder: "+list.get(i).getTime() ); | |
| 64 | 63 | //设置运动时间 |
| 65 | 64 | myHolder.up_record_minit.setText(TimeUtil.stampToChronometer(Long.parseLong(list.get(i).getTime()))); |
| 66 | 65 | //设置配速 | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/LineUpAgainFragment.java
| ... | ... | @@ -7,15 +7,20 @@ import android.support.annotation.Nullable; |
| 7 | 7 | import android.view.View; |
| 8 | 8 | |
| 9 | 9 | import com.cnlive.libs.base.frame.fragment.MvpBindingFragment; |
| 10 | +import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; | |
| 10 | 11 | import com.cnlive.moudle.pedometer.frame.presenter.LineUpAgainPresenter; |
| 11 | 12 | import com.cnlive.moudle.pedometer.frame.view.LineUpAgainView; |
| 13 | +import com.cnlive.moudle.pedometer.sql.entity.FailedEntity; | |
| 14 | +import com.cnlive.moudle.pedometer.utils.StepUtil; | |
| 12 | 15 | import com.example.moudle_pedometer.R; |
| 13 | 16 | import com.example.moudle_pedometer.databinding.FragmentLineUpAgainBinding; |
| 14 | 17 | |
| 18 | +import java.util.List; | |
| 19 | + | |
| 15 | 20 | /** |
| 16 | 21 | * Created by hanyayun 019/06/20. |
| 17 | 22 | */ |
| 18 | -public class LineUpAgainFragment extends MvpBindingFragment<LineUpAgainView, LineUpAgainPresenter,Object,FragmentLineUpAgainBinding> { | |
| 23 | +public class LineUpAgainFragment extends MvpBindingFragment<LineUpAgainView, LineUpAgainPresenter, Object, FragmentLineUpAgainBinding> { | |
| 19 | 24 | |
| 20 | 25 | |
| 21 | 26 | public LineUpAgainFragment() { |
| ... | ... | @@ -31,7 +36,16 @@ public class LineUpAgainFragment extends MvpBindingFragment<LineUpAgainView, Lin |
| 31 | 36 | @Override |
| 32 | 37 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
| 33 | 38 | super.onViewCreated(view, savedInstanceState); |
| 34 | - if(getMvpView() != null) getMvpView().initView(); | |
| 39 | + List<FailedEntity> failedEntities = StepUtil.getFailListData(getActivity(), CommonInfo.getUserId(getActivity())); | |
| 40 | + | |
| 41 | + if (getMvpView() != null) { | |
| 42 | + getMvpView().initView(); | |
| 43 | + if (failedEntities == null||failedEntities.size()<1) { | |
| 44 | + binding.llNoFailTip.setVisibility(View.VISIBLE); | |
| 45 | + } else { | |
| 46 | + getMvpView().setData(failedEntities); | |
| 47 | + } | |
| 48 | + } | |
| 35 | 49 | binding.refreshLayout.setEnableLoadMore(false); |
| 36 | 50 | binding.refreshLayout.setEnableRefresh(false); |
| 37 | 51 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunMainFragment.java
| ... | ... | @@ -16,6 +16,7 @@ import com.cnlive.moudle.pedometer.frame.presenter.RunMainFragmentPresenter; |
| 16 | 16 | import com.cnlive.moudle.pedometer.frame.view.RunMainFragmentView; |
| 17 | 17 | import com.cnlive.moudle.pedometer.model.Constant; |
| 18 | 18 | import com.cnlive.moudle.pedometer.model.MessageEvent; |
| 19 | +import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo; | |
| 19 | 20 | import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; |
| 20 | 21 | import com.cnlive.moudle.pedometer.utils.GsonUtil; |
| 21 | 22 | import com.cnlive.moudle.pedometer.utils.StepUtil; |
| ... | ... | @@ -31,17 +32,12 @@ import java.io.Serializable; |
| 31 | 32 | import java.util.List; |
| 32 | 33 | |
| 33 | 34 | public class RunMainFragment extends QMUIFragment<RunMainFragmentView, RunMainFragmentPresenter, FragmentRunMainBinding> { |
| 34 | - private final String TAG = "CollRunMainFragment"; | |
| 35 | - private String userId = "yangshuai"; | |
| 36 | - private String startPointAdd; | |
| 37 | - private String endPointAdd; | |
| 38 | - private List<LatLng> importStreetPoints; | |
| 35 | + private final String TAG = "RunMainFragment"; | |
| 36 | + private RunRaceDetailInfo runRaceDetailInfo; | |
| 39 | 37 | |
| 40 | - public static RunMainFragment newInstance(String startPointAdd, String endPointAdd, List<LatLng> importStreetPoints) { | |
| 38 | + public static RunMainFragment newInstance(RunRaceDetailInfo runRaceDetailInfo) { | |
| 41 | 39 | Bundle bundle = new Bundle(); |
| 42 | - bundle.putString("startPointAdd", startPointAdd); | |
| 43 | - bundle.putString("endPointAdd", endPointAdd); | |
| 44 | - bundle.putSerializable("importStreetPoints", (Serializable) importStreetPoints); | |
| 40 | + bundle.putSerializable("runRaceDetailInfo", (Serializable) runRaceDetailInfo); | |
| 45 | 41 | RunMainFragment fragment = new RunMainFragment(); |
| 46 | 42 | fragment.setArguments(bundle); |
| 47 | 43 | return fragment; |
| ... | ... | @@ -54,30 +50,31 @@ public class RunMainFragment extends QMUIFragment<RunMainFragmentView, RunMainFr |
| 54 | 50 | StatusBarUtil2.setColor(getActivity(), getResources().getColor(R.color.run_main_bg), 0); |
| 55 | 51 | EventBus.getDefault().register(this); |
| 56 | 52 | if (getArguments() != null) { |
| 57 | - startPointAdd = getArguments().getString("startPointAdd"); | |
| 58 | - endPointAdd = getArguments().getString("endPointAdd"); | |
| 59 | - importStreetPoints = (List<LatLng>) getArguments().getSerializable("importStreetPoints"); | |
| 53 | + runRaceDetailInfo = (RunRaceDetailInfo) getArguments().getSerializable("runRaceDetailInfo"); | |
| 60 | 54 | UserStepEntity userStepEntity = StepUtil.getUserStepData(getActivity(), CommonInfo.getUserId(getActivity())); |
| 61 | 55 | if (userStepEntity != null) { |
| 62 | - if (!TextUtils.isEmpty(startPointAdd) && !TextUtils.isEmpty(endPointAdd)) { | |
| 63 | - userStepEntity.setStartPoint(startPointAdd); | |
| 64 | - userStepEntity.setEndPoint(endPointAdd); | |
| 56 | + if (runRaceDetailInfo != null) { | |
| 57 | + userStepEntity.setStartPoint(runRaceDetailInfo.getStartLocation()); | |
| 58 | + userStepEntity.setEndPoint(runRaceDetailInfo.getEndLocation()); | |
| 65 | 59 | //更新数据 |
| 66 | 60 | StepUtil.updateStepData(getActivity(), userStepEntity); |
| 61 | + //获取数据库中的重要点 | |
| 62 | + String importStr = userStepEntity.getImportPoint(); | |
| 63 | + if (TextUtils.isEmpty(runRaceDetailInfo.getLatLongitude())) { | |
| 64 | + //设置重要点 | |
| 65 | + StepUtil.setImportPoints(getActivity(), CommonInfo.getUserId(getActivity()), GsonUtil.GsonString(runRaceDetailInfo.getLatLongitude())); | |
| 66 | + } | |
| 67 | 67 | } |
| 68 | - //获取数据库中的重要点 | |
| 69 | - String importStr = userStepEntity.getImportPoint(); | |
| 70 | - if (TextUtils.isEmpty(importStr) && importStreetPoints != null) { | |
| 71 | - //设置重要点 | |
| 72 | - StepUtil.setImportPoints(getActivity(), CommonInfo.getUserId(getActivity()), GsonUtil.GsonString(importStreetPoints)); | |
| 73 | - } | |
| 68 | + | |
| 74 | 69 | } |
| 75 | 70 | } |
| 76 | 71 | if (getMvpView() != null) { |
| 77 | 72 | new Handler().postDelayed(new Runnable() { |
| 78 | 73 | @Override |
| 79 | 74 | public void run() { |
| 80 | - getMvpView().initView(); | |
| 75 | + if (runRaceDetailInfo != null) { | |
| 76 | + getMvpView().initView(runRaceDetailInfo); | |
| 77 | + } | |
| 81 | 78 | } |
| 82 | 79 | }, 5); |
| 83 | 80 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunRaceDetailFragment.java
| ... | ... | @@ -64,6 +64,7 @@ public class RunRaceDetailFragment extends QMUIFragment<RunRaceDetailFragmentVie |
| 64 | 64 | if (getMvpView() != null) { |
| 65 | 65 | getMvpView().initMap(); |
| 66 | 66 | } |
| 67 | + | |
| 67 | 68 | if (getPresenter() != null) { |
| 68 | 69 | if (!TextUtils.isEmpty(CommonInfo.getStreetId(getActivity()))) { |
| 69 | 70 | getPresenter().getRunRaceDetailInfo(getActivity(), CommonInfo.getStreetId(getActivity()), CommonInfo.getUserId(getActivity()), "0"); |
| ... | ... | @@ -179,7 +180,7 @@ public class RunRaceDetailFragment extends QMUIFragment<RunRaceDetailFragmentVie |
| 179 | 180 | if (getMvpView() != null) { |
| 180 | 181 | Log.e(TAG, "跳转: " + getMvpView().importStreetPoints.size()); |
| 181 | 182 | QMUITipDialogUtil.dismessDialog(); |
| 182 | - PedometerMainActivity.startActivity(getActivity(), binding.includeStreet.tvStartAddr.getText().toString(), binding.includeStreet.tvEndAddr.getText().toString(), getMvpView().importStreetPoints); | |
| 183 | + PedometerMainActivity.startActivity(getActivity(), getMvpView().runRaceDetailInfo); | |
| 183 | 184 | } |
| 184 | 185 | } |
| 185 | 186 | //启动鹰眼失败 | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunningFinishFragment.java
| ... | ... | @@ -3,6 +3,7 @@ package com.cnlive.moudle.pedometer.ui.fragment; |
| 3 | 3 | import android.os.Bundle; |
| 4 | 4 | import android.os.Handler; |
| 5 | 5 | import android.support.annotation.Nullable; |
| 6 | +import android.util.Log; | |
| 6 | 7 | import android.view.View; |
| 7 | 8 | |
| 8 | 9 | import com.cnlive.libs.base.ui.QMUIFragment; |
| ... | ... | @@ -55,20 +56,13 @@ public class RunningFinishFragment extends QMUIFragment<RunningFinishFragmentVie |
| 55 | 56 | getMvpView().initView(runningFinishBean); |
| 56 | 57 | } |
| 57 | 58 | } |
| 59 | + UserStepEntity userStepEntity = StepUtil.getUserStepData(getActivity(), CommonInfo.getUserId(getActivity())); | |
| 60 | + if (getMvpView() != null && userStepEntity != null) { | |
| 61 | +// getPresenter().getServerStreetTrace(getActivity(), userStepEntity); | |
| 62 | + getPresenter().queryHistoryTrace(getActivity(), userStepEntity, runningFinishBean); | |
| 63 | + } | |
| 58 | 64 | } |
| 59 | - UserStepEntity userStepEntity = StepUtil.getUserStepData(getActivity(), CommonInfo.getUserId(getActivity())); | |
| 60 | - if (getMvpView() != null && userStepEntity != null) { | |
| 61 | - QMUITipDialogUtil.loadingDialog(getContext(), "正在获取轨迹信息,请稍后", false); | |
| 62 | - getPresenter().getServerStreetTrace(getActivity(), userStepEntity); | |
| 63 | - new Handler().postDelayed(new Runnable() { | |
| 64 | - @Override | |
| 65 | - public void run() { | |
| 66 | - getPresenter().queryHistoryTrace(getActivity(), userStepEntity, runningFinishBean); | |
| 67 | - } | |
| 68 | - },2000); | |
| 69 | -// StepUtil.clearRunData(context, CommonInfo.getUserId(context)); | |
| 70 | -// CommonInfo.reset(context); | |
| 71 | - } | |
| 65 | + | |
| 72 | 66 | |
| 73 | 67 | } |
| 74 | 68 | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/UploadFailDetailFragment.java
0 → 100644
| 1 | +package com.cnlive.moudle.pedometer.ui.fragment; | |
| 2 | + | |
| 3 | +import android.os.Bundle; | |
| 4 | +import android.support.annotation.Nullable; | |
| 5 | +import android.view.View; | |
| 6 | + | |
| 7 | +import com.cnlive.libs.base.ui.QMUIFragment; | |
| 8 | +import com.cnlive.libs.base.util.StatusBarUtil2; | |
| 9 | +import com.cnlive.moudle.pedometer.frame.presenter.UploadFailDetailFragmentPresenter; | |
| 10 | +import com.cnlive.moudle.pedometer.frame.view.UploadFailDetailFragmentView; | |
| 11 | +import com.cnlive.moudle.pedometer.sql.entity.FailedEntity; | |
| 12 | +import com.example.moudle_pedometer.R; | |
| 13 | +import com.example.moudle_pedometer.databinding.FragmentFinishRunMapBinding; | |
| 14 | + | |
| 15 | +import java.io.Serializable; | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * 重新 上传详情页面 | |
| 19 | + * | |
| 20 | + * @author ShinnyYang | |
| 21 | + */ | |
| 22 | +public class UploadFailDetailFragment extends QMUIFragment<UploadFailDetailFragmentView, UploadFailDetailFragmentPresenter, FragmentFinishRunMapBinding> { | |
| 23 | + private FailedEntity failedEntity; | |
| 24 | + | |
| 25 | + @Override | |
| 26 | + protected int getToolbarId() { | |
| 27 | + return 0; | |
| 28 | + } | |
| 29 | + | |
| 30 | + @Override | |
| 31 | + public String getTitle() { | |
| 32 | + return null; | |
| 33 | + } | |
| 34 | + | |
| 35 | + @Override | |
| 36 | + protected int getLayoutId() { | |
| 37 | + return R.layout.fragment_finish_run_map; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public static UploadFailDetailFragment newInstance(FailedEntity failedEntity) { | |
| 41 | + UploadFailDetailFragment failDetailFragment = new UploadFailDetailFragment(); | |
| 42 | + Bundle bundle = new Bundle(); | |
| 43 | + bundle.putSerializable("failedEntity", (Serializable) failedEntity); | |
| 44 | + failDetailFragment.setArguments(bundle); | |
| 45 | + return failDetailFragment; | |
| 46 | + } | |
| 47 | + | |
| 48 | + @Override | |
| 49 | + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | |
| 50 | + super.onViewCreated(view, savedInstanceState); | |
| 51 | + StatusBarUtil2.setColor(getActivity(), getResources().getColor(R.color.run_main_bg), 0); | |
| 52 | + | |
| 53 | + if (getArguments() != null) { | |
| 54 | + failedEntity = (FailedEntity) getArguments().getSerializable("failedEntity"); | |
| 55 | + if (failedEntity != null) { | |
| 56 | + if (getMvpView() != null) { | |
| 57 | + getMvpView().initView(failedEntity); | |
| 58 | + } | |
| 59 | + } | |
| 60 | + } | |
| 61 | + } | |
| 62 | +} | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/GsonUtil.java
| ... | ... | @@ -66,13 +66,17 @@ public class GsonUtil { |
| 66 | 66 | * @return |
| 67 | 67 | */ |
| 68 | 68 | public static <T> List<T> jsonToList(String json, Class<T> cls) { |
| 69 | - Gson gson = new Gson(); | |
| 70 | - List<T> list = new ArrayList<T>(); | |
| 71 | - JsonArray array = new JsonParser().parse(json).getAsJsonArray(); | |
| 72 | - for (final JsonElement elem : array) { | |
| 73 | - list.add(gson.fromJson(elem, cls)); | |
| 69 | + try { | |
| 70 | + Gson gson = new Gson(); | |
| 71 | + List<T> list = new ArrayList<T>(); | |
| 72 | + JsonArray array = new JsonParser().parse(json).getAsJsonArray(); | |
| 73 | + for (final JsonElement elem : array) { | |
| 74 | + list.add(gson.fromJson(elem, cls)); | |
| 75 | + } | |
| 76 | + return list; | |
| 77 | + } catch (Exception e) { | |
| 78 | + return null; | |
| 74 | 79 | } |
| 75 | - return list; | |
| 76 | 80 | } |
| 77 | 81 | |
| 78 | 82 | |
| ... | ... | @@ -89,9 +93,9 @@ public class GsonUtil { |
| 89 | 93 | new TypeToken<List<Map<String, String>>>() { |
| 90 | 94 | }.getType()); |
| 91 | 95 | } |
| 92 | - for(int i=0;i<list.size();i++){ | |
| 93 | - for(Map.Entry<String, String> entry:list.get(i).entrySet()){ | |
| 94 | - if(entry.getValue()==null) { | |
| 96 | + for (int i = 0; i < list.size(); i++) { | |
| 97 | + for (Map.Entry<String, String> entry : list.get(i).entrySet()) { | |
| 98 | + if (entry.getValue() == null) { | |
| 95 | 99 | entry.setValue(""); |
| 96 | 100 | } |
| 97 | 101 | } |
| ... | ... | @@ -100,7 +104,6 @@ public class GsonUtil { |
| 100 | 104 | } |
| 101 | 105 | |
| 102 | 106 | |
| 103 | - | |
| 104 | 107 | /** |
| 105 | 108 | * 转成map的 |
| 106 | 109 | * |
| ... | ... | @@ -118,31 +121,31 @@ public class GsonUtil { |
| 118 | 121 | |
| 119 | 122 | /** |
| 120 | 123 | * 过滤null |
| 124 | + * | |
| 121 | 125 | * @param jsonElement |
| 122 | 126 | * @return |
| 123 | 127 | */ |
| 124 | - public static String StrConver(JsonElement jsonElement){ | |
| 125 | - if(jsonElement==null||jsonElement.isJsonNull()||jsonElement.equals("null")){ | |
| 128 | + public static String StrConver(JsonElement jsonElement) { | |
| 129 | + if (jsonElement == null || jsonElement.isJsonNull() || jsonElement.equals("null")) { | |
| 126 | 130 | return ""; |
| 127 | - } | |
| 128 | - else { | |
| 131 | + } else { | |
| 129 | 132 | return jsonElement.getAsString(); |
| 130 | 133 | } |
| 131 | 134 | } |
| 132 | - public static int IntConver(JsonElement jsonElement){ | |
| 133 | - if(jsonElement.isJsonNull()){ | |
| 135 | + | |
| 136 | + public static int IntConver(JsonElement jsonElement) { | |
| 137 | + if (jsonElement.isJsonNull()) { | |
| 134 | 138 | return 0; |
| 135 | - } | |
| 136 | - else { | |
| 139 | + } else { | |
| 137 | 140 | return jsonElement.getAsInt(); |
| 138 | 141 | } |
| 139 | 142 | } |
| 140 | 143 | |
| 141 | - public static JsonObject toJsonObject(String str){ | |
| 144 | + public static JsonObject toJsonObject(String str) { | |
| 142 | 145 | return new JsonParser().parse(str).getAsJsonObject(); |
| 143 | 146 | } |
| 144 | 147 | |
| 145 | - public static JsonArray toJsonArray(String str){ | |
| 148 | + public static JsonArray toJsonArray(String str) { | |
| 146 | 149 | return new JsonParser().parse(str).getAsJsonArray(); |
| 147 | 150 | } |
| 148 | 151 | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/MyMapUtil.java
| ... | ... | @@ -92,7 +92,7 @@ public class MyMapUtil { |
| 92 | 92 | LatLng importLatLng = importPoints.get(i); |
| 93 | 93 | for (int j = index; j < trackPoints.size(); j++) { |
| 94 | 94 | double distance = DistanceUtil.getDistance(importLatLng, trackPoints.get(j)); |
| 95 | - if (distance < 50) { | |
| 95 | + if (distance < Constant.CHECK_ACCURACY) { | |
| 96 | 96 | importHash.put(i, true); |
| 97 | 97 | index = j; |
| 98 | 98 | } |
| ... | ... | @@ -168,21 +168,23 @@ public class MyMapUtil { |
| 168 | 168 | Log.e(TAG, "onHistoryTrackCallback: " + response.getMessage()); |
| 169 | 169 | if (StatusCodes.SUCCESS != response.getStatus()) { |
| 170 | 170 | // if (response.getStatus() == 14004) { |
| 171 | - //给3次重新查询的机会 | |
| 172 | - if (queryNum < 4) { | |
| 173 | - //重新查询 | |
| 171 | + //给3次重新查询的机会 | |
| 172 | + if (queryNum < 4) { | |
| 173 | + //重新查询 | |
| 174 | 174 | // new Handler().postDelayed(new Runnable() { |
| 175 | 175 | // @Override |
| 176 | 176 | // public void run() { |
| 177 | 177 | // //间隔3秒查一次 |
| 178 | - queryHistoryTrace(context, mClient, entityName, startTime, endTime, callBack); | |
| 179 | - queryNum++; | |
| 178 | + queryHistoryTrace(context, mClient, entityName, startTime, endTime, callBack); | |
| 179 | + queryNum++; | |
| 180 | 180 | // } |
| 181 | 181 | // }, 1000); |
| 182 | 182 | |
| 183 | - } else { | |
| 183 | + } else { | |
| 184 | + if (callBack != null) { | |
| 184 | 185 | callBack.success(null); |
| 185 | 186 | } |
| 187 | + } | |
| 186 | 188 | |
| 187 | 189 | // } else { |
| 188 | 190 | // Toast.makeText(context, "获取轨迹失败!" + response.getMessage() + "," + response.getStatus(), Toast.LENGTH_SHORT).show(); |
| ... | ... | @@ -207,17 +209,17 @@ public class MyMapUtil { |
| 207 | 209 | } |
| 208 | 210 | } |
| 209 | 211 | } |
| 210 | - } | |
| 211 | - if (total > pageSize * pageIndex) { | |
| 212 | - historyTrackRequest.setPageIndex(++pageIndex); | |
| 213 | - queryHistoryTrace(context, mClient, entityName, startTime, endTime, callBack); | |
| 214 | - } else { | |
| 215 | - if (callBack != null) { | |
| 216 | - callBack.success(trackPoints); | |
| 217 | - trackPoints.clear(); | |
| 212 | + | |
| 213 | + if (total > pageSize * pageIndex) { | |
| 214 | + historyTrackRequest.setPageIndex(++pageIndex); | |
| 215 | + queryHistoryTrace(context, mClient, entityName, startTime, endTime, callBack); | |
| 216 | + } else { | |
| 217 | + if (callBack != null) { | |
| 218 | + callBack.success(trackPoints); | |
| 219 | + trackPoints.clear(); | |
| 220 | + } | |
| 218 | 221 | } |
| 219 | 222 | } |
| 220 | - | |
| 221 | 223 | } |
| 222 | 224 | }; |
| 223 | 225 | //开始查询历史轨迹 |
| ... | ... | @@ -355,9 +357,11 @@ public class MyMapUtil { |
| 355 | 357 | startPoint = points.get(points.size() - 1); |
| 356 | 358 | endPoint = points.get(0); |
| 357 | 359 | } |
| 358 | - | |
| 359 | 360 | // 添加起点图标 |
| 360 | - Bitmap startPointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), startIconRes), 24, 30); | |
| 361 | + Bitmap startPointBitmap = null; | |
| 362 | + if (null != context.getResources()) { | |
| 363 | + startPointBitmap = BitmapUtil.getBitmapFromDp(context, BitmapFactory.decodeResource(context.getResources(), startIconRes), 24, 30); | |
| 364 | + } | |
| 361 | 365 | OverlayOptions startOptions = null; |
| 362 | 366 | if (startPointBitmap != null) { |
| 363 | 367 | startOptions = new MarkerOptions() | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/NotificationUtil.java
0 → 100644
| 1 | +package com.cnlive.moudle.pedometer.utils; | |
| 2 | + | |
| 3 | +import android.app.Activity; | |
| 4 | +import android.content.Intent; | |
| 5 | +import android.os.Build; | |
| 6 | +import android.provider.Settings; | |
| 7 | +import android.support.v4.app.NotificationManagerCompat; | |
| 8 | +import android.widget.Toast; | |
| 9 | + | |
| 10 | +import static android.app.Notification.EXTRA_CHANNEL_ID; | |
| 11 | +import static android.provider.Settings.EXTRA_APP_PACKAGE; | |
| 12 | + | |
| 13 | +public class NotificationUtil { | |
| 14 | + private static boolean isOpen; | |
| 15 | + private static NotificationManagerCompat notificationManagerCompat; | |
| 16 | + | |
| 17 | + public static boolean isOpenNotification(Activity activity) { | |
| 18 | + //监测通知权限是否打开 | |
| 19 | + notificationManagerCompat = NotificationManagerCompat.from(activity); | |
| 20 | + isOpen = notificationManagerCompat.areNotificationsEnabled(); | |
| 21 | + if (!isOpen) { | |
| 22 | + goToSettingNo(activity); | |
| 23 | + } | |
| 24 | + return isOpen; | |
| 25 | + } | |
| 26 | + | |
| 27 | + private static void goToSettingNo(Activity activity) { | |
| 28 | + Toast.makeText(activity, "您尚未开启通知权限,无法进行计步", Toast.LENGTH_LONG).show(); | |
| 29 | + Intent intent1 = new Intent(); | |
| 30 | + try { | |
| 31 | + // 根据isOpened结果,判断是否需要提醒用户跳转AppInfo页面,去打开App通知权限 | |
| 32 | + intent1.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS); | |
| 33 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |
| 34 | + //这种方案适用于 API 26, 即8.0(含8.0)以上可以用 | |
| 35 | + intent1.putExtra(EXTRA_APP_PACKAGE, activity.getPackageName()); | |
| 36 | + intent1.putExtra(EXTRA_CHANNEL_ID, activity.getApplicationInfo().uid); | |
| 37 | + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | |
| 38 | + //这种方案适用于 API21——25,即 5.0——7.1 之间的版本可以使用 | |
| 39 | + intent1.putExtra("app_package", activity.getPackageName()); | |
| 40 | + intent1.putExtra("app_uid", activity.getApplicationInfo().uid); | |
| 41 | + } | |
| 42 | + | |
| 43 | + // 小米6 -MIUI9.6-8.0.0系统,是个特例,通知设置界面只能控制"允许使用通知圆点"——然而这个玩意并没有卵用,我想对雷布斯说:I'm not ok!!! | |
| 44 | + // if ("MI 6".equals(Build.MODEL)) { | |
| 45 | + // intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); | |
| 46 | + // Uri uri = Uri.fromParts("package", getPackageName(), null); | |
| 47 | + // intent.setData(uri); | |
| 48 | + // // intent.setAction("com.android.settings/.SubSettings"); | |
| 49 | + // } | |
| 50 | + activity.startActivity(intent1); | |
| 51 | + } catch (Exception e) { | |
| 52 | + //其他低版本或者异常情况,走该节点。进入APP设置界面 | |
| 53 | + intent1.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); | |
| 54 | + intent1.putExtra("package", activity.getPackageName()); | |
| 55 | + activity.startActivity(intent1); | |
| 56 | + } | |
| 57 | + } | |
| 58 | +} | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/StepUtil.java
| ... | ... | @@ -32,6 +32,41 @@ public class StepUtil { |
| 32 | 32 | return UUID.randomUUID().toString().replace("-", ""); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | + /** | |
| 36 | + * 删除临时保存数据 | |
| 37 | + * | |
| 38 | + * @param context | |
| 39 | + * @param entity | |
| 40 | + */ | |
| 41 | + public static void deleteTempSaveFailData(Context context, FailedEntity entity) { | |
| 42 | + DbCore.init(context, dbName); | |
| 43 | + if (entity != null && !TextUtils.isEmpty(entity.getUuid())) { | |
| 44 | + DbCore.getDaoSession().getFailedEntityDao().deleteByKey(entity.getUuid()); | |
| 45 | + Log.e(TAG, "deleteTempSaveFailData: 删除临时保存数据"); | |
| 46 | + } | |
| 47 | + } | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * 获取暂存的失败数据 | |
| 51 | + * | |
| 52 | + * @param context | |
| 53 | + * @param uid | |
| 54 | + * @param userStartTime | |
| 55 | + * @return | |
| 56 | + */ | |
| 57 | + public static FailedEntity getTempSaveFailData(Context context, String uid, long userStartTime) { | |
| 58 | + DbCore.init(context, dbName); | |
| 59 | + List<FailedEntity> list = DbCore.getDaoSession().getFailedEntityDao().queryBuilder().where(FailedEntityDao.Properties.Uid.eq(uid), FailedEntityDao.Properties.UserStartTime.eq(userStartTime)).list(); | |
| 60 | + if (list != null && list.size() > 0) { | |
| 61 | + if (list.get(0) == null) { | |
| 62 | + return null; | |
| 63 | + } else { | |
| 64 | + return list.get(0); | |
| 65 | + } | |
| 66 | + } | |
| 67 | + return null; | |
| 68 | + } | |
| 69 | + | |
| 35 | 70 | //获取上传失败列表 |
| 36 | 71 | public static List<FailedEntity> getFailListData(Context context, String uid) { |
| 37 | 72 | DbCore.init(context, dbName); |
| ... | ... | @@ -194,7 +229,7 @@ public class StepUtil { |
| 194 | 229 | DbCore.init(context, dbName); |
| 195 | 230 | List<UserStepEntity> list = DbCore.getDaoSession().getUserStepEntityDao().queryBuilder().where(UserStepEntityDao.Properties.UserId.eq(uid)).list(); |
| 196 | 231 | if (list != null && list.size() > 0) { |
| 197 | - Log.e(TAG, "clearRunData: " + list.size()); | |
| 232 | + Log.e(TAG, "clearRunData:删除用户逻辑数据 " + list.size()); | |
| 198 | 233 | DbCore.getDaoSession().getUserStepEntityDao().delete(list.get(0)); |
| 199 | 234 | DbCore.getDaoSession().getUserStepEntityDao().detachAll(); |
| 200 | 235 | } | ... | ... |
moudle_pedometer/src/main/res/drawable-hdpi/icon_no_fail_line.png
0 → 100644
14.5 KB
moudle_pedometer/src/main/res/drawable-xhdpi/icon_no_fail_line.png
0 → 100644
16.6 KB
moudle_pedometer/src/main/res/drawable-xxhdpi/icon_no_fail_line.png
0 → 100644
32 KB
moudle_pedometer/src/main/res/layout/fragment_line_up_again.xml
| 1 | 1 | <layout xmlns:android="http://schemas.android.com/apk/res/android"> |
| 2 | 2 | |
| 3 | + | |
| 3 | 4 | <LinearLayout |
| 4 | 5 | android:layout_width="match_parent" |
| 5 | 6 | android:layout_height="match_parent" |
| ... | ... | @@ -10,19 +11,48 @@ |
| 10 | 11 | android:layout_width="match_parent" |
| 11 | 12 | android:layout_height="?attr/qmui_topbar_height" /> |
| 12 | 13 | |
| 13 | - <com.scwang.smartrefresh.layout.SmartRefreshLayout | |
| 14 | - android:id="@+id/refreshLayout" | |
| 14 | + <FrameLayout | |
| 15 | 15 | android:layout_width="match_parent" |
| 16 | - android:layout_height="match_parent" | |
| 17 | - android:background="#F8F8F8" > | |
| 16 | + android:layout_height="match_parent"> | |
| 17 | + | |
| 18 | + <com.scwang.smartrefresh.layout.SmartRefreshLayout | |
| 19 | + android:id="@+id/refreshLayout" | |
| 20 | + android:layout_width="match_parent" | |
| 21 | + android:layout_height="match_parent" | |
| 22 | + android:background="#F8F8F8"> | |
| 18 | 23 | |
| 19 | - <android.support.v7.widget.RecyclerView | |
| 20 | - android:id="@+id/recycler" | |
| 24 | + <android.support.v7.widget.RecyclerView | |
| 25 | + android:id="@+id/recycler" | |
| 26 | + android:layout_width="match_parent" | |
| 27 | + android:layout_height="match_parent" /> | |
| 28 | + | |
| 29 | + </com.scwang.smartrefresh.layout.SmartRefreshLayout> | |
| 30 | + <!----> | |
| 31 | + //没有失败记录 | |
| 32 | + | |
| 33 | + <LinearLayout | |
| 34 | + android:id="@+id/ll_no_fail_tip" | |
| 21 | 35 | android:layout_width="match_parent" |
| 22 | 36 | android:layout_height="match_parent" |
| 23 | - /> | |
| 37 | + android:background="@color/white" | |
| 38 | + android:gravity="center" | |
| 39 | + android:orientation="vertical" | |
| 40 | + android:visibility="gone"> | |
| 24 | 41 | |
| 25 | - </com.scwang.smartrefresh.layout.SmartRefreshLayout> | |
| 42 | + <ImageView | |
| 43 | + android:layout_width="224dp" | |
| 44 | + android:layout_height="124dp" | |
| 45 | + android:background="@drawable/icon_no_fail_line" /> | |
| 46 | + | |
| 47 | + <TextView | |
| 48 | + android:layout_width="wrap_content" | |
| 49 | + android:layout_height="wrap_content" | |
| 50 | + android:layout_marginTop="10dp" | |
| 51 | + android:text="@string/no_fail_line_text_tip" | |
| 52 | + android:textColor="@color/text_black" /> | |
| 53 | + </LinearLayout> | |
| 54 | + </FrameLayout> | |
| 26 | 55 | </LinearLayout> |
| 56 | + | |
| 27 | 57 | </layout> |
| 28 | 58 | ... | ... |
moudle_pedometer/src/main/res/layout/layout_finish_running_route.xml
| ... | ... | @@ -56,7 +56,7 @@ |
| 56 | 56 | android:layout_width="wrap_content" |
| 57 | 57 | android:layout_height="wrap_content" |
| 58 | 58 | android:layout_marginLeft="10dp" |
| 59 | - android:text="首都师范大学操场东门" | |
| 59 | + android:text="--" | |
| 60 | 60 | android:textColor="@color/black" |
| 61 | 61 | android:textSize="12sp" /> |
| 62 | 62 | </LinearLayout> |
| ... | ... | @@ -93,7 +93,7 @@ |
| 93 | 93 | android:layout_width="wrap_content" |
| 94 | 94 | android:layout_height="wrap_content" |
| 95 | 95 | android:layout_marginLeft="10dp" |
| 96 | - android:text="首都师范大学操场东门" | |
| 96 | + android:text="--" | |
| 97 | 97 | android:textColor="@color/black" |
| 98 | 98 | android:textSize="12sp" /> |
| 99 | 99 | </LinearLayout> |
| ... | ... | @@ -128,7 +128,7 @@ |
| 128 | 128 | android:layout_height="wrap_content" |
| 129 | 129 | android:layout_marginLeft="10dp" |
| 130 | 130 | android:layout_marginTop="5dp" |
| 131 | - android:text="00:27:23" | |
| 131 | + android:text="--" | |
| 132 | 132 | android:textColor="@color/text_black" |
| 133 | 133 | android:textSize="18sp" |
| 134 | 134 | android:textStyle="bold" /> |
| ... | ... | @@ -170,7 +170,7 @@ |
| 170 | 170 | android:layout_width="wrap_content" |
| 171 | 171 | android:layout_height="wrap_content" |
| 172 | 172 | android:layout_marginLeft="10dp" |
| 173 | - android:text="路线完成" | |
| 173 | + android:text="--" | |
| 174 | 174 | android:textColor="@color/text_gray" |
| 175 | 175 | android:textSize="11sp" /> |
| 176 | 176 | </LinearLayout> | ... | ... |
moudle_pedometer/src/main/res/layout/layout_finish_step.xml
| ... | ... | @@ -38,7 +38,7 @@ |
| 38 | 38 | android:id="@+id/tv_step" |
| 39 | 39 | android:layout_width="wrap_content" |
| 40 | 40 | android:layout_height="wrap_content" |
| 41 | - android:text="1233" | |
| 41 | + android:text="--" | |
| 42 | 42 | android:textColor="@color/green_round" |
| 43 | 43 | android:textSize="28sp" |
| 44 | 44 | android:textStyle="bold" /> | ... | ... |
moudle_pedometer/src/main/res/layout/layout_finish_user_info.xml
| ... | ... | @@ -8,7 +8,7 @@ |
| 8 | 8 | |
| 9 | 9 | <LinearLayout |
| 10 | 10 | android:layout_width="match_parent" |
| 11 | - android:layout_height="170dp" | |
| 11 | + android:layout_height="190dp" | |
| 12 | 12 | android:layout_marginTop="30dp" |
| 13 | 13 | android:background="@drawable/shape_10dp_white_raduis_bg" |
| 14 | 14 | android:orientation="vertical"> |
| ... | ... | @@ -19,7 +19,7 @@ |
| 19 | 19 | android:layout_height="wrap_content" |
| 20 | 20 | android:layout_marginLeft="80dp" |
| 21 | 21 | android:layout_marginTop="10dp" |
| 22 | - android:text="用户昵称" | |
| 22 | + android:text="--" | |
| 23 | 23 | android:textColor="@color/text_black" |
| 24 | 24 | android:textSize="13sp" /> |
| 25 | 25 | <!----> |
| ... | ... | @@ -40,7 +40,7 @@ |
| 40 | 40 | android:layout_height="wrap_content" |
| 41 | 41 | android:layout_marginLeft="15dp" |
| 42 | 42 | android:layout_marginTop="15dp" |
| 43 | - android:text="奥森公园南路" | |
| 43 | + android:text="--" | |
| 44 | 44 | android:textColor="@color/text_black" |
| 45 | 45 | android:textSize="15sp" /> |
| 46 | 46 | |
| ... | ... | @@ -50,7 +50,7 @@ |
| 50 | 50 | android:layout_height="wrap_content" |
| 51 | 51 | android:layout_marginLeft="15dp" |
| 52 | 52 | android:layout_marginTop="5dp" |
| 53 | - android:text="2019/06/10 9:51" | |
| 53 | + android:text="--" | |
| 54 | 54 | android:textColor="@color/text_gray" |
| 55 | 55 | android:textSize="10sp" /> |
| 56 | 56 | </LinearLayout> |
| ... | ... | @@ -66,7 +66,7 @@ |
| 66 | 66 | android:layout_width="wrap_content" |
| 67 | 67 | android:layout_height="wrap_content" |
| 68 | 68 | android:layout_marginRight="10dp" |
| 69 | - android:text="1.53" | |
| 69 | + android:text="--" | |
| 70 | 70 | android:textColor="@color/text_black" |
| 71 | 71 | android:textSize="45sp" |
| 72 | 72 | android:textStyle="bold" /> |
| ... | ... | @@ -104,7 +104,7 @@ |
| 104 | 104 | android:id="@+id/tv_speed" |
| 105 | 105 | android:layout_width="wrap_content" |
| 106 | 106 | android:layout_height="wrap_content" |
| 107 | - android:text="34'33''" | |
| 107 | + android:text="--" | |
| 108 | 108 | android:textColor="@color/text_black" |
| 109 | 109 | android:textSize="20sp" |
| 110 | 110 | android:textStyle="bold" /> |
| ... | ... | @@ -129,7 +129,7 @@ |
| 129 | 129 | android:id="@+id/tv_timer" |
| 130 | 130 | android:layout_width="wrap_content" |
| 131 | 131 | android:layout_height="wrap_content" |
| 132 | - android:text="00:00:00" | |
| 132 | + android:text="--" | |
| 133 | 133 | android:textColor="@color/text_black" |
| 134 | 134 | android:textSize="20sp" |
| 135 | 135 | android:textStyle="bold" /> | ... | ... |
moudle_pedometer/src/main/res/values/ids.xml
moudle_pedometer/src/main/res/values/strings.xml
| ... | ... | @@ -69,7 +69,7 @@ |
| 69 | 69 | <string name="loc_gps_accuracy_mid">GPS信号质量中等</string> |
| 70 | 70 | <string name="loc_gps_accuracy_good">GPS信号质量好</string> |
| 71 | 71 | <string name="layout_street_active_type">活动类型</string> |
| 72 | - <string name="open_gps_tip">您尚未开启GPS,为确保定位准确性,请您打开后使用!</string> | |
| 72 | + <string name="open_gps_tip">请开启GPS饼将其设置为高精度模式!</string> | |
| 73 | 73 | <!----> |
| 74 | 74 | <!--网络请求--> |
| 75 | 75 | <string name="retry">重试</string> |
| ... | ... | @@ -88,6 +88,7 @@ |
| 88 | 88 | <string name="add_path">添加轨迹</string> |
| 89 | 89 | <string name="addpath">绑定轨迹</string> |
| 90 | 90 | <string name="delect">删除</string> |
| 91 | + <string name="no_fail_line_text_tip">没有上传失败的路线哦</string> | |
| 91 | 92 | |
| 92 | 93 | |
| 93 | 94 | </resources> | ... | ... |