Commit ecf908192f0d82733d1e4ed373304b60879e3798
1 parent
2cb5ca60
1 修复轨迹工具上传数据时,绘制历史轨迹闪退问题
Showing
14 changed files
with
474 additions
and
363 deletions
app/src/main/java/com/example/modulepedometer/MainActivity.java
| ... | ... | @@ -31,8 +31,7 @@ public class MainActivity extends AppCompatActivity { |
| 31 | 31 | findViewById(R.id.tooll).setOnClickListener(new View.OnClickListener() { |
| 32 | 32 | @Override |
| 33 | 33 | public void onClick(View v) { |
| 34 | - Intent intent = new Intent(MainActivity.this, RaceListActivity.class); | |
| 35 | - startActivity(intent); | |
| 34 | + RaceListActivity.newInstance(getApplicationContext(),"10513196",null,null); | |
| 36 | 35 | //跳转界面 |
| 37 | 36 | // CollRunningFinishActivity.startActivity(MainActivity.this); |
| 38 | 37 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunningFinishFragmentView.java
| ... | ... | @@ -312,6 +312,8 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener { |
| 312 | 312 | if (null != resultPoints) { |
| 313 | 313 | //绘制轨迹 |
| 314 | 314 | MyMapUtil.drawHistoryTrack(getContext(), baiduMap, resultPoints, SortType.asc, R.color.green_round, R.drawable.icon_start, R.drawable.icon_end); |
| 315 | + MyMapUtil.setMapAutoZoom(baiduMap, resultPoints,-1.5f); | |
| 316 | + | |
| 315 | 317 | } else { |
| 316 | 318 | SelectDialog selectDialog = new SelectDialog(getContext(), "轨迹获取失败,是否重试?", "取消", new SelectDialog.DialogInterface() { |
| 317 | 319 | @Override |
| ... | ... | @@ -475,37 +477,6 @@ public class CollRunningFinishFragmentView implements MvpView, OnFenceListener { |
| 475 | 477 | mUiSettings.setCompassEnabled(false); |
| 476 | 478 | //显示定位图层 |
| 477 | 479 | baiduMap.setMyLocationEnabled(false); |
| 478 | - LocationClientOption option = new LocationClientOption(); | |
| 479 | - option.setOpenGps(true); // 打开gps | |
| 480 | - //可选,设置返回经纬度坐标类型,默认GCJ02 | |
| 481 | - //GCJ02:国测局坐标; | |
| 482 | - //BD09ll:百度经纬度坐标; | |
| 483 | - //BD09:百度墨卡托坐标; | |
| 484 | - //海外地区定位,无需设置坐标类型,统一返回WGS84类型坐标 | |
| 485 | - option.setCoorType("gcj02"); // 设置坐标类型 | |
| 486 | - //可选,默认false,设置是否开启Gps定位 | |
| 487 | - option.setOpenGps(true); | |
| 488 | - //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者,该模式下开发者无需再关心定位间隔是多少,定位SDK本身发现位置变化就会及时回调给开发者 | |
| 489 | - option.setOpenAutoNotifyMode(); | |
| 490 | - //可选,默认高精度,设置定位模式,高精度,低功耗,仅设备 | |
| 491 | - //LocationMode.Hight_Accuracy:高精度; | |
| 492 | - //LocationMode. Battery_Saving:低功耗; | |
| 493 | - //LocationMode. Device_Sensors:仅使用设备; | |
| 494 | - option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); | |
| 495 | - //可选,设置是否需要地址信息,默认不需要 | |
| 496 | - option.setIsNeedAddress(false); | |
| 497 | - //可选,设置是否需要地址描述 | |
| 498 | - option.setIsNeedLocationDescribe(false); | |
| 499 | - //可选,设置是否需要设备方向结果 | |
| 500 | - option.setNeedDeviceDirect(false); | |
| 501 | - //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者 | |
| 502 | - //minTimeInterval - 最短定位时间间隔,单位毫秒,最小值0,开发者可以在设置希望的位置回调最短时间间隔 | |
| 503 | - //minDistance - 最短定位距离间隔,单位米,最小值0,开发者可以设置希望的位置回调距离间隔 | |
| 504 | - //locSensitivity - 定位变化敏感程度,LOC_SENSITIVITY_HIGHT,LOC_SENSITIVITY_MIDDLE,LOC_SENSITIVITY_LOW | |
| 505 | - option.setOpenAutoNotifyMode(3000, 1, LocationClientOption.LOC_SENSITIVITY_HIGHT); | |
| 506 | - //可选,定位SDK内部是一个service,并放到了独立进程。 | |
| 507 | - //设置是否在stop的时候杀死这个进程,默认(建议)不杀死,即setIgnoreKillProcess(true) | |
| 508 | - option.setIgnoreKillProcess(true); | |
| 509 | 480 | |
| 510 | 481 | } |
| 511 | 482 | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunningMapFragmentView.java
| ... | ... | @@ -34,6 +34,7 @@ import com.baidu.mapapi.map.UiSettings; |
| 34 | 34 | import com.baidu.mapapi.model.LatLng; |
| 35 | 35 | import com.baidu.mapapi.utils.DistanceUtil; |
| 36 | 36 | import com.baidu.trace.model.SortType; |
| 37 | +import com.cnlive.libs.base.util.AlertUtil; | |
| 37 | 38 | import com.cnlive.moudle.collectionTrace.model.CollectPoint; |
| 38 | 39 | import com.cnlive.moudle.collectionTrace.service.CollStepService; |
| 39 | 40 | import com.cnlive.moudle.collectionTrace.ui.activity.CollRunningFinishActivity; |
| ... | ... | @@ -278,15 +279,21 @@ public class CollRunningMapFragmentView implements MvpView, SensorEventListener |
| 278 | 279 | fragment.binding.flEndPoint.setOnClickListener(new View.OnClickListener() { |
| 279 | 280 | @Override |
| 280 | 281 | public void onClick(View view) { |
| 281 | - if (null != followMyLocation) { | |
| 282 | - currentImportLatLng = new LatLng(followMyLocation.latitude, followMyLocation.longitude); | |
| 283 | - //获取当前地点 | |
| 284 | - if (!TextUtils.isEmpty(currentAddress)) { | |
| 285 | - endSelectDialog.setTipMessage("确定将" + "\"" + currentAddress + "\"" + "设为结束地点?"); | |
| 286 | - endSelectDialog.show(); | |
| 287 | - } else { | |
| 288 | - isShowEndFollowAddress = true; | |
| 289 | - Toast.makeText(getContext(), "正在获取当前地点信息,请稍后", Toast.LENGTH_SHORT).show(); | |
| 282 | + //先获取打点数量 | |
| 283 | + int canTakePointCount = CollStepUtil.getCollImportPointSize(getContext(), CollCommonInfo.getUserId(getContext())); | |
| 284 | + if (0 == canTakePointCount) { | |
| 285 | + AlertUtil.showDeftToast(getContext(), "您尚未打点,请打点后结束"); | |
| 286 | + } else { | |
| 287 | + if (null != followMyLocation) { | |
| 288 | + currentImportLatLng = new LatLng(followMyLocation.latitude, followMyLocation.longitude); | |
| 289 | + //获取当前地点 | |
| 290 | + if (!TextUtils.isEmpty(currentAddress)) { | |
| 291 | + endSelectDialog.setTipMessage("确定将" + "\"" + currentAddress + "\"" + "设为结束地点?"); | |
| 292 | + endSelectDialog.show(); | |
| 293 | + } else { | |
| 294 | + isShowEndFollowAddress = true; | |
| 295 | + Toast.makeText(getContext(), "正在获取当前地点信息,请稍后", Toast.LENGTH_SHORT).show(); | |
| 296 | + } | |
| 290 | 297 | } |
| 291 | 298 | } |
| 292 | 299 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollTraceListDetailFragmentView.java
| ... | ... | @@ -2,6 +2,8 @@ package com.cnlive.moudle.collectionTrace.frame.view; |
| 2 | 2 | |
| 3 | 3 | import android.app.Activity; |
| 4 | 4 | import android.content.Context; |
| 5 | +import android.graphics.Bitmap; | |
| 6 | +import android.graphics.BitmapFactory; | |
| 5 | 7 | import android.os.Handler; |
| 6 | 8 | import android.support.v7.widget.LinearLayoutManager; |
| 7 | 9 | import android.text.TextUtils; |
| ... | ... | @@ -9,8 +11,12 @@ import android.util.Log; |
| 9 | 11 | import android.view.MotionEvent; |
| 10 | 12 | import android.view.View; |
| 11 | 13 | |
| 14 | +import com.baidu.location.LocationClient; | |
| 15 | +import com.baidu.location.LocationClientOption; | |
| 12 | 16 | import com.baidu.mapapi.map.BaiduMap; |
| 17 | +import com.baidu.mapapi.map.BitmapDescriptorFactory; | |
| 13 | 18 | import com.baidu.mapapi.map.MapView; |
| 19 | +import com.baidu.mapapi.map.MyLocationConfiguration; | |
| 14 | 20 | import com.baidu.mapapi.map.Overlay; |
| 15 | 21 | import com.baidu.mapapi.map.UiSettings; |
| 16 | 22 | import com.baidu.mapapi.model.LatLng; |
| ... | ... | @@ -44,6 +50,7 @@ import com.cnlive.moudle.collectionTrace.utils.CollStepUtil; |
| 44 | 50 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 45 | 51 | import com.cnlive.moudle.pedometer.model.Constant; |
| 46 | 52 | import com.cnlive.moudle.pedometer.ui.widget.SelectDialog; |
| 53 | +import com.cnlive.moudle.pedometer.utils.BitmapUtil; | |
| 47 | 54 | import com.cnlive.moudle.pedometer.utils.GsonUtil; |
| 48 | 55 | import com.cnlive.moudle.pedometer.utils.MyMapUtil; |
| 49 | 56 | import com.cnlive.moudle.pedometer.utils.NetUtil; |
| ... | ... | @@ -76,6 +83,7 @@ public class CollTraceListDetailFragmentView implements MvpView, OnFenceListener |
| 76 | 83 | this.fragment = fragment; |
| 77 | 84 | } |
| 78 | 85 | |
| 86 | + | |
| 79 | 87 | public Context getContext() { |
| 80 | 88 | return fragment == null ? null : fragment.getActivity(); |
| 81 | 89 | } |
| ... | ... | @@ -110,56 +118,56 @@ public class CollTraceListDetailFragmentView implements MvpView, OnFenceListener |
| 110 | 118 | fragment.binding.rlScrollViewStartBtn.setOnTouchListener(new View.OnTouchListener() { |
| 111 | 119 | @Override |
| 112 | 120 | public boolean onTouch(View view, MotionEvent motionEvent) { |
| 113 | - if (motionEvent.getAction()==MotionEvent.ACTION_DOWN){ | |
| 114 | - if ("0".equals(fragment.binding.rlScrollViewStartBtn.getTag().toString())) { | |
| 115 | - return false; | |
| 116 | - } | |
| 117 | - if (!NetUtil.isNetworkConnected(fragment.getActivity())) { | |
| 118 | - AlertUtil.showDeftToast(fragment.getActivity(), "无法连接网络"); | |
| 119 | - return false; | |
| 120 | - } | |
| 121 | - importPoints = null; | |
| 122 | - //设置打的重要点 | |
| 123 | - if (!TextUtils.isEmpty(eventShoeLinesBean.getLatLongitude())) { | |
| 124 | - List<CollectPoint> collectPoints = GsonUtil.jsonToList(eventShoeLinesBean.getLatLongitude(), CollectPoint.class); | |
| 125 | - if (null != collectPoints) { | |
| 126 | - importPoints = new ArrayList<>(); | |
| 127 | - for (CollectPoint collectPoint : collectPoints) { | |
| 128 | - com.baidu.trace.model.LatLng latLng = new com.baidu.trace.model.LatLng(collectPoint.getLatitude(), collectPoint.getLongitude()); | |
| 129 | - importPoints.add(latLng); | |
| 130 | - } | |
| 131 | - } | |
| 132 | - } | |
| 133 | - SelectDialog selectDialog = new SelectDialog(fragment.getActivity(), "确定绑定该轨迹?", "否", new SelectDialog.DialogInterface() { | |
| 134 | - @Override | |
| 135 | - public void onClick(SelectDialog dialog) { | |
| 136 | - dialog.cancel(); | |
| 137 | - } | |
| 138 | - }, "是", new SelectDialog.DialogInterface() { | |
| 139 | - @Override | |
| 140 | - public void onClick(SelectDialog dialog) { | |
| 141 | - dialog.cancel(); | |
| 142 | - //先判断当前是否已经绑定轨迹 | |
| 143 | - if (TextUtils.isEmpty(fenceEntityName)) { | |
| 144 | - Log.e(TAG, "onClick: 未绑定轨迹"); | |
| 145 | - //开始绑定轨迹 | |
| 146 | - //判断是否有打的点 | |
| 147 | - if (null != importPoints && !TextUtils.isEmpty(eventShoeLinesBean.getDarenId()) && !TextUtils.isEmpty(eventShoeLinesBean.getEventName())) { | |
| 148 | - addFence(eventShoeLinesBean.getDarenId(), eventShoeLinesBean.getEventName(), importPoints); | |
| 149 | - } | |
| 150 | - } else { | |
| 151 | - Log.e(TAG, "onClick: 已绑定轨迹"); | |
| 152 | - //开始查询 | |
| 153 | - queryFenceList(fenceEntityName); | |
| 154 | - } | |
| 155 | - | |
| 156 | - } | |
| 157 | - }); | |
| 158 | - selectDialog.setCancelable(false); | |
| 159 | - selectDialog.setCanceledOnTouchOutside(false); | |
| 160 | - selectDialog.show(); | |
| 161 | - // | |
| 162 | - } | |
| 121 | + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { | |
| 122 | + if ("0".equals(fragment.binding.rlScrollViewStartBtn.getTag().toString())) { | |
| 123 | + return false; | |
| 124 | + } | |
| 125 | + if (!NetUtil.isNetworkConnected(fragment.getActivity())) { | |
| 126 | + AlertUtil.showDeftToast(fragment.getActivity(), "无法连接网络"); | |
| 127 | + return false; | |
| 128 | + } | |
| 129 | + importPoints = null; | |
| 130 | + //设置打的重要点 | |
| 131 | + if (!TextUtils.isEmpty(eventShoeLinesBean.getLatLongitude())) { | |
| 132 | + List<CollectPoint> collectPoints = GsonUtil.jsonToList(eventShoeLinesBean.getLatLongitude(), CollectPoint.class); | |
| 133 | + if (null != collectPoints) { | |
| 134 | + importPoints = new ArrayList<>(); | |
| 135 | + for (CollectPoint collectPoint : collectPoints) { | |
| 136 | + com.baidu.trace.model.LatLng latLng = new com.baidu.trace.model.LatLng(collectPoint.getLatitude(), collectPoint.getLongitude()); | |
| 137 | + importPoints.add(latLng); | |
| 138 | + } | |
| 139 | + } | |
| 140 | + } | |
| 141 | + SelectDialog selectDialog = new SelectDialog(fragment.getActivity(), "确定绑定该轨迹?", "否", new SelectDialog.DialogInterface() { | |
| 142 | + @Override | |
| 143 | + public void onClick(SelectDialog dialog) { | |
| 144 | + dialog.cancel(); | |
| 145 | + } | |
| 146 | + }, "是", new SelectDialog.DialogInterface() { | |
| 147 | + @Override | |
| 148 | + public void onClick(SelectDialog dialog) { | |
| 149 | + dialog.cancel(); | |
| 150 | + //先判断当前是否已经绑定轨迹 | |
| 151 | + if (TextUtils.isEmpty(fenceEntityName)) { | |
| 152 | + Log.e(TAG, "onClick: 未绑定轨迹"); | |
| 153 | + //开始绑定轨迹 | |
| 154 | + //判断是否有打的点 | |
| 155 | + if (null != importPoints && !TextUtils.isEmpty(eventShoeLinesBean.getDarenId()) && !TextUtils.isEmpty(eventShoeLinesBean.getEventName())) { | |
| 156 | + addFence(eventShoeLinesBean.getDarenId(), eventShoeLinesBean.getEventName(), importPoints); | |
| 157 | + } | |
| 158 | + } else { | |
| 159 | + Log.e(TAG, "onClick: 已绑定轨迹"); | |
| 160 | + //开始查询 | |
| 161 | + queryFenceList(fenceEntityName); | |
| 162 | + } | |
| 163 | + | |
| 164 | + } | |
| 165 | + }); | |
| 166 | + selectDialog.setCancelable(false); | |
| 167 | + selectDialog.setCanceledOnTouchOutside(false); | |
| 168 | + selectDialog.show(); | |
| 169 | + // | |
| 170 | + } | |
| 163 | 171 | return false; |
| 164 | 172 | } |
| 165 | 173 | }); |
| ... | ... | @@ -223,7 +231,11 @@ public class CollTraceListDetailFragmentView implements MvpView, OnFenceListener |
| 223 | 231 | @Override |
| 224 | 232 | public void success(List<LatLng> resultPoints) { |
| 225 | 233 | if (null != resultPoints) { |
| 234 | + if (null == baiduMap) { | |
| 235 | + return; | |
| 236 | + } | |
| 226 | 237 | MyMapUtil.drawHistoryTrack(getContext(), baiduMap, resultPoints, SortType.asc, R.color.green_round, R.drawable.icon_start, R.drawable.icon_end); |
| 238 | + MyMapUtil.setMapAutoZoom(baiduMap, resultPoints,-1.5f); | |
| 227 | 239 | } |
| 228 | 240 | } |
| 229 | 241 | }); |
| ... | ... | @@ -265,6 +277,26 @@ public class CollTraceListDetailFragmentView implements MvpView, OnFenceListener |
| 265 | 277 | } |
| 266 | 278 | } |
| 267 | 279 | |
| 280 | + public void initMap() { | |
| 281 | + this.mMapView = fragment.binding.mapView; | |
| 282 | + if (baiduMap == null) { | |
| 283 | + baiduMap = mMapView.getMap(); | |
| 284 | + } | |
| 285 | + if (mUiSettings == null) { | |
| 286 | + mUiSettings = baiduMap.getUiSettings(); | |
| 287 | + } | |
| 288 | + //启动所有手势 | |
| 289 | + mUiSettings.setAllGesturesEnabled(true); | |
| 290 | + //通过设置enable为true或false 选择是否显示缩放按钮 | |
| 291 | + mMapView.showZoomControls(false); | |
| 292 | + mUiSettings.setEnlargeCenterWithDoubleClickEnable(true); | |
| 293 | + //隐藏自带的指南针,改用自定义指南针 杨帅 | |
| 294 | + mUiSettings.setCompassEnabled(false); | |
| 295 | + //显示定位图层 | |
| 296 | + baiduMap.setMyLocationEnabled(false); | |
| 297 | + | |
| 298 | + } | |
| 299 | + | |
| 268 | 300 | /** |
| 269 | 301 | * 查询地理围栏 |
| 270 | 302 | */ | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/StartTraceFragmentView.java
| ... | ... | @@ -10,6 +10,7 @@ import android.hardware.SensorEventListener; |
| 10 | 10 | import android.hardware.SensorManager; |
| 11 | 11 | import android.support.v4.content.ContextCompat; |
| 12 | 12 | import android.text.TextUtils; |
| 13 | +import android.util.Log; | |
| 13 | 14 | import android.view.View; |
| 14 | 15 | import android.widget.Toast; |
| 15 | 16 | |
| ... | ... | @@ -27,9 +28,11 @@ import com.baidu.mapapi.map.MyLocationConfiguration; |
| 27 | 28 | import com.baidu.mapapi.map.MyLocationData; |
| 28 | 29 | import com.baidu.mapapi.map.UiSettings; |
| 29 | 30 | import com.baidu.mapapi.model.LatLng; |
| 31 | +import com.cnlive.libs.base.util.AlertUtil; | |
| 30 | 32 | import com.cnlive.moudle.collectionTrace.service.CollKeepLiveService; |
| 31 | 33 | import com.cnlive.moudle.collectionTrace.service.CollStepService; |
| 32 | 34 | import com.cnlive.moudle.collectionTrace.ui.activity.CollRunRaceDetailActivity; |
| 35 | +import com.cnlive.moudle.collectionTrace.ui.activity.CollRunningFinishActivity; | |
| 33 | 36 | import com.cnlive.moudle.collectionTrace.ui.activity.CollRunningMapActivity; |
| 34 | 37 | import com.cnlive.moudle.collectionTrace.ui.fragment.StartTraceFragment; |
| 35 | 38 | import com.cnlive.moudle.collectionTrace.commonInfo.CollCommonInfo; |
| ... | ... | @@ -41,6 +44,7 @@ import com.cnlive.moudle.pedometer.sql.entity.CollUserStepEntity; |
| 41 | 44 | import com.cnlive.moudle.pedometer.ui.widget.SelectDialog; |
| 42 | 45 | import com.cnlive.moudle.pedometer.utils.BitmapUtil; |
| 43 | 46 | import com.cnlive.moudle.pedometer.utils.GsonUtil; |
| 47 | +import com.cnlive.moudle.pedometer.utils.NetUtil; | |
| 44 | 48 | import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil; |
| 45 | 49 | import com.cnlive.moudle.pedometer.utils.ServiceUtils; |
| 46 | 50 | import com.cnlive.moudle.pedometer.utils.TimeUtil; |
| ... | ... | @@ -112,15 +116,19 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { |
| 112 | 116 | fragment.binding.btnIdentify.setOnClickListener(new View.OnClickListener() { |
| 113 | 117 | @Override |
| 114 | 118 | public void onClick(View view) { |
| 115 | - //获取当前地点 | |
| 116 | - if (!TextUtils.isEmpty(currentAddress)) { | |
| 117 | - selectDialog.setTipMessage("确定将" + "\"" + currentAddress + "\"" + "设置开始地点?"); | |
| 118 | - selectDialog.show(); | |
| 119 | - } else { | |
| 120 | - isShowFollowAddress = true; | |
| 121 | - Toast.makeText(getContext(), "正在获取当前地点信息,请稍后", Toast.LENGTH_SHORT).show(); | |
| 119 | +// if (!NetUtil.isNetworkConnected(getContext())) { | |
| 120 | +// AlertUtil.showDeftToast(getContext(), "无法连接网络,请稍后重试"); | |
| 121 | +// } else { | |
| 122 | + //获取当前地点 | |
| 123 | + if (!TextUtils.isEmpty(currentAddress)) { | |
| 124 | + selectDialog.setTipMessage("确定将" + "\"" + currentAddress + "\"" + "设置开始地点?"); | |
| 125 | + selectDialog.show(); | |
| 126 | + } else { | |
| 127 | + isShowFollowAddress = true; | |
| 128 | + Toast.makeText(getContext(), "正在获取当前地点信息,请稍后", Toast.LENGTH_SHORT).show(); | |
| 129 | + } | |
| 122 | 130 | } |
| 123 | - } | |
| 131 | +// } | |
| 124 | 132 | }); |
| 125 | 133 | |
| 126 | 134 | } |
| ... | ... | @@ -132,40 +140,67 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { |
| 132 | 140 | //先判断有没有数据 |
| 133 | 141 | CollUserStepEntity userStepEntity = CollStepUtil.getCollUserStepData(getContext(), CommonInfo.getUserId(getContext())); |
| 134 | 142 | if (null != userStepEntity) { |
| 135 | - String eventId = CollCommonInfo.getStreetId(getContext()); | |
| 136 | - //判断赛事id是否相同 | |
| 137 | - String runStreetId = userStepEntity.getStreetId(); | |
| 138 | - //是相同赛事id | |
| 139 | - if (eventId.equals(runStreetId)) { | |
| 140 | - //赛事相同(询问用户是否继续 | |
| 141 | - SelectDialog selectDialog = new SelectDialog(getContext(), "是否继续运动", "否", new SelectDialog.DialogInterface() { | |
| 142 | - @Override | |
| 143 | - public void onClick(SelectDialog dialog) { | |
| 144 | - //删除数据 | |
| 145 | - CollStepUtil.clearRunData(getContext(), CollCommonInfo.getUserId(getContext())); | |
| 146 | - stopStepService(); | |
| 147 | - //清除数据 | |
| 148 | - CollCommonInfo.reset(getContext()); | |
| 149 | - dialog.dismiss(); | |
| 150 | - } | |
| 151 | - }, "是", new SelectDialog.DialogInterface() { | |
| 152 | - @Override | |
| 153 | - public void onClick(SelectDialog dialog) { | |
| 154 | - //继续运动 | |
| 155 | - dialog.dismiss(); | |
| 156 | - //检查百度是否正在运行 | |
| 157 | - checkBaiduServiceState(); | |
| 143 | + //判断用户是否点击wanc | |
| 144 | + if (0 == userStepEntity.getFinishTimeStamp()) { | |
| 145 | + String eventId = CollCommonInfo.getStreetId(getContext()); | |
| 146 | + //判断赛事id是否相同 | |
| 147 | + String runStreetId = userStepEntity.getStreetId(); | |
| 148 | + //是相同赛事id | |
| 149 | + if (eventId.equals(runStreetId)) { | |
| 150 | + //赛事相同(询问用户是否继续 | |
| 151 | + SelectDialog selectDialog = new SelectDialog(getContext(), "是否继续运动", "否", new SelectDialog.DialogInterface() { | |
| 152 | + @Override | |
| 153 | + public void onClick(SelectDialog dialog) { | |
| 154 | + //删除数据 | |
| 155 | + CollStepUtil.clearRunData(getContext(), CollCommonInfo.getUserId(getContext())); | |
| 156 | + stopStepService(); | |
| 157 | + //清除数据 | |
| 158 | + CollCommonInfo.reset(getContext()); | |
| 159 | + dialog.dismiss(); | |
| 160 | + } | |
| 161 | + }, "是", new SelectDialog.DialogInterface() { | |
| 162 | + @Override | |
| 163 | + public void onClick(SelectDialog dialog) { | |
| 164 | + //继续运动 | |
| 165 | + dialog.dismiss(); | |
| 166 | + //检查百度是否正在运行 | |
| 167 | + checkBaiduServiceState(); | |
| 158 | 168 | |
| 159 | - } | |
| 160 | - }); | |
| 161 | - selectDialog.setCancelable(false); | |
| 162 | - selectDialog.setCanceledOnTouchOutside(false); | |
| 163 | - selectDialog.show(); | |
| 164 | - } | |
| 165 | - //赛事id不同,但是有正在进行的赛事 | |
| 166 | - else { | |
| 167 | - //询问用户 | |
| 168 | - SelectDialog selectDialog = new SelectDialog(getContext(), "你正在进行另一赛事,是否回到该赛事?", "否", new SelectDialog.DialogInterface() { | |
| 169 | + } | |
| 170 | + }); | |
| 171 | + selectDialog.setCancelable(false); | |
| 172 | + selectDialog.setCanceledOnTouchOutside(false); | |
| 173 | + selectDialog.show(); | |
| 174 | + } | |
| 175 | + //赛事id不同,但是有正在进行的赛事 | |
| 176 | + else { | |
| 177 | + //询问用户 | |
| 178 | + SelectDialog selectDialog = new SelectDialog(getContext(), "你正在进行另一赛事,是否回到该赛事?", "否", new SelectDialog.DialogInterface() { | |
| 179 | + @Override | |
| 180 | + public void onClick(SelectDialog dialog) { | |
| 181 | + //删除数据 | |
| 182 | + CollStepUtil.clearRunData(getContext(), CollCommonInfo.getUserId(getContext())); | |
| 183 | + stopStepService(); | |
| 184 | + //清除数据 | |
| 185 | + CollCommonInfo.reset(getContext()); | |
| 186 | + dialog.dismiss(); | |
| 187 | + } | |
| 188 | + }, "是", new SelectDialog.DialogInterface() { | |
| 189 | + @Override | |
| 190 | + public void onClick(SelectDialog dialog) { | |
| 191 | + //继续运动 | |
| 192 | + dialog.dismiss(); | |
| 193 | + //检查百度是否正在运行 | |
| 194 | + checkBaiduServiceState(); | |
| 195 | + } | |
| 196 | + }); | |
| 197 | + selectDialog.setCancelable(false); | |
| 198 | + selectDialog.setCanceledOnTouchOutside(false); | |
| 199 | + selectDialog.show(); | |
| 200 | + } | |
| 201 | + } else { | |
| 202 | + //已经完成,但是没有上传 | |
| 203 | + SelectDialog selectDialog = new SelectDialog(getContext(), "您还有未上传成功的数据,是否重新上传?", "取消", new SelectDialog.DialogInterface() { | |
| 169 | 204 | @Override |
| 170 | 205 | public void onClick(SelectDialog dialog) { |
| 171 | 206 | //删除数据 |
| ... | ... | @@ -174,17 +209,18 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { |
| 174 | 209 | //清除数据 |
| 175 | 210 | CollCommonInfo.reset(getContext()); |
| 176 | 211 | dialog.dismiss(); |
| 212 | + Log.e("取消", "onClick: " ); | |
| 177 | 213 | } |
| 178 | - }, "是", new SelectDialog.DialogInterface() { | |
| 214 | + }, "上传", new SelectDialog.DialogInterface() { | |
| 179 | 215 | @Override |
| 180 | 216 | public void onClick(SelectDialog dialog) { |
| 181 | - //继续运动 | |
| 182 | 217 | dialog.dismiss(); |
| 183 | - //检查百度是否正在运行 | |
| 184 | - checkBaiduServiceState(); | |
| 218 | + //直接跳转页面 | |
| 219 | + CollRunningFinishActivity.startActivity(fragment.getActivity()); | |
| 220 | + fragment.getActivity().finish(); | |
| 185 | 221 | } |
| 186 | 222 | }); |
| 187 | - selectDialog.setCancelable(false); | |
| 223 | + selectDialog.setCanceledOnTouchOutside(false); | |
| 188 | 224 | selectDialog.setCanceledOnTouchOutside(false); |
| 189 | 225 | selectDialog.show(); |
| 190 | 226 | } |
| ... | ... | @@ -210,21 +246,24 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { |
| 210 | 246 | } |
| 211 | 247 | |
| 212 | 248 | private void checkBaiduServiceState() { |
| 213 | - | |
| 249 | + CollCommonInfo.setTsRunBaiduTraceService(getContext(), true); | |
| 250 | + CollCommonInfo.setIsRunKeepAliveService(getContext(), true); | |
| 251 | + CollCommonInfo.setIsWriteUserStep(getContext(), true); | |
| 252 | + CollCommonInfo.setIsFirstStepSendTraceTip(getContext(), true); | |
| 214 | 253 | // boolean isRunBaidu = CollCommonInfo.getIsRunBaiduTraceService(getContext()); |
| 215 | 254 | // //要运行百度 |
| 216 | 255 | // if (isRunBaidu) { |
| 217 | - //判断百度服务是否运行 | |
| 218 | - boolean isBaiduRun = ServiceUtils.isServiceRunning(getContext(), "com.baidu.trace.LBSTraceService"); | |
| 219 | - boolean isKeepRun = ServiceUtils.isServiceRunning(getContext(), "com.cnlive.moudle.collectionTrace.service.CollKeepLiveService"); | |
| 220 | - boolean isStepRun = ServiceUtils.isServiceRunning(getContext(), "com.cnlive.moudle.collectionTrace.service.CollStepService"); | |
| 221 | - if (!isBaiduRun || !isKeepRun || !isStepRun) { | |
| 222 | - stopStepService(); | |
| 223 | - startStepService(getContext()); | |
| 224 | - } else { | |
| 225 | - CollRunningMapActivity.startActivity(fragment.getActivity(), runRaceDetailInfo); | |
| 226 | - fragment.getActivity().finish(); | |
| 227 | - } | |
| 256 | + //判断百度服务是否运行 | |
| 257 | + boolean isBaiduRun = ServiceUtils.isServiceRunning(getContext(), "com.baidu.trace.LBSTraceService"); | |
| 258 | + boolean isKeepRun = ServiceUtils.isServiceRunning(getContext(), "com.cnlive.moudle.collectionTrace.service.CollKeepLiveService"); | |
| 259 | + boolean isStepRun = ServiceUtils.isServiceRunning(getContext(), "com.cnlive.moudle.collectionTrace.service.CollStepService"); | |
| 260 | + if (!isBaiduRun || !isKeepRun || !isStepRun) { | |
| 261 | + stopStepService(); | |
| 262 | + startStepService(getContext()); | |
| 263 | + } else { | |
| 264 | + CollRunningMapActivity.startActivity(fragment.getActivity(), runRaceDetailInfo); | |
| 265 | + fragment.getActivity().finish(); | |
| 266 | + } | |
| 228 | 267 | // } else { |
| 229 | 268 | // CollRunningMapActivity.startActivity(fragment.getActivity(), runRaceDetailInfo); |
| 230 | 269 | // fragment.getActivity().finish(); |
| ... | ... | @@ -232,10 +271,7 @@ public class StartTraceFragmentView implements MvpView, SensorEventListener { |
| 232 | 271 | } |
| 233 | 272 | |
| 234 | 273 | private void stopStepService() { |
| 235 | - CollCommonInfo.setTsRunBaiduTraceService(getContext(), false); | |
| 236 | - CollCommonInfo.setIsRunKeepAliveService(getContext(), false); | |
| 237 | - CollCommonInfo.setIsWriteUserStep(getContext(), false); | |
| 238 | - CollCommonInfo.setIsFirstStepSendTraceTip(getContext(), true); | |
| 274 | + | |
| 239 | 275 | |
| 240 | 276 | if (CollStepService.mClient != null) { |
| 241 | 277 | CollStepService.mClient.stopGather(CollStepService.traceListener); | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/service/CollKeepLiveService.java
| ... | ... | @@ -217,11 +217,10 @@ public class CollKeepLiveService extends Service implements MediaPlayer.OnComple |
| 217 | 217 | @Override |
| 218 | 218 | public void onDestroy() { |
| 219 | 219 | super.onDestroy(); |
| 220 | - if (myReceiver != null) { | |
| 221 | - unregisterReceiver(myReceiver); | |
| 222 | - } | |
| 223 | 220 | try { |
| 224 | -// stopForeground(true); | |
| 221 | + if (myReceiver != null) { | |
| 222 | + unregisterReceiver(myReceiver); | |
| 223 | + } | |
| 225 | 224 | } catch (Exception e) { |
| 226 | 225 | } |
| 227 | 226 | stopPlaySong(); | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/service/CollStepService.java
| ... | ... | @@ -167,6 +167,7 @@ public class CollStepService extends Service implements SensorEventListener { |
| 167 | 167 | private static int retryIndex = 0; |
| 168 | 168 | |
| 169 | 169 | private void initTrace() { |
| 170 | + Log.e(TAG, "initTrace: "); | |
| 170 | 171 | if (mClient == null) { |
| 171 | 172 | mClient = new LBSTraceClient(getApplicationContext()); |
| 172 | 173 | // 设置定位和打包周期 |
| ... | ... | @@ -222,6 +223,7 @@ public class CollStepService extends Service implements SensorEventListener { |
| 222 | 223 | */ |
| 223 | 224 | @Override |
| 224 | 225 | public void onStartTraceCallback(int errorNo, String message) { |
| 226 | + Log.e(TAG, "onStartTraceCallback: " + message + "," + errorNo); | |
| 225 | 227 | if (StatusCodes.SUCCESS == errorNo || StatusCodes.START_TRACE_NETWORK_CONNECT_FAILED <= errorNo) { |
| 226 | 228 | //开始进行采集 |
| 227 | 229 | if (mClient != null) { |
| ... | ... | @@ -233,8 +235,6 @@ public class CollStepService extends Service implements SensorEventListener { |
| 233 | 235 | CollCommonInfo.setIsFirstStepSendTraceTip(getApplicationContext(), false); |
| 234 | 236 | EventBus.getDefault().post(new MessageEvent(Constant.COLL_START_TRACE_GATHER_SUCCESS, "")); |
| 235 | 237 | } |
| 236 | - | |
| 237 | - | |
| 238 | 238 | } |
| 239 | 239 | } else { |
| 240 | 240 | |
| ... | ... | @@ -243,6 +243,8 @@ public class CollStepService extends Service implements SensorEventListener { |
| 243 | 243 | if (mClient != null) { |
| 244 | 244 | mClient.startTrace(mTrace, traceListener); |
| 245 | 245 | retryIndex++; |
| 246 | + } else { | |
| 247 | + Log.e(TAG, "onStartTraceCallback: 失败"); | |
| 246 | 248 | } |
| 247 | 249 | } else { |
| 248 | 250 | boolean isFirstSendNotification = CollCommonInfo.getIsFirstStepSendTraceTip(getApplicationContext()); |
| ... | ... | @@ -272,7 +274,6 @@ public class CollStepService extends Service implements SensorEventListener { |
| 272 | 274 | if (mClient != null) { |
| 273 | 275 | mClient.stopTrace(mTrace, traceListener); |
| 274 | 276 | Toast.makeText(getApplicationContext(), "停止轨迹服务", Toast.LENGTH_LONG).show(); |
| 275 | - | |
| 276 | 277 | } |
| 277 | 278 | } |
| 278 | 279 | } |
| ... | ... | @@ -289,6 +290,7 @@ public class CollStepService extends Service implements SensorEventListener { |
| 289 | 290 | */ |
| 290 | 291 | @Override |
| 291 | 292 | public void onStartGatherCallback(int errorNo, String message) { |
| 293 | + Log.e(TAG, "onStartGatherCallback: " + message + "," + errorNo); | |
| 292 | 294 | if (StatusCodes.SUCCESS == errorNo || StatusCodes.GATHER_STARTED == errorNo) { |
| 293 | 295 | retryIndex = 0; |
| 294 | 296 | Toast.makeText(getApplicationContext(), "开始采集", Toast.LENGTH_LONG).show(); |
| ... | ... | @@ -299,6 +301,8 @@ public class CollStepService extends Service implements SensorEventListener { |
| 299 | 301 | mClient.startGather(traceListener); |
| 300 | 302 | } |
| 301 | 303 | retryIndex++; |
| 304 | + } else { | |
| 305 | + Log.e(TAG, "onStartGatherCallback: 失败"); | |
| 302 | 306 | } |
| 303 | 307 | } |
| 304 | 308 | } |
| ... | ... | @@ -362,13 +366,13 @@ public class CollStepService extends Service implements SensorEventListener { |
| 362 | 366 | @SuppressLint("WrongConstant") |
| 363 | 367 | @Override |
| 364 | 368 | public int onStartCommand(Intent intent, int flags, int startId) { |
| 369 | + if (!EventBus.getDefault().isRegistered(this)) { | |
| 370 | + EventBus.getDefault().register(this); | |
| 371 | + } | |
| 365 | 372 | userId = CollCommonInfo.getUserId(getApplicationContext()); |
| 366 | 373 | if (userId != null && !TextUtils.isEmpty(userId)) { |
| 367 | 374 | //初始化数据库 |
| 368 | 375 | CollStepUtil.initCollDataBase(getApplicationContext(), userId); |
| 369 | - if (!EventBus.getDefault().isRegistered(this)) { | |
| 370 | - EventBus.getDefault().register(this); | |
| 371 | - } | |
| 372 | 376 | entityName = userId; |
| 373 | 377 | initTodayData(userId); |
| 374 | 378 | initTrace(); |
| ... | ... | @@ -384,20 +388,6 @@ public class CollStepService extends Service implements SensorEventListener { |
| 384 | 388 | } else { |
| 385 | 389 | EventBus.getDefault().post(new MessageEvent(Constant.START_TRACE_GATHER_FAIL, "")); |
| 386 | 390 | } |
| 387 | -// if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { | |
| 388 | -// //开始配置JobInfo | |
| 389 | -// mServieComponent = new ComponentName(this, CollJobSchedulerService.class);// 获取到我们自己的jobservice,同时启动该service | |
| 390 | -// JobInfo.Builder builder = new JobInfo.Builder(mJobId++, mServieComponent); | |
| 391 | -//// builder.setOverrideDeadline(Long.valueOf(2) * 1000); | |
| 392 | -// //设置任务每隔intervalMillis运行一次 | |
| 393 | -// builder.setPeriodic(Long.valueOf(2) * 1000); | |
| 394 | -// //你的任务只有当用户没有在使用该设备且有一段时间没有使用时才会启动该任务。 | |
| 395 | -//// builder.setRequiresDeviceIdle(true); | |
| 396 | -//// builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY); | |
| 397 | -// JobScheduler mJobScheduler = (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE); | |
| 398 | -// mJobScheduler.schedule(builder.build()); | |
| 399 | -// | |
| 400 | -// } | |
| 401 | 391 | |
| 402 | 392 | flags = START_STICKY; |
| 403 | 393 | return super.onStartCommand(intent, flags, startId); |
| ... | ... | @@ -934,9 +924,8 @@ public class CollStepService extends Service implements SensorEventListener { |
| 934 | 924 | if (userStepEntity == null) { |
| 935 | 925 | CollUserStepEntity data = new CollUserStepEntity(); |
| 936 | 926 | data.setUserId(userId); |
| 937 | - data.setDate(CURRENT_DATE); | |
| 938 | 927 | data.setStepCount(tempStep + ""); |
| 939 | - CollStepUtil.insertCollStepData(getApplicationContext(), data); | |
| 928 | + CollStepUtil.insertCollStepData(getApplicationContext(), CollCommonInfo.getUserId(getApplicationContext()), data); | |
| 940 | 929 | } else { |
| 941 | 930 | userStepEntity.setStepCount(tempStep + ""); |
| 942 | 931 | CollStepUtil.updateCollStepData(getApplicationContext(), userStepEntity); | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/activity/RaceListActivity.java
| ... | ... | @@ -7,6 +7,7 @@ import android.os.Bundle; |
| 7 | 7 | |
| 8 | 8 | import com.cnlive.libs.base.util.StatusBarUtil; |
| 9 | 9 | import com.cnlive.libs.base.util.StatusBarUtil2; |
| 10 | +import com.cnlive.moudle.collectionTrace.commonInfo.CollCommonInfo; | |
| 10 | 11 | import com.cnlive.moudle.collectionTrace.ui.fragment.RaceListFragment; |
| 11 | 12 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 12 | 13 | import com.example.moudle_pedometer.R; |
| ... | ... | @@ -18,6 +19,7 @@ import com.example.moudle_pedometer.R; |
| 18 | 19 | public class RaceListActivity extends AppCompatActivity { |
| 19 | 20 | |
| 20 | 21 | public static void newInstance(Context context,String userId,String userName,String userIcon){ |
| 22 | + CollCommonInfo.setUserId(context, userId); | |
| 21 | 23 | Intent intent = new Intent(context,RaceListActivity.class); |
| 22 | 24 | intent.putExtra("userId",userId); |
| 23 | 25 | intent.putExtra("userName",userName); | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/fragment/CollRunningFinishFragment.java
| ... | ... | @@ -54,6 +54,7 @@ public class CollRunningFinishFragment extends QMUIFragment<CollRunningFinishFra |
| 54 | 54 | CollUserStepEntity collUserStepEntity = CollStepUtil.getCollUserStepData(getContext(), CommonInfo.getUserId(getContext())); |
| 55 | 55 | if (collUserStepEntity != null) { |
| 56 | 56 | if (getMvpView() != null) { |
| 57 | + getMvpView().initMap(); | |
| 57 | 58 | getMvpView().initView(collUserStepEntity); |
| 58 | 59 | } |
| 59 | 60 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/fragment/CollTraceListDetailFragment.java
| ... | ... | @@ -58,7 +58,8 @@ public class CollTraceListDetailFragment extends QMUIFragment<CollTraceListDetai |
| 58 | 58 | position = getArguments().getString("position"); |
| 59 | 59 | if (null != eventShoeLinesBean) { |
| 60 | 60 | if (null != getMvpView()) { |
| 61 | - getMvpView().initView(eventShoeLinesBean, fenceEntityName,position); | |
| 61 | + getMvpView().initMap(); | |
| 62 | + getMvpView().initView(eventShoeLinesBean, fenceEntityName, position); | |
| 62 | 63 | } |
| 63 | 64 | } |
| 64 | 65 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/utils/CollStepUtil.java
| ... | ... | @@ -41,16 +41,21 @@ public class CollStepUtil { |
| 41 | 41 | * @param fenceID |
| 42 | 42 | */ |
| 43 | 43 | public static void setFenceId(Context context, String uid, String fenceID) { |
| 44 | - //先获取有没有 | |
| 45 | - if (getCollUserStepData(context, uid) != null) { | |
| 46 | - CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 47 | - if (null != entity) { | |
| 48 | - //设置围栏id | |
| 49 | - entity.setFenceId(fenceID); | |
| 50 | - //更新数据 | |
| 51 | - updateCollStepData(context, entity); | |
| 44 | + try { | |
| 45 | + //先获取有没有 | |
| 46 | + if (getCollUserStepData(context, uid) != null) { | |
| 47 | + CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 48 | + if (null != entity) { | |
| 49 | + //设置围栏id | |
| 50 | + entity.setFenceId(fenceID); | |
| 51 | + //更新数据 | |
| 52 | + updateCollStepData(context, entity); | |
| 53 | + } | |
| 52 | 54 | } |
| 55 | + } catch (Exception e) { | |
| 56 | + Log.e(TAG, "setFenceId: " + e.getMessage()); | |
| 53 | 57 | } |
| 58 | + | |
| 54 | 59 | } |
| 55 | 60 | |
| 56 | 61 | /** |
| ... | ... | @@ -60,16 +65,21 @@ public class CollStepUtil { |
| 60 | 65 | * @param uid |
| 61 | 66 | */ |
| 62 | 67 | public static void setEmployTimeStamp(Context context, String uid, String employTime) { |
| 63 | - //先获取有没有 | |
| 64 | - if (getCollUserStepData(context, uid) != null) { | |
| 65 | - CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 66 | - if (null != entity) { | |
| 67 | - //设置用户完成时间 | |
| 68 | - entity.setEmployTime(employTime); | |
| 69 | - //更新数据 | |
| 70 | - updateCollStepData(context, entity); | |
| 68 | + try { | |
| 69 | + //先获取有没有 | |
| 70 | + if (getCollUserStepData(context, uid) != null) { | |
| 71 | + CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 72 | + if (null != entity) { | |
| 73 | + //设置用户完成时间 | |
| 74 | + entity.setEmployTime(employTime); | |
| 75 | + //更新数据 | |
| 76 | + updateCollStepData(context, entity); | |
| 77 | + } | |
| 71 | 78 | } |
| 79 | + } catch (Exception e) { | |
| 80 | + Log.e(TAG, "setEmployTimeStamp: " + e.getMessage()); | |
| 72 | 81 | } |
| 82 | + | |
| 73 | 83 | } |
| 74 | 84 | |
| 75 | 85 | /** |
| ... | ... | @@ -80,16 +90,21 @@ public class CollStepUtil { |
| 80 | 90 | * @param collectPoint |
| 81 | 91 | */ |
| 82 | 92 | public static void setCollEndPointData(Context context, String uid, CollectPoint collectPoint) { |
| 83 | - //先获取有没有 | |
| 84 | - if (getCollUserStepData(context, uid) != null) { | |
| 85 | - CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 86 | - if (null != entity) { | |
| 87 | - //设置用户结束数据 | |
| 88 | - entity.setCollEndPointData(GsonUtil.GsonString(collectPoint)); | |
| 89 | - //更新数据 | |
| 90 | - updateCollStepData(context, entity); | |
| 93 | + try { | |
| 94 | + //先获取有没有 | |
| 95 | + if (getCollUserStepData(context, uid) != null) { | |
| 96 | + CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 97 | + if (null != entity) { | |
| 98 | + //设置用户结束数据 | |
| 99 | + entity.setCollEndPointData(GsonUtil.GsonString(collectPoint)); | |
| 100 | + //更新数据 | |
| 101 | + updateCollStepData(context, entity); | |
| 102 | + } | |
| 91 | 103 | } |
| 104 | + } catch (Exception e) { | |
| 105 | + Log.e(TAG, "setCollEndPointData: " + e.getMessage()); | |
| 92 | 106 | } |
| 107 | + | |
| 93 | 108 | } |
| 94 | 109 | |
| 95 | 110 | |
| ... | ... | @@ -101,16 +116,21 @@ public class CollStepUtil { |
| 101 | 116 | * @param userFinishTime |
| 102 | 117 | */ |
| 103 | 118 | public static void setCollUserFinishTimeStamp(Context context, String uid, long userFinishTime) { |
| 104 | - //先获取有没有 | |
| 105 | - if (getCollUserStepData(context, uid) != null) { | |
| 106 | - CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 107 | - if (null != entity) { | |
| 108 | - //设置用户完成时间 | |
| 109 | - entity.setFinishTimeStamp(userFinishTime); | |
| 110 | - //更新数据 | |
| 111 | - updateCollStepData(context, entity); | |
| 119 | + try { | |
| 120 | + //先获取有没有 | |
| 121 | + if (getCollUserStepData(context, uid) != null) { | |
| 122 | + CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 123 | + if (null != entity) { | |
| 124 | + //设置用户完成时间 | |
| 125 | + entity.setFinishTimeStamp(userFinishTime); | |
| 126 | + //更新数据 | |
| 127 | + updateCollStepData(context, entity); | |
| 128 | + } | |
| 112 | 129 | } |
| 130 | + } catch (Exception e) { | |
| 131 | + Log.e(TAG, "setCollUserFinishTimeStamp: " + e.getMessage()); | |
| 113 | 132 | } |
| 133 | + | |
| 114 | 134 | } |
| 115 | 135 | |
| 116 | 136 | /** |
| ... | ... | @@ -120,23 +140,29 @@ public class CollStepUtil { |
| 120 | 140 | * @param uid |
| 121 | 141 | */ |
| 122 | 142 | public static List<CollectPoint> getCollImportPointList(Context context, String uid) { |
| 123 | - //先获取有没有 | |
| 124 | - if (getCollUserStepData(context, uid) != null) { | |
| 125 | - CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 126 | - if (null != entity) { | |
| 127 | - //判断有没有打过点 | |
| 128 | - if (!TextUtils.isEmpty(entity.getImportPoint())) { | |
| 129 | - //已经打过点,先把打的点取出来 | |
| 130 | - List<CollectPoint> lngs = GsonUtil.jsonToList(entity.getImportPoint(), CollectPoint.class); | |
| 131 | - if (null != lngs) { | |
| 132 | - return lngs; | |
| 133 | - } else { | |
| 134 | - return null; | |
| 143 | + try { | |
| 144 | + //先获取有没有 | |
| 145 | + if (getCollUserStepData(context, uid) != null) { | |
| 146 | + CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 147 | + if (null != entity) { | |
| 148 | + //判断有没有打过点 | |
| 149 | + if (!TextUtils.isEmpty(entity.getImportPoint())) { | |
| 150 | + //已经打过点,先把打的点取出来 | |
| 151 | + List<CollectPoint> lngs = GsonUtil.jsonToList(entity.getImportPoint(), CollectPoint.class); | |
| 152 | + if (null != lngs) { | |
| 153 | + return lngs; | |
| 154 | + } else { | |
| 155 | + return null; | |
| 156 | + } | |
| 135 | 157 | } |
| 136 | 158 | } |
| 137 | 159 | } |
| 160 | + return null; | |
| 161 | + } catch (Exception e) { | |
| 162 | + Log.e(TAG, "getCollImportPointList: " + e.getMessage()); | |
| 163 | + return null; | |
| 138 | 164 | } |
| 139 | - return null; | |
| 165 | + | |
| 140 | 166 | } |
| 141 | 167 | |
| 142 | 168 | |
| ... | ... | @@ -147,25 +173,29 @@ public class CollStepUtil { |
| 147 | 173 | * @param uid |
| 148 | 174 | */ |
| 149 | 175 | public static int getCollImportPointSize(Context context, String uid) { |
| 150 | - //先获取有没有 | |
| 151 | - if (getCollUserStepData(context, uid) != null) { | |
| 152 | - CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 153 | - if (null != entity) { | |
| 154 | - //判断有没有打过点 | |
| 155 | - if (!TextUtils.isEmpty(entity.getImportPoint())) { | |
| 156 | - //已经打过点,先把打的点取出来 | |
| 157 | - List<CollectPoint> lngs = GsonUtil.jsonToList(entity.getImportPoint(), CollectPoint.class); | |
| 158 | - if (null != lngs) { | |
| 159 | - return lngs.size(); | |
| 176 | + try { | |
| 177 | + //先获取有没有 | |
| 178 | + if (getCollUserStepData(context, uid) != null) { | |
| 179 | + CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 180 | + if (null != entity) { | |
| 181 | + //判断有没有打过点 | |
| 182 | + if (!TextUtils.isEmpty(entity.getImportPoint())) { | |
| 183 | + //已经打过点,先把打的点取出来 | |
| 184 | + List<CollectPoint> lngs = GsonUtil.jsonToList(entity.getImportPoint(), CollectPoint.class); | |
| 185 | + if (null != lngs) { | |
| 186 | + return lngs.size(); | |
| 187 | + } | |
| 160 | 188 | } else { |
| 161 | - return 98; | |
| 189 | + return 0; | |
| 162 | 190 | } |
| 163 | - } else { | |
| 164 | - return 0; | |
| 165 | 191 | } |
| 166 | 192 | } |
| 193 | + return 98; | |
| 194 | + } catch (Exception e) { | |
| 195 | + Log.e(TAG, "getCollImportPointSize: " + e.getMessage()); | |
| 196 | + return 98; | |
| 167 | 197 | } |
| 168 | - return 98; | |
| 198 | + | |
| 169 | 199 | } |
| 170 | 200 | |
| 171 | 201 | /** |
| ... | ... | @@ -175,12 +205,17 @@ public class CollStepUtil { |
| 175 | 205 | * @param uid |
| 176 | 206 | */ |
| 177 | 207 | public static void initCollDataBase(Context context, String uid) { |
| 178 | - if (null == getCollUserStepData(context, uid)) { | |
| 179 | - CollUserStepEntity entity = new CollUserStepEntity(); | |
| 180 | - entity.setUserId(uid); | |
| 181 | - insertCollStepData(context, entity); | |
| 208 | + try { | |
| 209 | + if (null == getCollUserStepData(context, uid)) { | |
| 210 | + CollUserStepEntity entity = new CollUserStepEntity(); | |
| 211 | + entity.setUserId(uid); | |
| 212 | + insertCollStepData(context,uid, entity); | |
| 213 | + } | |
| 214 | + } catch (Exception e) { | |
| 215 | + Log.e(TAG, "initCollDataBase: " + e.getMessage()); | |
| 182 | 216 | } |
| 183 | 217 | |
| 218 | + | |
| 184 | 219 | } |
| 185 | 220 | |
| 186 | 221 | |
| ... | ... | @@ -191,15 +226,20 @@ public class CollStepUtil { |
| 191 | 226 | * @param uid |
| 192 | 227 | */ |
| 193 | 228 | public static void setCollStartPointData(Context context, String uid, CollectPoint collectPoint) { |
| 194 | - //先获取有没有 | |
| 195 | - if (getCollUserStepData(context, uid) != null) { | |
| 196 | - CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 197 | - if (null != entity) { | |
| 198 | - entity.setCollStartPointData(GsonUtil.GsonString(collectPoint)); | |
| 199 | - //更新数据 | |
| 200 | - updateCollStepData(context, entity); | |
| 229 | + try { | |
| 230 | + //先获取有没有 | |
| 231 | + if (getCollUserStepData(context, uid) != null) { | |
| 232 | + CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 233 | + if (null != entity) { | |
| 234 | + entity.setCollStartPointData(GsonUtil.GsonString(collectPoint)); | |
| 235 | + //更新数据 | |
| 236 | + updateCollStepData(context, entity); | |
| 237 | + } | |
| 201 | 238 | } |
| 239 | + } catch (Exception e) { | |
| 240 | + Log.e(TAG, "setCollStartPointData: " + e.getMessage()); | |
| 202 | 241 | } |
| 242 | + | |
| 203 | 243 | } |
| 204 | 244 | |
| 205 | 245 | /** |
| ... | ... | @@ -210,38 +250,43 @@ public class CollStepUtil { |
| 210 | 250 | * @param collectPoint |
| 211 | 251 | */ |
| 212 | 252 | public static void setCollImportPoints(Context context, String uid, CollectPoint collectPoint) { |
| 213 | - //先获取有没有 | |
| 214 | - if (getCollUserStepData(context, uid) != null) { | |
| 215 | - CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 216 | - if (null != entity) { | |
| 217 | - //判断有没有打过点 | |
| 218 | - if (!TextUtils.isEmpty(entity.getImportPoint())) { | |
| 219 | - //已经打过点,先把打的点取出来 | |
| 220 | - List<CollectPoint> lngs = GsonUtil.jsonToList(entity.getImportPoint(), CollectPoint.class); | |
| 221 | - if (null != lngs) { | |
| 222 | - //加入新打的点 | |
| 223 | - if (!lngs.contains(collectPoint)) { | |
| 224 | - lngs.add(collectPoint); | |
| 225 | - //重新设置打的点 | |
| 226 | - entity.setImportPoint(GsonUtil.GsonString(lngs)); | |
| 227 | - //更新数据 | |
| 228 | - updateCollStepData(context, entity); | |
| 229 | - } | |
| 253 | + try { | |
| 254 | + //先获取有没有 | |
| 255 | + if (getCollUserStepData(context, uid) != null) { | |
| 256 | + CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 257 | + if (null != entity) { | |
| 258 | + //判断有没有打过点 | |
| 259 | + if (!TextUtils.isEmpty(entity.getImportPoint())) { | |
| 260 | + //已经打过点,先把打的点取出来 | |
| 261 | + List<CollectPoint> lngs = GsonUtil.jsonToList(entity.getImportPoint(), CollectPoint.class); | |
| 262 | + if (null != lngs) { | |
| 263 | + //加入新打的点 | |
| 264 | + if (!lngs.contains(collectPoint)) { | |
| 265 | + lngs.add(collectPoint); | |
| 266 | + //重新设置打的点 | |
| 267 | + entity.setImportPoint(GsonUtil.GsonString(lngs)); | |
| 268 | + //更新数据 | |
| 269 | + updateCollStepData(context, entity); | |
| 270 | + } | |
| 230 | 271 | |
| 272 | + } | |
| 273 | + } | |
| 274 | + //没有打过点 | |
| 275 | + else { | |
| 276 | + //则设置一个 | |
| 277 | + List<CollectPoint> lngs = new ArrayList<>(); | |
| 278 | + lngs.add(collectPoint); | |
| 279 | + //重新设置打的点 | |
| 280 | + entity.setImportPoint(GsonUtil.GsonString(lngs)); | |
| 281 | + //更新数据 | |
| 282 | + updateCollStepData(context, entity); | |
| 231 | 283 | } |
| 232 | - } | |
| 233 | - //没有打过点 | |
| 234 | - else { | |
| 235 | - //则设置一个 | |
| 236 | - List<CollectPoint> lngs = new ArrayList<>(); | |
| 237 | - lngs.add(collectPoint); | |
| 238 | - //重新设置打的点 | |
| 239 | - entity.setImportPoint(GsonUtil.GsonString(lngs)); | |
| 240 | - //更新数据 | |
| 241 | - updateCollStepData(context, entity); | |
| 242 | 284 | } |
| 243 | 285 | } |
| 286 | + } catch (Exception e) { | |
| 287 | + Log.e(TAG, "setCollImportPoints: " + e.getMessage()); | |
| 244 | 288 | } |
| 289 | + | |
| 245 | 290 | } |
| 246 | 291 | |
| 247 | 292 | /** |
| ... | ... | @@ -252,12 +297,17 @@ public class CollStepUtil { |
| 252 | 297 | * @param streetTitle |
| 253 | 298 | */ |
| 254 | 299 | public static void setCollStreetTitle(Context context, String uid, String streetTitle) { |
| 255 | - if (getCollUserStepData(context, uid) != null) { | |
| 256 | - CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 257 | - entity.setStreetTitle(streetTitle); | |
| 258 | - //更新数据 | |
| 259 | - updateCollStepData(context, entity); | |
| 300 | + try { | |
| 301 | + if (getCollUserStepData(context, uid) != null) { | |
| 302 | + CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 303 | + entity.setStreetTitle(streetTitle); | |
| 304 | + //更新数据 | |
| 305 | + updateCollStepData(context, entity); | |
| 306 | + } | |
| 307 | + } catch (Exception e) { | |
| 308 | + Log.e(TAG, "setCollStreetTitle: " + e.getMessage()); | |
| 260 | 309 | } |
| 310 | + | |
| 261 | 311 | } |
| 262 | 312 | |
| 263 | 313 | /** |
| ... | ... | @@ -267,11 +317,16 @@ public class CollStepUtil { |
| 267 | 317 | * @param userStepEntity |
| 268 | 318 | */ |
| 269 | 319 | public static void updateCollStepData(Context context, CollUserStepEntity userStepEntity) { |
| 270 | - if (userStepEntity != null) { | |
| 271 | - DbCore.init(context, dbName); | |
| 272 | - DbCore.getDaoSession().getCollUserStepEntityDao().update(userStepEntity); | |
| 320 | + try { | |
| 321 | + if (userStepEntity != null) { | |
| 322 | + DbCore.init(context, dbName); | |
| 323 | + DbCore.getDaoSession().getCollUserStepEntityDao().update(userStepEntity); | |
| 324 | + } | |
| 325 | + } catch (Exception e) { | |
| 326 | + Log.e(TAG, "updateCollStepData: " + e.getMessage()); | |
| 273 | 327 | } |
| 274 | 328 | |
| 329 | + | |
| 275 | 330 | } |
| 276 | 331 | |
| 277 | 332 | /** |
| ... | ... | @@ -280,9 +335,21 @@ public class CollStepUtil { |
| 280 | 335 | * @param context |
| 281 | 336 | * @param userStepEntity |
| 282 | 337 | */ |
| 283 | - public static void insertCollStepData(Context context, CollUserStepEntity userStepEntity) { | |
| 284 | - DbCore.init(context, dbName); | |
| 285 | - DbCore.getDaoSession().getCollUserStepEntityDao().insert(userStepEntity); | |
| 338 | + public static void insertCollStepData(Context context, String uid, CollUserStepEntity userStepEntity) { | |
| 339 | + | |
| 340 | + try { | |
| 341 | + if (null == getCollUserStepData(context, uid)) { | |
| 342 | + DbCore.init(context, dbName); | |
| 343 | + DbCore.getDaoSession().getCollUserStepEntityDao().insert(userStepEntity); | |
| 344 | + } else { | |
| 345 | + DbCore.init(context, dbName); | |
| 346 | + DbCore.getDaoSession().getCollUserStepEntityDao().update(userStepEntity); | |
| 347 | + } | |
| 348 | + } catch ( | |
| 349 | + Exception e) { | |
| 350 | + Log.e(TAG, "insertCollStepData: " + e.getMessage()); | |
| 351 | + } | |
| 352 | + | |
| 286 | 353 | } |
| 287 | 354 | |
| 288 | 355 | /** |
| ... | ... | @@ -293,18 +360,23 @@ public class CollStepUtil { |
| 293 | 360 | * @param time |
| 294 | 361 | */ |
| 295 | 362 | public static void setCollChronometerBase(Context context, String uid, long time) { |
| 296 | - if (getCollUserStepData(context, uid) != null) { | |
| 297 | - CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 298 | - entity.setChronometerBase(time); | |
| 299 | - //更新数据 | |
| 300 | - updateCollStepData(context, entity); | |
| 301 | - } else { | |
| 302 | - //创建数据 | |
| 303 | - CollUserStepEntity userStepEntity = new CollUserStepEntity(); | |
| 304 | - userStepEntity.setUserId(uid); | |
| 305 | - userStepEntity.setChronometerBase(time); | |
| 306 | - insertCollStepData(context, userStepEntity); | |
| 363 | + try { | |
| 364 | + if (getCollUserStepData(context, uid) != null) { | |
| 365 | + CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 366 | + entity.setChronometerBase(time); | |
| 367 | + //更新数据 | |
| 368 | + updateCollStepData(context, entity); | |
| 369 | + } else { | |
| 370 | + //创建数据 | |
| 371 | + CollUserStepEntity userStepEntity = new CollUserStepEntity(); | |
| 372 | + userStepEntity.setUserId(uid); | |
| 373 | + userStepEntity.setChronometerBase(time); | |
| 374 | + insertCollStepData(context, uid, userStepEntity); | |
| 375 | + } | |
| 376 | + } catch (Exception e) { | |
| 377 | + Log.e(TAG, "setCollChronometerBase: " + e.getMessage()); | |
| 307 | 378 | } |
| 379 | + | |
| 308 | 380 | } |
| 309 | 381 | |
| 310 | 382 | /** |
| ... | ... | @@ -316,20 +388,25 @@ public class CollStepUtil { |
| 316 | 388 | * @param streetId |
| 317 | 389 | */ |
| 318 | 390 | public static void setCollStepStartData(Context context, String uid, long startStamp, String streetId) { |
| 319 | - if (getCollUserStepData(context, uid) != null) { | |
| 320 | - CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 321 | - entity.setStartTimeStamp(startStamp); | |
| 322 | - entity.setStreetId(streetId); | |
| 323 | - //更新数据 | |
| 324 | - updateCollStepData(context, entity); | |
| 325 | - } else { | |
| 326 | - //创建数据 | |
| 327 | - CollUserStepEntity userStepEntity = new CollUserStepEntity(); | |
| 328 | - userStepEntity.setUserId(uid); | |
| 329 | - userStepEntity.setStartTimeStamp(startStamp); | |
| 330 | - userStepEntity.setStreetId(streetId); | |
| 331 | - insertCollStepData(context, userStepEntity); | |
| 391 | + try { | |
| 392 | + if (getCollUserStepData(context, uid) != null) { | |
| 393 | + CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 394 | + entity.setStartTimeStamp(startStamp); | |
| 395 | + entity.setStreetId(streetId); | |
| 396 | + //更新数据 | |
| 397 | + updateCollStepData(context, entity); | |
| 398 | + } else { | |
| 399 | + //创建数据 | |
| 400 | + CollUserStepEntity userStepEntity = new CollUserStepEntity(); | |
| 401 | + userStepEntity.setUserId(uid); | |
| 402 | + userStepEntity.setStartTimeStamp(startStamp); | |
| 403 | + userStepEntity.setStreetId(streetId); | |
| 404 | + insertCollStepData(context,uid, userStepEntity); | |
| 405 | + } | |
| 406 | + } catch (Exception e) { | |
| 407 | + Log.e(TAG, "setCollStepStartData: " + e.getMessage()); | |
| 332 | 408 | } |
| 409 | + | |
| 333 | 410 | } |
| 334 | 411 | |
| 335 | 412 | /** |
| ... | ... | @@ -383,14 +460,19 @@ public class CollStepUtil { |
| 383 | 460 | * @param uid |
| 384 | 461 | */ |
| 385 | 462 | public static void clearRunData(Context context, String uid) { |
| 386 | - DbCore.init(context, dbName); | |
| 387 | - String CURRENT_DATE = getTodayDate(); | |
| 388 | - List<CollUserStepEntity> list = DbCore.getDaoSession().getCollUserStepEntityDao().queryBuilder().where(CollUserStepEntityDao.Properties.UserId.eq(uid)).list(); | |
| 389 | - if (list != null && list.size() > 0) { | |
| 390 | - Log.e(TAG, "clearRunData: " + list.size()); | |
| 391 | - DbCore.getDaoSession().getCollUserStepEntityDao().deleteByKey(list.get(0).getUserId()); | |
| 392 | - DbCore.getDaoSession().getCollUserStepEntityDao().detachAll(); | |
| 463 | + try { | |
| 464 | + DbCore.init(context, dbName); | |
| 465 | + String CURRENT_DATE = getTodayDate(); | |
| 466 | + List<CollUserStepEntity> list = DbCore.getDaoSession().getCollUserStepEntityDao().queryBuilder().where(CollUserStepEntityDao.Properties.UserId.eq(uid)).list(); | |
| 467 | + if (list != null && list.size() > 0) { | |
| 468 | + Log.e(TAG, "clearRunData: " + list.size()); | |
| 469 | + DbCore.getDaoSession().getCollUserStepEntityDao().deleteByKey(list.get(0).getUserId()); | |
| 470 | + DbCore.getDaoSession().getCollUserStepEntityDao().detachAll(); | |
| 471 | + } | |
| 472 | + } catch (Exception e) { | |
| 473 | + Log.e(TAG, "clearRunData: " + e.getMessage()); | |
| 393 | 474 | } |
| 475 | + | |
| 394 | 476 | } |
| 395 | 477 | |
| 396 | 478 | /** |
| ... | ... | @@ -401,36 +483,28 @@ public class CollStepUtil { |
| 401 | 483 | * @return |
| 402 | 484 | */ |
| 403 | 485 | public static CollUserStepEntity getCollUserStepData(Context context, String uid) { |
| 404 | - if (!TextUtils.isEmpty(uid)) { | |
| 405 | - DbCore.init(context, dbName); | |
| 406 | - DbCore.getDaoSession().getCollUserStepEntityDao().detachAll(); | |
| 407 | - DbCore.getDaoSession().clear(); | |
| 408 | - List<CollUserStepEntity> list = DbCore.getDaoSession().getCollUserStepEntityDao().queryBuilder().where(CollUserStepEntityDao.Properties.UserId.eq(uid)).list(); | |
| 409 | - if (list != null && list.size() > 0) { | |
| 410 | - return list.get(0); | |
| 486 | + try { | |
| 487 | + if (!TextUtils.isEmpty(uid)) { | |
| 488 | + DbCore.init(context, dbName); | |
| 489 | + DbCore.getDaoSession().getCollUserStepEntityDao().detachAll(); | |
| 490 | + DbCore.getDaoSession().clear(); | |
| 491 | + List<CollUserStepEntity> list = DbCore.getDaoSession().getCollUserStepEntityDao().queryBuilder().where(CollUserStepEntityDao.Properties.UserId.eq(uid)).list(); | |
| 492 | + if (list != null && list.size() > 0) { | |
| 493 | + return list.get(0); | |
| 494 | + } else { | |
| 495 | + return null; | |
| 496 | + } | |
| 411 | 497 | } else { |
| 412 | 498 | return null; |
| 413 | 499 | } |
| 414 | - } else { | |
| 500 | + } catch (Exception e) { | |
| 501 | + Log.e(TAG, "getCollUserStepData: " + e.getMessage()); | |
| 415 | 502 | return null; |
| 416 | 503 | } |
| 417 | - } | |
| 418 | 504 | |
| 419 | - /** | |
| 420 | - * 获取用户数据 | |
| 421 | - * | |
| 422 | - * @param context | |
| 423 | - * @param uid | |
| 424 | - * @return | |
| 425 | - */ | |
| 426 | - public static void setServerTraceData(Context context, String uid, CollUserStepEntity userStepEntity) { | |
| 427 | - if (getCollUserStepData(context, uid) != null) { | |
| 428 | - CollUserStepEntity entity = getCollUserStepData(context, uid); | |
| 429 | - } else { | |
| 430 | - | |
| 431 | - } | |
| 432 | 505 | } |
| 433 | 506 | |
| 507 | + | |
| 434 | 508 | /** |
| 435 | 509 | * 获取当天日期 |
| 436 | 510 | * | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/DaoMaster.java
| ... | ... | @@ -21,18 +21,18 @@ public class DaoMaster extends AbstractDaoMaster { |
| 21 | 21 | |
| 22 | 22 | /** Creates underlying database table using DAOs. */ |
| 23 | 23 | public static void createAllTables(Database db, boolean ifNotExists) { |
| 24 | + CollFailedEntityDao.createTable(db, ifNotExists); | |
| 24 | 25 | CollUserStepEntityDao.createTable(db, ifNotExists); |
| 25 | 26 | FailedEntityDao.createTable(db, ifNotExists); |
| 26 | 27 | UserStepEntityDao.createTable(db, ifNotExists); |
| 27 | - CollFailedEntityDao.createTable(db, ifNotExists); | |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** Drops underlying database table using DAOs. */ |
| 31 | 31 | public static void dropAllTables(Database db, boolean ifExists) { |
| 32 | + CollFailedEntityDao.dropTable(db, ifExists); | |
| 32 | 33 | CollUserStepEntityDao.dropTable(db, ifExists); |
| 33 | 34 | FailedEntityDao.dropTable(db, ifExists); |
| 34 | 35 | UserStepEntityDao.dropTable(db, ifExists); |
| 35 | - CollFailedEntityDao.dropTable(db, ifExists); | |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
| ... | ... | @@ -51,10 +51,10 @@ public class DaoMaster extends AbstractDaoMaster { |
| 51 | 51 | |
| 52 | 52 | public DaoMaster(Database db) { |
| 53 | 53 | super(db, SCHEMA_VERSION); |
| 54 | + registerDaoClass(CollFailedEntityDao.class); | |
| 54 | 55 | registerDaoClass(CollUserStepEntityDao.class); |
| 55 | 56 | registerDaoClass(FailedEntityDao.class); |
| 56 | 57 | registerDaoClass(UserStepEntityDao.class); |
| 57 | - registerDaoClass(CollFailedEntityDao.class); | |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | public DaoSession newSession() { | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/DaoSession.java
| ... | ... | @@ -8,15 +8,15 @@ import org.greenrobot.greendao.database.Database; |
| 8 | 8 | import org.greenrobot.greendao.identityscope.IdentityScopeType; |
| 9 | 9 | import org.greenrobot.greendao.internal.DaoConfig; |
| 10 | 10 | |
| 11 | +import com.cnlive.moudle.pedometer.sql.entity.CollFailedEntity; | |
| 11 | 12 | import com.cnlive.moudle.pedometer.sql.entity.CollUserStepEntity; |
| 12 | 13 | import com.cnlive.moudle.pedometer.sql.entity.FailedEntity; |
| 13 | 14 | import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; |
| 14 | -import com.cnlive.moudle.pedometer.sql.entity.CollFailedEntity; | |
| 15 | 15 | |
| 16 | +import com.cnlive.moudle.pedometer.sql.dao.CollFailedEntityDao; | |
| 16 | 17 | import com.cnlive.moudle.pedometer.sql.dao.CollUserStepEntityDao; |
| 17 | 18 | import com.cnlive.moudle.pedometer.sql.dao.FailedEntityDao; |
| 18 | 19 | import com.cnlive.moudle.pedometer.sql.dao.UserStepEntityDao; |
| 19 | -import com.cnlive.moudle.pedometer.sql.dao.CollFailedEntityDao; | |
| 20 | 20 | |
| 21 | 21 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. |
| 22 | 22 | |
| ... | ... | @@ -27,20 +27,23 @@ import com.cnlive.moudle.pedometer.sql.dao.CollFailedEntityDao; |
| 27 | 27 | */ |
| 28 | 28 | public class DaoSession extends AbstractDaoSession { |
| 29 | 29 | |
| 30 | + private final DaoConfig collFailedEntityDaoConfig; | |
| 30 | 31 | private final DaoConfig collUserStepEntityDaoConfig; |
| 31 | 32 | private final DaoConfig failedEntityDaoConfig; |
| 32 | 33 | private final DaoConfig userStepEntityDaoConfig; |
| 33 | - private final DaoConfig collFailedEntityDaoConfig; | |
| 34 | 34 | |
| 35 | + private final CollFailedEntityDao collFailedEntityDao; | |
| 35 | 36 | private final CollUserStepEntityDao collUserStepEntityDao; |
| 36 | 37 | private final FailedEntityDao failedEntityDao; |
| 37 | 38 | private final UserStepEntityDao userStepEntityDao; |
| 38 | - private final CollFailedEntityDao collFailedEntityDao; | |
| 39 | 39 | |
| 40 | 40 | public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> |
| 41 | 41 | daoConfigMap) { |
| 42 | 42 | super(db); |
| 43 | 43 | |
| 44 | + collFailedEntityDaoConfig = daoConfigMap.get(CollFailedEntityDao.class).clone(); | |
| 45 | + collFailedEntityDaoConfig.initIdentityScope(type); | |
| 46 | + | |
| 44 | 47 | collUserStepEntityDaoConfig = daoConfigMap.get(CollUserStepEntityDao.class).clone(); |
| 45 | 48 | collUserStepEntityDaoConfig.initIdentityScope(type); |
| 46 | 49 | |
| ... | ... | @@ -50,25 +53,26 @@ public class DaoSession extends AbstractDaoSession { |
| 50 | 53 | userStepEntityDaoConfig = daoConfigMap.get(UserStepEntityDao.class).clone(); |
| 51 | 54 | userStepEntityDaoConfig.initIdentityScope(type); |
| 52 | 55 | |
| 53 | - collFailedEntityDaoConfig = daoConfigMap.get(CollFailedEntityDao.class).clone(); | |
| 54 | - collFailedEntityDaoConfig.initIdentityScope(type); | |
| 55 | - | |
| 56 | + collFailedEntityDao = new CollFailedEntityDao(collFailedEntityDaoConfig, this); | |
| 56 | 57 | collUserStepEntityDao = new CollUserStepEntityDao(collUserStepEntityDaoConfig, this); |
| 57 | 58 | failedEntityDao = new FailedEntityDao(failedEntityDaoConfig, this); |
| 58 | 59 | userStepEntityDao = new UserStepEntityDao(userStepEntityDaoConfig, this); |
| 59 | - collFailedEntityDao = new CollFailedEntityDao(collFailedEntityDaoConfig, this); | |
| 60 | 60 | |
| 61 | + registerDao(CollFailedEntity.class, collFailedEntityDao); | |
| 61 | 62 | registerDao(CollUserStepEntity.class, collUserStepEntityDao); |
| 62 | 63 | registerDao(FailedEntity.class, failedEntityDao); |
| 63 | 64 | registerDao(UserStepEntity.class, userStepEntityDao); |
| 64 | - registerDao(CollFailedEntity.class, collFailedEntityDao); | |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | public void clear() { |
| 68 | + collFailedEntityDaoConfig.clearIdentityScope(); | |
| 68 | 69 | collUserStepEntityDaoConfig.clearIdentityScope(); |
| 69 | 70 | failedEntityDaoConfig.clearIdentityScope(); |
| 70 | 71 | userStepEntityDaoConfig.clearIdentityScope(); |
| 71 | - collFailedEntityDaoConfig.clearIdentityScope(); | |
| 72 | + } | |
| 73 | + | |
| 74 | + public CollFailedEntityDao getCollFailedEntityDao() { | |
| 75 | + return collFailedEntityDao; | |
| 72 | 76 | } |
| 73 | 77 | |
| 74 | 78 | public CollUserStepEntityDao getCollUserStepEntityDao() { |
| ... | ... | @@ -83,8 +87,4 @@ public class DaoSession extends AbstractDaoSession { |
| 83 | 87 | return userStepEntityDao; |
| 84 | 88 | } |
| 85 | 89 | |
| 86 | - public CollFailedEntityDao getCollFailedEntityDao() { | |
| 87 | - return collFailedEntityDao; | |
| 88 | - } | |
| 89 | - | |
| 90 | 90 | } | ... | ... |
moudle_pedometer/src/main/res/layout/fragment_collect_running_map.xml
| ... | ... | @@ -160,12 +160,12 @@ |
| 160 | 160 | android:id="@+id/tv_can_take_point_size" |
| 161 | 161 | android:layout_width="wrap_content" |
| 162 | 162 | android:layout_height="wrap_content" |
| 163 | - android:layout_marginLeft="30dp" | |
| 163 | + android:layout_gravity="right" | |
| 164 | 164 | android:layout_marginTop="10dp" |
| 165 | + android:layout_marginRight="30dp" | |
| 165 | 166 | android:text="可打点数量" |
| 166 | - android:textColor="@color/text_black" | |
| 167 | - android:textSize="12sp" | |
| 168 | - android:textStyle="bold" /> | |
| 167 | + android:textColor="@color/text_gray" | |
| 168 | + android:textSize="12sp" /> | |
| 169 | 169 | |
| 170 | 170 | <LinearLayout |
| 171 | 171 | android:layout_width="match_parent" | ... | ... |