Commit 7ea646bdca48097203f6365be9eee0b71ea74c33
Merge branch 'master' of bj.gitlab.cnlive.com:cnlive-team/ModulePedometer
Showing
12 changed files
with
632 additions
and
314 deletions
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/commonInfo/CommonInfo.java
| @@ -276,11 +276,31 @@ public class CommonInfo { | @@ -276,11 +276,31 @@ public class CommonInfo { | ||
| 276 | return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("IsFirstShowTimeTip", true); | 276 | return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("IsFirstShowTimeTip", true); |
| 277 | } | 277 | } |
| 278 | 278 | ||
| 279 | + /** | ||
| 280 | + * 是否暂停 | ||
| 281 | + * | ||
| 282 | + * @param context | ||
| 283 | + * @param isAllow | ||
| 284 | + */ | ||
| 285 | + public static void setIsPauseState(Context context, boolean isAllow) { | ||
| 286 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).putBoolean("runIsPauseState", isAllow); | ||
| 287 | + } | ||
| 288 | + | ||
| 289 | + /** | ||
| 290 | + * 获取是否暂停 | ||
| 291 | + * | ||
| 292 | + * @param context | ||
| 293 | + */ | ||
| 294 | + public static boolean getIsPause(Context context) { | ||
| 295 | + return MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).getBoolean("runIsPauseState", false); | ||
| 296 | + } | ||
| 279 | 297 | ||
| 280 | /*重置 | 298 | /*重置 |
| 281 | * @param context | 299 | * @param context |
| 282 | */ | 300 | */ |
| 283 | public static void reset(Context context) { | 301 | public static void reset(Context context) { |
| 302 | + | ||
| 303 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("IsFirstShowTimeTip"); | ||
| 284 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("writeUserStep"); | 304 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("writeUserStep"); |
| 285 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("runStepService"); | 305 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("runStepService"); |
| 286 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("KeepAliveService"); | 306 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("KeepAliveService"); |
| @@ -295,6 +315,7 @@ public class CommonInfo { | @@ -295,6 +315,7 @@ public class CommonInfo { | ||
| 295 | * @param context | 315 | * @param context |
| 296 | */ | 316 | */ |
| 297 | public static void resetRace(Context context) { | 317 | public static void resetRace(Context context) { |
| 318 | + MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("IsFirstShowTimeTip"); | ||
| 298 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("writeUserStep"); | 319 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("writeUserStep"); |
| 299 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("runStepService"); | 320 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("runStepService"); |
| 300 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("KeepAliveService"); | 321 | MySpHelper.getInstance(context, Context.MODE_MULTI_PROCESS).removeKey("KeepAliveService"); |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/presenter/RunningMapFragmentPresenter.java
| @@ -69,6 +69,7 @@ import com.cnlive.moudle.pedometer.utils.CommonUtil; | @@ -69,6 +69,7 @@ import com.cnlive.moudle.pedometer.utils.CommonUtil; | ||
| 69 | import com.cnlive.moudle.pedometer.utils.GsonUtil; | 69 | import com.cnlive.moudle.pedometer.utils.GsonUtil; |
| 70 | import com.cnlive.moudle.pedometer.utils.MapUtil; | 70 | import com.cnlive.moudle.pedometer.utils.MapUtil; |
| 71 | import com.cnlive.moudle.pedometer.utils.MyMapUtil; | 71 | import com.cnlive.moudle.pedometer.utils.MyMapUtil; |
| 72 | +import com.cnlive.moudle.pedometer.utils.StepUtil; | ||
| 72 | import com.example.moudle_pedometer.R; | 73 | import com.example.moudle_pedometer.R; |
| 73 | import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; | 74 | import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; |
| 74 | 75 | ||
| @@ -105,144 +106,169 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter<RunningMapFrag | @@ -105,144 +106,169 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter<RunningMapFrag | ||
| 105 | /** | 106 | /** |
| 106 | * 轨迹点集合 | 107 | * 轨迹点集合 |
| 107 | */ | 108 | */ |
| 108 | - private List<LatLng> trackPoints; | ||
| 109 | private List<LatLng> realTimePoints; | 109 | private List<LatLng> realTimePoints; |
| 110 | private String imports = "[{\"latitude\":39.93395837223,\"latitudeE6\":3.993395837223E7,\"longitude\":116.30855458458,\"longitudeE6\":1.1630855458457999E8},{\"latitude\":39.93396326228,\"latitudeE6\":3.993396326228E7,\"longitude\":116.30861833018,\"longitudeE6\":1.1630861833017999E8},{\"latitude\":39.934156956749995,\"latitudeE6\":3.993415695675E7,\"longitude\":116.30869672329999,\"longitudeE6\":1.163086967233E8},{\"latitude\":39.934220163784,\"latitudeE6\":3.9934220163784E7,\"longitude\":116.3087100148,\"longitudeE6\":1.163087100148E8},{\"latitude\":39.934285263072,\"latitudeE6\":3.9934285263072E7,\"longitude\":116.30866498582,\"longitudeE6\":1.1630866498582E8},{\"latitude\":39.934351994321,\"latitudeE6\":3.9934351994320996E7,\"longitude\":116.30865820422,\"longitudeE6\":1.1630865820422E8},{\"latitude\":39.934393506188,\"latitudeE6\":3.9934393506188005E7,\"longitude\":116.3087268324,\"longitudeE6\":1.163087268324E8},{\"latitude\":39.934515310648,\"latitudeE6\":3.9934515310648E7,\"longitude\":116.30877023341,\"longitudeE6\":1.1630877023341E8},{\"latitude\":39.934576888398,\"latitudeE6\":3.9934576888398E7,\"longitude\":116.30876860572,\"longitudeE6\":1.1630876860572E8},{\"latitude\":39.934641987882,\"latitudeE6\":3.9934641987882E7,\"longitude\":116.30872520428,\"longitudeE6\":1.1630872520427999E8},{\"latitude\":39.934720386354,\"latitudeE6\":3.9934720386354E7,\"longitude\":116.30874175083,\"longitudeE6\":1.1630874175083E8},{\"latitude\":39.934703845843,\"latitudeE6\":3.9934703845843E7,\"longitude\":116.30880197017,\"longitudeE6\":1.1630880197016999E8},{\"latitude\":39.934719055573,\"latitudeE6\":3.9934719055573E7,\"longitude\":116.30896553874,\"longitudeE6\":1.1630896553874E8},{\"latitude\":39.93482461107,\"latitudeE6\":3.993482461107E7,\"longitude\":116.30924466304002,\"longitudeE6\":1.1630924466304001E8},{\"latitude\":39.934804821527,\"latitudeE6\":3.9934804821527004E7,\"longitude\":116.30935804892,\"longitudeE6\":1.1630935804892E8},{\"latitude\":39.934856643274,\"latitudeE6\":3.9934856643274E7,\"longitude\":116.30943996874,\"longitudeE6\":1.1630943996874E8},{\"latitude\":39.934844987999,\"latitudeE6\":3.9934844987999E7,\"longitude\":116.30952026112,\"longitudeE6\":1.1630952026112E8},{\"latitude\":39.934722121282,\"latitudeE6\":3.9934722121282004E7,\"longitude\":116.30967542086,\"longitudeE6\":1.1630967542086E8},{\"latitude\":39.934828721701,\"latitudeE6\":3.9934828721701E7,\"longitude\":116.30960516489,\"longitudeE6\":1.1630960516489E8},{\"latitude\":39.934408798988,\"latitudeE6\":3.9934408798988E7,\"longitude\":116.30961357453,\"longitudeE6\":1.1630961357453E8},{\"latitude\":39.934345321571,\"latitudeE6\":3.9934345321571E7,\"longitude\":116.30960842073,\"longitudeE6\":1.1630960842073E8},{\"latitude\":39.93436159016,\"latitudeE6\":3.9934361590160005E7,\"longitude\":116.30954331882,\"longitudeE6\":1.1630954331882E8},{\"latitude\":39.934295133241,\"latitudeE6\":3.9934295133241E7,\"longitude\":116.30957668364,\"longitudeE6\":1.1630957668364E8},{\"latitude\":39.934188525341,\"latitudeE6\":3.9934188525341E7,\"longitude\":116.30958183769,\"longitudeE6\":1.1630958183769001E8},{\"latitude\":39.933976660469,\"latitudeE6\":3.9933976660469E7,\"longitude\":116.30954494693,\"longitudeE6\":1.1630954494693E8},{\"latitude\":39.933993190121,\"latitudeE6\":3.9933993190121E7,\"longitude\":116.30939114375,\"longitudeE6\":1.1630939114375001E8},{\"latitude\":39.933938115564,\"latitudeE6\":3.9933938115563996E7,\"longitude\":116.30932956832,\"longitudeE6\":1.1630932956831999E8},{\"latitude\":39.933916130555,\"latitudeE6\":3.9933916130555E7,\"longitude\":116.30922269279,\"longitudeE6\":1.1630922269279E8},{\"latitude\":39.933836097011,\"latitudeE6\":3.9933836097011E7,\"longitude\":116.30914077307,\"longitudeE6\":1.1630914077307E8}]\n"; | 110 | private String imports = "[{\"latitude\":39.93395837223,\"latitudeE6\":3.993395837223E7,\"longitude\":116.30855458458,\"longitudeE6\":1.1630855458457999E8},{\"latitude\":39.93396326228,\"latitudeE6\":3.993396326228E7,\"longitude\":116.30861833018,\"longitudeE6\":1.1630861833017999E8},{\"latitude\":39.934156956749995,\"latitudeE6\":3.993415695675E7,\"longitude\":116.30869672329999,\"longitudeE6\":1.163086967233E8},{\"latitude\":39.934220163784,\"latitudeE6\":3.9934220163784E7,\"longitude\":116.3087100148,\"longitudeE6\":1.163087100148E8},{\"latitude\":39.934285263072,\"latitudeE6\":3.9934285263072E7,\"longitude\":116.30866498582,\"longitudeE6\":1.1630866498582E8},{\"latitude\":39.934351994321,\"latitudeE6\":3.9934351994320996E7,\"longitude\":116.30865820422,\"longitudeE6\":1.1630865820422E8},{\"latitude\":39.934393506188,\"latitudeE6\":3.9934393506188005E7,\"longitude\":116.3087268324,\"longitudeE6\":1.163087268324E8},{\"latitude\":39.934515310648,\"latitudeE6\":3.9934515310648E7,\"longitude\":116.30877023341,\"longitudeE6\":1.1630877023341E8},{\"latitude\":39.934576888398,\"latitudeE6\":3.9934576888398E7,\"longitude\":116.30876860572,\"longitudeE6\":1.1630876860572E8},{\"latitude\":39.934641987882,\"latitudeE6\":3.9934641987882E7,\"longitude\":116.30872520428,\"longitudeE6\":1.1630872520427999E8},{\"latitude\":39.934720386354,\"latitudeE6\":3.9934720386354E7,\"longitude\":116.30874175083,\"longitudeE6\":1.1630874175083E8},{\"latitude\":39.934703845843,\"latitudeE6\":3.9934703845843E7,\"longitude\":116.30880197017,\"longitudeE6\":1.1630880197016999E8},{\"latitude\":39.934719055573,\"latitudeE6\":3.9934719055573E7,\"longitude\":116.30896553874,\"longitudeE6\":1.1630896553874E8},{\"latitude\":39.93482461107,\"latitudeE6\":3.993482461107E7,\"longitude\":116.30924466304002,\"longitudeE6\":1.1630924466304001E8},{\"latitude\":39.934804821527,\"latitudeE6\":3.9934804821527004E7,\"longitude\":116.30935804892,\"longitudeE6\":1.1630935804892E8},{\"latitude\":39.934856643274,\"latitudeE6\":3.9934856643274E7,\"longitude\":116.30943996874,\"longitudeE6\":1.1630943996874E8},{\"latitude\":39.934844987999,\"latitudeE6\":3.9934844987999E7,\"longitude\":116.30952026112,\"longitudeE6\":1.1630952026112E8},{\"latitude\":39.934722121282,\"latitudeE6\":3.9934722121282004E7,\"longitude\":116.30967542086,\"longitudeE6\":1.1630967542086E8},{\"latitude\":39.934828721701,\"latitudeE6\":3.9934828721701E7,\"longitude\":116.30960516489,\"longitudeE6\":1.1630960516489E8},{\"latitude\":39.934408798988,\"latitudeE6\":3.9934408798988E7,\"longitude\":116.30961357453,\"longitudeE6\":1.1630961357453E8},{\"latitude\":39.934345321571,\"latitudeE6\":3.9934345321571E7,\"longitude\":116.30960842073,\"longitudeE6\":1.1630960842073E8},{\"latitude\":39.93436159016,\"latitudeE6\":3.9934361590160005E7,\"longitude\":116.30954331882,\"longitudeE6\":1.1630954331882E8},{\"latitude\":39.934295133241,\"latitudeE6\":3.9934295133241E7,\"longitude\":116.30957668364,\"longitudeE6\":1.1630957668364E8},{\"latitude\":39.934188525341,\"latitudeE6\":3.9934188525341E7,\"longitude\":116.30958183769,\"longitudeE6\":1.1630958183769001E8},{\"latitude\":39.933976660469,\"latitudeE6\":3.9933976660469E7,\"longitude\":116.30954494693,\"longitudeE6\":1.1630954494693E8},{\"latitude\":39.933993190121,\"latitudeE6\":3.9933993190121E7,\"longitude\":116.30939114375,\"longitudeE6\":1.1630939114375001E8},{\"latitude\":39.933938115564,\"latitudeE6\":3.9933938115563996E7,\"longitude\":116.30932956832,\"longitudeE6\":1.1630932956831999E8},{\"latitude\":39.933916130555,\"latitudeE6\":3.9933916130555E7,\"longitude\":116.30922269279,\"longitudeE6\":1.1630922269279E8},{\"latitude\":39.933836097011,\"latitudeE6\":3.9933836097011E7,\"longitude\":116.30914077307,\"longitudeE6\":1.1630914077307E8}]\n"; |
| 111 | private HashMap<Integer, Boolean> importHash; | 111 | private HashMap<Integer, Boolean> importHash; |
| 112 | private static int matchIndex = 0; | 112 | private static int matchIndex = 0; |
| 113 | 113 | ||
| 114 | - /** | ||
| 115 | - * 查询历史轨迹 | ||
| 116 | - * | ||
| 117 | - * @param startTime | ||
| 118 | - * @param endTime | ||
| 119 | - */ | ||
| 120 | - public void queryHistoryTrace(Context context, String entityName, long startTime, long endTime) { | ||
| 121 | - Log.e(TAG, "queryHistoryTrace: 时间:" + startTime); | ||
| 122 | - importHash = new HashMap<>(); | ||
| 123 | - matchIndex = 0; | ||
| 124 | - //打的重要点 | ||
| 125 | - List<LatLng> importPoints = GsonUtil.jsonToList(imports, LatLng.class); | ||
| 126 | - for (int i = 0; i < importPoints.size(); i++) { | ||
| 127 | - if (i % 3 != 0) { | ||
| 128 | - importPoints.remove(i); | ||
| 129 | - } | ||
| 130 | - } | ||
| 131 | - | ||
| 132 | - for (int i = 0; i < importPoints.size(); i++) { | ||
| 133 | - importHash.put(i, false); | ||
| 134 | - } | ||
| 135 | - | ||
| 136 | - if (historyTrackRequest == null) { | ||
| 137 | - historyTrackRequest = new HistoryTrackRequest(tag, Constant.SERVICE_ID, entityName); | ||
| 138 | - //设置查询设备名称 | ||
| 139 | - historyTrackRequest.setEntityName(entityName); | ||
| 140 | - //历史轨迹开始时间 | ||
| 141 | - historyTrackRequest.setStartTime(startTime); | ||
| 142 | - //历史轨迹结束时间 | ||
| 143 | - historyTrackRequest.setEndTime(endTime); | ||
| 144 | - //分页索引 | ||
| 145 | - historyTrackRequest.setPageIndex(pageIndex); | ||
| 146 | - //分页大小 | ||
| 147 | - historyTrackRequest.setPageSize(pageSize); | ||
| 148 | - //设置是否进行纠偏 | ||
| 149 | - historyTrackRequest.setProcessed(true); | ||
| 150 | - //设置返回坐标系 | ||
| 151 | - historyTrackRequest.setCoordTypeOutput(CoordType.gcj02); | ||
| 152 | - //其他设置 | ||
| 153 | - ProcessOption processOption = new ProcessOption(); | ||
| 154 | - //去噪:可设置是否需要去除角度、速度和方向异常的轨迹点 | ||
| 155 | - processOption.setNeedDenoise(true); | ||
| 156 | - //绑路:设置是否将轨迹点绑定至路网道路 | ||
| 157 | - processOption.setNeedMapMatch(false); | ||
| 158 | - //抽稀:设置是否进行抽稀处理,对冗余的轨迹点进行抽稀去除处理,如一条直线上除起终点外的多个轨迹点 | ||
| 159 | - processOption.setNeedVacuate(true); | ||
| 160 | - //自动判断交通方式 | ||
| 161 | - processOption.setTransportMode(TransportMode.walking); | ||
| 162 | - // 设置精度过滤值(定位精度大于100米的过滤掉) | ||
| 163 | - processOption.setRadiusThreshold(9); | ||
| 164 | - // 设置纠偏选项 | ||
| 165 | - historyTrackRequest.setProcessOption(processOption); | ||
| 166 | - // 设置里程填充方式为驾车 | ||
| 167 | - historyTrackRequest.setSupplementMode(SupplementMode.walking); | ||
| 168 | - | ||
| 169 | - } | ||
| 170 | - //创建里程查询 | ||
| 171 | - if (distanceRequest == null) { | ||
| 172 | - // 创建里程查询请求实例 | ||
| 173 | - distanceRequest = new DistanceRequest(tag, Constant.SERVICE_ID, entityName); | ||
| 174 | - // 设置开始时间 | ||
| 175 | - distanceRequest.setStartTime(startTime); | ||
| 176 | - // 设置结束时间 | ||
| 177 | - distanceRequest.setEndTime(endTime); | ||
| 178 | - // 设置需要纠偏 | ||
| 179 | - distanceRequest.setProcessed(true); | ||
| 180 | - | ||
| 181 | - // 创建纠偏选项实例 | ||
| 182 | - ProcessOption processOption = new ProcessOption(); | ||
| 183 | - // 设置需要去噪 | ||
| 184 | - processOption.setNeedDenoise(true); | ||
| 185 | - // 设置需要绑路 | ||
| 186 | - processOption.setNeedMapMatch(false); | ||
| 187 | - //抽稀:设置是否进行抽稀处理,对冗余的轨迹点进行抽稀去除处理,如一条直线上除起终点外的多个轨迹点 | ||
| 188 | - processOption.setNeedVacuate(true); | ||
| 189 | - // 设置精度过滤值(定位精度大于100米的过滤掉) | ||
| 190 | - processOption.setRadiusThreshold(9); | ||
| 191 | - // 设置交通方式为不行 | ||
| 192 | - processOption.setTransportMode(TransportMode.walking); | ||
| 193 | - // 设置纠偏选项 | ||
| 194 | - distanceRequest.setProcessOption(processOption); | ||
| 195 | - // 设置里程填充方式为步行 | ||
| 196 | - distanceRequest.setSupplementMode(SupplementMode.walking); | ||
| 197 | - | ||
| 198 | - } | ||
| 199 | - if (trackPoints == null) { | ||
| 200 | - trackPoints = new ArrayList<>(); | ||
| 201 | - } | ||
| 202 | - //轨迹查询监听器 | ||
| 203 | - OnTrackListener historyTrackListener = new OnTrackListener() { | ||
| 204 | - @Override | ||
| 205 | - public void onHistoryTrackCallback(HistoryTrackResponse response) { | ||
| 206 | - super.onHistoryTrackCallback(response); | ||
| 207 | - int total = response.getTotal(); | ||
| 208 | - | ||
| 209 | - if (StatusCodes.SUCCESS != response.getStatus()) { | ||
| 210 | - Toast.makeText(context, "获取轨迹失败!" + response.getStatus(), Toast.LENGTH_SHORT).show(); | ||
| 211 | - } else if (0 == total) { | ||
| 212 | - Toast.makeText(context, "暂未查到您的轨迹,请稍后重试!", Toast.LENGTH_SHORT).show(); | ||
| 213 | - } else { | ||
| 214 | - //查询到轨迹 | ||
| 215 | - List<TrackPoint> points = response.getTrackPoints(); | ||
| 216 | - if (null != points) { | ||
| 217 | - for (TrackPoint trackPoint : points) { | ||
| 218 | - if (!CommonUtil.isZeroPoint(trackPoint.getLocation().getLatitude(), | ||
| 219 | - trackPoint.getLocation().getLongitude())) { | ||
| 220 | - //将轨迹点转换为地图坐标点 | ||
| 221 | - trackPoints.add(MyMapUtil.convertTrace2Map(trackPoint.getLocation())); | ||
| 222 | - } | ||
| 223 | - } | ||
| 224 | - } | ||
| 225 | - } | ||
| 226 | - if (total > pageSize * pageIndex) { | ||
| 227 | - historyTrackRequest.setPageIndex(++pageIndex); | ||
| 228 | - queryHistoryTrace(context, entityName, startTime, endTime); | ||
| 229 | - } else { | ||
| 230 | - if (getView() != null) { | ||
| 231 | - if (trackPoints.size() == 1) { | ||
| 232 | - getView().setHistoryLastPoint(trackPoints.get(0)); | ||
| 233 | - } else if (trackPoints.size() > 1) { | ||
| 234 | - getView().setHistoryLastPoint(trackPoints.get(trackPoints.size() - 1)); | ||
| 235 | - } | ||
| 236 | - //开始比较(杨帅的思路) | ||
| 237 | -// for (int i = 0; i < trackPoints.size(); i++) { | ||
| 238 | -// if (matchIndex < importPoints.size() - 1) { | ||
| 239 | -// LatLng matchLatLng = importPoints.get(matchIndex); | ||
| 240 | -// LatLng historyLatLng = trackPoints.get(i); | ||
| 241 | -// Log.e(TAG, "距离: " + DistanceUtil.getDistance(matchLatLng, historyLatLng)); | ||
| 242 | -// double distance = DistanceUtil.getDistance(matchLatLng, historyLatLng); | ||
| 243 | -// if (distance < 200) { | ||
| 244 | -// importHash.put(matchIndex, true); | ||
| 245 | -// matchIndex++; | 114 | +// /** |
| 115 | +// * 查询历史轨迹 | ||
| 116 | +// * | ||
| 117 | +// * @param startTime | ||
| 118 | +// * @param endTime | ||
| 119 | +// */ | ||
| 120 | +// public void queryHistoryTrace(Context context, String entityName, long startTime, long endTime) { | ||
| 121 | +// Log.e(TAG, "queryHistoryTrace: 时间:" + startTime); | ||
| 122 | +// importHash = new HashMap<>(); | ||
| 123 | +// matchIndex = 0; | ||
| 124 | +// //打的重要点 | ||
| 125 | +// List<LatLng> importPoints = GsonUtil.jsonToList(imports, LatLng.class); | ||
| 126 | +// for (int i = 0; i < importPoints.size(); i++) { | ||
| 127 | +// if (i % 3 != 0) { | ||
| 128 | +// importPoints.remove(i); | ||
| 129 | +// } | ||
| 130 | +// } | ||
| 131 | +// | ||
| 132 | +// for (int i = 0; i < importPoints.size(); i++) { | ||
| 133 | +// importHash.put(i, false); | ||
| 134 | +// } | ||
| 135 | +// | ||
| 136 | +// if (historyTrackRequest == null) { | ||
| 137 | +// historyTrackRequest = new HistoryTrackRequest(tag, Constant.SERVICE_ID, entityName); | ||
| 138 | +// //设置查询设备名称 | ||
| 139 | +// historyTrackRequest.setEntityName(entityName); | ||
| 140 | +// //历史轨迹开始时间 | ||
| 141 | +// historyTrackRequest.setStartTime(startTime); | ||
| 142 | +// //历史轨迹结束时间 | ||
| 143 | +// historyTrackRequest.setEndTime(endTime); | ||
| 144 | +// //分页索引 | ||
| 145 | +// historyTrackRequest.setPageIndex(pageIndex); | ||
| 146 | +// //分页大小 | ||
| 147 | +// historyTrackRequest.setPageSize(pageSize); | ||
| 148 | +// //设置是否进行纠偏 | ||
| 149 | +// historyTrackRequest.setProcessed(true); | ||
| 150 | +// //设置返回坐标系 | ||
| 151 | +// historyTrackRequest.setCoordTypeOutput(CoordType.gcj02); | ||
| 152 | +// //其他设置 | ||
| 153 | +// ProcessOption processOption = new ProcessOption(); | ||
| 154 | +// //去噪:可设置是否需要去除角度、速度和方向异常的轨迹点 | ||
| 155 | +// processOption.setNeedDenoise(true); | ||
| 156 | +// //绑路:设置是否将轨迹点绑定至路网道路 | ||
| 157 | +// processOption.setNeedMapMatch(false); | ||
| 158 | +// //抽稀:设置是否进行抽稀处理,对冗余的轨迹点进行抽稀去除处理,如一条直线上除起终点外的多个轨迹点 | ||
| 159 | +// processOption.setNeedVacuate(true); | ||
| 160 | +// //自动判断交通方式 | ||
| 161 | +// processOption.setTransportMode(TransportMode.walking); | ||
| 162 | +// // 设置精度过滤值(定位精度大于100米的过滤掉) | ||
| 163 | +// processOption.setRadiusThreshold(9); | ||
| 164 | +// // 设置纠偏选项 | ||
| 165 | +// historyTrackRequest.setProcessOption(processOption); | ||
| 166 | +// // 设置里程填充方式为驾车 | ||
| 167 | +// historyTrackRequest.setSupplementMode(SupplementMode.walking); | ||
| 168 | +// | ||
| 169 | +// } | ||
| 170 | +// //创建里程查询 | ||
| 171 | +// if (distanceRequest == null) { | ||
| 172 | +// // 创建里程查询请求实例 | ||
| 173 | +// distanceRequest = new DistanceRequest(tag, Constant.SERVICE_ID, entityName); | ||
| 174 | +// // 设置开始时间 | ||
| 175 | +// distanceRequest.setStartTime(startTime); | ||
| 176 | +// // 设置结束时间 | ||
| 177 | +// distanceRequest.setEndTime(endTime); | ||
| 178 | +// // 设置需要纠偏 | ||
| 179 | +// distanceRequest.setProcessed(true); | ||
| 180 | +// | ||
| 181 | +// // 创建纠偏选项实例 | ||
| 182 | +// ProcessOption processOption = new ProcessOption(); | ||
| 183 | +// // 设置需要去噪 | ||
| 184 | +// processOption.setNeedDenoise(true); | ||
| 185 | +// // 设置需要绑路 | ||
| 186 | +// processOption.setNeedMapMatch(false); | ||
| 187 | +// //抽稀:设置是否进行抽稀处理,对冗余的轨迹点进行抽稀去除处理,如一条直线上除起终点外的多个轨迹点 | ||
| 188 | +// processOption.setNeedVacuate(true); | ||
| 189 | +// // 设置精度过滤值(定位精度大于100米的过滤掉) | ||
| 190 | +// processOption.setRadiusThreshold(9); | ||
| 191 | +// // 设置交通方式为不行 | ||
| 192 | +// processOption.setTransportMode(TransportMode.walking); | ||
| 193 | +// // 设置纠偏选项 | ||
| 194 | +// distanceRequest.setProcessOption(processOption); | ||
| 195 | +// // 设置里程填充方式为步行 | ||
| 196 | +// distanceRequest.setSupplementMode(SupplementMode.walking); | ||
| 197 | +// | ||
| 198 | +// } | ||
| 199 | +// if (trackPoints == null) { | ||
| 200 | +// trackPoints = new ArrayList<>(); | ||
| 201 | +// } | ||
| 202 | +// //轨迹查询监听器 | ||
| 203 | +// OnTrackListener historyTrackListener = new OnTrackListener() { | ||
| 204 | +// @Override | ||
| 205 | +// public void onHistoryTrackCallback(HistoryTrackResponse response) { | ||
| 206 | +// super.onHistoryTrackCallback(response); | ||
| 207 | +// int total = response.getTotal(); | ||
| 208 | +// | ||
| 209 | +// if (StatusCodes.SUCCESS != response.getStatus()) { | ||
| 210 | +// Toast.makeText(context, "获取轨迹失败!" + response.getStatus(), Toast.LENGTH_SHORT).show(); | ||
| 211 | +// } else if (0 == total) { | ||
| 212 | +// Toast.makeText(context, "暂未查到您的轨迹,请稍后重试!", Toast.LENGTH_SHORT).show(); | ||
| 213 | +// } else { | ||
| 214 | +// //查询到轨迹 | ||
| 215 | +// List<TrackPoint> points = response.getTrackPoints(); | ||
| 216 | +// if (null != points) { | ||
| 217 | +// for (TrackPoint trackPoint : points) { | ||
| 218 | +// if (!CommonUtil.isZeroPoint(trackPoint.getLocation().getLatitude(), | ||
| 219 | +// trackPoint.getLocation().getLongitude())) { | ||
| 220 | +// //将轨迹点转换为地图坐标点 | ||
| 221 | +// trackPoints.add(MyMapUtil.convertTrace2Map(trackPoint.getLocation())); | ||
| 222 | +// } | ||
| 223 | +// } | ||
| 224 | +// } | ||
| 225 | +// } | ||
| 226 | +// if (total > pageSize * pageIndex) { | ||
| 227 | +// historyTrackRequest.setPageIndex(++pageIndex); | ||
| 228 | +// queryHistoryTrace(context, entityName, startTime, endTime); | ||
| 229 | +// } else { | ||
| 230 | +// if (getView() != null) { | ||
| 231 | +// if (trackPoints.size() == 1) { | ||
| 232 | +// getView().setHistoryLastPoint(trackPoints.get(0)); | ||
| 233 | +// } else if (trackPoints.size() > 1) { | ||
| 234 | +// getView().setHistoryLastPoint(trackPoints.get(trackPoints.size() - 1)); | ||
| 235 | +// } | ||
| 236 | +// //开始比较(杨帅的思路) | ||
| 237 | +//// for (int i = 0; i < trackPoints.size(); i++) { | ||
| 238 | +//// if (matchIndex < importPoints.size() - 1) { | ||
| 239 | +//// LatLng matchLatLng = importPoints.get(matchIndex); | ||
| 240 | +//// LatLng historyLatLng = trackPoints.get(i); | ||
| 241 | +//// Log.e(TAG, "距离: " + DistanceUtil.getDistance(matchLatLng, historyLatLng)); | ||
| 242 | +//// double distance = DistanceUtil.getDistance(matchLatLng, historyLatLng); | ||
| 243 | +//// if (distance < 200) { | ||
| 244 | +//// importHash.put(matchIndex, true); | ||
| 245 | +//// matchIndex++; | ||
| 246 | +//// } | ||
| 247 | +//// } | ||
| 248 | +//// } | ||
| 249 | +//// //输出 | ||
| 250 | +//// int result = 0; | ||
| 251 | +//// for (int i = 0; i < importHash.size(); i++) { | ||
| 252 | +//// if (!importHash.get(i)) { | ||
| 253 | +//// result++; | ||
| 254 | +//// Log.e(TAG, "onHistoryTrackCallback: 没过:" + i + importHash.get(i)); | ||
| 255 | +//// } | ||
| 256 | +//// } | ||
| 257 | +//// if (result > importPoints.size() * 0.4) { | ||
| 258 | +//// Toast.makeText(context, "没有完成", Toast.LENGTH_LONG).show(); | ||
| 259 | +//// | ||
| 260 | +//// } else { | ||
| 261 | +//// Toast.makeText(context, "已完成", Toast.LENGTH_LONG).show(); | ||
| 262 | +//// } | ||
| 263 | +// //郭瑞鹏的思路 | ||
| 264 | +// int index = 0; | ||
| 265 | +// for (int i = 0; i < importPoints.size(); i++) { | ||
| 266 | +// LatLng importLatLng = importPoints.get(i); | ||
| 267 | +// for (int j = index; j < trackPoints.size(); j++) { | ||
| 268 | +// double distance = DistanceUtil.getDistance(importLatLng, trackPoints.get(j)); | ||
| 269 | +// if (distance < 50) { | ||
| 270 | +// importHash.put(i, true); | ||
| 271 | +// index = j; | ||
| 246 | // } | 272 | // } |
| 247 | // } | 273 | // } |
| 248 | // } | 274 | // } |
| @@ -251,7 +277,7 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter<RunningMapFrag | @@ -251,7 +277,7 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter<RunningMapFrag | ||
| 251 | // for (int i = 0; i < importHash.size(); i++) { | 277 | // for (int i = 0; i < importHash.size(); i++) { |
| 252 | // if (!importHash.get(i)) { | 278 | // if (!importHash.get(i)) { |
| 253 | // result++; | 279 | // result++; |
| 254 | -// Log.e(TAG, "onHistoryTrackCallback: 没过:" + i + importHash.get(i)); | 280 | +//// Log.e(TAG, "onHistoryTrackCallback: 没过:" + i + importHash.get(i)); |
| 255 | // } | 281 | // } |
| 256 | // } | 282 | // } |
| 257 | // if (result > importPoints.size() * 0.4) { | 283 | // if (result > importPoints.size() * 0.4) { |
| @@ -260,134 +286,71 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter<RunningMapFrag | @@ -260,134 +286,71 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter<RunningMapFrag | ||
| 260 | // } else { | 286 | // } else { |
| 261 | // Toast.makeText(context, "已完成", Toast.LENGTH_LONG).show(); | 287 | // Toast.makeText(context, "已完成", Toast.LENGTH_LONG).show(); |
| 262 | // } | 288 | // } |
| 263 | - //郭瑞鹏的思路 | ||
| 264 | - int index = 0; | ||
| 265 | - for (int i = 0; i < importPoints.size(); i++) { | ||
| 266 | - LatLng importLatLng = importPoints.get(i); | ||
| 267 | - for (int j = index; j < trackPoints.size(); j++) { | ||
| 268 | - double distance = DistanceUtil.getDistance(importLatLng, trackPoints.get(j)); | ||
| 269 | - if (distance < 50) { | ||
| 270 | - importHash.put(i, true); | ||
| 271 | - index = j; | ||
| 272 | - } | ||
| 273 | - } | ||
| 274 | - } | ||
| 275 | - //输出 | ||
| 276 | - int result = 0; | ||
| 277 | - for (int i = 0; i < importHash.size(); i++) { | ||
| 278 | - if (!importHash.get(i)) { | ||
| 279 | - result++; | ||
| 280 | -// Log.e(TAG, "onHistoryTrackCallback: 没过:" + i + importHash.get(i)); | ||
| 281 | - } | ||
| 282 | - } | ||
| 283 | - if (result > importPoints.size() * 0.4) { | ||
| 284 | - Toast.makeText(context, "没有完成", Toast.LENGTH_LONG).show(); | 289 | +// Log.e(TAG, "结果: " + result); |
| 290 | +// Log.e(TAG, "onHistoryTrackCallback: 轨迹点:" + trackPoints.size() + ",详情" + GsonUtil.GsonString(trackPoints)); | ||
| 291 | +// | ||
| 292 | +// MyMapUtil.drawHistoryTrack(context, getView().baiduMap, trackPoints, SortType.asc, R.color.red, R.drawable.icon_start, R.drawable.icon_end); | ||
| 293 | +//// MyMapUtil.drawMapLineRoutePoint(context, getView().baiduMap, MyMapUtil.optimizePoints(routePoints), R.color.red); | ||
| 294 | +// } | ||
| 295 | +// } | ||
| 296 | +// } | ||
| 297 | +// | ||
| 298 | +// @Override | ||
| 299 | +// public void onDistanceCallback(DistanceResponse distanceResponse) { | ||
| 300 | +// super.onDistanceCallback(distanceResponse); | ||
| 301 | +//// Toast.makeText(context, "查询的里程数:" + (int) distanceResponse.getDistance() + "米", Toast.LENGTH_SHORT).show(); | ||
| 302 | +// Log.e(TAG, "onDistanceCallback: " + distanceResponse.getDistance()); | ||
| 303 | +// } | ||
| 304 | +// }; | ||
| 305 | +// //开始查询历史轨迹 | ||
| 306 | +// if (StepService.mClient != null) { | ||
| 307 | +// StepService.mClient.queryHistoryTrack(historyTrackRequest, historyTrackListener); | ||
| 308 | +// // 查询里程 | ||
| 309 | +// StepService.mClient.queryDistance(distanceRequest, historyTrackListener); | ||
| 310 | +// } | ||
| 311 | +// | ||
| 312 | +// } | ||
| 313 | + | ||
| 285 | 314 | ||
| 286 | - } else { | ||
| 287 | - Toast.makeText(context, "已完成", Toast.LENGTH_LONG).show(); | 315 | + /** |
| 316 | + * 查询历史轨迹 | ||
| 317 | + * | ||
| 318 | + * @param startTime | ||
| 319 | + * @param endTime | ||
| 320 | + */ | ||
| 321 | + public void queryHistoryTrace(Context context, String entityName, long startTime, long endTime) { | ||
| 322 | + Log.e(TAG, "queryHistoryTrace: 时间:" + startTime); | ||
| 323 | + //打的重要点 | ||
| 324 | + List<LatLng> importPoints = GsonUtil.jsonToList(imports, LatLng.class); | ||
| 325 | + MyMapUtil.queryHistoryTrace(context, StepService.mClient, entityName, startTime, endTime, new MyMapUtil.CallBack() { | ||
| 326 | + @Override | ||
| 327 | + public void success(List<LatLng> resultPoints) { | ||
| 328 | + if (resultPoints != null&&resultPoints.size()>1) { | ||
| 329 | + if (getView() != null && resultPoints != null) { | ||
| 330 | + if (resultPoints.size() == 1) { | ||
| 331 | + getView().setHistoryLastPoint(resultPoints.get(0)); | ||
| 332 | + } else if (resultPoints.size() > 1) { | ||
| 333 | + getView().setHistoryLastPoint(resultPoints.get(resultPoints.size() - 1)); | ||
| 288 | } | 334 | } |
| 289 | - Log.e(TAG, "结果: " + result); | ||
| 290 | - Log.e(TAG, "onHistoryTrackCallback: 轨迹点:" + trackPoints.size() + ",详情" + GsonUtil.GsonString(trackPoints)); | 335 | + if (importPoints != null && resultPoints != null) { |
| 336 | + boolean isFinish = MyMapUtil.checkIsFinishTrace(importPoints, resultPoints, 0.6); | ||
| 337 | + if (isFinish) { | ||
| 338 | + Toast.makeText(context, "已完成", Toast.LENGTH_LONG).show(); | ||
| 339 | + | ||
| 340 | + } else { | ||
| 341 | + Toast.makeText(context, "没有完成", Toast.LENGTH_LONG).show(); | ||
| 291 | 342 | ||
| 292 | - MyMapUtil.drawHistoryTrack(context, getView().baiduMap, trackPoints, SortType.asc, R.color.red, R.drawable.icon_start, R.drawable.icon_end); | ||
| 293 | -// MyMapUtil.drawMapLineRoutePoint(context, getView().baiduMap, MyMapUtil.optimizePoints(routePoints), R.color.red); | 343 | + } |
| 344 | + MyMapUtil.drawHistoryTrack(context, getView().baiduMap, resultPoints, SortType.asc, R.color.red, R.drawable.icon_start, R.drawable.icon_end); | ||
| 345 | + } | ||
| 294 | } | 346 | } |
| 295 | } | 347 | } |
| 296 | } | 348 | } |
| 297 | - | ||
| 298 | - @Override | ||
| 299 | - public void onDistanceCallback(DistanceResponse distanceResponse) { | ||
| 300 | - super.onDistanceCallback(distanceResponse); | ||
| 301 | -// Toast.makeText(context, "查询的里程数:" + (int) distanceResponse.getDistance() + "米", Toast.LENGTH_SHORT).show(); | ||
| 302 | - Log.e(TAG, "onDistanceCallback: " + distanceResponse.getDistance()); | ||
| 303 | - } | ||
| 304 | - }; | ||
| 305 | - //开始查询历史轨迹 | ||
| 306 | - if (StepService.mClient != null) { | ||
| 307 | - StepService.mClient.queryHistoryTrack(historyTrackRequest, historyTrackListener); | ||
| 308 | - // 查询里程 | ||
| 309 | - StepService.mClient.queryDistance(distanceRequest, historyTrackListener); | ||
| 310 | - } | 349 | + }); |
| 311 | 350 | ||
| 312 | } | 351 | } |
| 313 | 352 | ||
| 314 | 353 | ||
| 315 | - public void queryRealTimeTrace(Context context, String entityName, long activeTime) { | ||
| 316 | - if (realTimeListRequest == null) { | ||
| 317 | - List<String> names = new ArrayList<>(); | ||
| 318 | - names.add(entityName); | ||
| 319 | - realTimeListRequest = new LocRequest(); | ||
| 320 | - realTimeListRequest.setServiceId(Constant.SERVICE_ID); | ||
| 321 | - realTimeListRequest.setTag(1); | ||
| 322 | - } | ||
| 323 | - if (realTimePoints == null) { | ||
| 324 | - realTimePoints = new ArrayList<>(); | ||
| 325 | - } | ||
| 326 | - | ||
| 327 | - OnEntityListener onEntityListener = new OnEntityListener() { | ||
| 328 | - Overlay realTimeOverlay = null; | ||
| 329 | - | ||
| 330 | - @Override | ||
| 331 | - public void onEntityListCallback(EntityListResponse entityListResponse) { | ||
| 332 | - super.onEntityListCallback(entityListResponse); | ||
| 333 | - Log.e(TAG, "onEntityListCallback"); | ||
| 334 | -// Toast.makeText(context, "onEntityListCallback", Toast.LENGTH_SHORT).show(); | ||
| 335 | - } | ||
| 336 | - | ||
| 337 | - @Override | ||
| 338 | - public void onSearchEntityCallback(SearchResponse searchResponse) { | ||
| 339 | - super.onSearchEntityCallback(searchResponse); | ||
| 340 | - Log.e(TAG, "onSearchEntityCallback"); | ||
| 341 | - Toast.makeText(context, "onSearchEntityCallback", Toast.LENGTH_SHORT).show(); | ||
| 342 | - | ||
| 343 | - } | ||
| 344 | - | ||
| 345 | - @Override | ||
| 346 | - public void onBoundSearchCallback(BoundSearchResponse boundSearchResponse) { | ||
| 347 | - super.onBoundSearchCallback(boundSearchResponse); | ||
| 348 | - Log.e(TAG, "onBoundSearchCallback"); | ||
| 349 | - Toast.makeText(context, "onBoundSearchCallback", Toast.LENGTH_SHORT).show(); | ||
| 350 | - | ||
| 351 | - } | ||
| 352 | - | ||
| 353 | - @Override | ||
| 354 | - public void onAroundSearchCallback(AroundSearchResponse aroundSearchResponse) { | ||
| 355 | - super.onAroundSearchCallback(aroundSearchResponse); | ||
| 356 | - Log.e(TAG, "onAroundSearchCallback"); | ||
| 357 | - Toast.makeText(context, "onAroundSearchCallback", Toast.LENGTH_SHORT).show(); | ||
| 358 | - | ||
| 359 | - } | ||
| 360 | - | ||
| 361 | - @Override | ||
| 362 | - public void onPolygonSearchCallback(PolygonSearchResponse polygonSearchResponse) { | ||
| 363 | - super.onPolygonSearchCallback(polygonSearchResponse); | ||
| 364 | - Log.e(TAG, "onPolygonSearchCallback"); | ||
| 365 | - Toast.makeText(context, "onPolygonSearchCallback", Toast.LENGTH_SHORT).show(); | ||
| 366 | - } | ||
| 367 | - | ||
| 368 | - @Override | ||
| 369 | - public void onDistrictSearchCallback(DistrictSearchResponse districtSearchResponse) { | ||
| 370 | - super.onDistrictSearchCallback(districtSearchResponse); | ||
| 371 | - Log.e(TAG, "onDistrictSearchCallback"); | ||
| 372 | - Toast.makeText(context, "onDistrictSearchCallback", Toast.LENGTH_SHORT).show(); | ||
| 373 | - | ||
| 374 | - } | ||
| 375 | - | ||
| 376 | - /**实时定位回调接口 | ||
| 377 | - * @param traceLocation | ||
| 378 | - */ | ||
| 379 | - @Override | ||
| 380 | - public void onReceiveLocation(TraceLocation traceLocation) { | ||
| 381 | - super.onReceiveLocation(traceLocation); | ||
| 382 | - } | ||
| 383 | - }; | ||
| 384 | - //查询实时轨迹 | ||
| 385 | - if (StepService.mClient != null) { | ||
| 386 | - StepService.mClient.queryRealTimeLoc(realTimeListRequest, onEntityListener); | ||
| 387 | - } | ||
| 388 | - | ||
| 389 | - } | ||
| 390 | - | ||
| 391 | //创建地理围栏 | 354 | //创建地理围栏 |
| 392 | public void createFence(Context context, List<com.baidu.trace.model.LatLng> latLngs) { | 355 | public void createFence(Context context, List<com.baidu.trace.model.LatLng> latLngs) { |
| 393 | CreateFenceRequest createFenceRequest = null; | 356 | CreateFenceRequest createFenceRequest = null; |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunMainFragmentView.java
| @@ -116,6 +116,7 @@ public class RunMainFragmentView implements MvpView { | @@ -116,6 +116,7 @@ public class RunMainFragmentView implements MvpView { | ||
| 116 | * 初始化相关视图 | 116 | * 初始化相关视图 |
| 117 | */ | 117 | */ |
| 118 | public void initView() { | 118 | public void initView() { |
| 119 | + Log.e(TAG, "initView: +时间" + SystemClock.elapsedRealtime()); | ||
| 119 | uid = CommonInfo.getUserId(getContext()); | 120 | uid = CommonInfo.getUserId(getContext()); |
| 120 | initLocationClient(); | 121 | initLocationClient(); |
| 121 | fragment.binding.llRunMainRoot.setVisibility(View.GONE); | 122 | fragment.binding.llRunMainRoot.setVisibility(View.GONE); |
| @@ -149,6 +150,8 @@ public class RunMainFragmentView implements MvpView { | @@ -149,6 +150,8 @@ public class RunMainFragmentView implements MvpView { | ||
| 149 | fragment.binding.chronometer.setFormat("00:00:01"); | 150 | fragment.binding.chronometer.setFormat("00:00:01"); |
| 150 | fragment.binding.chronometer.setBase(SystemClock.elapsedRealtime()); | 151 | fragment.binding.chronometer.setBase(SystemClock.elapsedRealtime()); |
| 151 | fragment.binding.chronometer.start(); | 152 | fragment.binding.chronometer.start(); |
| 153 | + //设置计步开始时间 | ||
| 154 | + StepUtil.setChronometerBase(getContext(), uid, fragment.binding.chronometer.getBase()); | ||
| 152 | } | 155 | } |
| 153 | } | 156 | } |
| 154 | }, 10); | 157 | }, 10); |
| @@ -194,11 +197,30 @@ public class RunMainFragmentView implements MvpView { | @@ -194,11 +197,30 @@ public class RunMainFragmentView implements MvpView { | ||
| 194 | if (firstTimeFlag) { | 197 | if (firstTimeFlag) { |
| 195 | firstTimeFlag = false; | 198 | firstTimeFlag = false; |
| 196 | if (userStepEntity != null) { | 199 | if (userStepEntity != null) { |
| 197 | - if ((userStepEntity.getPauseTimeStamp() != 0) && (userStepEntity.getRecordTime() != 0)) { | ||
| 198 | - fragment.binding.chronometer.setBase(userStepEntity.getPauseTimeStamp() + (SystemClock.elapsedRealtime() - userStepEntity.getRecordTime())); | ||
| 199 | - } else { | ||
| 200 | - fragment.binding.chronometer.setFormat("00:00:01"); | ||
| 201 | - fragment.binding.chronometer.setBase(SystemClock.elapsedRealtime()); | 200 | + //判断显示时间 |
| 201 | + boolean isPasue = CommonInfo.getIsPause(getContext()); | ||
| 202 | + Log.e(TAG, "run: 是否暂停" + isPasue); | ||
| 203 | + //如果暂停则从暂停那一刻开始 | ||
| 204 | + if (isPasue) { | ||
| 205 | + if ((userStepEntity.getPauseTimeStamp() != 0) && (userStepEntity.getRecordTime() != 0)) { | ||
| 206 | + fragment.binding.chronometer.setBase(userStepEntity.getPauseTimeStamp() + (SystemClock.elapsedRealtime() - userStepEntity.getRecordTime())); | ||
| 207 | + } else { | ||
| 208 | + fragment.binding.chronometer.setFormat("00:00:01"); | ||
| 209 | + fragment.binding.chronometer.setBase(SystemClock.elapsedRealtime()); | ||
| 210 | + } | ||
| 211 | + //因为进来以后就运动了,所以需要改变状态 | ||
| 212 | + CommonInfo.setIsPauseState(getContext(), false); | ||
| 213 | + //重新设置开始时间 | ||
| 214 | + userStepEntity.setChronometerBase(fragment.binding.chronometer.getBase()); | ||
| 215 | + } | ||
| 216 | + //没有暂停,从初始时间开始 | ||
| 217 | + else { | ||
| 218 | + if (userStepEntity.getChronometerBase() != 0) { | ||
| 219 | + fragment.binding.chronometer.setBase(userStepEntity.getChronometerBase()); | ||
| 220 | + } else { | ||
| 221 | + fragment.binding.chronometer.setFormat("00:00:01"); | ||
| 222 | + fragment.binding.chronometer.setBase(SystemClock.elapsedRealtime()); | ||
| 223 | + } | ||
| 202 | } | 224 | } |
| 203 | //设置步数 | 225 | //设置步数 |
| 204 | if (!TextUtils.isEmpty(userStepEntity.getStepCount())) { | 226 | if (!TextUtils.isEmpty(userStepEntity.getStepCount())) { |
| @@ -237,6 +259,8 @@ public class RunMainFragmentView implements MvpView { | @@ -237,6 +259,8 @@ public class RunMainFragmentView implements MvpView { | ||
| 237 | fragment.binding.flContinue.setOnClickListener(new View.OnClickListener() { | 259 | fragment.binding.flContinue.setOnClickListener(new View.OnClickListener() { |
| 238 | @Override | 260 | @Override |
| 239 | public void onClick(View view) { | 261 | public void onClick(View view) { |
| 262 | + //设置继续标志 | ||
| 263 | + CommonInfo.setIsPauseState(getContext(), false); | ||
| 240 | //继续记录轨迹 | 264 | //继续记录轨迹 |
| 241 | if (StepService.mClient != null && StepService.traceListener != null) { | 265 | if (StepService.mClient != null && StepService.traceListener != null) { |
| 242 | CommonInfo.setTsRunBaiduTraceService(getContext(), true); | 266 | CommonInfo.setTsRunBaiduTraceService(getContext(), true); |
| @@ -371,13 +395,15 @@ public class RunMainFragmentView implements MvpView { | @@ -371,13 +395,15 @@ public class RunMainFragmentView implements MvpView { | ||
| 371 | fragment.binding.flPause.setOnClickListener(new View.OnClickListener() { | 395 | fragment.binding.flPause.setOnClickListener(new View.OnClickListener() { |
| 372 | @Override | 396 | @Override |
| 373 | public void onClick(View view) { | 397 | public void onClick(View view) { |
| 398 | + //将当前计时器时间戳写入数据库 | ||
| 399 | + setSQLPauseTime(uid); | ||
| 400 | + //设置暂停标志 | ||
| 401 | + CommonInfo.setIsPauseState(getContext(), true); | ||
| 374 | //暂停轨迹记录 | 402 | //暂停轨迹记录 |
| 375 | if (StepService.mClient != null && StepService.traceListener != null) { | 403 | if (StepService.mClient != null && StepService.traceListener != null) { |
| 376 | CommonInfo.setTsRunBaiduTraceService(getContext(), false); | 404 | CommonInfo.setTsRunBaiduTraceService(getContext(), false); |
| 377 | StepService.mClient.stopGather(StepService.traceListener); | 405 | StepService.mClient.stopGather(StepService.traceListener); |
| 378 | } | 406 | } |
| 379 | - //将当前计时器时间戳写入数据库 | ||
| 380 | - setSQLPauseTime(uid); | ||
| 381 | needWriteDataFlag = false; | 407 | needWriteDataFlag = false; |
| 382 | ButtonAnimUtil.setViewHideZoomOut(fragment.binding.llPause); | 408 | ButtonAnimUtil.setViewHideZoomOut(fragment.binding.llPause); |
| 383 | handler.postDelayed(new Runnable() { | 409 | handler.postDelayed(new Runnable() { |
| @@ -468,37 +494,39 @@ public class RunMainFragmentView implements MvpView { | @@ -468,37 +494,39 @@ public class RunMainFragmentView implements MvpView { | ||
| 468 | } | 494 | } |
| 469 | 495 | ||
| 470 | public void setSQLPauseTime(String id) { | 496 | public void setSQLPauseTime(String id) { |
| 471 | - if (needWriteDataFlag) { | 497 | + Log.e(TAG, "setSQLPauseTime: " ); |
| 498 | +// if (needWriteDataFlag) { | ||
| 472 | //将当前计时器时间戳写入数据库 | 499 | //将当前计时器时间戳写入数据库 |
| 473 | -// String id = MySpHelper.getInstance(getContext(), Context.MODE_MULTI_PROCESS).getString("userId", ""); | ||
| 474 | if (!TextUtils.isEmpty(id)) { | 500 | if (!TextUtils.isEmpty(id)) { |
| 475 | UserStepEntity userStepEntity = StepUtil.getUserStepData(fragment.getActivity(), uid); | 501 | UserStepEntity userStepEntity = StepUtil.getUserStepData(fragment.getActivity(), uid); |
| 476 | if (userStepEntity != null) { | 502 | if (userStepEntity != null) { |
| 477 | userStepEntity.setPauseTimeStamp(fragment.binding.chronometer.getBase()); | 503 | userStepEntity.setPauseTimeStamp(fragment.binding.chronometer.getBase()); |
| 478 | //设置当前暂停的时间戳 | 504 | //设置当前暂停的时间戳 |
| 479 | userStepEntity.setRecordTime(SystemClock.elapsedRealtime()); | 505 | userStepEntity.setRecordTime(SystemClock.elapsedRealtime()); |
| 506 | + //设置当前用户暂停的时间戳 | ||
| 507 | + userStepEntity.setUserPauseTimeStamp(TimeUtil.getNowTimeStamp()); | ||
| 480 | //设置暂停次数 | 508 | //设置暂停次数 |
| 481 | userStepEntity.setPauseCount(userStepEntity.getPauseCount() + 1); | 509 | userStepEntity.setPauseCount(userStepEntity.getPauseCount() + 1); |
| 482 | //更新数据 | 510 | //更新数据 |
| 483 | StepUtil.updateStepData(fragment.getActivity(), userStepEntity); | 511 | StepUtil.updateStepData(fragment.getActivity(), userStepEntity); |
| 484 | } | 512 | } |
| 485 | } | 513 | } |
| 486 | - } | 514 | +// } |
| 487 | } | 515 | } |
| 488 | 516 | ||
| 489 | - public void setFragmentPauseTime(String id) { | ||
| 490 | - if (!TextUtils.isEmpty(id)) { | ||
| 491 | - UserStepEntity userStepEntity = StepUtil.getUserStepData(fragment.getActivity(), uid); | ||
| 492 | - if (userStepEntity != null) { | ||
| 493 | - userStepEntity.setPauseTimeStamp(fragment.binding.chronometer.getBase()); | ||
| 494 | - userStepEntity.setRecordTime(SystemClock.elapsedRealtime()); | ||
| 495 | - //设置当前暂停的时间戳 | ||
| 496 | - userStepEntity.setUserPauseTimeStamp(TimeUtil.getNowTimeStamp()); | ||
| 497 | - //更新数据 | ||
| 498 | - StepUtil.updateStepData(fragment.getActivity(), userStepEntity); | ||
| 499 | - } | ||
| 500 | - } | ||
| 501 | - } | 517 | +// public void setFragmentPauseTime(String id) { |
| 518 | +// if (!TextUtils.isEmpty(id)) { | ||
| 519 | +// UserStepEntity userStepEntity = StepUtil.getUserStepData(fragment.getActivity(), uid); | ||
| 520 | +// if (userStepEntity != null) { | ||
| 521 | +// userStepEntity.setPauseTimeStamp(fragment.binding.chronometer.getBase()); | ||
| 522 | +// userStepEntity.setRecordTime(SystemClock.elapsedRealtime()); | ||
| 523 | +// //设置当前暂停的时间戳 | ||
| 524 | +// userStepEntity.setUserPauseTimeStamp(TimeUtil.getNowTimeStamp()); | ||
| 525 | +// //更新数据 | ||
| 526 | +// StepUtil.updateStepData(fragment.getActivity(), userStepEntity); | ||
| 527 | +// } | ||
| 528 | +// } | ||
| 529 | +// } | ||
| 502 | 530 | ||
| 503 | 531 | ||
| 504 | /** | 532 | /** |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
| @@ -8,6 +8,7 @@ import android.hardware.Sensor; | @@ -8,6 +8,7 @@ import android.hardware.Sensor; | ||
| 8 | import android.hardware.SensorEvent; | 8 | import android.hardware.SensorEvent; |
| 9 | import android.hardware.SensorEventListener; | 9 | import android.hardware.SensorEventListener; |
| 10 | import android.hardware.SensorManager; | 10 | import android.hardware.SensorManager; |
| 11 | +import android.os.SystemClock; | ||
| 11 | import android.support.v4.content.ContextCompat; | 12 | import android.support.v4.content.ContextCompat; |
| 12 | import android.text.TextUtils; | 13 | import android.text.TextUtils; |
| 13 | import android.util.Log; | 14 | import android.util.Log; |
| @@ -24,6 +25,7 @@ import com.baidu.mapapi.map.BaiduMap; | @@ -24,6 +25,7 @@ import com.baidu.mapapi.map.BaiduMap; | ||
| 24 | import com.baidu.mapapi.map.BitmapDescriptor; | 25 | import com.baidu.mapapi.map.BitmapDescriptor; |
| 25 | import com.baidu.mapapi.map.BitmapDescriptorFactory; | 26 | import com.baidu.mapapi.map.BitmapDescriptorFactory; |
| 26 | import com.baidu.mapapi.map.MapStatus; | 27 | import com.baidu.mapapi.map.MapStatus; |
| 28 | +import com.baidu.mapapi.map.MapStatusUpdate; | ||
| 27 | import com.baidu.mapapi.map.MapStatusUpdateFactory; | 29 | import com.baidu.mapapi.map.MapStatusUpdateFactory; |
| 28 | import com.baidu.mapapi.map.MapView; | 30 | import com.baidu.mapapi.map.MapView; |
| 29 | import com.baidu.mapapi.map.MarkerOptions; | 31 | import com.baidu.mapapi.map.MarkerOptions; |
| @@ -34,6 +36,7 @@ import com.baidu.mapapi.map.OverlayOptions; | @@ -34,6 +36,7 @@ import com.baidu.mapapi.map.OverlayOptions; | ||
| 34 | import com.baidu.mapapi.map.PolylineOptions; | 36 | import com.baidu.mapapi.map.PolylineOptions; |
| 35 | import com.baidu.mapapi.map.UiSettings; | 37 | import com.baidu.mapapi.map.UiSettings; |
| 36 | import com.baidu.mapapi.model.LatLng; | 38 | import com.baidu.mapapi.model.LatLng; |
| 39 | +import com.baidu.mapapi.model.LatLngBounds; | ||
| 37 | import com.baidu.mapapi.search.core.SearchResult; | 40 | import com.baidu.mapapi.search.core.SearchResult; |
| 38 | import com.baidu.mapapi.search.route.BikingRouteResult; | 41 | import com.baidu.mapapi.search.route.BikingRouteResult; |
| 39 | import com.baidu.mapapi.search.route.DrivingRouteResult; | 42 | import com.baidu.mapapi.search.route.DrivingRouteResult; |
| @@ -46,9 +49,13 @@ import com.baidu.mapapi.search.route.TransitRouteResult; | @@ -46,9 +49,13 @@ import com.baidu.mapapi.search.route.TransitRouteResult; | ||
| 46 | import com.baidu.mapapi.search.route.WalkingRoutePlanOption; | 49 | import com.baidu.mapapi.search.route.WalkingRoutePlanOption; |
| 47 | import com.baidu.mapapi.search.route.WalkingRouteResult; | 50 | import com.baidu.mapapi.search.route.WalkingRouteResult; |
| 48 | import com.baidu.mapapi.utils.DistanceUtil; | 51 | import com.baidu.mapapi.utils.DistanceUtil; |
| 52 | +import com.baidu.trace.LBSTraceClient; | ||
| 53 | +import com.baidu.trace.Trace; | ||
| 54 | +import com.baidu.trace.model.LocationMode; | ||
| 49 | import com.baidu.trace.model.SortType; | 55 | import com.baidu.trace.model.SortType; |
| 50 | import com.cnlive.moudle.pedometer.commonInfo.CollCommonInfo; | 56 | import com.cnlive.moudle.pedometer.commonInfo.CollCommonInfo; |
| 51 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; | 57 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 58 | +import com.cnlive.moudle.pedometer.model.Constant; | ||
| 52 | import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo; | 59 | import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo; |
| 53 | import com.cnlive.moudle.pedometer.service.KeepLiveService; | 60 | import com.cnlive.moudle.pedometer.service.KeepLiveService; |
| 54 | import com.cnlive.moudle.pedometer.service.StepService; | 61 | import com.cnlive.moudle.pedometer.service.StepService; |
| @@ -115,10 +122,10 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | @@ -115,10 +122,10 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | ||
| 115 | // 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}]"; | 122 | // 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}]"; |
| 116 | private LinkedList<LatLng> importLatLngs;//关键点 | 123 | private LinkedList<LatLng> importLatLngs;//关键点 |
| 117 | private LatLng startLatLng = new LatLng(39.934733, 116.308646);//起始点 | 124 | private LatLng startLatLng = new LatLng(39.934733, 116.308646);//起始点 |
| 118 | - private List<LatLng> trackPoints; | ||
| 119 | private RunRaceDetailInfo runRaceDetailInfo; | 125 | private RunRaceDetailInfo runRaceDetailInfo; |
| 120 | private UserStepEntity userStepEntity; | 126 | private UserStepEntity userStepEntity; |
| 121 | private boolean isDifferentStreet = false; | 127 | private boolean isDifferentStreet = false; |
| 128 | + private LBSTraceClient mClient = null; | ||
| 122 | 129 | ||
| 123 | public RunRaceDetailFragmentView(RunRaceDetailFragment fragment) { | 130 | public RunRaceDetailFragmentView(RunRaceDetailFragment fragment) { |
| 124 | this.fragment = fragment; | 131 | this.fragment = fragment; |
| @@ -135,22 +142,60 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | @@ -135,22 +142,60 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | ||
| 135 | } | 142 | } |
| 136 | this.runRaceDetailInfo = runRaceDetailInfo; | 143 | this.runRaceDetailInfo = runRaceDetailInfo; |
| 137 | // //初始化地图点位 | 144 | // //初始化地图点位 |
| 138 | - if (runRaceDetailInfo.getLatLongitude() != null) { | ||
| 139 | - Log.e(TAG, "initView: 长度:" + runRaceDetailInfo.getLatLongitude().length()); | ||
| 140 | - trackPoints = GsonUtil.jsonToList(runRaceDetailInfo.getLatLongitude().trim(), LatLng.class); | ||
| 141 | - Log.e(TAG, "initView: trackPoints" + trackPoints.size()); | ||
| 142 | - MyMapUtil.drawServerLineTrack(getContext(), baiduMap, trackPoints, SortType.asc, R.color.green_round, R.drawable.icon_start, R.drawable.icon_end); | ||
| 143 | - //自动计算地图缩放 | ||
| 144 | - MapStatus.Builder builder = new MapStatus.Builder(); | ||
| 145 | - builder.target(MyMapUtil.getCenterZoomPosition(trackPoints)); | ||
| 146 | - builder.zoom(MyMapUtil.getZoom(trackPoints)); | ||
| 147 | - baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); | 145 | +// if (runRaceDetailInfo.getLatLongitude() != null) { |
| 146 | +// Log.e(TAG, "initView: 长度:" + runRaceDetailInfo.getLatLongitude().length()); | ||
| 147 | +// trackPoints = GsonUtil.jsonToList(runRaceDetailInfo.getLatLongitude().trim(), LatLng.class); | ||
| 148 | +// Log.e(TAG, "initView: trackPoints" + trackPoints.size()); | ||
| 149 | +// MyMapUtil.drawServerLineTrack(getContext(), baiduMap, trackPoints, SortType.asc, R.color.green_round, R.drawable.icon_start, R.drawable.icon_end); | ||
| 150 | +// //自动计算地图缩放 | ||
| 151 | +// MapStatus.Builder builder = new MapStatus.Builder(); | ||
| 152 | +// builder.target(MyMapUtil.getCenterZoomPosition(trackPoints)); | ||
| 153 | +// builder.zoom(MyMapUtil.getZoom(trackPoints)); | ||
| 154 | +// baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); | ||
| 155 | +// } | ||
| 156 | + //轨迹开始时间 | ||
| 157 | + long startTime = 0; | ||
| 158 | + //轨迹结束时间 | ||
| 159 | + long endTime = 0; | ||
| 160 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getStartTime()) && !TextUtils.isEmpty(runRaceDetailInfo.getEndTime())&&!TextUtils.isEmpty(runRaceDetailInfo.getEntityName())) { | ||
| 161 | + startTime = Long.parseLong(runRaceDetailInfo.getStartTime()); | ||
| 162 | + endTime = Long.parseLong(runRaceDetailInfo.getEndTime()); | ||
| 163 | + mClient = new LBSTraceClient(getContext()); | ||
| 164 | + //获取轨迹 | ||
| 165 | + if (mClient != null) { | ||
| 166 | + MyMapUtil.queryHistoryTrace(getContext(), mClient, runRaceDetailInfo.getEntityName(), startTime, endTime, new MyMapUtil.CallBack() { | ||
| 167 | + @Override | ||
| 168 | + public void success(List<LatLng> resultPoints) { | ||
| 169 | + if (resultPoints != null && resultPoints.size() > 1) { | ||
| 170 | + Log.e(TAG, "resultPoints: " + resultPoints.size()); | ||
| 171 | + MyMapUtil.drawServerLineTrack(getContext(), baiduMap, resultPoints, SortType.asc, R.color.green_round, R.drawable.icon_start, R.drawable.icon_end); | ||
| 172 | +// //自动计算地图缩放 | ||
| 173 | +// MapStatus.Builder builder = new MapStatus.Builder(); | ||
| 174 | +// builder.target(MyMapUtil.getCenterZoomPosition(resultPoints)); | ||
| 175 | +// builder.zoom(MyMapUtil.getZoom(resultPoints)); | ||
| 176 | +// baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); | ||
| 177 | + | ||
| 178 | + LatLngBounds.Builder builder = new LatLngBounds.Builder(); | ||
| 179 | + for (LatLng latLng : resultPoints) { | ||
| 180 | + builder.include(latLng); | ||
| 181 | + } | ||
| 182 | + MapStatusUpdate mapStatusUpdate = MapStatusUpdateFactory.newLatLngBounds(builder.build()); | ||
| 183 | + baiduMap.setMapStatus(mapStatusUpdate); | ||
| 184 | + MapStatusUpdate msu = MapStatusUpdateFactory.zoomBy(-0.8f); | ||
| 185 | + baiduMap.setMapStatus(msu); | ||
| 186 | + | ||
| 187 | + } | ||
| 188 | + } | ||
| 189 | + }); | ||
| 190 | + | ||
| 191 | + } | ||
| 192 | + // | ||
| 148 | } | 193 | } |
| 149 | 194 | ||
| 150 | //显示地图 | 195 | //显示地图 |
| 151 | fragment.binding.mapView.setVisibility(View.VISIBLE); | 196 | fragment.binding.mapView.setVisibility(View.VISIBLE); |
| 152 | - //隐藏底部滑动卡片 | ||
| 153 | - fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); | 197 | + //显示底部滑动卡片 |
| 198 | +// fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); | ||
| 154 | //隐藏空视图 | 199 | //隐藏空视图 |
| 155 | fragment.binding.emptyLayout.setVisibility(View.GONE); | 200 | fragment.binding.emptyLayout.setVisibility(View.GONE); |
| 156 | //显示立即报名按钮 | 201 | //显示立即报名按钮 |
| @@ -202,6 +247,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | @@ -202,6 +247,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | ||
| 202 | } | 247 | } |
| 203 | }); | 248 | }); |
| 204 | /*************************设置相关页面数据***************************/ | 249 | /*************************设置相关页面数据***************************/ |
| 250 | + | ||
| 205 | //设置围栏ID | 251 | //设置围栏ID |
| 206 | if (!TextUtils.isEmpty(runRaceDetailInfo.getFenceId())) { | 252 | if (!TextUtils.isEmpty(runRaceDetailInfo.getFenceId())) { |
| 207 | CommonInfo.setFenceId(getContext(), Integer.parseInt(runRaceDetailInfo.getFenceId())); | 253 | CommonInfo.setFenceId(getContext(), Integer.parseInt(runRaceDetailInfo.getFenceId())); |
| @@ -209,6 +255,13 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | @@ -209,6 +255,13 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | ||
| 209 | //设置标题 | 255 | //设置标题 |
| 210 | if (!TextUtils.isEmpty(runRaceDetailInfo.getTitle())) { | 256 | if (!TextUtils.isEmpty(runRaceDetailInfo.getTitle())) { |
| 211 | fragment.binding.includeStreet.tvRaceTitle.setText(runRaceDetailInfo.getTitle()); | 257 | fragment.binding.includeStreet.tvRaceTitle.setText(runRaceDetailInfo.getTitle()); |
| 258 | + //根据标题字数动态设置卡片高度 | ||
| 259 | + if (runRaceDetailInfo.getTitle().length() > 19) { | ||
| 260 | + fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 149)); | ||
| 261 | + } else { | ||
| 262 | + fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 141)); | ||
| 263 | + } | ||
| 264 | + fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); | ||
| 212 | } | 265 | } |
| 213 | //设置活动地点 | 266 | //设置活动地点 |
| 214 | if (!TextUtils.isEmpty(runRaceDetailInfo.getAddress())) { | 267 | if (!TextUtils.isEmpty(runRaceDetailInfo.getAddress())) { |
| @@ -448,7 +501,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | @@ -448,7 +501,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | ||
| 448 | public void onClick(View view) { | 501 | public void onClick(View view) { |
| 449 | ARouter.getInstance().build("/web/WebViewColorActivity") | 502 | ARouter.getInstance().build("/web/WebViewColorActivity") |
| 450 | .withString("url", "http://wjjh5test.cnlive.com/cnSportList.html") | 503 | .withString("url", "http://wjjh5test.cnlive.com/cnSportList.html") |
| 451 | - .withString("title",runRaceDetailInfo.getTitle()+"排行榜") | 504 | + .withString("title", runRaceDetailInfo.getTitle() + "排行榜") |
| 452 | .navigation(fragment.getActivity()); | 505 | .navigation(fragment.getActivity()); |
| 453 | } | 506 | } |
| 454 | }); | 507 | }); |
| @@ -811,16 +864,24 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | @@ -811,16 +864,24 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | ||
| 811 | //数据库保存的id | 864 | //数据库保存的id |
| 812 | String dbStreetId = userStepEntity.getStreetId(); | 865 | String dbStreetId = userStepEntity.getStreetId(); |
| 813 | //获取当前时间戳 | 866 | //获取当前时间戳 |
| 814 | - long currnetTime = TimeUtil.getNowTimeStamp(); | 867 | + long currnetTime = SystemClock.elapsedRealtime(); |
| 815 | //获取用户暂停的时间戳 | 868 | //获取用户暂停的时间戳 |
| 816 | - long userPauseTime = userStepEntity.getUserPauseTimeStamp(); | 869 | + long userPauseTime = userStepEntity.getChronometerBase(); |
| 817 | //判断时间是否小于9小时 | 870 | //判断时间是否小于9小时 |
| 871 | + Log.e(TAG, "checkStartBtnState: " + currnetTime + ",userPauseTime:" + userPauseTime); | ||
| 818 | if ((currnetTime - userPauseTime) <= (9 * 60 * 60 * 1000)) { | 872 | if ((currnetTime - userPauseTime) <= (9 * 60 * 60 * 1000)) { |
| 873 | + Log.e(TAG, "小于9小时"); | ||
| 819 | fragment.binding.tvRunNow.setText("继续运动"); | 874 | fragment.binding.tvRunNow.setText("继续运动"); |
| 820 | fragment.binding.rlScrollViewStartBtn.setTag("2"); | 875 | fragment.binding.rlScrollViewStartBtn.setTag("2"); |
| 821 | } else { | 876 | } else { |
| 877 | + Log.e(TAG, "大于9小时"); | ||
| 878 | + //重置数据 | ||
| 879 | + CommonInfo.resetRace(getContext()); | ||
| 880 | + //清空数据库 | ||
| 881 | + StepUtil.clearRunData(getContext(), CommonInfo.getUserId(getContext())); | ||
| 822 | fragment.binding.tvRunNow.setText("立即开始"); | 882 | fragment.binding.tvRunNow.setText("立即开始"); |
| 823 | fragment.binding.rlScrollViewStartBtn.setTag("1"); | 883 | fragment.binding.rlScrollViewStartBtn.setTag("1"); |
| 884 | + | ||
| 824 | } | 885 | } |
| 825 | 886 | ||
| 826 | if (currentStreetId.equals(dbStreetId)) { | 887 | if (currentStreetId.equals(dbStreetId)) { |
| @@ -997,5 +1058,4 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | @@ -997,5 +1058,4 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | ||
| 997 | fragment.binding.tvGoTip.setVisibility(View.VISIBLE); | 1058 | fragment.binding.tvGoTip.setVisibility(View.VISIBLE); |
| 998 | } | 1059 | } |
| 999 | 1060 | ||
| 1000 | - | ||
| 1001 | } | 1061 | } |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/UserStepEntityDao.java
| @@ -38,6 +38,7 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | @@ -38,6 +38,7 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | ||
| 38 | public final static Property StreetId = new Property(11, String.class, "streetId", false, "STREET_ID"); | 38 | public final static Property StreetId = new Property(11, String.class, "streetId", false, "STREET_ID"); |
| 39 | public final static Property PauseCount = new Property(12, int.class, "pauseCount", false, "PAUSE_COUNT"); | 39 | public final static Property PauseCount = new Property(12, int.class, "pauseCount", false, "PAUSE_COUNT"); |
| 40 | public final static Property UserPauseTimeStamp = new Property(13, long.class, "userPauseTimeStamp", false, "USER_PAUSE_TIME_STAMP"); | 40 | public final static Property UserPauseTimeStamp = new Property(13, long.class, "userPauseTimeStamp", false, "USER_PAUSE_TIME_STAMP"); |
| 41 | + public final static Property ChronometerBase = new Property(14, long.class, "chronometerBase", false, "CHRONOMETER_BASE"); | ||
| 41 | } | 42 | } |
| 42 | 43 | ||
| 43 | 44 | ||
| @@ -66,7 +67,8 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | @@ -66,7 +67,8 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | ||
| 66 | "\"FINISH_TIME_STAMP\" INTEGER NOT NULL ," + // 10: finishTimeStamp | 67 | "\"FINISH_TIME_STAMP\" INTEGER NOT NULL ," + // 10: finishTimeStamp |
| 67 | "\"STREET_ID\" TEXT," + // 11: streetId | 68 | "\"STREET_ID\" TEXT," + // 11: streetId |
| 68 | "\"PAUSE_COUNT\" INTEGER NOT NULL ," + // 12: pauseCount | 69 | "\"PAUSE_COUNT\" INTEGER NOT NULL ," + // 12: pauseCount |
| 69 | - "\"USER_PAUSE_TIME_STAMP\" INTEGER NOT NULL );"); // 13: userPauseTimeStamp | 70 | + "\"USER_PAUSE_TIME_STAMP\" INTEGER NOT NULL ," + // 13: userPauseTimeStamp |
| 71 | + "\"CHRONOMETER_BASE\" INTEGER NOT NULL );"); // 14: chronometerBase | ||
| 70 | } | 72 | } |
| 71 | 73 | ||
| 72 | /** Drops the underlying database table. */ | 74 | /** Drops the underlying database table. */ |
| @@ -120,6 +122,7 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | @@ -120,6 +122,7 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | ||
| 120 | } | 122 | } |
| 121 | stmt.bindLong(13, entity.getPauseCount()); | 123 | stmt.bindLong(13, entity.getPauseCount()); |
| 122 | stmt.bindLong(14, entity.getUserPauseTimeStamp()); | 124 | stmt.bindLong(14, entity.getUserPauseTimeStamp()); |
| 125 | + stmt.bindLong(15, entity.getChronometerBase()); | ||
| 123 | } | 126 | } |
| 124 | 127 | ||
| 125 | @Override | 128 | @Override |
| @@ -167,6 +170,7 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | @@ -167,6 +170,7 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | ||
| 167 | } | 170 | } |
| 168 | stmt.bindLong(13, entity.getPauseCount()); | 171 | stmt.bindLong(13, entity.getPauseCount()); |
| 169 | stmt.bindLong(14, entity.getUserPauseTimeStamp()); | 172 | stmt.bindLong(14, entity.getUserPauseTimeStamp()); |
| 173 | + stmt.bindLong(15, entity.getChronometerBase()); | ||
| 170 | } | 174 | } |
| 171 | 175 | ||
| 172 | @Override | 176 | @Override |
| @@ -190,7 +194,8 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | @@ -190,7 +194,8 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | ||
| 190 | cursor.getLong(offset + 10), // finishTimeStamp | 194 | cursor.getLong(offset + 10), // finishTimeStamp |
| 191 | cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // streetId | 195 | cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // streetId |
| 192 | cursor.getInt(offset + 12), // pauseCount | 196 | cursor.getInt(offset + 12), // pauseCount |
| 193 | - cursor.getLong(offset + 13) // userPauseTimeStamp | 197 | + cursor.getLong(offset + 13), // userPauseTimeStamp |
| 198 | + cursor.getLong(offset + 14) // chronometerBase | ||
| 194 | ); | 199 | ); |
| 195 | return entity; | 200 | return entity; |
| 196 | } | 201 | } |
| @@ -211,6 +216,7 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | @@ -211,6 +216,7 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { | ||
| 211 | entity.setStreetId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); | 216 | entity.setStreetId(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11)); |
| 212 | entity.setPauseCount(cursor.getInt(offset + 12)); | 217 | entity.setPauseCount(cursor.getInt(offset + 12)); |
| 213 | entity.setUserPauseTimeStamp(cursor.getLong(offset + 13)); | 218 | entity.setUserPauseTimeStamp(cursor.getLong(offset + 13)); |
| 219 | + entity.setChronometerBase(cursor.getLong(offset + 14)); | ||
| 214 | } | 220 | } |
| 215 | 221 | ||
| 216 | @Override | 222 | @Override |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/entity/UserStepEntity.java
| @@ -21,11 +21,12 @@ public class UserStepEntity { | @@ -21,11 +21,12 @@ public class UserStepEntity { | ||
| 21 | private String streetId;//赛事ID | 21 | private String streetId;//赛事ID |
| 22 | private int pauseCount;//暂停次数 | 22 | private int pauseCount;//暂停次数 |
| 23 | private long userPauseTimeStamp;//暂停时间戳 | 23 | private long userPauseTimeStamp;//暂停时间戳 |
| 24 | + private long chronometerBase;//计时器设置基础时间 | ||
| 24 | 25 | ||
| 25 | - @Generated(hash = 446594441) | ||
| 26 | - public UserStepEntity(String userId, String date, String stepCount, long pauseTimeStamp, long recordTime, double caloriesCount, | ||
| 27 | - String serverTraceData, String startPoint, String endPoint, long startTimeStamp, long finishTimeStamp, String streetId, int pauseCount, | ||
| 28 | - long userPauseTimeStamp) { | 26 | + @Generated(hash = 562353866) |
| 27 | + public UserStepEntity(String userId, String date, String stepCount, long pauseTimeStamp, long recordTime, double caloriesCount, String serverTraceData, | ||
| 28 | + String startPoint, String endPoint, long startTimeStamp, long finishTimeStamp, String streetId, int pauseCount, long userPauseTimeStamp, | ||
| 29 | + long chronometerBase) { | ||
| 29 | this.userId = userId; | 30 | this.userId = userId; |
| 30 | this.date = date; | 31 | this.date = date; |
| 31 | this.stepCount = stepCount; | 32 | this.stepCount = stepCount; |
| @@ -40,6 +41,7 @@ public class UserStepEntity { | @@ -40,6 +41,7 @@ public class UserStepEntity { | ||
| 40 | this.streetId = streetId; | 41 | this.streetId = streetId; |
| 41 | this.pauseCount = pauseCount; | 42 | this.pauseCount = pauseCount; |
| 42 | this.userPauseTimeStamp = userPauseTimeStamp; | 43 | this.userPauseTimeStamp = userPauseTimeStamp; |
| 44 | + this.chronometerBase = chronometerBase; | ||
| 43 | } | 45 | } |
| 44 | 46 | ||
| 45 | @Generated(hash = 273857141) | 47 | @Generated(hash = 273857141) |
| @@ -158,5 +160,13 @@ public class UserStepEntity { | @@ -158,5 +160,13 @@ public class UserStepEntity { | ||
| 158 | this.userPauseTimeStamp = userPauseTimeStamp; | 160 | this.userPauseTimeStamp = userPauseTimeStamp; |
| 159 | } | 161 | } |
| 160 | 162 | ||
| 163 | + public long getChronometerBase() { | ||
| 164 | + return this.chronometerBase; | ||
| 165 | + } | ||
| 166 | + | ||
| 167 | + public void setChronometerBase(long chronometerBase) { | ||
| 168 | + this.chronometerBase = chronometerBase; | ||
| 169 | + } | ||
| 170 | + | ||
| 161 | 171 | ||
| 162 | } | 172 | } |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunMainFragment.java
| @@ -60,11 +60,11 @@ public class RunMainFragment extends QMUIFragment<RunMainFragmentView, RunMainFr | @@ -60,11 +60,11 @@ public class RunMainFragment extends QMUIFragment<RunMainFragmentView, RunMainFr | ||
| 60 | super.onPause(); | 60 | super.onPause(); |
| 61 | //todo 第二期在用 | 61 | //todo 第二期在用 |
| 62 | //记录当前计时器相关数据 | 62 | //记录当前计时器相关数据 |
| 63 | - if (getMvpView() != null) { | ||
| 64 | - if (!TextUtils.isEmpty(CommonInfo.getUserId(getActivity()))) { | ||
| 65 | - getMvpView().setFragmentPauseTime(userId); | ||
| 66 | - } | ||
| 67 | - } | 63 | +// if (getMvpView() != null) { |
| 64 | +// if (!TextUtils.isEmpty(CommonInfo.getUserId(getActivity()))) { | ||
| 65 | +// getMvpView().setFragmentPauseTime(userId); | ||
| 66 | +// } | ||
| 67 | +// } | ||
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | @Override | 70 | @Override |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunningMapFragment.java
| @@ -113,18 +113,16 @@ public class RunningMapFragment extends QMUIFragment<RunningMapFragmentView, Run | @@ -113,18 +113,16 @@ public class RunningMapFragment extends QMUIFragment<RunningMapFragmentView, Run | ||
| 113 | // CommonInfo.getStepStartTime(getActivity()); | 113 | // CommonInfo.getStepStartTime(getActivity()); |
| 114 | Log.e(TAG, "onViewCreated: 时间"+stepStartTime ); | 114 | Log.e(TAG, "onViewCreated: 时间"+stepStartTime ); |
| 115 | long startTime = 0; | 115 | long startTime = 0; |
| 116 | - if (stepStartTime != 0) { | ||
| 117 | - startTime = stepStartTime; | ||
| 118 | - } else { | ||
| 119 | - startTime = (int) (System.currentTimeMillis() / 1000 -12 * 60 * 60); | ||
| 120 | - } | 116 | +// if (stepStartTime != 0) { |
| 117 | +// startTime = stepStartTime; | ||
| 118 | +// } else { | ||
| 119 | + startTime = (int) (System.currentTimeMillis() / 1000 -12); | ||
| 120 | +// } | ||
| 121 | long current = TimeUtil.getNowTimeStamp(); | 121 | long current = TimeUtil.getNowTimeStamp(); |
| 122 | // long startTime = current - hour * 3600 * 1000 - minute * 60 * 1000 - second * 1000; | 122 | // long startTime = current - hour * 3600 * 1000 - minute * 60 * 1000 - second * 1000; |
| 123 | long endTime = current; | 123 | long endTime = current; |
| 124 | // Log.e(TAG, "onViewCreated: " + "hour:" + hour + ",minute" + minute + ",second:" + second); | 124 | // Log.e(TAG, "onViewCreated: " + "hour:" + hour + ",minute" + minute + ",second:" + second); |
| 125 | - getPresenter().queryHistoryTrace(getActivity(), StepService.entityName, 1560859257, endTime); | ||
| 126 | - //查询实时轨迹 | ||
| 127 | - getPresenter().queryRealTimeTrace(getActivity(), StepService.entityName, startTime); | 125 | + getPresenter().queryHistoryTrace(getActivity(), StepService.entityName, startTime, endTime); |
| 128 | 126 | ||
| 129 | } | 127 | } |
| 130 | 128 |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/MyMapUtil.java
| @@ -4,6 +4,9 @@ import android.content.Context; | @@ -4,6 +4,9 @@ import android.content.Context; | ||
| 4 | import android.graphics.Bitmap; | 4 | import android.graphics.Bitmap; |
| 5 | import android.graphics.BitmapFactory; | 5 | import android.graphics.BitmapFactory; |
| 6 | import android.location.LocationManager; | 6 | import android.location.LocationManager; |
| 7 | +import android.os.Handler; | ||
| 8 | +import android.util.Log; | ||
| 9 | +import android.widget.Toast; | ||
| 7 | 10 | ||
| 8 | import com.baidu.mapapi.map.BaiduMap; | 11 | import com.baidu.mapapi.map.BaiduMap; |
| 9 | import com.baidu.mapapi.map.BitmapDescriptorFactory; | 12 | import com.baidu.mapapi.map.BitmapDescriptorFactory; |
| @@ -13,17 +16,205 @@ import com.baidu.mapapi.map.OverlayOptions; | @@ -13,17 +16,205 @@ import com.baidu.mapapi.map.OverlayOptions; | ||
| 13 | import com.baidu.mapapi.map.PolylineOptions; | 16 | import com.baidu.mapapi.map.PolylineOptions; |
| 14 | import com.baidu.mapapi.model.LatLng; | 17 | import com.baidu.mapapi.model.LatLng; |
| 15 | import com.baidu.mapapi.utils.DistanceUtil; | 18 | import com.baidu.mapapi.utils.DistanceUtil; |
| 19 | +import com.baidu.trace.LBSTraceClient; | ||
| 20 | +import com.baidu.trace.api.track.DistanceRequest; | ||
| 21 | +import com.baidu.trace.api.track.DistanceResponse; | ||
| 22 | +import com.baidu.trace.api.track.HistoryTrackRequest; | ||
| 23 | +import com.baidu.trace.api.track.HistoryTrackResponse; | ||
| 24 | +import com.baidu.trace.api.track.OnTrackListener; | ||
| 25 | +import com.baidu.trace.api.track.SupplementMode; | ||
| 26 | +import com.baidu.trace.api.track.TrackPoint; | ||
| 27 | +import com.baidu.trace.model.CoordType; | ||
| 28 | +import com.baidu.trace.model.ProcessOption; | ||
| 16 | import com.baidu.trace.model.SortType; | 29 | import com.baidu.trace.model.SortType; |
| 30 | +import com.baidu.trace.model.StatusCodes; | ||
| 31 | +import com.baidu.trace.model.TransportMode; | ||
| 32 | +import com.cnlive.moudle.pedometer.model.Constant; | ||
| 17 | import com.cnlive.moudle.pedometer.model.RoutePoint; | 33 | import com.cnlive.moudle.pedometer.model.RoutePoint; |
| 34 | +import com.cnlive.moudle.pedometer.service.StepService; | ||
| 18 | import com.example.moudle_pedometer.R; | 35 | import com.example.moudle_pedometer.R; |
| 19 | 36 | ||
| 20 | import java.util.ArrayList; | 37 | import java.util.ArrayList; |
| 38 | +import java.util.HashMap; | ||
| 21 | import java.util.List; | 39 | import java.util.List; |
| 22 | 40 | ||
| 23 | /** | 41 | /** |
| 24 | * @author ShinnyYang | 42 | * @author ShinnyYang |
| 25 | */ | 43 | */ |
| 26 | public class MyMapUtil { | 44 | public class MyMapUtil { |
| 45 | + private static final String TAG = "MyMapUtil"; | ||
| 46 | + //分页大小 | ||
| 47 | + private static int pageSize = 1000; | ||
| 48 | + //分页索引 | ||
| 49 | + private static int pageIndex = 1; | ||
| 50 | + private static List<LatLng> trackPoints; | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 判断用户是否完成比赛 | ||
| 54 | + * | ||
| 55 | + * @param importPoints | ||
| 56 | + * @param trackPoints | ||
| 57 | + * @param passRate 及格率,如60%----0.6 | ||
| 58 | + * @return | ||
| 59 | + */ | ||
| 60 | + public static boolean checkIsFinishTrace(List<LatLng> importPoints, List<LatLng> trackPoints, double passRate) { | ||
| 61 | + HashMap<Integer, Boolean> importHash = new HashMap<>(); | ||
| 62 | + for (int i = 0; i < importPoints.size(); i++) { | ||
| 63 | + if (i % 3 != 0) { | ||
| 64 | + importPoints.remove(i); | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + for (int i = 0; i < importPoints.size(); i++) { | ||
| 68 | + importHash.put(i, false); | ||
| 69 | + } | ||
| 70 | + //开始比较数据 | ||
| 71 | + int index = 0; | ||
| 72 | + for (int i = 0; i < importPoints.size(); i++) { | ||
| 73 | + LatLng importLatLng = importPoints.get(i); | ||
| 74 | + for (int j = index; j < trackPoints.size(); j++) { | ||
| 75 | + double distance = DistanceUtil.getDistance(importLatLng, trackPoints.get(j)); | ||
| 76 | + if (distance < 50) { | ||
| 77 | + importHash.put(i, true); | ||
| 78 | + index = j; | ||
| 79 | + } | ||
| 80 | + } | ||
| 81 | + } | ||
| 82 | + //输出 | ||
| 83 | + int result = 0; | ||
| 84 | + for (int i = 0; i < importHash.size(); i++) { | ||
| 85 | + if (!importHash.get(i)) { | ||
| 86 | + result++; | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + if (result > importPoints.size() * (1 - passRate)) { | ||
| 90 | +// Toast.makeText(context, "没有完成", Toast.LENGTH_LONG).show(); | ||
| 91 | + return false; | ||
| 92 | + | ||
| 93 | + } else { | ||
| 94 | +// Toast.makeText(context, "已完成", Toast.LENGTH_LONG).show(); | ||
| 95 | + return true; | ||
| 96 | + } | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + /** | ||
| 100 | + * 查询历史轨迹 | ||
| 101 | + * | ||
| 102 | + * @param startTime | ||
| 103 | + * @param endTime | ||
| 104 | + */ | ||
| 105 | + private static int queryNum = 0;//查询次数 | ||
| 106 | + | ||
| 107 | + public static void queryHistoryTrace(Context context, LBSTraceClient mClient, String entityName, long startTime, long endTime, CallBack callBack) { | ||
| 108 | + Log.e(TAG, "queryHistoryTrace: 时间:" + startTime); | ||
| 109 | + HistoryTrackRequest historyTrackRequest = new HistoryTrackRequest(Constant.TAG, Constant.SERVICE_ID, entityName); | ||
| 110 | + //设置查询设备名称 | ||
| 111 | + historyTrackRequest.setEntityName(entityName); | ||
| 112 | + //历史轨迹开始时间 | ||
| 113 | + historyTrackRequest.setStartTime(startTime); | ||
| 114 | + //历史轨迹结束时间 | ||
| 115 | + historyTrackRequest.setEndTime(endTime); | ||
| 116 | + //分页索引 | ||
| 117 | + historyTrackRequest.setPageIndex(pageIndex); | ||
| 118 | + //分页大小 | ||
| 119 | + historyTrackRequest.setPageSize(pageSize); | ||
| 120 | + //设置是否进行纠偏 | ||
| 121 | + historyTrackRequest.setProcessed(true); | ||
| 122 | + //设置返回坐标系 | ||
| 123 | + historyTrackRequest.setCoordTypeOutput(CoordType.gcj02); | ||
| 124 | + //其他设置 | ||
| 125 | + ProcessOption processOption = new ProcessOption(); | ||
| 126 | + //去噪:可设置是否需要去除角度、速度和方向异常的轨迹点 | ||
| 127 | + processOption.setNeedDenoise(true); | ||
| 128 | + //绑路:设置是否将轨迹点绑定至路网道路 | ||
| 129 | + processOption.setNeedMapMatch(false); | ||
| 130 | + //抽稀:设置是否进行抽稀处理,对冗余的轨迹点进行抽稀去除处理,如一条直线上除起终点外的多个轨迹点 | ||
| 131 | + processOption.setNeedVacuate(true); | ||
| 132 | + //自动判断交通方式 | ||
| 133 | + processOption.setTransportMode(TransportMode.walking); | ||
| 134 | + // 设置精度过滤值(定位精度大于100米的过滤掉) | ||
| 135 | + processOption.setRadiusThreshold(9); | ||
| 136 | + // 设置纠偏选项 | ||
| 137 | + historyTrackRequest.setProcessOption(processOption); | ||
| 138 | + // 设置里程填充方式为驾车 | ||
| 139 | + historyTrackRequest.setSupplementMode(SupplementMode.walking); | ||
| 140 | + | ||
| 141 | + if (trackPoints == null) { | ||
| 142 | + trackPoints = new ArrayList<>(); | ||
| 143 | + } | ||
| 144 | + //轨迹查询监听器 | ||
| 145 | + OnTrackListener historyTrackListener = new OnTrackListener() { | ||
| 146 | + @Override | ||
| 147 | + public void onHistoryTrackCallback(HistoryTrackResponse response) { | ||
| 148 | + super.onHistoryTrackCallback(response); | ||
| 149 | + int total = response.getTotal(); | ||
| 150 | + Log.e(TAG, "onHistoryTrackCallback: " + response.getMessage()); | ||
| 151 | + if (StatusCodes.SUCCESS != response.getStatus()) { | ||
| 152 | + if (response.getStatus() == 14004) { | ||
| 153 | + //给3次重新查询的机会 | ||
| 154 | + if (queryNum < 4) { | ||
| 155 | + //重新查询 | ||
| 156 | +// new Handler().postDelayed(new Runnable() { | ||
| 157 | +// @Override | ||
| 158 | +// public void run() { | ||
| 159 | +// //间隔3秒查一次 | ||
| 160 | + queryHistoryTrace(context, mClient, entityName, startTime, endTime, callBack); | ||
| 161 | + queryNum++; | ||
| 162 | +// } | ||
| 163 | +// }, 1000); | ||
| 164 | + | ||
| 165 | + } else { | ||
| 166 | + callBack.success(null); | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + } else { | ||
| 170 | + Toast.makeText(context, "获取轨迹失败!" + response.getMessage() + "," + response.getStatus(), Toast.LENGTH_SHORT).show(); | ||
| 171 | + } | ||
| 172 | + } else if (0 == total) { | ||
| 173 | + if (callBack != null) { | ||
| 174 | + callBack.success(new ArrayList<>()); | ||
| 175 | + trackPoints.clear(); | ||
| 176 | + } | ||
| 177 | + queryNum = 0; | ||
| 178 | + Toast.makeText(context, "暂未查到您的轨迹,请稍后重试!", Toast.LENGTH_SHORT).show(); | ||
| 179 | + } else { | ||
| 180 | + queryNum = 0; | ||
| 181 | + //查询到轨迹 | ||
| 182 | + List<TrackPoint> points = response.getTrackPoints(); | ||
| 183 | + if (null != points) { | ||
| 184 | + for (TrackPoint trackPoint : points) { | ||
| 185 | + if (!CommonUtil.isZeroPoint(trackPoint.getLocation().getLatitude(), | ||
| 186 | + trackPoint.getLocation().getLongitude())) { | ||
| 187 | + //将轨迹点转换为地图坐标点 | ||
| 188 | + trackPoints.add(MyMapUtil.convertTrace2Map(trackPoint.getLocation())); | ||
| 189 | + } | ||
| 190 | + } | ||
| 191 | + } | ||
| 192 | + } | ||
| 193 | + if (total > pageSize * pageIndex) { | ||
| 194 | + historyTrackRequest.setPageIndex(++pageIndex); | ||
| 195 | + queryHistoryTrace(context, mClient, entityName, startTime, endTime, callBack); | ||
| 196 | + } else { | ||
| 197 | + if (callBack != null) { | ||
| 198 | + callBack.success(trackPoints); | ||
| 199 | + trackPoints.clear(); | ||
| 200 | + } | ||
| 201 | + } | ||
| 202 | + | ||
| 203 | + } | ||
| 204 | + }; | ||
| 205 | + //开始查询历史轨迹 | ||
| 206 | + if (mClient != null) { | ||
| 207 | + mClient.queryHistoryTrack(historyTrackRequest, historyTrackListener); | ||
| 208 | + } | ||
| 209 | +// if (trackPoints != null && trackPoints.size() > 0) { | ||
| 210 | +// Log.e(TAG, "queryHistoryTrace: " + trackPoints.size()); | ||
| 211 | +// return trackPoints; | ||
| 212 | +// } else { | ||
| 213 | +// Log.e(TAG, "queryHistoryTrace: trackPoints:null"); | ||
| 214 | +// return null; | ||
| 215 | +// } | ||
| 216 | + } | ||
| 217 | + | ||
| 27 | /** | 218 | /** |
| 28 | * 判断GPS是否开启,GPS或者AGPS开启一个就认为是开启的 | 219 | * 判断GPS是否开启,GPS或者AGPS开启一个就认为是开启的 |
| 29 | * | 220 | * |
| @@ -649,4 +840,8 @@ public class MyMapUtil { | @@ -649,4 +840,8 @@ public class MyMapUtil { | ||
| 649 | } | 840 | } |
| 650 | return inPoint; | 841 | return inPoint; |
| 651 | } | 842 | } |
| 843 | + | ||
| 844 | + public interface CallBack { | ||
| 845 | + public void success(List<LatLng> resultPoints); | ||
| 846 | + } | ||
| 652 | } | 847 | } |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/StepUtil.java
| @@ -134,6 +134,14 @@ public class StepUtil { | @@ -134,6 +134,14 @@ public class StepUtil { | ||
| 134 | } | 134 | } |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | + /** | ||
| 138 | + * 初始化计步相关数据 | ||
| 139 | + * | ||
| 140 | + * @param context | ||
| 141 | + * @param uid | ||
| 142 | + * @param startStamp | ||
| 143 | + * @param streetId | ||
| 144 | + */ | ||
| 137 | public static void setStepStartData(Context context, String uid, long startStamp, String streetId) { | 145 | public static void setStepStartData(Context context, String uid, long startStamp, String streetId) { |
| 138 | if (getUserStepData(context, uid) != null) { | 146 | if (getUserStepData(context, uid) != null) { |
| 139 | UserStepEntity entity = getUserStepData(context, uid); | 147 | UserStepEntity entity = getUserStepData(context, uid); |
| @@ -151,6 +159,34 @@ public class StepUtil { | @@ -151,6 +159,34 @@ public class StepUtil { | ||
| 151 | } | 159 | } |
| 152 | } | 160 | } |
| 153 | 161 | ||
| 162 | + /** | ||
| 163 | + * 设置计步开始时间 | ||
| 164 | + * | ||
| 165 | + * @param context | ||
| 166 | + * @param uid | ||
| 167 | + * @param time | ||
| 168 | + */ | ||
| 169 | + public static void setChronometerBase(Context context, String uid, long time) { | ||
| 170 | + if (getUserStepData(context, uid) != null) { | ||
| 171 | + UserStepEntity entity = getUserStepData(context, uid); | ||
| 172 | + entity.setChronometerBase(time); | ||
| 173 | + //更新数据 | ||
| 174 | + updateStepData(context, entity); | ||
| 175 | + } else { | ||
| 176 | + //创建数据 | ||
| 177 | + UserStepEntity userStepEntity = new UserStepEntity(); | ||
| 178 | + userStepEntity.setUserId(uid); | ||
| 179 | + userStepEntity.setChronometerBase(time); | ||
| 180 | + insertStepData(context, userStepEntity); | ||
| 181 | + } | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + /** | ||
| 185 | + * 插入计步数据 | ||
| 186 | + * | ||
| 187 | + * @param context | ||
| 188 | + * @param userStepEntity | ||
| 189 | + */ | ||
| 154 | public static void insertStepData(Context context, UserStepEntity userStepEntity) { | 190 | public static void insertStepData(Context context, UserStepEntity userStepEntity) { |
| 155 | DbCore.init(context, dbName); | 191 | DbCore.init(context, dbName); |
| 156 | DbCore.getDaoSession().getUserStepEntityDao().insert(userStepEntity); | 192 | DbCore.getDaoSession().getUserStepEntityDao().insert(userStepEntity); |
moudle_pedometer/src/main/res/layout/fragment_run_main.xml
| @@ -63,8 +63,9 @@ | @@ -63,8 +63,9 @@ | ||
| 63 | 63 | ||
| 64 | <ImageView | 64 | <ImageView |
| 65 | android:id="@+id/iv_back" | 65 | android:id="@+id/iv_back" |
| 66 | - android:layout_width="20dp" | ||
| 67 | - android:layout_height="40dp" | 66 | + android:layout_width="15dp" |
| 67 | + android:layout_height="20dp" | ||
| 68 | + android:layout_margin="10dp" | ||
| 68 | android:background="@drawable/back" /> | 69 | android:background="@drawable/back" /> |
| 69 | </FrameLayout> | 70 | </FrameLayout> |
| 70 | <!--GPS信息--> | 71 | <!--GPS信息--> |
moudle_pedometer/src/main/res/layout/fragment_run_race_detail.xml
| @@ -14,7 +14,7 @@ | @@ -14,7 +14,7 @@ | ||
| 14 | sothree:umanoDragView="@+id/dragView" | 14 | sothree:umanoDragView="@+id/dragView" |
| 15 | sothree:umanoFadeColor="@color/black_20" | 15 | sothree:umanoFadeColor="@color/black_20" |
| 16 | sothree:umanoOverlay="true" | 16 | sothree:umanoOverlay="true" |
| 17 | - sothree:umanoPanelHeight="141dp" | 17 | + |
| 18 | sothree:umanoParallaxOffset="250dp" | 18 | sothree:umanoParallaxOffset="250dp" |
| 19 | sothree:umanoScrollableView="@+id/scrollView" | 19 | sothree:umanoScrollableView="@+id/scrollView" |
| 20 | sothree:umanoShadowHeight="0dp"> | 20 | sothree:umanoShadowHeight="0dp"> |