Commit cbfcd861f1497914d4befa394fc1ded03cc81056

Authored by 杨帅
1 parent 36877953

1.判断用户是否完成

Showing 24 changed files with 872 additions and 324 deletions
.idea/gradle.xml
@@ -9,8 +9,11 @@ @@ -9,8 +9,11 @@
9 <set> 9 <set>
10 <option value="$PROJECT_DIR$" /> 10 <option value="$PROJECT_DIR$" />
11 <option value="$PROJECT_DIR$/app" /> 11 <option value="$PROJECT_DIR$/app" />
  12 + <option value="$PROJECT_DIR$/app_user" />
  13 + <option value="$PROJECT_DIR$/lib_network" />
12 <option value="$PROJECT_DIR$/library_baidumap" /> 14 <option value="$PROJECT_DIR$/library_baidumap" />
13 <option value="$PROJECT_DIR$/moudle_pedometer" /> 15 <option value="$PROJECT_DIR$/moudle_pedometer" />
  16 + <option value="$PROJECT_DIR$/share" />
14 </set> 17 </set>
15 </option> 18 </option>
16 <option name="resolveModulePerSourceSet" value="false" /> 19 <option name="resolveModulePerSourceSet" value="false" />
lib_network/src/main/java/com/cnlive/strike/data/network/api/ApiServiceDaren.java
@@ -8,6 +8,7 @@ import com.cnlive.strike.data.network.model.DarenApplyModel; @@ -8,6 +8,7 @@ import com.cnlive.strike.data.network.model.DarenApplyModel;
8 import com.cnlive.strike.data.network.model.GifEmojiItemData; 8 import com.cnlive.strike.data.network.model.GifEmojiItemData;
9 import com.cnlive.strike.data.network.model.GifListData; 9 import com.cnlive.strike.data.network.model.GifListData;
10 import com.cnlive.strike.data.network.model.ShortLinkInfo; 10 import com.cnlive.strike.data.network.model.ShortLinkInfo;
  11 +import com.cnlive.strike.data.network.model.runAbout.RunRaceDetailInfo;
11 12
12 import java.util.List; 13 import java.util.List;
13 import java.util.Map; 14 import java.util.Map;
@@ -16,6 +17,7 @@ import io.reactivex.Observable; @@ -16,6 +17,7 @@ import io.reactivex.Observable;
16 import okhttp3.MultipartBody; 17 import okhttp3.MultipartBody;
17 import okhttp3.RequestBody; 18 import okhttp3.RequestBody;
18 import retrofit2.adapter.rxjava2.Result; 19 import retrofit2.adapter.rxjava2.Result;
  20 +import retrofit2.http.GET;
19 import retrofit2.http.Multipart; 21 import retrofit2.http.Multipart;
20 import retrofit2.http.POST; 22 import retrofit2.http.POST;
21 import retrofit2.http.Part; 23 import retrofit2.http.Part;
@@ -88,5 +90,15 @@ public interface ApiServiceDaren { @@ -88,5 +90,15 @@ public interface ApiServiceDaren {
88 Observable<Result<BaseInfo>> userAddGroup(@QueryMap Map<String, String> map); 90 Observable<Result<BaseInfo>> userAddGroup(@QueryMap Map<String, String> map);
89 91
90 92
  93 + /************************************体育中国跑步相关网络接口**********************************************************/
  94 + /**
  95 + * http://bj.gitlab.cnlive.com/cnlive/BOSS-Wiki/wikis/getEventDetails
  96 + * 线下约跑赛事详情页
  97 + * 杨帅
  98 + * id int true 赛事id
  99 + * sid String true 用户sid
  100 + */
  101 + @GET("Daren/event/getEventDetails.action")
  102 + Observable<Result<BaseInfo<RunRaceDetailInfo>>> getRunRaceDetail(@QueryMap Map<String, String> map);
91 } 103 }
92 104
lib_network/src/main/java/com/cnlive/strike/data/network/model/runAbout/RunRaceDetailInfo.java 0 → 100644
  1 +package com.cnlive.strike.data.network.model.runAbout;
  2 +
  3 +import java.util.List;
  4 +
  5 +/**
  6 + * 线下约跑赛事详情页
  7 + *
  8 + * @author ShinnyYang
  9 + */
  10 +public class RunRaceDetailInfo {
  11 +
  12 + /**
  13 + * address : 澳大利亚黄金海岸
  14 + * employTime : 00:0:30
  15 + * endLocation : 首都师范大学操场西门
  16 + * end_time : 1571140800000
  17 + * faceUrl : ["http://yweb0.cnliveimg.com/images/headImg/2019/0505/1557039035723_small.jpg","http://yweb0.cnliveimg.com/images/headImg/2019/0505/1557034319038_small.jpg","http://yweb0.cnliveimg.com/images/headImg/2018/0902/1535858459612_small.jpg"]
  18 + * finishFaceUrl : ["http://yweb0.cnliveimg.com/images/headImg/2019/0505/1557039035723_small.jpg","http://yweb0.cnliveimg.com/images/headImg/2019/0523/1558599016203_small.jpg","http://yweb0.cnliveimg.com/images/headImg/2019/0523/1558599016203_small.jpg","http://yweb0.cnliveimg.com/images/headImg/2019/0523/1558599016203_small.jpg","http://yweb0.cnliveimg.com/images/headImg/2019/0523/1558599016203_small.jpg"]
  19 + * firstEmployTime : 33
  20 + * firstFaceUrl : http://yweb0.cnliveimg.com/images/headImg/2019/0523/1558599016203_small.jpg
  21 + * firstName : 峨眉派掌门候选人
  22 + * id : 116
  23 + * latLongitude : ["39.74788,116.14294","39.74888,116.14394"]
  24 + * mileage : 全长4.42公里
  25 + * pace : 22.33
  26 + * roadmap : http://yweb0.cnliveimg.com/images/headImg/2019/051
  27 + * sign_up_end_time : 1521043200000
  28 + * sign_up_start_time : 1509494400000
  29 + * signupNum : 3
  30 + * startLocation : 首都师范大学操场东门
  31 + * start_time : 1522454400000
  32 + * step : 10000
  33 + * title : 2018国际网络徒步大赛黄金海岸站
  34 + * userMileage : 5.5
  35 + */
  36 +
  37 + private String address;
  38 + private String employTime;
  39 + private String endLocation;
  40 + private long end_time;
  41 + private String firstEmployTime;
  42 + private String firstFaceUrl;
  43 + private String firstName;
  44 + private int id;
  45 + private String latLongitude;
  46 + private String mileage;
  47 + private String pace;
  48 + private String roadmap;
  49 + private long sign_up_end_time;
  50 + private long sign_up_start_time;
  51 + private int signupNum;
  52 + private String startLocation;
  53 + private long start_time;
  54 + private String step;
  55 + private String title;
  56 + private String userMileage;
  57 + private List<String> faceUrl;
  58 + private List<String> finishFaceUrl;
  59 +
  60 + public String getAddress() {
  61 + return address;
  62 + }
  63 +
  64 + public void setAddress(String address) {
  65 + this.address = address;
  66 + }
  67 +
  68 + public String getEmployTime() {
  69 + return employTime;
  70 + }
  71 +
  72 + public void setEmployTime(String employTime) {
  73 + this.employTime = employTime;
  74 + }
  75 +
  76 + public String getEndLocation() {
  77 + return endLocation;
  78 + }
  79 +
  80 + public void setEndLocation(String endLocation) {
  81 + this.endLocation = endLocation;
  82 + }
  83 +
  84 + public long getEnd_time() {
  85 + return end_time;
  86 + }
  87 +
  88 + public void setEnd_time(long end_time) {
  89 + this.end_time = end_time;
  90 + }
  91 +
  92 + public String getFirstEmployTime() {
  93 + return firstEmployTime;
  94 + }
  95 +
  96 + public void setFirstEmployTime(String firstEmployTime) {
  97 + this.firstEmployTime = firstEmployTime;
  98 + }
  99 +
  100 + public String getFirstFaceUrl() {
  101 + return firstFaceUrl;
  102 + }
  103 +
  104 + public void setFirstFaceUrl(String firstFaceUrl) {
  105 + this.firstFaceUrl = firstFaceUrl;
  106 + }
  107 +
  108 + public String getFirstName() {
  109 + return firstName;
  110 + }
  111 +
  112 + public void setFirstName(String firstName) {
  113 + this.firstName = firstName;
  114 + }
  115 +
  116 + public int getId() {
  117 + return id;
  118 + }
  119 +
  120 + public void setId(int id) {
  121 + this.id = id;
  122 + }
  123 +
  124 + public String getLatLongitude() {
  125 + return latLongitude;
  126 + }
  127 +
  128 + public void setLatLongitude(String latLongitude) {
  129 + this.latLongitude = latLongitude;
  130 + }
  131 +
  132 + public String getMileage() {
  133 + return mileage;
  134 + }
  135 +
  136 + public void setMileage(String mileage) {
  137 + this.mileage = mileage;
  138 + }
  139 +
  140 + public String getPace() {
  141 + return pace;
  142 + }
  143 +
  144 + public void setPace(String pace) {
  145 + this.pace = pace;
  146 + }
  147 +
  148 + public String getRoadmap() {
  149 + return roadmap;
  150 + }
  151 +
  152 + public void setRoadmap(String roadmap) {
  153 + this.roadmap = roadmap;
  154 + }
  155 +
  156 + public long getSign_up_end_time() {
  157 + return sign_up_end_time;
  158 + }
  159 +
  160 + public void setSign_up_end_time(long sign_up_end_time) {
  161 + this.sign_up_end_time = sign_up_end_time;
  162 + }
  163 +
  164 + public long getSign_up_start_time() {
  165 + return sign_up_start_time;
  166 + }
  167 +
  168 + public void setSign_up_start_time(long sign_up_start_time) {
  169 + this.sign_up_start_time = sign_up_start_time;
  170 + }
  171 +
  172 + public int getSignupNum() {
  173 + return signupNum;
  174 + }
  175 +
  176 + public void setSignupNum(int signupNum) {
  177 + this.signupNum = signupNum;
  178 + }
  179 +
  180 + public String getStartLocation() {
  181 + return startLocation;
  182 + }
  183 +
  184 + public void setStartLocation(String startLocation) {
  185 + this.startLocation = startLocation;
  186 + }
  187 +
  188 + public long getStart_time() {
  189 + return start_time;
  190 + }
  191 +
  192 + public void setStart_time(long start_time) {
  193 + this.start_time = start_time;
  194 + }
  195 +
  196 + public String getStep() {
  197 + return step;
  198 + }
  199 +
  200 + public void setStep(String step) {
  201 + this.step = step;
  202 + }
  203 +
  204 + public String getTitle() {
  205 + return title;
  206 + }
  207 +
  208 + public void setTitle(String title) {
  209 + this.title = title;
  210 + }
  211 +
  212 + public String getUserMileage() {
  213 + return userMileage;
  214 + }
  215 +
  216 + public void setUserMileage(String userMileage) {
  217 + this.userMileage = userMileage;
  218 + }
  219 +
  220 + public List<String> getFaceUrl() {
  221 + return faceUrl;
  222 + }
  223 +
  224 + public void setFaceUrl(List<String> faceUrl) {
  225 + this.faceUrl = faceUrl;
  226 + }
  227 +
  228 + public List<String> getFinishFaceUrl() {
  229 + return finishFaceUrl;
  230 + }
  231 +
  232 + public void setFinishFaceUrl(List<String> finishFaceUrl) {
  233 + this.finishFaceUrl = finishFaceUrl;
  234 + }
  235 +}
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/presenter/RunRaceDetailFragmentPresenter.java
1 package com.cnlive.moudle.pedometer.frame.presenter; 1 package com.cnlive.moudle.pedometer.frame.presenter;
2 2
  3 +import android.content.Context;
  4 +
  5 +import com.cnlive.libs.base.logic.Logic;
  6 +import com.cnlive.libs.base.logic.callback.FailureCallback;
  7 +import com.cnlive.libs.data.network.model.IBaseInfo;
3 import com.cnlive.moudle.pedometer.frame.view.RunRaceDetailFragmentView; 8 import com.cnlive.moudle.pedometer.frame.view.RunRaceDetailFragmentView;
4 import com.cnlive.moudle.pedometer.frame.view.RunningMapFragmentView; 9 import com.cnlive.moudle.pedometer.frame.view.RunningMapFragmentView;
5 import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; 10 import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
6 11
  12 +import java.util.HashMap;
  13 +import java.util.Map;
  14 +
  15 +import io.reactivex.disposables.Disposable;
  16 +
7 public class RunRaceDetailFragmentPresenter extends MvpBasePresenter<RunRaceDetailFragmentView> { 17 public class RunRaceDetailFragmentPresenter extends MvpBasePresenter<RunRaceDetailFragmentView> {
  18 +
  19 + public void getRunRaceDetailInfo(Context context, String id, String userId) {
  20 + //设置请求参数
  21 + Map<String, String> paramsMap = new HashMap<>();
  22 + //赛事id
  23 + paramsMap.put("id", id);
  24 + paramsMap.put("userId", userId);
  25 +
  26 +// Logic.create(paramsMap)
  27 +// .action(new Logic.Action<Map<String, String>, BaseInfo>() {
  28 +// @Override
  29 +// public Disposable action(Map<String, String> paramsMap, DataCallback<SubscriptionBaseInfo> dataCallback) {
  30 +// return SubscriptionRequest.service(ApiServiceInterest.class, api -> api.userFollowAddGroup(paramsMap)).subscribe(context, dataCallback);
  31 +// }
  32 +// }).<SubscriptionBaseInfo>event()
  33 +// .setSuccessCallback(new SuccessCallback<SubscriptionBaseInfo>() {
  34 +// @Override
  35 +// public void onSuccess(SubscriptionBaseInfo subscriptionBaseInfo) {
  36 +// if (getView() != null) {
  37 +// getView().hideQmuiDialog();
  38 +// }
  39 +// callBack.onSuccess();
  40 +// }
  41 +//
  42 +// })
  43 +// .setFailureCallback(new FailureCallback() {
  44 +// @Override
  45 +// public void onFailure(int i, String s) {
  46 +// if (getView() != null) {
  47 +// getView().hideQmuiDialog();
  48 +// getView().showFailDailog("网络请求失败,请稍后重试", 2);
  49 +// if (!TextUtils.isEmpty(s)) {
  50 +// callBack.onFailed(s);
  51 +// } else {
  52 +// callBack.onFailed("接口请求失败,请重试!");
  53 +// }
  54 +// }
  55 +// }
  56 +// })
  57 +//
  58 +// .start();
  59 +
  60 + }
8 } 61 }
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/presenter/RunningMapFragmentPresenter.java
@@ -12,6 +12,7 @@ import com.baidu.mapapi.map.MarkerOptions; @@ -12,6 +12,7 @@ import com.baidu.mapapi.map.MarkerOptions;
12 import com.baidu.mapapi.map.Overlay; 12 import com.baidu.mapapi.map.Overlay;
13 import com.baidu.mapapi.map.OverlayOptions; 13 import com.baidu.mapapi.map.OverlayOptions;
14 import com.baidu.mapapi.model.LatLng; 14 import com.baidu.mapapi.model.LatLng;
  15 +import com.baidu.mapapi.utils.DistanceUtil;
15 import com.baidu.trace.api.entity.AddEntityResponse; 16 import com.baidu.trace.api.entity.AddEntityResponse;
16 import com.baidu.trace.api.entity.AroundSearchResponse; 17 import com.baidu.trace.api.entity.AroundSearchResponse;
17 import com.baidu.trace.api.entity.BoundSearchResponse; 18 import com.baidu.trace.api.entity.BoundSearchResponse;
@@ -72,6 +73,7 @@ import com.example.moudle_pedometer.R; @@ -72,6 +73,7 @@ import com.example.moudle_pedometer.R;
72 import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; 73 import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
73 74
74 import java.util.ArrayList; 75 import java.util.ArrayList;
  76 +import java.util.HashMap;
75 import java.util.List; 77 import java.util.List;
76 78
77 public class RunningMapFragmentPresenter extends MvpBasePresenter<RunningMapFragmentView> { 79 public class RunningMapFragmentPresenter extends MvpBasePresenter<RunningMapFragmentView> {
@@ -105,7 +107,9 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter&lt;RunningMapFrag @@ -105,7 +107,9 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter&lt;RunningMapFrag
105 */ 107 */
106 private List<LatLng> trackPoints; 108 private List<LatLng> trackPoints;
107 private List<LatLng> realTimePoints; 109 private List<LatLng> realTimePoints;
108 - 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;
  112 + private static int matchIndex = 0;
109 113
110 /** 114 /**
111 * 查询历史轨迹 115 * 查询历史轨迹
@@ -114,6 +118,20 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter&lt;RunningMapFrag @@ -114,6 +118,20 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter&lt;RunningMapFrag
114 * @param endTime 118 * @param endTime
115 */ 119 */
116 public void queryHistoryTrace(Context context, String entityName, long startTime, long endTime) { 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 + }
117 135
118 if (historyTrackRequest == null) { 136 if (historyTrackRequest == null) {
119 historyTrackRequest = new HistoryTrackRequest(tag, StepService.serviceId, entityName); 137 historyTrackRequest = new HistoryTrackRequest(tag, StepService.serviceId, entityName);
@@ -210,11 +228,62 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter&lt;RunningMapFrag @@ -210,11 +228,62 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter&lt;RunningMapFrag
210 queryHistoryTrace(context, entityName, startTime, endTime); 228 queryHistoryTrace(context, entityName, startTime, endTime);
211 } else { 229 } else {
212 if (getView() != null) { 230 if (getView() != null) {
213 - List<RoutePoint> routePoints = new ArrayList<>();  
214 - for (LatLng latLng : trackPoints) {  
215 - routePoints.add(new RoutePoint(latLng.latitude, latLng.longitude)); 231 +
  232 + //开始比较(杨帅的思路)
  233 +// for (int i = 0; i < trackPoints.size(); i++) {
  234 +// if (matchIndex < importPoints.size() - 1) {
  235 +// LatLng matchLatLng = importPoints.get(matchIndex);
  236 +// LatLng historyLatLng = trackPoints.get(i);
  237 +// Log.e(TAG, "距离: " + DistanceUtil.getDistance(matchLatLng, historyLatLng));
  238 +// double distance = DistanceUtil.getDistance(matchLatLng, historyLatLng);
  239 +// if (distance < 200) {
  240 +// importHash.put(matchIndex, true);
  241 +// matchIndex++;
  242 +// }
  243 +// }
  244 +// }
  245 +// //输出
  246 +// int result = 0;
  247 +// for (int i = 0; i < importHash.size(); i++) {
  248 +// if (!importHash.get(i)) {
  249 +// result++;
  250 +// Log.e(TAG, "onHistoryTrackCallback: 没过:" + i + importHash.get(i));
  251 +// }
  252 +// }
  253 +// if (result > importPoints.size() * 0.4) {
  254 +// Toast.makeText(context, "没有完成", Toast.LENGTH_LONG).show();
  255 +//
  256 +// } else {
  257 +// Toast.makeText(context, "已完成", Toast.LENGTH_LONG).show();
  258 +// }
  259 + //郭瑞鹏的思路
  260 + int index = 0;
  261 + for (int i = 0; i < importPoints.size(); i++) {
  262 + LatLng importLatLng = importPoints.get(i);
  263 + for (int j = index; j < trackPoints.size(); j++) {
  264 + double distance = DistanceUtil.getDistance(importLatLng, trackPoints.get(j));
  265 + if (distance<100){
  266 + importHash.put(i,true);
  267 + index=j;
  268 + }
  269 + }
  270 + }
  271 + //输出
  272 + int result = 0;
  273 + for (int i = 0; i < importHash.size(); i++) {
  274 + if (!importHash.get(i)) {
  275 + result++;
  276 + Log.e(TAG, "onHistoryTrackCallback: 没过:" + i + importHash.get(i));
  277 + }
  278 + }
  279 + if (result > importPoints.size() * 0.4) {
  280 + Toast.makeText(context, "没有完成", Toast.LENGTH_LONG).show();
  281 +
  282 + } else {
  283 + Toast.makeText(context, "已完成", Toast.LENGTH_LONG).show();
216 } 284 }
217 - Log.e(TAG, "onHistoryTrackCallback: 轨迹点:"+trackPoints.size()+",详情"+GsonUtil.GsonString(trackPoints) ); 285 + Log.e(TAG, "结果: " + result);
  286 + Log.e(TAG, "onHistoryTrackCallback: 轨迹点:" + trackPoints.size() + ",详情" + GsonUtil.GsonString(trackPoints));
218 MyMapUtil.drawHistoryTrack(context, getView().baiduMap, trackPoints, SortType.asc, R.color.red, R.drawable.icon_start, R.drawable.icon_end); 287 MyMapUtil.drawHistoryTrack(context, getView().baiduMap, trackPoints, SortType.asc, R.color.red, R.drawable.icon_start, R.drawable.icon_end);
219 // MyMapUtil.drawMapLineRoutePoint(context, getView().baiduMap, MyMapUtil.optimizePoints(routePoints), R.color.red); 288 // MyMapUtil.drawMapLineRoutePoint(context, getView().baiduMap, MyMapUtil.optimizePoints(routePoints), R.color.red);
220 } 289 }
@@ -224,7 +293,7 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter&lt;RunningMapFrag @@ -224,7 +293,7 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter&lt;RunningMapFrag
224 @Override 293 @Override
225 public void onDistanceCallback(DistanceResponse distanceResponse) { 294 public void onDistanceCallback(DistanceResponse distanceResponse) {
226 super.onDistanceCallback(distanceResponse); 295 super.onDistanceCallback(distanceResponse);
227 - Toast.makeText(context,"查询的里程数:"+(int)distanceResponse.getDistance()+"米",Toast.LENGTH_SHORT).show(); 296 +// Toast.makeText(context, "查询的里程数:" + (int) distanceResponse.getDistance() + "米", Toast.LENGTH_SHORT).show();
228 Log.e(TAG, "onDistanceCallback: " + distanceResponse.getDistance()); 297 Log.e(TAG, "onDistanceCallback: " + distanceResponse.getDistance());
229 } 298 }
230 }; 299 };
@@ -257,7 +326,7 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter&lt;RunningMapFrag @@ -257,7 +326,7 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter&lt;RunningMapFrag
257 public void onEntityListCallback(EntityListResponse entityListResponse) { 326 public void onEntityListCallback(EntityListResponse entityListResponse) {
258 super.onEntityListCallback(entityListResponse); 327 super.onEntityListCallback(entityListResponse);
259 Log.e(TAG, "onEntityListCallback"); 328 Log.e(TAG, "onEntityListCallback");
260 - Toast.makeText(context, "onEntityListCallback", Toast.LENGTH_SHORT).show(); 329 +// Toast.makeText(context, "onEntityListCallback", Toast.LENGTH_SHORT).show();
261 } 330 }
262 331
263 @Override 332 @Override
@@ -325,7 +394,7 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter&lt;RunningMapFrag @@ -325,7 +394,7 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter&lt;RunningMapFrag
325 @Override 394 @Override
326 public void onCreateFenceCallback(CreateFenceResponse createFenceResponse) { 395 public void onCreateFenceCallback(CreateFenceResponse createFenceResponse) {
327 if ("成功".equals(createFenceResponse.getMessage())) { 396 if ("成功".equals(createFenceResponse.getMessage())) {
328 - Toast.makeText(context, "创建围栏回调成功", Toast.LENGTH_SHORT).show(); 397 +// Toast.makeText(context, "创建围栏回调成功", Toast.LENGTH_SHORT).show();
329 Log.e(TAG, "onCreateFenceCallback: " + createFenceResponse.getFenceId()); 398 Log.e(TAG, "onCreateFenceCallback: " + createFenceResponse.getFenceId());
330 // 查询围栏监控者状态 399 // 查询围栏监控者状态
331 List<Long> list = new ArrayList<>(); 400 List<Long> list = new ArrayList<>();
@@ -351,7 +420,7 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter&lt;RunningMapFrag @@ -351,7 +420,7 @@ public class RunningMapFragmentPresenter extends MvpBasePresenter&lt;RunningMapFrag
351 @Override 420 @Override
352 public void onFenceListCallback(FenceListResponse fenceListResponse) { 421 public void onFenceListCallback(FenceListResponse fenceListResponse) {
353 if ("成功".equals(fenceListResponse.getMessage())) { 422 if ("成功".equals(fenceListResponse.getMessage())) {
354 - Toast.makeText(context, "围栏列表回调成功:" + fenceListResponse.getSize(), Toast.LENGTH_SHORT).show(); 423 +// Toast.makeText(context, "围栏列表回调成功:" + fenceListResponse.getSize(), Toast.LENGTH_SHORT).show();
355 } 424 }
356 425
357 426
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunMainFragmentView.java
@@ -310,7 +310,6 @@ public class RunMainFragmentView implements MvpView { @@ -310,7 +310,6 @@ public class RunMainFragmentView implements MvpView {
310 if (StepService.mClient != null) { 310 if (StepService.mClient != null) {
311 StepService.mClient.stopGather(StepService.traceListener); 311 StepService.mClient.stopGather(StepService.traceListener);
312 } 312 }
313 - CommonInfo.setStepStartTime(getContext(), 0);  
314 fragment.getActivity().stopService(new Intent(fragment.getActivity(), StepService.class)); 313 fragment.getActivity().stopService(new Intent(fragment.getActivity(), StepService.class));
315 RunningFinishBean runningFinishBean = new RunningFinishBean(); 314 RunningFinishBean runningFinishBean = new RunningFinishBean();
316 runningFinishBean.setStartPoint("开始地点"); 315 runningFinishBean.setStartPoint("开始地点");
@@ -455,6 +454,9 @@ public class RunMainFragmentView implements MvpView { @@ -455,6 +454,9 @@ public class RunMainFragmentView implements MvpView {
455 * @param userId 454 * @param userId
456 */ 455 */
457 public void startStepService(Context context, String userId) { 456 public void startStepService(Context context, String userId) {
  457 + if (CommonInfo.getStepStartTime(context) == 0) {
  458 + CommonInfo.setStepStartTime(context, TimeUtil.getNowTimeStamp());
  459 + }
458 Intent intent = new Intent(fragment.getActivity(), StepService.class); 460 Intent intent = new Intent(fragment.getActivity(), StepService.class);
459 intent.putExtra("userId", userId); 461 intent.putExtra("userId", userId);
460 ContextCompat.startForegroundService(fragment.getActivity(), intent); 462 ContextCompat.startForegroundService(fragment.getActivity(), intent);
@@ -505,10 +507,10 @@ public class RunMainFragmentView implements MvpView { @@ -505,10 +507,10 @@ public class RunMainFragmentView implements MvpView {
505 fragment.binding.tvLookTrace.setText(getContext().getString(R.string.loc_gps_accuracy_unknown)); 507 fragment.binding.tvLookTrace.setText(getContext().getString(R.string.loc_gps_accuracy_unknown));
506 fragment.binding.tvLookTrace.setTextColor(getContext().getResources().getColor(R.color.red)); 508 fragment.binding.tvLookTrace.setTextColor(getContext().getResources().getColor(R.color.red));
507 } 509 }
508 - if (fragment.binding.tvLookTrace.getVisibility()!=View.VISIBLE){ 510 + if (fragment.binding.tvLookTrace.getVisibility() != View.VISIBLE) {
509 fragment.binding.tvLookTrace.setVisibility(View.VISIBLE); 511 fragment.binding.tvLookTrace.setVisibility(View.VISIBLE);
510 } 512 }
511 - if (fragment.binding.ivGps.getTag()==null||!fragment.binding.ivGps.getTag().toString().equals("rt_training_gps_0")) { 513 + if (fragment.binding.ivGps.getTag() == null || !fragment.binding.ivGps.getTag().toString().equals("rt_training_gps_0")) {
512 fragment.binding.ivGps.setTag("rt_training_gps_0"); 514 fragment.binding.ivGps.setTag("rt_training_gps_0");
513 //设置图标 515 //设置图标
514 fragment.binding.ivGps.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_0)); 516 fragment.binding.ivGps.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_0));
@@ -523,10 +525,10 @@ public class RunMainFragmentView implements MvpView { @@ -523,10 +525,10 @@ public class RunMainFragmentView implements MvpView {
523 fragment.binding.tvLookTrace.setTextColor(getContext().getResources().getColor(R.color.text_gray99)); 525 fragment.binding.tvLookTrace.setTextColor(getContext().getResources().getColor(R.color.text_gray99));
524 526
525 } 527 }
526 - if (fragment.binding.tvLookTrace.getVisibility()!=View.VISIBLE){ 528 + if (fragment.binding.tvLookTrace.getVisibility() != View.VISIBLE) {
527 fragment.binding.tvLookTrace.setVisibility(View.VISIBLE); 529 fragment.binding.tvLookTrace.setVisibility(View.VISIBLE);
528 } 530 }
529 - if (fragment.binding.ivGps.getTag()==null||!fragment.binding.ivGps.getTag().toString().equals("GPS_ACCURACY_BAD")) { 531 + if (fragment.binding.ivGps.getTag() == null || !fragment.binding.ivGps.getTag().toString().equals("GPS_ACCURACY_BAD")) {
530 fragment.binding.ivGps.setTag("GPS_ACCURACY_BAD"); 532 fragment.binding.ivGps.setTag("GPS_ACCURACY_BAD");
531 //设置图标 533 //设置图标
532 fragment.binding.ivGps.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_1)); 534 fragment.binding.ivGps.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_1));
@@ -537,7 +539,7 @@ public class RunMainFragmentView implements MvpView { @@ -537,7 +539,7 @@ public class RunMainFragmentView implements MvpView {
537 if (fragment.binding.tvLookTrace.getVisibility() == View.VISIBLE) { 539 if (fragment.binding.tvLookTrace.getVisibility() == View.VISIBLE) {
538 fragment.binding.tvLookTrace.setVisibility(View.GONE); 540 fragment.binding.tvLookTrace.setVisibility(View.GONE);
539 } 541 }
540 - if (fragment.binding.ivGps.getTag()==null||!fragment.binding.ivGps.getTag().toString().equals("GPS_ACCURACY_MID")) { 542 + if (fragment.binding.ivGps.getTag() == null || !fragment.binding.ivGps.getTag().toString().equals("GPS_ACCURACY_MID")) {
541 fragment.binding.ivGps.setTag("GPS_ACCURACY_MID"); 543 fragment.binding.ivGps.setTag("GPS_ACCURACY_MID");
542 //设置图标 544 //设置图标
543 fragment.binding.ivGps.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_2)); 545 fragment.binding.ivGps.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_2));
@@ -547,7 +549,7 @@ public class RunMainFragmentView implements MvpView { @@ -547,7 +549,7 @@ public class RunMainFragmentView implements MvpView {
547 if (fragment.binding.tvLookTrace.getVisibility() == View.VISIBLE) { 549 if (fragment.binding.tvLookTrace.getVisibility() == View.VISIBLE) {
548 fragment.binding.tvLookTrace.setVisibility(View.GONE); 550 fragment.binding.tvLookTrace.setVisibility(View.GONE);
549 } 551 }
550 - if (fragment.binding.ivGps.getTag()==null||!fragment.binding.ivGps.getTag().toString().equals("GPS_ACCURACY_GOOD")) { 552 + if (fragment.binding.ivGps.getTag() == null || !fragment.binding.ivGps.getTag().toString().equals("GPS_ACCURACY_GOOD")) {
551 fragment.binding.ivGps.setTag("GPS_ACCURACY_GOOD"); 553 fragment.binding.ivGps.setTag("GPS_ACCURACY_GOOD");
552 //设置图标 554 //设置图标
553 fragment.binding.ivGps.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_3)); 555 fragment.binding.ivGps.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_3));
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
@@ -4,13 +4,16 @@ import android.content.Context; @@ -4,13 +4,16 @@ import android.content.Context;
4 import android.content.Intent; 4 import android.content.Intent;
5 import android.graphics.Bitmap; 5 import android.graphics.Bitmap;
6 import android.graphics.BitmapFactory; 6 import android.graphics.BitmapFactory;
  7 +import android.graphics.drawable.AnimationDrawable;
7 import android.hardware.Sensor; 8 import android.hardware.Sensor;
8 import android.hardware.SensorEvent; 9 import android.hardware.SensorEvent;
9 import android.hardware.SensorEventListener; 10 import android.hardware.SensorEventListener;
10 import android.hardware.SensorManager; 11 import android.hardware.SensorManager;
11 import android.util.Log; 12 import android.util.Log;
  13 +import android.view.LayoutInflater;
12 import android.view.View; 14 import android.view.View;
13 import android.view.ViewGroup; 15 import android.view.ViewGroup;
  16 +import android.widget.ImageView;
14 import android.widget.LinearLayout; 17 import android.widget.LinearLayout;
15 import android.widget.Toast; 18 import android.widget.Toast;
16 19
@@ -261,7 +264,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -261,7 +264,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
261 fragment.binding.ivBack.setOnClickListener(new View.OnClickListener() { 264 fragment.binding.ivBack.setOnClickListener(new View.OnClickListener() {
262 @Override 265 @Override
263 public void onClick(View view) { 266 public void onClick(View view) {
264 - if (fragment.getActivity()==null){ 267 + if (fragment.getActivity() == null) {
265 return; 268 return;
266 } 269 }
267 fragment.getActivity().finish(); 270 fragment.getActivity().finish();
@@ -270,6 +273,14 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -270,6 +273,14 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
270 } 273 }
271 274
272 private void initMap() { 275 private void initMap() {
  276 + List<String> icons = new ArrayList<>();
  277 + icons.add("http://yweb0.cnliveimg.com/images/headImg/2019/0505/1557039035723_small.jpg");
  278 + icons.add("http://yweb0.cnliveimg.com/images/headImg/2019/0505/1557034319038_small.jpg");
  279 + icons.add("http://yweb0.cnliveimg.com/images/headImg/2018/0902/1535858459612_small.jpg");
  280 + icons.add("http://yweb0.cnliveimg.com/images/headImg/2019/0523/1558599016203_small.jpg");
  281 + icons.add("http://yweb0.cnliveimg.com/images/headImg/2019/0505/1557039035723_small.jpg");
  282 +
  283 + fragment.binding.includeStreet.fiveJoinPerson.initIconData(icons);
273 this.mMapView = fragment.binding.mapView; 284 this.mMapView = fragment.binding.mapView;
274 if (baiduMap == null) { 285 if (baiduMap == null) {
275 baiduMap = mMapView.getMap(); 286 baiduMap = mMapView.getMap();
@@ -284,6 +295,13 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { @@ -284,6 +295,13 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener {
284 mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL; 295 mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL;
285 // 设置定位图标修改为自定义marker 296 // 设置定位图标修改为自定义marker
286 Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.rt_ic_location), 50, 50); 297 Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.rt_ic_location), 50, 50);
  298 +// View view = LayoutInflater.from(getContext()).inflate(R.layout.layout_anim, null);
  299 +// ImageView image = (ImageView) view.findViewById(R.id.iv_anim);
  300 +//// image.setBackgroundResource(R.drawable.fat_po);
  301 +// image.setImageResource(R.drawable.fat_po);
  302 +// AnimationDrawable anim = (AnimationDrawable) image.getDrawable();
  303 +// anim.start();
  304 +// BitmapDescriptorFactory.fromView(view);
287 mCurrentMarker = BitmapDescriptorFactory.fromBitmap(pointBitmap); 305 mCurrentMarker = BitmapDescriptorFactory.fromBitmap(pointBitmap);
288 //设置定位蓝点精度圆圈的填充颜色为透明色 306 //设置定位蓝点精度圆圈的填充颜色为透明色
289 accuracyCircleFillColor = getContext().getResources().getColor(R.color.transparent); 307 accuracyCircleFillColor = getContext().getResources().getColor(R.color.transparent);
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunningMapFragmentView.java
@@ -74,10 +74,6 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { @@ -74,10 +74,6 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
74 private List<LatLng> trackPoints; 74 private List<LatLng> trackPoints;
75 private Overlay currentLine; 75 private Overlay currentLine;
76 private List<LatLng> currentPoints; 76 private List<LatLng> currentPoints;
77 - private HashMap<Integer, Boolean> importHash;  
78 - List<LatLng> importPoints;  
79 - private String imports = "[{\"latitude\":39.933908761246,\"latitudeE6\":3.9933908761246E7,\"longitude\":116.30882855517,\"longitudeE6\":1.1630882855517E8},{\"latitude\":39.933706935562,\"latitudeE6\":3.9933706935562E7,\"longitude\":116.30881011005,\"longitudeE6\":1.1630881011005001E8},{\"latitude\":39.93371370814,\"latitudeE6\":3.993371370814E7,\"longitude\":116.30872981771,\"longitudeE6\":1.1630872981771E8},{\"latitude\":39.933935049796,\"latitudeE6\":3.9933935049796E7,\"longitude\":116.30861317635,\"longitudeE6\":1.1630861317635E8},{\"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";  
80 - private static int currentIndex = 0;  
81 77
82 public RunningMapFragmentView(RunningMapFragment fragment) { 78 public RunningMapFragmentView(RunningMapFragment fragment) {
83 this.fragment = fragment; 79 this.fragment = fragment;
@@ -88,19 +84,6 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { @@ -88,19 +84,6 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
88 } 84 }
89 85
90 public void initView(List<LatLng> trackPoints) { 86 public void initView(List<LatLng> trackPoints) {
91 - importHash = new HashMap<>();  
92 - //打的重要点  
93 - List<LatLng> importPoints = GsonUtil.jsonToList(imports, LatLng.class);  
94 - for (int i = 0; i < importPoints.size(); i++) {  
95 - if (i % 3 != 0) {  
96 - importPoints.remove(i);  
97 - }  
98 - }  
99 - for (int i = 0; i < importPoints.size(); i++) {  
100 - importHash.put(i, false);  
101 - }  
102 -  
103 - Log.e(TAG, "重要点数量: " + importPoints.size());  
104 currentPoints = new ArrayList<>(); 87 currentPoints = new ArrayList<>();
105 this.trackPoints = trackPoints; 88 this.trackPoints = trackPoints;
106 this.mMapView = fragment.binding.mapView; 89 this.mMapView = fragment.binding.mapView;
@@ -365,17 +348,6 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener { @@ -365,17 +348,6 @@ public class RunningMapFragmentView implements MvpView, SensorEventListener {
365 currentLine = MyMapUtil.drawMapLine(getContext(), baiduMap, currentPoints, R.color.red); 348 currentLine = MyMapUtil.drawMapLine(getContext(), baiduMap, currentPoints, R.color.red);
366 } 349 }
367 350
368 - //开始比较  
369 - if (currentIndex < importPoints.size()) {  
370 - LatLng curLatLng = new LatLng(location.getLatitude(),  
371 - location.getLongitude());  
372 - LatLng importLatLng = importPoints.get(currentIndex);  
373 - if (DistanceUtil.getDistance(importLatLng, curLatLng) < 50) {  
374 - importHash.put(currentIndex, true);  
375 - currentIndex++;  
376 - Toast.makeText(getContext(), "开始比较第" + currentIndex + "个点", Toast.LENGTH_SHORT).show();  
377 - }  
378 - }  
379 } 351 }
380 myCurLatLng = new LatLng(location.getLatitude(), 352 myCurLatLng = new LatLng(location.getLatitude(),
381 location.getLongitude()); 353 location.getLongitude());
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/db/DBMigrationHelper.java deleted 100644 → 0
1 -package com.cnlive.moudle.pedometer.sql.db;  
2 -  
3 -import android.database.Cursor;  
4 -import android.database.SQLException;  
5 -import android.database.sqlite.SQLiteDatabase;  
6 -import android.support.annotation.NonNull;  
7 -import android.text.TextUtils;  
8 -import android.util.Log;  
9 -  
10 -import org.greenrobot.greendao.AbstractDao;  
11 -import org.greenrobot.greendao.database.Database;  
12 -import org.greenrobot.greendao.database.StandardDatabase;  
13 -import org.greenrobot.greendao.internal.DaoConfig;  
14 -  
15 -import java.lang.reflect.InvocationTargetException;  
16 -import java.lang.reflect.Method;  
17 -import java.util.ArrayList;  
18 -import java.util.Arrays;  
19 -import java.util.List;  
20 -  
21 -  
22 -/**  
23 - * greenDao升级类  
24 - */  
25 -public class DBMigrationHelper {  
26 - public static boolean DEBUG = false;  
27 - private static String TAG = "MigrationHelper2";  
28 - private static final String SQLITE_MASTER = "sqlite_master";  
29 - private static final String SQLITE_TEMP_MASTER = "sqlite_temp_master";  
30 -  
31 - public static void migrate(SQLiteDatabase db, Class<? extends AbstractDao<?, ?>>... daoClasses) {  
32 - printLog("【The Old Database Version】" + db.getVersion());  
33 - Database database = new StandardDatabase(db);  
34 - migrate(database, daoClasses);  
35 - }  
36 -  
37 - public static void migrate(Database database, Class<? extends AbstractDao<?, ?>>... daoClasses) {  
38 - printLog("【Generate temp table】start");  
39 - generateTempTables(database, daoClasses);  
40 - printLog("【Generate temp table】complete");  
41 -  
42 - dropAllTables(database, true, daoClasses);  
43 - createAllTables(database, false, daoClasses);  
44 -  
45 - printLog("【Restore data】start");  
46 - restoreData(database, daoClasses);  
47 - printLog("【Restore data】complete");  
48 - }  
49 -  
50 - private static void generateTempTables(Database db, Class<? extends AbstractDao<?, ?>>... daoClasses) {  
51 - for (int i = 0; i < daoClasses.length; i++) {  
52 - String tempTableName = null;  
53 -  
54 - DaoConfig daoConfig = new DaoConfig(db, daoClasses[i]);  
55 - String tableName = daoConfig.tablename;  
56 - if (!isTableExists(db, false, tableName)) {  
57 - printLog("【New Table】" + tableName);  
58 - continue;  
59 - }  
60 - try {  
61 - tempTableName = daoConfig.tablename.concat("_TEMP");  
62 - StringBuilder dropTableStringBuilder = new StringBuilder();  
63 - dropTableStringBuilder.append("DROP TABLE IF EXISTS ").append(tempTableName).append(";");  
64 - db.execSQL(dropTableStringBuilder.toString());  
65 -  
66 - StringBuilder insertTableStringBuilder = new StringBuilder();  
67 - insertTableStringBuilder.append("CREATE TEMPORARY TABLE ").append(tempTableName);  
68 - insertTableStringBuilder.append(" AS SELECT * FROM ").append(tableName).append(";");  
69 - db.execSQL(insertTableStringBuilder.toString());  
70 - printLog("【Table】" + tableName + "\n ---Columns-->" + getColumnsStr(daoConfig));  
71 - printLog("【Generate temp table】" + tempTableName);  
72 - } catch (SQLException e) {  
73 - Log.e(TAG, "【Failed to generate temp table】" + tempTableName, e);  
74 - }  
75 - }  
76 - }  
77 -  
78 - private static boolean isTableExists(Database db, boolean isTemp, String tableName) {  
79 - if (db == null || TextUtils.isEmpty(tableName)) {  
80 - return false;  
81 - }  
82 - String dbName = isTemp ? SQLITE_TEMP_MASTER : SQLITE_MASTER;  
83 - String sql = "SELECT COUNT(*) FROM " + dbName + " WHERE type = ? AND name = ?";  
84 - Cursor cursor = null;  
85 - int count = 0;  
86 - try {  
87 - cursor = db.rawQuery(sql, new String[]{"table", tableName});  
88 - if (cursor == null || !cursor.moveToFirst()) {  
89 - return false;  
90 - }  
91 - count = cursor.getInt(0);  
92 - } catch (Exception e) {  
93 - e.printStackTrace();  
94 - } finally {  
95 - if (cursor != null) {  
96 - cursor.close();  
97 - }  
98 - }  
99 - return count > 0;  
100 - }  
101 -  
102 -  
103 - private static String getColumnsStr(DaoConfig daoConfig) {  
104 - if (daoConfig == null) {  
105 - return "no columns";  
106 - }  
107 - StringBuilder builder = new StringBuilder();  
108 - for (int i = 0; i < daoConfig.allColumns.length; i++) {  
109 - builder.append(daoConfig.allColumns[i]);  
110 - builder.append(",");  
111 - }  
112 - if (builder.length() > 0) {  
113 - builder.deleteCharAt(builder.length() - 1);  
114 - }  
115 - return builder.toString();  
116 - }  
117 -  
118 -  
119 - private static void dropAllTables(Database db, boolean ifExists, @NonNull Class<? extends AbstractDao<?, ?>>... daoClasses) {  
120 - reflectMethod(db, "dropTable", ifExists, daoClasses);  
121 - printLog("【Drop all table】");  
122 - }  
123 -  
124 - private static void createAllTables(Database db, boolean ifNotExists, @NonNull Class<? extends AbstractDao<?, ?>>... daoClasses) {  
125 - reflectMethod(db, "createTable", ifNotExists, daoClasses);  
126 - printLog("【Create all table】");  
127 - }  
128 -  
129 - /**  
130 - * dao class already define the sql exec method, so just invoke it  
131 - */  
132 - private static void reflectMethod(Database db, String methodName, boolean isExists, @NonNull Class<? extends AbstractDao<?, ?>>... daoClasses) {  
133 - if (daoClasses.length < 1) {  
134 - return;  
135 - }  
136 - try {  
137 - for (Class cls : daoClasses) {  
138 - Method method = cls.getDeclaredMethod(methodName, Database.class, boolean.class);  
139 - method.invoke(null, db, isExists);  
140 - }  
141 - } catch (NoSuchMethodException e) {  
142 - e.printStackTrace();  
143 - } catch (InvocationTargetException e) {  
144 - e.printStackTrace();  
145 - } catch (IllegalAccessException e) {  
146 - e.printStackTrace();  
147 - }  
148 - }  
149 -  
150 - private static void restoreData(Database db, Class<? extends AbstractDao<?, ?>>... daoClasses) {  
151 - for (int i = 0; i < daoClasses.length; i++) {  
152 - DaoConfig daoConfig = new DaoConfig(db, daoClasses[i]);  
153 - String tableName = daoConfig.tablename;  
154 - String tempTableName = daoConfig.tablename.concat("_TEMP");  
155 -  
156 - if (!isTableExists(db, true, tempTableName)) {  
157 - continue;  
158 - }  
159 -  
160 - try {  
161 - // get all columns from tempTable, take careful to use the columns list  
162 - List<String> columns = getColumns(db, tempTableName);  
163 - ArrayList<String> properties = new ArrayList<>(columns.size());  
164 - for (int j = 0; j < daoConfig.properties.length; j++) {  
165 - String columnName = daoConfig.properties[j].columnName;  
166 - if (columns.contains(columnName)) {  
167 - properties.add(columnName);  
168 - }  
169 - }  
170 - if (properties.size() > 0) {  
171 - final String columnSQL = TextUtils.join(",", properties);  
172 -  
173 - StringBuilder insertTableStringBuilder = new StringBuilder();  
174 - insertTableStringBuilder.append("INSERT INTO ").append(tableName).append(" (");  
175 - insertTableStringBuilder.append(columnSQL);  
176 - insertTableStringBuilder.append(") SELECT ");  
177 - insertTableStringBuilder.append(columnSQL);  
178 - insertTableStringBuilder.append(" FROM ").append(tempTableName).append(";");  
179 - db.execSQL(insertTableStringBuilder.toString());  
180 - printLog("【Restore data】 to " + tableName);  
181 - }  
182 - StringBuilder dropTableStringBuilder = new StringBuilder();  
183 - dropTableStringBuilder.append("DROP TABLE ").append(tempTableName);  
184 - db.execSQL(dropTableStringBuilder.toString());  
185 - printLog("【Drop temp table】" + tempTableName);  
186 - } catch (SQLException e) {  
187 - Log.e(TAG, "【Failed to restore data from temp table 】" + tempTableName, e);  
188 - }  
189 - }  
190 - }  
191 -  
192 - private static List<String> getColumns(Database db, String tableName) {  
193 - List<String> columns = null;  
194 - Cursor cursor = null;  
195 - try {  
196 - cursor = db.rawQuery("SELECT * FROM " + tableName + " limit 0", null);  
197 - if (null != cursor && cursor.getColumnCount() > 0) {  
198 - columns = Arrays.asList(cursor.getColumnNames());  
199 - }  
200 - } catch (Exception e) {  
201 - e.printStackTrace();  
202 - } finally {  
203 - if (cursor != null) {  
204 - cursor.close();  
205 - }  
206 - if (null == columns) {  
207 - columns = new ArrayList<>();  
208 - }  
209 - }  
210 - return columns;  
211 - }  
212 -  
213 - private static void printLog(String info) {  
214 - if (DEBUG) {  
215 - Log.d(TAG, info);  
216 - }  
217 - }  
218 -  
219 -  
220 -}  
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/db/MyOpenHelper.java
@@ -47,7 +47,7 @@ import android.content.Context; @@ -47,7 +47,7 @@ import android.content.Context;
47 47
48 import com.cnlive.moudle.pedometer.sql.dao.DaoMaster; 48 import com.cnlive.moudle.pedometer.sql.dao.DaoMaster;
49 import com.cnlive.moudle.pedometer.sql.dao.UserStepEntityDao; 49 import com.cnlive.moudle.pedometer.sql.dao.UserStepEntityDao;
50 -import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; 50 +import com.cnlive.moudle.pedometer.sql.updateDB.UpgradeHelper;
51 51
52 import org.greenrobot.greendao.database.Database; 52 import org.greenrobot.greendao.database.Database;
53 53
@@ -64,6 +64,8 @@ import org.greenrobot.greendao.database.Database; @@ -64,6 +64,8 @@ import org.greenrobot.greendao.database.Database;
64 */ 64 */
65 65
66 public class MyOpenHelper extends DaoMaster.OpenHelper { 66 public class MyOpenHelper extends DaoMaster.OpenHelper {
  67 + private final String TAG = "MyOpenHelper";
  68 +
67 public MyOpenHelper(Context context, String name) { 69 public MyOpenHelper(Context context, String name) {
68 super(context, name); 70 super(context, name);
69 } 71 }
@@ -71,37 +73,25 @@ public class MyOpenHelper extends DaoMaster.OpenHelper { @@ -71,37 +73,25 @@ public class MyOpenHelper extends DaoMaster.OpenHelper {
71 @Override 73 @Override
72 public void onUpgrade(Database db, int oldVersion, int newVersion) { 74 public void onUpgrade(Database db, int oldVersion, int newVersion) {
73 try { 75 try {
74 - //判断版本, 设置需要修改得表 我这边设置一个 FileInfo  
75 - DBMigrationHelper.migrate(db, UserStepEntityDao.class); 76 + //进行数据库升级
  77 + new UpgradeHelper().migrate(db,
  78 + UserStepEntityDao.class
  79 + );
76 } catch (ClassCastException e) { 80 } catch (ClassCastException e) {
77 } 81 }
78 -// KLog.w("db version update from " + oldVersion + " to " + newVersion);  
79 -// MigrationHelper.migrate(db, new MigrationHelper.ReCreateAllTableListener() { 82 +// switch (oldVersion) {
  83 +// case 1:
80 // 84 //
81 -// @Override  
82 -// public void onCreateAllTables(Database db, boolean ifNotExists) {  
83 -// DaoMaster.createAllTables(db, ifNotExists);  
84 -// } 85 +// //不能先删除表,否则数据都木了
  86 +//// StudentDao.dropTable(db, true);
85 // 87 //
86 -// @Override  
87 -// public void onDropAllTables(Database db, boolean ifExists) {  
88 -// DaoMaster.dropAllTables(db, ifExists);  
89 -// }  
90 -// },G106InfoDao.class);//, GovernanceTechnologyDao.class, TestData3Dao.class  
91 -// }  
92 - switch (oldVersion) {  
93 - case 1:  
94 -  
95 - //不能先删除表,否则数据都木了  
96 -// StudentDao.dropTable(db, true);  
97 -  
98 -// StudentDao.createTable(db, true);  
99 -  
100 - // 加入新字段 score  
101 -// db.execSQL("ALTER TABLE 'STUDENT' ADD 'SCORE' TEXT;");  
102 -  
103 - break;  
104 - } 88 +//// StudentDao.createTable(db, true);
  89 +//
  90 +// // 加入新字段 score
  91 +//// db.execSQL("ALTER TABLE 'STUDENT' ADD 'SCORE' TEXT;");
  92 +//
  93 +// break;
  94 +// }
105 95
106 } 96 }
107 } 97 }
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/entity/UserStepEntity.java
@@ -88,4 +88,5 @@ public class UserStepEntity { @@ -88,4 +88,5 @@ public class UserStepEntity {
88 } 88 }
89 89
90 90
  91 +
91 } 92 }
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/updateDB/UpgradeHelper.java 0 → 100644
  1 +package com.cnlive.moudle.pedometer.sql.updateDB;
  2 +
  3 +import android.database.Cursor;
  4 +import android.text.TextUtils;
  5 +
  6 +import com.cnlive.moudle.pedometer.sql.dao.DaoMaster;
  7 +
  8 +import org.greenrobot.greendao.AbstractDao;
  9 +import org.greenrobot.greendao.database.Database;
  10 +import org.greenrobot.greendao.internal.DaoConfig;
  11 +
  12 +import java.util.ArrayList;
  13 +import java.util.Arrays;
  14 +import java.util.List;
  15 +
  16 +/**
  17 + * Created by cnlive20080010 on 2018/8/27.
  18 + */
  19 +
  20 +public class UpgradeHelper {
  21 +
  22 + private static final String CONVERSION_CLASS_NOT_FOUND_EXCEPTION = "MIGRATION HELPER - CLASS DOESN'T MATCH WITH THE CURRENT PARAMETERS";
  23 +
  24 + public void migrate(final Database db, final Class<? extends AbstractDao<?, ?>>... daoClasses) {
  25 + generateTempTables(db, daoClasses);
  26 + DaoMaster.dropAllTables(db, true);
  27 + DaoMaster.createAllTables(db, false);
  28 + restoreData(db, daoClasses);
  29 + }
  30 +
  31 + private void generateTempTables(Database db, Class<? extends AbstractDao<?, ?>>... daoClasses) {
  32 + for (int i = 0; i < daoClasses.length; i++) {
  33 + try {
  34 + DaoConfig daoConfig = new DaoConfig(db, daoClasses[i]);
  35 + String divider = "";
  36 + String tableName = daoConfig.tablename;
  37 + String tempTableName = daoConfig.tablename.concat("_TEMP");
  38 + ArrayList<String> properties = new ArrayList<>();
  39 +
  40 + StringBuilder createTableStringBuilder = new StringBuilder();
  41 +
  42 + createTableStringBuilder.append("CREATE TABLE ").append(tempTableName).append(" (");
  43 +
  44 + for (int j = 0; j < daoConfig.properties.length; j++) {
  45 + String columnName = daoConfig.properties[j].columnName;
  46 +
  47 + if (getColumns(db, tableName).contains(columnName)) {
  48 + properties.add(columnName);
  49 +
  50 + String type = null;
  51 +
  52 + try {
  53 + type = getTypeByClass(daoConfig.properties[j].type);
  54 + } catch (Exception exception) {
  55 + exception.printStackTrace();
  56 + }
  57 +
  58 + createTableStringBuilder.append(divider).append(columnName).append(" ").append(type);
  59 +
  60 + if (daoConfig.properties[j].primaryKey) {
  61 + createTableStringBuilder.append(" PRIMARY KEY");
  62 + }
  63 +
  64 + divider = ",";
  65 + }
  66 + }
  67 + createTableStringBuilder.append(");");
  68 +
  69 + db.execSQL(createTableStringBuilder.toString());
  70 +
  71 + StringBuilder insertTableStringBuilder = new StringBuilder();
  72 +
  73 + insertTableStringBuilder.append("INSERT INTO ").append(tempTableName).append(" (");
  74 + insertTableStringBuilder.append(TextUtils.join(",", properties));
  75 + insertTableStringBuilder.append(") SELECT ");
  76 + insertTableStringBuilder.append(TextUtils.join(",", properties));
  77 + insertTableStringBuilder.append(" FROM ").append(tableName).append(";");
  78 +
  79 + db.execSQL(insertTableStringBuilder.toString());
  80 + } catch (Exception e) {
  81 + e.printStackTrace();
  82 + } finally {
  83 + continue;
  84 + }
  85 + }
  86 + }
  87 +
  88 + private void restoreData(Database db, Class<? extends AbstractDao<?, ?>>... daoClasses) {
  89 + for (int i = 0; i < daoClasses.length; i++) {
  90 + try {
  91 + DaoConfig daoConfig = new DaoConfig(db, daoClasses[i]);
  92 + String tableName = daoConfig.tablename;
  93 + String tempTableName = daoConfig.tablename.concat("_TEMP");
  94 + ArrayList<String> properties = new ArrayList();
  95 +
  96 + for (int j = 0; j < daoConfig.properties.length; j++) {
  97 + String columnName = daoConfig.properties[j].columnName;
  98 +
  99 + if (getColumns(db, tempTableName).contains(columnName)) {
  100 + properties.add(columnName);
  101 + }
  102 + }
  103 +
  104 + StringBuilder insertTableStringBuilder = new StringBuilder();
  105 +
  106 + insertTableStringBuilder.append("INSERT INTO ").append(tableName).append(" (");
  107 + insertTableStringBuilder.append(TextUtils.join(",", properties));
  108 + insertTableStringBuilder.append(") SELECT ");
  109 + insertTableStringBuilder.append(TextUtils.join(",", properties));
  110 + insertTableStringBuilder.append(" FROM ").append(tempTableName).append(";");
  111 +
  112 + StringBuilder dropTableStringBuilder = new StringBuilder();
  113 +
  114 + dropTableStringBuilder.append("DROP TABLE ").append(tempTableName);
  115 +
  116 + db.execSQL(insertTableStringBuilder.toString());
  117 + db.execSQL(dropTableStringBuilder.toString());
  118 + } catch (Exception e) {
  119 + e.printStackTrace();
  120 + } finally {
  121 + continue;
  122 + }
  123 + }
  124 + }
  125 +
  126 + private String getTypeByClass(Class<?> type) throws Exception {
  127 + if (type.equals(String.class)) {
  128 + return " TEXT";
  129 + }
  130 + if (type.equals(Integer.class) || type.equals(int.class) ||
  131 + type.equals(byte.class) || type.equals(Byte.class) ||
  132 + type.equals(short.class) || type.equals(Short.class)) {
  133 + return " INTEGER DEFAULT 0";
  134 + }
  135 +
  136 + if (type.equals(Double.class) || type.equals(double.class)) {
  137 + return "DOUBLE DEFAULT 0";
  138 + }
  139 +
  140 + if(type.equals(float.class) || type.equals(Float.class)){
  141 + return "FLOAT DEFAULT 0";
  142 + }
  143 +
  144 + if (type.equals(Long.class) || type.equals(long.class)) {
  145 + return " Long DEFAULT 0";
  146 + }
  147 + if (type.equals(Boolean.class) || type.equals(boolean.class)) {
  148 + return " NUMERIC DEFAULT 0";
  149 + }
  150 +
  151 + Exception exception = new Exception(CONVERSION_CLASS_NOT_FOUND_EXCEPTION.concat(" - Class: ").concat(type.toString()));
  152 + exception.printStackTrace();
  153 + throw exception;
  154 + }
  155 +
  156 + private static List<String> getColumns(Database db, String tableName) {
  157 +
  158 + List<String> columns = new ArrayList<>();
  159 + Cursor cursor = null;
  160 + try {
  161 + cursor = db.rawQuery("SELECT * FROM " + tableName + " limit 1", null);
  162 + if (cursor != null) {
  163 + columns = new ArrayList<>(Arrays.asList(cursor.getColumnNames()));
  164 + }
  165 + } catch (Exception e) {
  166 + e.printStackTrace();
  167 + } finally {
  168 + if (cursor != null)
  169 + cursor.close();
  170 + }
  171 + return columns;
  172 + }
  173 +}
  174 +
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/PedometerMainActivity.java
@@ -24,6 +24,7 @@ import com.cnlive.libs.base.ui.QMUIFragment; @@ -24,6 +24,7 @@ import com.cnlive.libs.base.ui.QMUIFragment;
24 import com.cnlive.libs.base.ui.QMUIFragmentActivity; 24 import com.cnlive.libs.base.ui.QMUIFragmentActivity;
25 import com.cnlive.libs.base.util.StatusBarUtil2; 25 import com.cnlive.libs.base.util.StatusBarUtil2;
26 import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment; 26 import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment;
  27 +import com.cnlive.moudle.pedometer.utils.MyMapUtil;
27 import com.cnlive.moudle.pedometer.utils.lib_permisshelper.PermissionsListener; 28 import com.cnlive.moudle.pedometer.utils.lib_permisshelper.PermissionsListener;
28 import com.cnlive.moudle.pedometer.utils.lib_permisshelper.PermissionsUtils; 29 import com.cnlive.moudle.pedometer.utils.lib_permisshelper.PermissionsUtils;
29 import com.example.moudle_pedometer.R; 30 import com.example.moudle_pedometer.R;
@@ -54,7 +55,7 @@ public class PedometerMainActivity extends QMUIFragmentActivity { @@ -54,7 +55,7 @@ public class PedometerMainActivity extends QMUIFragmentActivity {
54 super.onCreate(savedInstanceState); 55 super.onCreate(savedInstanceState);
55 StatusBarUtil2.setColor(this, getResources().getColor(R.color.run_main_bg), 0); 56 StatusBarUtil2.setColor(this, getResources().getColor(R.color.run_main_bg), 0);
56 // setContentView(R.layout.activity_pedometer_main); 57 // setContentView(R.layout.activity_pedometer_main);
57 - getPermissionsWithTip(); 58 +
58 } 59 }
59 60
60 61
@@ -149,6 +150,7 @@ public class PedometerMainActivity extends QMUIFragmentActivity { @@ -149,6 +150,7 @@ public class PedometerMainActivity extends QMUIFragmentActivity {
149 // } 150 // }
150 // } 151 // }
151 // } 152 // }
  153 + getPermissionsWithTip();
152 } 154 }
153 155
154 private void addFragment() { 156 private void addFragment() {
@@ -176,11 +178,11 @@ public class PedometerMainActivity extends QMUIFragmentActivity { @@ -176,11 +178,11 @@ public class PedometerMainActivity extends QMUIFragmentActivity {
176 public void onGranted() { 178 public void onGranted() {
177 179
178 //判断GPS是否开启 180 //判断GPS是否开启
179 - if (!isOPen(getApplicationContext())) {  
180 -// KLog.e("gps未开启");  
181 -// //开启GPS 181 + if (!MyMapUtil.isOPenGps(getApplicationContext())) {
  182 + //开启GPS
182 Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); 183 Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
183 startActivityForResult(intent, 10); 184 startActivityForResult(intent, 10);
  185 + Toast.makeText(getApplicationContext(), getString(R.string.open_gps_tip), Toast.LENGTH_LONG).show();
184 } else { 186 } else {
185 addFragment(); 187 addFragment();
186 } 188 }
@@ -206,25 +208,6 @@ public class PedometerMainActivity extends QMUIFragmentActivity { @@ -206,25 +208,6 @@ public class PedometerMainActivity extends QMUIFragmentActivity {
206 // , Manifest.permission.ACCESS_FINE_LOCATION); 208 // , Manifest.permission.ACCESS_FINE_LOCATION);
207 } 209 }
208 210
209 - /**  
210 - * 判断GPS是否开启,GPS或者AGPS开启一个就认为是开启的  
211 - *  
212 - * @param context  
213 - * @return true 表示开启  
214 - */  
215 - public static final boolean isOPen(final Context context) {  
216 - LocationManager locationManager  
217 - = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);  
218 - // 通过GPS卫星定位,定位级别可以精确到街(通过24颗卫星定位,在室外和空旷的地方定位准确、速度快)  
219 - boolean gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);  
220 - // 通过WLAN或移动网络(3G/2G)确定的位置(也称作AGPS,辅助GPS定位。主要用于在室内或遮盖物(建筑群或茂密的深林等)密集的地方定位)  
221 - boolean network = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);  
222 - if (gps || network) {  
223 - return true;  
224 - }  
225 -  
226 - return false;  
227 - }  
228 211
229 /** 212 /**
230 * 权限回调 213 * 权限回调
@@ -241,7 +224,6 @@ public class PedometerMainActivity extends QMUIFragmentActivity { @@ -241,7 +224,6 @@ public class PedometerMainActivity extends QMUIFragmentActivity {
241 } 224 }
242 225
243 226
244 -  
245 @Override 227 @Override
246 public void onBackPressed() { 228 public void onBackPressed() {
247 return; 229 return;
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunningMapFragment.java
@@ -110,16 +110,13 @@ public class RunningMapFragment extends QMUIFragment&lt;RunningMapFragmentView, Run @@ -110,16 +110,13 @@ public class RunningMapFragment extends QMUIFragment&lt;RunningMapFragmentView, Run
110 //开始进行历史轨迹查询 110 //开始进行历史轨迹查询
111 if (getPresenter() != null && !TextUtils.isEmpty(StepService.entityName)) { 111 if (getPresenter() != null && !TextUtils.isEmpty(StepService.entityName)) {
112 long stepStartTime = CommonInfo.getStepStartTime(getActivity()); 112 long stepStartTime = CommonInfo.getStepStartTime(getActivity());
  113 + Log.e(TAG, "onViewCreated: 时间"+stepStartTime );
113 long startTime = 0; 114 long startTime = 0;
114 if (stepStartTime != 0) { 115 if (stepStartTime != 0) {
115 startTime = stepStartTime; 116 startTime = stepStartTime;
116 } else { 117 } else {
117 - startTime = (int) (System.currentTimeMillis() / 1000 - 12 * 60 * 60); 118 + startTime = (int) (System.currentTimeMillis() / 1000 -12 * 60 * 60);
118 } 119 }
119 -// long base = runningMapBean.getTimeBase() + (SystemClock.elapsedRealtime() - runningMapBean.getRecordTime());  
120 -// int hour = (int) ((SystemClock.elapsedRealtime() - base) / 1000 / 60 / 60);  
121 -// int minute = (int) ((SystemClock.elapsedRealtime() - base) / 1000 / 60) % 60;  
122 -// int second = (int) ((SystemClock.elapsedRealtime() - base) / 1000) % 60;  
123 long current = TimeUtil.getCurrentTime(); 120 long current = TimeUtil.getCurrentTime();
124 // long startTime = current - hour * 3600 * 1000 - minute * 60 * 1000 - second * 1000; 121 // long startTime = current - hour * 3600 * 1000 - minute * 60 * 1000 - second * 1000;
125 long endTime = current; 122 long endTime = current;
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/widget/FivePersonIconView.java
@@ -94,6 +94,49 @@ public class FivePersonIconView extends LinearLayout { @@ -94,6 +94,49 @@ public class FivePersonIconView extends LinearLayout {
94 } 94 }
95 } 95 }
96 } 96 }
  97 + if (iconList == null) {
  98 + qr1.setVisibility(View.GONE);
  99 + qr2.setVisibility(View.GONE);
  100 + qr3.setVisibility(View.GONE);
  101 + qr4.setVisibility(View.GONE);
  102 + qr5.setVisibility(View.GONE);
  103 + } else if (iconList.size() == 0) {
  104 + qr1.setVisibility(View.GONE);
  105 + qr2.setVisibility(View.GONE);
  106 + qr3.setVisibility(View.GONE);
  107 + qr4.setVisibility(View.GONE);
  108 + qr5.setVisibility(View.GONE);
  109 + } else if (iconList.size() == 1) {
  110 + qr1.setVisibility(View.VISIBLE);
  111 + qr2.setVisibility(View.GONE);
  112 + qr3.setVisibility(View.GONE);
  113 + qr4.setVisibility(View.GONE);
  114 + qr5.setVisibility(View.GONE);
  115 + } else if (iconList.size() == 2) {
  116 + qr1.setVisibility(View.VISIBLE);
  117 + qr2.setVisibility(View.VISIBLE);
  118 + qr3.setVisibility(View.GONE);
  119 + qr4.setVisibility(View.GONE);
  120 + qr5.setVisibility(View.GONE);
  121 + } else if (iconList.size() == 3) {
  122 + qr1.setVisibility(View.VISIBLE);
  123 + qr2.setVisibility(View.VISIBLE);
  124 + qr3.setVisibility(View.VISIBLE);
  125 + qr4.setVisibility(View.GONE);
  126 + qr5.setVisibility(View.GONE);
  127 + } else if (iconList.size() == 4) {
  128 + qr1.setVisibility(View.VISIBLE);
  129 + qr2.setVisibility(View.VISIBLE);
  130 + qr3.setVisibility(View.VISIBLE);
  131 + qr4.setVisibility(View.VISIBLE);
  132 + qr5.setVisibility(View.GONE);
  133 + } else if (iconList.size() == 5) {
  134 + qr1.setVisibility(View.VISIBLE);
  135 + qr2.setVisibility(View.VISIBLE);
  136 + qr3.setVisibility(View.VISIBLE);
  137 + qr4.setVisibility(View.VISIBLE);
  138 + qr5.setVisibility(View.VISIBLE);
  139 + }
97 140
98 141
99 } 142 }
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/MyMapUtil.java
@@ -3,6 +3,7 @@ package com.cnlive.moudle.pedometer.utils; @@ -3,6 +3,7 @@ package com.cnlive.moudle.pedometer.utils;
3 import android.content.Context; 3 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 7
7 import com.baidu.mapapi.map.BaiduMap; 8 import com.baidu.mapapi.map.BaiduMap;
8 import com.baidu.mapapi.map.BitmapDescriptorFactory; 9 import com.baidu.mapapi.map.BitmapDescriptorFactory;
@@ -24,6 +25,26 @@ import java.util.List; @@ -24,6 +25,26 @@ import java.util.List;
24 */ 25 */
25 public class MyMapUtil { 26 public class MyMapUtil {
26 /** 27 /**
  28 + * 判断GPS是否开启,GPS或者AGPS开启一个就认为是开启的
  29 + *
  30 + * @param context
  31 + * @return true 表示开启
  32 + */
  33 + public static final boolean isOPenGps(final Context context) {
  34 + LocationManager locationManager
  35 + = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
  36 + // 通过GPS卫星定位,定位级别可以精确到街(通过24颗卫星定位,在室外和空旷的地方定位准确、速度快)
  37 + boolean gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
  38 + // 通过WLAN或移动网络(3G/2G)确定的位置(也称作AGPS,辅助GPS定位。主要用于在室内或遮盖物(建筑群或茂密的深林等)密集的地方定位)
  39 + boolean network = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
  40 + if (gps || network) {
  41 + return true;
  42 + }
  43 +
  44 + return false;
  45 + }
  46 +
  47 + /**
27 * 将轨迹坐标对象转换为地图坐标对象 48 * 将轨迹坐标对象转换为地图坐标对象
28 * 49 *
29 * @param traceLatLng 50 * @param traceLatLng
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/MySpHelper.java
@@ -11,6 +11,7 @@ import android.util.Log; @@ -11,6 +11,7 @@ import android.util.Log;
11 * @author ShinnyYang 11 * @author ShinnyYang
12 */ 12 */
13 public class MySpHelper { 13 public class MySpHelper {
  14 + private static final String TAG = "MySpHelper";
14 private static MySpHelper sharedPreferencesHelper = null; 15 private static MySpHelper sharedPreferencesHelper = null;
15 private static int SP_MODE;//指定模式 16 private static int SP_MODE;//指定模式
16 17
@@ -147,7 +148,7 @@ public class MySpHelper { @@ -147,7 +148,7 @@ public class MySpHelper {
147 editor.remove(key); 148 editor.remove(key);
148 editor.commit(); 149 editor.commit();
149 } catch (NullPointerException e) { 150 } catch (NullPointerException e) {
150 - Log.d("hcj", "" + e); 151 + Log.d(TAG, "removeKey:" + e);
151 } 152 }
152 } 153 }
153 } 154 }
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/QMUITipDialogUtil.java 0 → 100644
  1 +package com.cnlive.moudle.pedometer.utils;
  2 +
  3 +import android.content.Context;
  4 +import android.os.Build;
  5 +import android.os.Handler;
  6 +
  7 +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog;
  8 +
  9 +/**
  10 + * 文 件 名: QMUITipDialogUtil
  11 + * 创 建 人: 杨帅
  12 + * 创建日期: 2018/10/22 18:51
  13 + * 描 述:
  14 + * 修 改 人:
  15 + * 修改时间:
  16 + * 修改备注:
  17 + */
  18 +public class QMUITipDialogUtil {
  19 + private static QMUITipDialog tipDialog;
  20 +
  21 +
  22 + /**
  23 + * 初始化
  24 + */
  25 + public static void QMUITipDialogUtil(Context context) {
  26 + QMUITipDialog.Builder builder = new QMUITipDialog.Builder(context);
  27 + }
  28 +
  29 + /**
  30 + * Loading 类型提示框
  31 + *
  32 + * @param context
  33 + * @param tipStr
  34 + */
  35 + public static void loadingDialog(Context context, String tipStr, boolean isCancel) {
  36 + tipDialog = new QMUITipDialog.Builder(context)
  37 + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING)
  38 + .setTipWord(tipStr)
  39 + .create();
  40 + tipDialog.setCanceledOnTouchOutside(isCancel);//屏蔽返回键
  41 + tipDialog.setCancelable(isCancel);
  42 + tipDialog.show();
  43 + }
  44 +
  45 + /**
  46 + * 成功提示类型提示框
  47 + *
  48 + * @param context
  49 + */
  50 + public static void successDialog(Context context, String tipStr, int second) {
  51 + tipDialog = new QMUITipDialog.Builder(context)
  52 + .setIconType(QMUITipDialog.Builder.ICON_TYPE_SUCCESS)
  53 + .setTipWord(tipStr)
  54 + .create();
  55 + tipDialog.setCanceledOnTouchOutside(false);//屏蔽返回键
  56 + tipDialog.show();
  57 + new Handler().postDelayed(new Runnable() {
  58 + @Override
  59 + public void run() {
  60 +
  61 + /**
  62 + * 延时执行的代码
  63 + */
  64 + tipDialog.dismiss();
  65 + }
  66 + }, second * 1000); // 延时2秒
  67 + }
  68 +
  69 + /**
  70 + * 失败提示类型提示框
  71 + *
  72 + * @param context
  73 + */
  74 + public static void failedDialog(Context context, String tipStr, int second) {
  75 + tipDialog = new QMUITipDialog.Builder(context)
  76 + .setIconType(QMUITipDialog.Builder.ICON_TYPE_FAIL)
  77 + .setTipWord(tipStr)
  78 + .create();
  79 + tipDialog.setCanceledOnTouchOutside(false);//屏蔽返回键
  80 + tipDialog.show();
  81 + new Handler().postDelayed(new Runnable() {
  82 + @Override
  83 + public void run() {
  84 +
  85 + /**
  86 + * 延时执行的代码
  87 + */
  88 + tipDialog.dismiss();
  89 + }
  90 + }, second * 1000); // 延时2秒
  91 +
  92 + }
  93 +
  94 + /**
  95 + * 信息提示类型提示框
  96 + *
  97 + * @param context
  98 + */
  99 + public static void messageDialog(Context context, String tipStr, int second) {
  100 + tipDialog = new QMUITipDialog.Builder(context)
  101 + .setIconType(QMUITipDialog.Builder.ICON_TYPE_INFO)
  102 + .setTipWord(tipStr)
  103 + .create();
  104 + tipDialog.setCanceledOnTouchOutside(false);//屏蔽返回键
  105 + tipDialog.show();
  106 + new Handler().postDelayed(new Runnable() {
  107 + @Override
  108 + public void run() {
  109 +
  110 + /**
  111 + * 延时执行的代码
  112 + */
  113 + tipDialog.dismiss();
  114 + }
  115 + }, second * 1000); // 延时2秒
  116 + }
  117 +
  118 +
  119 + /**
  120 + * 单独文字类型提示框
  121 + *
  122 + * @param context
  123 + */
  124 + public static void textDialog(Context context, String tipStr, int second) {
  125 + tipDialog = new QMUITipDialog.Builder(context)
  126 + .setTipWord(tipStr)
  127 + .create();
  128 + tipDialog.setCanceledOnTouchOutside(false);//屏蔽返回键
  129 + tipDialog.show();
  130 + new Handler().postDelayed(new Runnable() {
  131 + @Override
  132 + public void run() {
  133 +
  134 + /**
  135 + * 延时执行的代码
  136 + */
  137 + tipDialog.dismiss();
  138 + }
  139 + }, second * 1000); // 延时2秒
  140 + }
  141 +
  142 + public static void dismessDialog() {
  143 + if (tipDialog != null) {
  144 + tipDialog.dismiss();
  145 + }
  146 + }
  147 +}
moudle_pedometer/src/main/res/drawable-hdpi/sport_type.png 0 → 100644

652 Bytes

moudle_pedometer/src/main/res/drawable-xhdpi/sport_type.png 0 → 100644

747 Bytes

moudle_pedometer/src/main/res/drawable-xxhdpi/sport_type.png 0 → 100644

1.29 KB

moudle_pedometer/src/main/res/layout/fragment_run_race_detail.xml
@@ -25,6 +25,14 @@ @@ -25,6 +25,14 @@
25 android:layout_width="match_parent" 25 android:layout_width="match_parent"
26 android:layout_height="match_parent"></com.baidu.mapapi.map.MapView> 26 android:layout_height="match_parent"></com.baidu.mapapi.map.MapView>
27 27
  28 + <!--地图上面加一层类似于全透明黑色蒙版-->
  29 + <LinearLayout
  30 + android:layout_width="match_parent"
  31 + android:layout_height="match_parent"
  32 + android:background="#0D000000"
  33 + android:clickable="false"
  34 + android:focusable="false"
  35 + android:focusableInTouchMode="false"></LinearLayout>
28 36
29 <ImageView 37 <ImageView
30 android:id="@+id/iv_back" 38 android:id="@+id/iv_back"
moudle_pedometer/src/main/res/layout/layout_run_detail_street.xml
@@ -314,6 +314,44 @@ @@ -314,6 +314,44 @@
314 android:layout_marginTop="5dp" 314 android:layout_marginTop="5dp"
315 android:layout_marginRight="10dp" 315 android:layout_marginRight="10dp"
316 android:background="@color/line" /> 316 android:background="@color/line" />
  317 + <!--活动类型-->
  318 + <LinearLayout
  319 + android:layout_width="match_parent"
  320 + android:layout_height="wrap_content"
  321 + android:layout_marginLeft="10dp"
  322 + android:layout_marginTop="10dp"
  323 + android:gravity="center_vertical">
  324 +
  325 + <ImageView
  326 + android:layout_width="14dp"
  327 + android:layout_height="14dp"
  328 + android:background="@drawable/sport_type" />
  329 +
  330 + <TextView
  331 + android:layout_width="wrap_content"
  332 + android:layout_height="wrap_content"
  333 + android:layout_marginLeft="5dp"
  334 + android:text="@string/layout_street_active_type"
  335 + android:textColor="@color/bottom_sheet_dialog_race_location_text"
  336 + android:textSize="14sp" />
  337 + </LinearLayout>
  338 + <!--类型-->
  339 + <LinearLayout
  340 + android:layout_width="match_parent"
  341 + android:layout_height="wrap_content"
  342 + android:layout_marginLeft="10dp"
  343 + android:layout_marginTop="10dp">
  344 +
  345 + <TextView
  346 + android:layout_width="wrap_content"
  347 + android:layout_height="wrap_content"
  348 + android:layout_marginLeft="25dp"
  349 + android:text="徒步"
  350 + android:textColor="@color/text_black"
  351 + android:textStyle="bold"
  352 + android:textSize="15sp" />
  353 +
  354 + </LinearLayout>
317 <!--参与人数--> 355 <!--参与人数-->
318 <LinearLayout 356 <LinearLayout
319 android:layout_width="match_parent" 357 android:layout_width="match_parent"
@@ -350,7 +388,7 @@ @@ -350,7 +388,7 @@
350 <TextView 388 <TextView
351 android:layout_width="wrap_content" 389 android:layout_width="wrap_content"
352 android:layout_height="wrap_content" 390 android:layout_height="wrap_content"
353 - android:layout_marginLeft="28dp" 391 + android:layout_marginLeft="33dp"
354 android:text="123" 392 android:text="123"
355 android:textColor="@color/text_black" 393 android:textColor="@color/text_black"
356 android:textSize="17sp" 394 android:textSize="17sp"
moudle_pedometer/src/main/res/values/strings.xml
@@ -67,5 +67,7 @@ @@ -67,5 +67,7 @@
67 <string name="loc_gps_accuracy_bad">信号糟糕,数据准确度低</string> 67 <string name="loc_gps_accuracy_bad">信号糟糕,数据准确度低</string>
68 <string name="loc_gps_accuracy_mid">GPS信号质量中等</string> 68 <string name="loc_gps_accuracy_mid">GPS信号质量中等</string>
69 <string name="loc_gps_accuracy_good">GPS信号质量好</string> 69 <string name="loc_gps_accuracy_good">GPS信号质量好</string>
  70 + <string name="layout_street_active_type">活动类型</string>
  71 + <string name="open_gps_tip">您尚未开启GPS,为确保定位准确性,请您打开后使用!</string>
70 <!----> 72 <!---->
71 </resources> 73 </resources>