Commit 8d291e0693cc332f82e59efdf18985c0d1a66db0
Merge branch 'master' of bj.gitlab.cnlive.com:cnlive-team/ModulePedometer
Showing
44 changed files
with
4187 additions
and
376 deletions
app/src/main/java/com/example/modulepedometer/MainActivity.java
| ... | ... | @@ -16,7 +16,7 @@ public class MainActivity extends AppCompatActivity { |
| 16 | 16 | startActivity(intent); |
| 17 | 17 | // ARouter.getInstance() |
| 18 | 18 | //// .build("/moudle_pedometer/InterestActivity") |
| 19 | -// .build("/moudle_pedometer/RunRaceDetailActivity") | |
| 19 | +// .build("/moudle_pedometer/CollRunRaceDetailActivity") | |
| 20 | 20 | // .navigation(this); |
| 21 | 21 | finish(); |
| 22 | 22 | // BottomSheetDialog bottomSheetDialog=new BottomSheetDialog(this); | ... | ... |
library_baidumap/build.gradle
moudle_pedometer/build.gradle
| ... | ... | @@ -110,9 +110,11 @@ dependencies { |
| 110 | 110 | implementation project(':library_baidumap') |
| 111 | 111 | implementation project(':share') |
| 112 | 112 | implementation project(':lib_network') |
| 113 | + compile project(path: ':lib_network') | |
| 113 | 114 | |
| 114 | 115 | } |
| 115 | 116 | |
| 117 | + | |
| 116 | 118 | configurations { |
| 117 | 119 | all*.exclude group: 'com.squareup.okhttp3', module: 'okhttp' |
| 118 | 120 | all*.exclude group: 'com.squareup.okio' | ... | ... |
moudle_pedometer/src/main/AndroidManifest.xml
| ... | ... | @@ -111,6 +111,21 @@ |
| 111 | 111 | <activity |
| 112 | 112 | android:name="com.cnlive.moudle.pedometer.ui.activity.RunningFinishActivity" |
| 113 | 113 | android:process=":step" /> |
| 114 | + | |
| 115 | + <!--路径工具--> | |
| 116 | + <activity | |
| 117 | + android:name="com.cnlive.moudle.collectionTrace.ui.activity.CollPedometerMainActivity" | |
| 118 | + android:launchMode="singleTask" | |
| 119 | + android:process=":step" /> | |
| 120 | + <activity | |
| 121 | + android:name="com.cnlive.moudle.collectionTrace.ui.activity.CollRunningFinishActivity" | |
| 122 | + android:process=":step" /> <!-- android:theme="@style/Theme.AppCompat.Light.NoActionBar" --> | |
| 123 | + <activity | |
| 124 | + android:name="com.cnlive.moudle.collectionTrace.ui.activity.CollRunningMapActivity" | |
| 125 | + android:process=":step" /> | |
| 126 | + <activity | |
| 127 | + android:name="com.cnlive.moudle.collectionTrace.ui.activity.CollRunRaceDetailActivity" | |
| 128 | + android:process=":step" /> | |
| 114 | 129 | </application> |
| 115 | 130 | |
| 116 | 131 | </manifest> |
| 117 | 132 | \ No newline at end of file | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/presenter/CollRunMainFragmentPresenter.java
0 → 100644
| 1 | +package com.cnlive.moudle.collectionTrace.frame.presenter; | |
| 2 | + | |
| 3 | +import com.cnlive.moudle.collectionTrace.frame.view.CollRunMainFragmentView; | |
| 4 | +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; | |
| 5 | + | |
| 6 | +public class CollRunMainFragmentPresenter extends MvpBasePresenter<CollRunMainFragmentView> { | |
| 7 | +} | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/presenter/CollRunRaceDetailFragmentPresenter.java
0 → 100644
| 1 | +package com.cnlive.moudle.collectionTrace.frame.presenter; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.view.View; | |
| 5 | + | |
| 6 | +import com.cnlive.libs.base.logic.Logic; | |
| 7 | +import com.cnlive.libs.base.logic.callback.DataCallback; | |
| 8 | +import com.cnlive.libs.base.logic.callback.FailureCallback; | |
| 9 | +import com.cnlive.libs.base.logic.callback.StateCallback; | |
| 10 | +import com.cnlive.libs.base.logic.callback.SuccessCallback; | |
| 11 | +import com.cnlive.moudle.collectionTrace.frame.view.CollRunRaceDetailFragmentView; | |
| 12 | +import com.cnlive.strike.data.network.api.ApiRequest; | |
| 13 | +import com.cnlive.strike.data.network.api.ApiServiceDaren; | |
| 14 | +import com.cnlive.strike.data.network.model.BaseInfo; | |
| 15 | +import com.cnlive.strike.data.network.model.runAbout.RunRaceDetailInfo; | |
| 16 | +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; | |
| 17 | + | |
| 18 | +import java.util.HashMap; | |
| 19 | +import java.util.Map; | |
| 20 | + | |
| 21 | +import io.reactivex.disposables.Disposable; | |
| 22 | + | |
| 23 | +import static com.cnlive.libs.base.logic.Config.STATE_IDLE; | |
| 24 | +import static com.cnlive.libs.base.logic.Config.STATE_LOAD; | |
| 25 | + | |
| 26 | +public class CollRunRaceDetailFragmentPresenter extends MvpBasePresenter<CollRunRaceDetailFragmentView> { | |
| 27 | + | |
| 28 | + public void getRunRaceDetailInfo(Context context, String id, String userId) { | |
| 29 | + //设置请求参数 | |
| 30 | + Map<String, String> paramsMap = new HashMap<>(); | |
| 31 | + //赛事id | |
| 32 | + paramsMap.put("id", id); | |
| 33 | + paramsMap.put("sid", userId); | |
| 34 | + | |
| 35 | +// Logic.create(paramsMap) | |
| 36 | +// .action(new Logic.Action<Map<String, String>, BaseInfo<RunRaceDetailInfo>>() { | |
| 37 | +// @Override | |
| 38 | +// public Disposable action(Map<String, String> paramsMap, DataCallback<BaseInfo<RunRaceDetailInfo>> dataCallback) { | |
| 39 | +// return ApiRequest.service(ApiServiceDaren.class, api -> api.getRunRaceDetail(paramsMap)).subscribe(context, dataCallback); | |
| 40 | +// } | |
| 41 | +// }).<BaseInfo<RunRaceDetailInfo>>event() | |
| 42 | +// .setStateCallback(new StateCallback() { | |
| 43 | +// @Override | |
| 44 | +// public void onState(int i) { | |
| 45 | +// if (getView() == null) { | |
| 46 | +// return; | |
| 47 | +// } | |
| 48 | +// if (i == STATE_LOAD) { | |
| 49 | +// QMUITipDialogUtil.loadingDialog(context, "正在获取赛事详情", false); | |
| 50 | +// } else if (i == STATE_IDLE) { | |
| 51 | +// } | |
| 52 | +// | |
| 53 | +// } | |
| 54 | +// }) | |
| 55 | +// .setSuccessCallback(new SuccessCallback<BaseInfo<RunRaceDetailInfo>>() { | |
| 56 | +// @Override | |
| 57 | +// public void onSuccess(BaseInfo<RunRaceDetailInfo> runRaceDetailInfoBaseInfo) { | |
| 58 | +// if (getView() == null) { | |
| 59 | +// return; | |
| 60 | +// } | |
| 61 | +// } | |
| 62 | +// }).setFailureCallback(new FailureCallback() { | |
| 63 | +// @Override | |
| 64 | +// public void onFailure(int i, String s) { | |
| 65 | +// if (getView() == null) { | |
| 66 | +// return; | |
| 67 | +// } | |
| 68 | +// } | |
| 69 | +// }).start(); | |
| 70 | + Logic.create(paramsMap).action(new Logic.Action<Map<String, String>, BaseInfo<RunRaceDetailInfo>>() { | |
| 71 | + @Override | |
| 72 | + public Disposable action(Map<String, String> stringStringMap, DataCallback<BaseInfo<RunRaceDetailInfo>> dataCallback) { | |
| 73 | + return ApiRequest.observable(ApiServiceDaren.class, api -> api.getRunRaceDetail(stringStringMap)).subscribe(context, dataCallback); | |
| 74 | + } | |
| 75 | + }).<BaseInfo<RunRaceDetailInfo>>event() | |
| 76 | + .setStateCallback(new StateCallback() { | |
| 77 | + @Override | |
| 78 | + public void onState(int i) { | |
| 79 | + if (getView() == null) { | |
| 80 | + return; | |
| 81 | + } | |
| 82 | + if (i == STATE_LOAD) { | |
| 83 | + getView().showLoadingView(); | |
| 84 | + } else if (i == STATE_IDLE) { | |
| 85 | + getView().hideLoadingView(); | |
| 86 | + } | |
| 87 | + } | |
| 88 | + }) | |
| 89 | + .setFailureCallback(new FailureCallback() { | |
| 90 | + @Override | |
| 91 | + public void onFailure(int code, String message) { | |
| 92 | + if (getView() == null) { | |
| 93 | + return; | |
| 94 | + } | |
| 95 | + getView().hideLoadingView(); | |
| 96 | + getView().showRetryView(code, new View.OnClickListener() { | |
| 97 | + @Override | |
| 98 | + public void onClick(View view) { | |
| 99 | + getRunRaceDetailInfo(context, id, userId); | |
| 100 | + } | |
| 101 | + }); | |
| 102 | + } | |
| 103 | + }).setSuccessCallback(new SuccessCallback<BaseInfo<RunRaceDetailInfo>>() { | |
| 104 | + @Override | |
| 105 | + public void onSuccess(BaseInfo<RunRaceDetailInfo> baseInfo) { | |
| 106 | + if (getView() == null) { | |
| 107 | + return; | |
| 108 | + } | |
| 109 | + if (baseInfo.getData() != null) { | |
| 110 | + getView().initView(baseInfo.getData()); | |
| 111 | + } | |
| 112 | + } | |
| 113 | + }).start(); | |
| 114 | + | |
| 115 | + } | |
| 116 | +} | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/presenter/CollRunningFinishFragmetPresenter.java
0 → 100644
| 1 | +package com.cnlive.moudle.collectionTrace.frame.presenter; | |
| 2 | + | |
| 3 | +import com.cnlive.moudle.collectionTrace.frame.view.CollRunningFinishFragmentView; | |
| 4 | +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; | |
| 5 | + | |
| 6 | +public class CollRunningFinishFragmetPresenter extends MvpBasePresenter<CollRunningFinishFragmentView> { | |
| 7 | +} | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/presenter/CollRunningMapFragmentPresenter.java
0 → 100644
| 1 | +package com.cnlive.moudle.collectionTrace.frame.presenter; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.os.Handler; | |
| 5 | +import android.util.Log; | |
| 6 | +import android.widget.Toast; | |
| 7 | + | |
| 8 | +import com.baidu.mapapi.map.Overlay; | |
| 9 | +import com.baidu.mapapi.model.LatLng; | |
| 10 | +import com.baidu.mapapi.utils.DistanceUtil; | |
| 11 | +import com.baidu.trace.api.entity.AroundSearchResponse; | |
| 12 | +import com.baidu.trace.api.entity.BoundSearchResponse; | |
| 13 | +import com.baidu.trace.api.entity.DistrictSearchResponse; | |
| 14 | +import com.baidu.trace.api.entity.EntityListResponse; | |
| 15 | +import com.baidu.trace.api.entity.LocRequest; | |
| 16 | +import com.baidu.trace.api.entity.OnEntityListener; | |
| 17 | +import com.baidu.trace.api.entity.PolygonSearchResponse; | |
| 18 | +import com.baidu.trace.api.entity.SearchResponse; | |
| 19 | +import com.baidu.trace.api.fence.AddMonitoredPersonResponse; | |
| 20 | +import com.baidu.trace.api.fence.CreateFenceRequest; | |
| 21 | +import com.baidu.trace.api.fence.CreateFenceResponse; | |
| 22 | +import com.baidu.trace.api.fence.DeleteFenceResponse; | |
| 23 | +import com.baidu.trace.api.fence.DeleteMonitoredPersonResponse; | |
| 24 | +import com.baidu.trace.api.fence.FenceListRequest; | |
| 25 | +import com.baidu.trace.api.fence.FenceListResponse; | |
| 26 | +import com.baidu.trace.api.fence.HistoryAlarmResponse; | |
| 27 | +import com.baidu.trace.api.fence.ListMonitoredPersonResponse; | |
| 28 | +import com.baidu.trace.api.fence.MonitoredStatus; | |
| 29 | +import com.baidu.trace.api.fence.MonitoredStatusByLocationResponse; | |
| 30 | +import com.baidu.trace.api.fence.MonitoredStatusInfo; | |
| 31 | +import com.baidu.trace.api.fence.MonitoredStatusRequest; | |
| 32 | +import com.baidu.trace.api.fence.MonitoredStatusResponse; | |
| 33 | +import com.baidu.trace.api.fence.OnFenceListener; | |
| 34 | +import com.baidu.trace.api.fence.UpdateFenceResponse; | |
| 35 | +import com.baidu.trace.api.track.DistanceRequest; | |
| 36 | +import com.baidu.trace.api.track.DistanceResponse; | |
| 37 | +import com.baidu.trace.api.track.HistoryTrackRequest; | |
| 38 | +import com.baidu.trace.api.track.HistoryTrackResponse; | |
| 39 | +import com.baidu.trace.api.track.OnTrackListener; | |
| 40 | +import com.baidu.trace.api.track.SupplementMode; | |
| 41 | +import com.baidu.trace.api.track.TrackPoint; | |
| 42 | +import com.baidu.trace.model.CoordType; | |
| 43 | +import com.baidu.trace.model.ProcessOption; | |
| 44 | +import com.baidu.trace.model.SortType; | |
| 45 | +import com.baidu.trace.model.StatusCodes; | |
| 46 | +import com.baidu.trace.model.TraceLocation; | |
| 47 | +import com.baidu.trace.model.TransportMode; | |
| 48 | +import com.cnlive.moudle.collectionTrace.frame.view.CollRunningMapFragmentView; | |
| 49 | +import com.cnlive.moudle.pedometer.service.StepService; | |
| 50 | +import com.cnlive.moudle.pedometer.utils.CommonUtil; | |
| 51 | +import com.cnlive.moudle.pedometer.utils.GsonUtil; | |
| 52 | +import com.cnlive.moudle.pedometer.utils.MyMapUtil; | |
| 53 | +import com.example.moudle_pedometer.R; | |
| 54 | +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; | |
| 55 | + | |
| 56 | +import java.util.ArrayList; | |
| 57 | +import java.util.HashMap; | |
| 58 | +import java.util.List; | |
| 59 | + | |
| 60 | +public class CollRunningMapFragmentPresenter extends MvpBasePresenter<CollRunningMapFragmentView> { | |
| 61 | + private final String TAG = "RunningMapPresenter"; | |
| 62 | + /******轨迹查询相关******/ | |
| 63 | + //分页大小 | |
| 64 | + private int pageSize = 1000; | |
| 65 | + //分页索引 | |
| 66 | + private int pageIndex = 1; | |
| 67 | + //分页大小 | |
| 68 | + private int realTimePageSize = 1000; | |
| 69 | + //分页索引 | |
| 70 | + private int realTimePageIndex = 1; | |
| 71 | + //查询标识 | |
| 72 | + private int tag = 1; | |
| 73 | + /** | |
| 74 | + * 历史轨迹请求 | |
| 75 | + */ | |
| 76 | + private HistoryTrackRequest historyTrackRequest; | |
| 77 | + /** | |
| 78 | + * 实时轨迹请求 | |
| 79 | + */ | |
| 80 | + private LocRequest realTimeListRequest; | |
| 81 | + | |
| 82 | + /** | |
| 83 | + * 创建里程查询请求实例 | |
| 84 | + */ | |
| 85 | + private DistanceRequest distanceRequest; | |
| 86 | + /** | |
| 87 | + * 轨迹点集合 | |
| 88 | + */ | |
| 89 | + private List<LatLng> trackPoints; | |
| 90 | + private List<LatLng> realTimePoints; | |
| 91 | + 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"; | |
| 92 | + private HashMap<Integer, Boolean> importHash; | |
| 93 | + private static int matchIndex = 0; | |
| 94 | + | |
| 95 | + /** | |
| 96 | + * 查询历史轨迹 | |
| 97 | + * | |
| 98 | + * @param startTime | |
| 99 | + * @param endTime | |
| 100 | + */ | |
| 101 | + public void queryHistoryTrace(Context context, String entityName, long startTime, long endTime) { | |
| 102 | + Log.e(TAG, "queryHistoryTrace: 时间:" + startTime); | |
| 103 | + importHash = new HashMap<>(); | |
| 104 | + matchIndex = 0; | |
| 105 | + //打的重要点 | |
| 106 | + List<LatLng> importPoints = GsonUtil.jsonToList(imports, LatLng.class); | |
| 107 | + for (int i = 0; i < importPoints.size(); i++) { | |
| 108 | + if (i % 3 != 0) { | |
| 109 | + importPoints.remove(i); | |
| 110 | + } | |
| 111 | + } | |
| 112 | + | |
| 113 | + for (int i = 0; i < importPoints.size(); i++) { | |
| 114 | + importHash.put(i, false); | |
| 115 | + } | |
| 116 | + | |
| 117 | + if (historyTrackRequest == null) { | |
| 118 | + historyTrackRequest = new HistoryTrackRequest(tag, StepService.serviceId, entityName); | |
| 119 | + //设置查询设备名称 | |
| 120 | + historyTrackRequest.setEntityName(entityName); | |
| 121 | + //历史轨迹开始时间 | |
| 122 | + historyTrackRequest.setStartTime(startTime); | |
| 123 | + //历史轨迹结束时间 | |
| 124 | + historyTrackRequest.setEndTime(endTime); | |
| 125 | + //分页索引 | |
| 126 | + historyTrackRequest.setPageIndex(pageIndex); | |
| 127 | + //分页大小 | |
| 128 | + historyTrackRequest.setPageSize(pageSize); | |
| 129 | + //设置是否进行纠偏 | |
| 130 | + historyTrackRequest.setProcessed(true); | |
| 131 | + //设置返回坐标系 | |
| 132 | + historyTrackRequest.setCoordTypeOutput(CoordType.gcj02); | |
| 133 | + //其他设置 | |
| 134 | + ProcessOption processOption = new ProcessOption(); | |
| 135 | + //去噪:可设置是否需要去除角度、速度和方向异常的轨迹点 | |
| 136 | + processOption.setNeedDenoise(true); | |
| 137 | + //绑路:设置是否将轨迹点绑定至路网道路 | |
| 138 | + processOption.setNeedMapMatch(false); | |
| 139 | + //抽稀:设置是否进行抽稀处理,对冗余的轨迹点进行抽稀去除处理,如一条直线上除起终点外的多个轨迹点 | |
| 140 | + processOption.setNeedVacuate(true); | |
| 141 | + //自动判断交通方式 | |
| 142 | + processOption.setTransportMode(TransportMode.walking); | |
| 143 | + // 设置精度过滤值(定位精度大于100米的过滤掉) | |
| 144 | + processOption.setRadiusThreshold(9); | |
| 145 | + // 设置纠偏选项 | |
| 146 | + historyTrackRequest.setProcessOption(processOption); | |
| 147 | + // 设置里程填充方式为驾车 | |
| 148 | + historyTrackRequest.setSupplementMode(SupplementMode.walking); | |
| 149 | + | |
| 150 | + } | |
| 151 | + //创建里程查询 | |
| 152 | + if (distanceRequest == null) { | |
| 153 | + // 创建里程查询请求实例 | |
| 154 | + distanceRequest = new DistanceRequest(tag, StepService.serviceId, entityName); | |
| 155 | + // 设置开始时间 | |
| 156 | + distanceRequest.setStartTime(startTime); | |
| 157 | + // 设置结束时间 | |
| 158 | + distanceRequest.setEndTime(endTime); | |
| 159 | + // 设置需要纠偏 | |
| 160 | + distanceRequest.setProcessed(true); | |
| 161 | + | |
| 162 | + // 创建纠偏选项实例 | |
| 163 | + ProcessOption processOption = new ProcessOption(); | |
| 164 | + // 设置需要去噪 | |
| 165 | + processOption.setNeedDenoise(true); | |
| 166 | + // 设置需要绑路 | |
| 167 | + processOption.setNeedMapMatch(false); | |
| 168 | + //抽稀:设置是否进行抽稀处理,对冗余的轨迹点进行抽稀去除处理,如一条直线上除起终点外的多个轨迹点 | |
| 169 | + processOption.setNeedVacuate(true); | |
| 170 | + // 设置精度过滤值(定位精度大于100米的过滤掉) | |
| 171 | + processOption.setRadiusThreshold(9); | |
| 172 | + // 设置交通方式为不行 | |
| 173 | + processOption.setTransportMode(TransportMode.walking); | |
| 174 | + // 设置纠偏选项 | |
| 175 | + distanceRequest.setProcessOption(processOption); | |
| 176 | + // 设置里程填充方式为步行 | |
| 177 | + distanceRequest.setSupplementMode(SupplementMode.walking); | |
| 178 | + | |
| 179 | + } | |
| 180 | + if (trackPoints == null) { | |
| 181 | + trackPoints = new ArrayList<>(); | |
| 182 | + } | |
| 183 | + //轨迹查询监听器 | |
| 184 | + OnTrackListener historyTrackListener = new OnTrackListener() { | |
| 185 | + @Override | |
| 186 | + public void onHistoryTrackCallback(HistoryTrackResponse response) { | |
| 187 | + super.onHistoryTrackCallback(response); | |
| 188 | + int total = response.getTotal(); | |
| 189 | + | |
| 190 | + if (StatusCodes.SUCCESS != response.getStatus()) { | |
| 191 | + Toast.makeText(context, "获取轨迹失败!" + response.getStatus(), Toast.LENGTH_SHORT).show(); | |
| 192 | + } else if (0 == total) { | |
| 193 | + Toast.makeText(context, "暂未查到您的轨迹,请稍后重试!", Toast.LENGTH_SHORT).show(); | |
| 194 | + } else { | |
| 195 | + //查询到轨迹 | |
| 196 | + List<TrackPoint> points = response.getTrackPoints(); | |
| 197 | + if (null != points) { | |
| 198 | + for (TrackPoint trackPoint : points) { | |
| 199 | + if (!CommonUtil.isZeroPoint(trackPoint.getLocation().getLatitude(), | |
| 200 | + trackPoint.getLocation().getLongitude())) { | |
| 201 | + //将轨迹点转换为地图坐标点 | |
| 202 | + trackPoints.add(MyMapUtil.convertTrace2Map(trackPoint.getLocation())); | |
| 203 | + } | |
| 204 | + } | |
| 205 | + } | |
| 206 | + } | |
| 207 | + if (total > pageSize * pageIndex) { | |
| 208 | + historyTrackRequest.setPageIndex(++pageIndex); | |
| 209 | + queryHistoryTrace(context, entityName, startTime, endTime); | |
| 210 | + } else { | |
| 211 | + if (getView() != null) { | |
| 212 | + | |
| 213 | + //开始比较(杨帅的思路) | |
| 214 | +// for (int i = 0; i < trackPoints.size(); i++) { | |
| 215 | +// if (matchIndex < importPoints.size() - 1) { | |
| 216 | +// LatLng matchLatLng = importPoints.get(matchIndex); | |
| 217 | +// LatLng historyLatLng = trackPoints.get(i); | |
| 218 | +// Log.e(TAG, "距离: " + DistanceUtil.getDistance(matchLatLng, historyLatLng)); | |
| 219 | +// double distance = DistanceUtil.getDistance(matchLatLng, historyLatLng); | |
| 220 | +// if (distance < 200) { | |
| 221 | +// importHash.put(matchIndex, true); | |
| 222 | +// matchIndex++; | |
| 223 | +// } | |
| 224 | +// } | |
| 225 | +// } | |
| 226 | +// //输出 | |
| 227 | +// int result = 0; | |
| 228 | +// for (int i = 0; i < importHash.size(); i++) { | |
| 229 | +// if (!importHash.get(i)) { | |
| 230 | +// result++; | |
| 231 | +// Log.e(TAG, "onHistoryTrackCallback: 没过:" + i + importHash.get(i)); | |
| 232 | +// } | |
| 233 | +// } | |
| 234 | +// if (result > importPoints.size() * 0.4) { | |
| 235 | +// Toast.makeText(context, "没有完成", Toast.LENGTH_LONG).show(); | |
| 236 | +// | |
| 237 | +// } else { | |
| 238 | +// Toast.makeText(context, "已完成", Toast.LENGTH_LONG).show(); | |
| 239 | +// } | |
| 240 | + //郭瑞鹏的思路 | |
| 241 | + int index = 0; | |
| 242 | + for (int i = 0; i < importPoints.size(); i++) { | |
| 243 | + LatLng importLatLng = importPoints.get(i); | |
| 244 | + for (int j = index; j < trackPoints.size(); j++) { | |
| 245 | + double distance = DistanceUtil.getDistance(importLatLng, trackPoints.get(j)); | |
| 246 | + if (distance<100){ | |
| 247 | + importHash.put(i,true); | |
| 248 | + index=j; | |
| 249 | + } | |
| 250 | + } | |
| 251 | + } | |
| 252 | + //输出 | |
| 253 | + int result = 0; | |
| 254 | + for (int i = 0; i < importHash.size(); i++) { | |
| 255 | + if (!importHash.get(i)) { | |
| 256 | + result++; | |
| 257 | + Log.e(TAG, "onHistoryTrackCallback: 没过:" + i + importHash.get(i)); | |
| 258 | + } | |
| 259 | + } | |
| 260 | + if (result > importPoints.size() * 0.4) { | |
| 261 | + Toast.makeText(context, "没有完成", Toast.LENGTH_LONG).show(); | |
| 262 | + | |
| 263 | + } else { | |
| 264 | + Toast.makeText(context, "已完成", Toast.LENGTH_LONG).show(); | |
| 265 | + } | |
| 266 | + Log.e(TAG, "结果: " + result); | |
| 267 | + Log.e(TAG, "onHistoryTrackCallback: 轨迹点:" + trackPoints.size() + ",详情" + GsonUtil.GsonString(trackPoints)); | |
| 268 | + MyMapUtil.drawHistoryTrack(context, getView().baiduMap, trackPoints, SortType.asc, R.color.red, R.drawable.icon_start, R.drawable.icon_end); | |
| 269 | +// MyMapUtil.drawMapLineRoutePoint(context, getView().baiduMap, MyMapUtil.optimizePoints(routePoints), R.color.red); | |
| 270 | + } | |
| 271 | + } | |
| 272 | + } | |
| 273 | + | |
| 274 | + @Override | |
| 275 | + public void onDistanceCallback(DistanceResponse distanceResponse) { | |
| 276 | + super.onDistanceCallback(distanceResponse); | |
| 277 | +// Toast.makeText(context, "查询的里程数:" + (int) distanceResponse.getDistance() + "米", Toast.LENGTH_SHORT).show(); | |
| 278 | + Log.e(TAG, "onDistanceCallback: " + distanceResponse.getDistance()); | |
| 279 | + } | |
| 280 | + }; | |
| 281 | + //开始查询历史轨迹 | |
| 282 | + if (StepService.mClient != null) { | |
| 283 | + StepService.mClient.queryHistoryTrack(historyTrackRequest, historyTrackListener); | |
| 284 | + // 查询里程 | |
| 285 | + StepService.mClient.queryDistance(distanceRequest, historyTrackListener); | |
| 286 | + } | |
| 287 | + | |
| 288 | + } | |
| 289 | + | |
| 290 | + | |
| 291 | + public void queryRealTimeTrace(Context context, String entityName, long activeTime) { | |
| 292 | + if (realTimeListRequest == null) { | |
| 293 | + List<String> names = new ArrayList<>(); | |
| 294 | + names.add(entityName); | |
| 295 | + realTimeListRequest = new LocRequest(); | |
| 296 | + realTimeListRequest.setServiceId(StepService.serviceId); | |
| 297 | + realTimeListRequest.setTag(1); | |
| 298 | + } | |
| 299 | + if (realTimePoints == null) { | |
| 300 | + realTimePoints = new ArrayList<>(); | |
| 301 | + } | |
| 302 | + | |
| 303 | + OnEntityListener onEntityListener = new OnEntityListener() { | |
| 304 | + Overlay realTimeOverlay = null; | |
| 305 | + | |
| 306 | + @Override | |
| 307 | + public void onEntityListCallback(EntityListResponse entityListResponse) { | |
| 308 | + super.onEntityListCallback(entityListResponse); | |
| 309 | + Log.e(TAG, "onEntityListCallback"); | |
| 310 | +// Toast.makeText(context, "onEntityListCallback", Toast.LENGTH_SHORT).show(); | |
| 311 | + } | |
| 312 | + | |
| 313 | + @Override | |
| 314 | + public void onSearchEntityCallback(SearchResponse searchResponse) { | |
| 315 | + super.onSearchEntityCallback(searchResponse); | |
| 316 | + Log.e(TAG, "onSearchEntityCallback"); | |
| 317 | + Toast.makeText(context, "onSearchEntityCallback", Toast.LENGTH_SHORT).show(); | |
| 318 | + | |
| 319 | + } | |
| 320 | + | |
| 321 | + @Override | |
| 322 | + public void onBoundSearchCallback(BoundSearchResponse boundSearchResponse) { | |
| 323 | + super.onBoundSearchCallback(boundSearchResponse); | |
| 324 | + Log.e(TAG, "onBoundSearchCallback"); | |
| 325 | + Toast.makeText(context, "onBoundSearchCallback", Toast.LENGTH_SHORT).show(); | |
| 326 | + | |
| 327 | + } | |
| 328 | + | |
| 329 | + @Override | |
| 330 | + public void onAroundSearchCallback(AroundSearchResponse aroundSearchResponse) { | |
| 331 | + super.onAroundSearchCallback(aroundSearchResponse); | |
| 332 | + Log.e(TAG, "onAroundSearchCallback"); | |
| 333 | + Toast.makeText(context, "onAroundSearchCallback", Toast.LENGTH_SHORT).show(); | |
| 334 | + | |
| 335 | + } | |
| 336 | + | |
| 337 | + @Override | |
| 338 | + public void onPolygonSearchCallback(PolygonSearchResponse polygonSearchResponse) { | |
| 339 | + super.onPolygonSearchCallback(polygonSearchResponse); | |
| 340 | + Log.e(TAG, "onPolygonSearchCallback"); | |
| 341 | + Toast.makeText(context, "onPolygonSearchCallback", Toast.LENGTH_SHORT).show(); | |
| 342 | + } | |
| 343 | + | |
| 344 | + @Override | |
| 345 | + public void onDistrictSearchCallback(DistrictSearchResponse districtSearchResponse) { | |
| 346 | + super.onDistrictSearchCallback(districtSearchResponse); | |
| 347 | + Log.e(TAG, "onDistrictSearchCallback"); | |
| 348 | + Toast.makeText(context, "onDistrictSearchCallback", Toast.LENGTH_SHORT).show(); | |
| 349 | + | |
| 350 | + } | |
| 351 | + | |
| 352 | + /**实时定位回调接口 | |
| 353 | + * @param traceLocation | |
| 354 | + */ | |
| 355 | + @Override | |
| 356 | + public void onReceiveLocation(TraceLocation traceLocation) { | |
| 357 | + super.onReceiveLocation(traceLocation); | |
| 358 | + } | |
| 359 | + }; | |
| 360 | + //查询实时轨迹 | |
| 361 | + if (StepService.mClient != null) { | |
| 362 | + StepService.mClient.queryRealTimeLoc(realTimeListRequest, onEntityListener); | |
| 363 | + } | |
| 364 | + | |
| 365 | + } | |
| 366 | + | |
| 367 | + //创建地理围栏 | |
| 368 | + public void createFence(Context context, List<com.baidu.trace.model.LatLng> latLngs) { | |
| 369 | + CreateFenceRequest createFenceRequest = null; | |
| 370 | + int offset = 20;// 偏离距离 | |
| 371 | + int denoise = 20; //围栏去噪精度 | |
| 372 | + // 初始化围栏监听器 | |
| 373 | + OnFenceListener onFenceListener = new OnFenceListener() { | |
| 374 | + // 创建围栏回调 | |
| 375 | + @Override | |
| 376 | + public void onCreateFenceCallback(CreateFenceResponse createFenceResponse) { | |
| 377 | + if ("成功".equals(createFenceResponse.getMessage())) { | |
| 378 | +// Toast.makeText(context, "创建围栏回调成功", Toast.LENGTH_SHORT).show(); | |
| 379 | + Log.e(TAG, "onCreateFenceCallback: " + createFenceResponse.getFenceId()); | |
| 380 | + // 查询围栏监控者状态 | |
| 381 | + List<Long> list = new ArrayList<>(); | |
| 382 | + list.add(createFenceResponse.getFenceId()); | |
| 383 | + // 创建查询服务端围栏监控状态请求 | |
| 384 | + | |
| 385 | + } | |
| 386 | + } | |
| 387 | + | |
| 388 | + // 更新围栏回调 | |
| 389 | + @Override | |
| 390 | + public void onUpdateFenceCallback(UpdateFenceResponse updateFenceResponse) { | |
| 391 | + | |
| 392 | + } | |
| 393 | + | |
| 394 | + // 删除围栏回调 | |
| 395 | + @Override | |
| 396 | + public void onDeleteFenceCallback(DeleteFenceResponse deleteFenceResponse) { | |
| 397 | + | |
| 398 | + } | |
| 399 | + | |
| 400 | + // 围栏列表回调 | |
| 401 | + @Override | |
| 402 | + public void onFenceListCallback(FenceListResponse fenceListResponse) { | |
| 403 | + if ("成功".equals(fenceListResponse.getMessage())) { | |
| 404 | +// Toast.makeText(context, "围栏列表回调成功:" + fenceListResponse.getSize(), Toast.LENGTH_SHORT).show(); | |
| 405 | + } | |
| 406 | + | |
| 407 | + | |
| 408 | +// //获取围栏列表响应结果 | |
| 409 | +// DeleteFenceRequest deleteFenceRequest = DeleteFenceRequest.buildServerRequest(1, StepService.serviceId, "yangshuai", null); | |
| 410 | +// StepService.mClient.deleteFence(deleteFenceRequest,this); | |
| 411 | + } | |
| 412 | + | |
| 413 | + // 监控状态回调 | |
| 414 | + @Override | |
| 415 | + public void onMonitoredStatusCallback(MonitoredStatusResponse monitoredStatusResponse) { | |
| 416 | + if (monitoredStatusResponse.getMonitoredStatusInfos() != null) { | |
| 417 | + Toast.makeText(context, "围栏列表回调成功:个数:" + monitoredStatusResponse.getMonitoredStatusInfos().size(), Toast.LENGTH_SHORT).show(); | |
| 418 | + } //查询监控对象状态响应结果 | |
| 419 | + List<MonitoredStatusInfo> monitoredStatusInfos = monitoredStatusResponse.getMonitoredStatusInfos(); | |
| 420 | + if (monitoredStatusInfos == null) { | |
| 421 | + return; | |
| 422 | + } | |
| 423 | + for (MonitoredStatusInfo monitoredStatusInfo : monitoredStatusInfos) { | |
| 424 | + monitoredStatusInfo.getFenceId(); | |
| 425 | + MonitoredStatus status = monitoredStatusInfo.getMonitoredStatus();//获取状态 | |
| 426 | + switch (status) { | |
| 427 | + case in: | |
| 428 | + //监控的设备在围栏内 | |
| 429 | + Toast.makeText(context, "监控的设备在围栏内", Toast.LENGTH_SHORT).show(); | |
| 430 | + Log.e(TAG, "监控的设备在围栏内: "); | |
| 431 | + break; | |
| 432 | + case out: | |
| 433 | + //监控的设备在围栏外 | |
| 434 | + Toast.makeText(context, "监控的设备在围栏外", Toast.LENGTH_SHORT).show(); | |
| 435 | + Log.e(TAG, "监控的设备在围栏外: "); | |
| 436 | + | |
| 437 | + break; | |
| 438 | + case unknown: | |
| 439 | + //监控的设备状态未知 | |
| 440 | + Toast.makeText(context, "监控的设备状态未知", Toast.LENGTH_SHORT).show(); | |
| 441 | + Log.e(TAG, "监控的设备状态未知: "); | |
| 442 | + | |
| 443 | + break; | |
| 444 | + } | |
| 445 | + } | |
| 446 | + } | |
| 447 | + | |
| 448 | + // 指定位置监控状态回调 | |
| 449 | + @Override | |
| 450 | + public void onMonitoredStatusByLocationCallback(MonitoredStatusByLocationResponse monitoredStatusByLocationResponse) { | |
| 451 | + Log.e(TAG, "onMonitoredStatusByLocationCallback: "); | |
| 452 | + } | |
| 453 | + | |
| 454 | + // 历史报警回调 | |
| 455 | + @Override | |
| 456 | + public void onHistoryAlarmCallback(HistoryAlarmResponse historyAlarmResponse) { | |
| 457 | + Log.e(TAG, "onHistoryAlarmCallback: "); | |
| 458 | + } | |
| 459 | + | |
| 460 | + @Override | |
| 461 | + public void onAddMonitoredPersonCallback(AddMonitoredPersonResponse addMonitoredPersonResponse) { | |
| 462 | + Log.e(TAG, "onAddMonitoredPersonCallback: "); | |
| 463 | + } | |
| 464 | + | |
| 465 | + @Override | |
| 466 | + public void onDeleteMonitoredPersonCallback(DeleteMonitoredPersonResponse deleteMonitoredPersonResponse) { | |
| 467 | + Log.e(TAG, "onDeleteMonitoredPersonCallback: "); | |
| 468 | + } | |
| 469 | + | |
| 470 | + @Override | |
| 471 | + public void onListMonitoredPersonCallback(ListMonitoredPersonResponse listMonitoredPersonResponse) { | |
| 472 | + Log.e(TAG, "onListMonitoredPersonCallback: "); | |
| 473 | + } | |
| 474 | + }; | |
| 475 | + // 创建本地圆形围栏 | |
| 476 | +// if (StepService.mClient != null) { | |
| 477 | +// if (createFenceRequest == null) { | |
| 478 | +// createFenceRequest = CreateFenceRequest.buildServerPolylineRequest(1, StepService.serviceId, "test", "yangshuai", latLngs, offset, denoise, CoordType.gcj02); | |
| 479 | +// StepService.mClient.createFence(createFenceRequest, onFenceListener); | |
| 480 | +// } | |
| 481 | +// } | |
| 482 | + | |
| 483 | + FenceListRequest request = FenceListRequest.buildServerRequest(tag, StepService.serviceId, "yangshuai", null, CoordType.gcj02); | |
| 484 | + | |
| 485 | + //发起查询围栏请求 | |
| 486 | + if (StepService.mClient != null) { | |
| 487 | + StepService.mClient.queryFenceList(request, onFenceListener); | |
| 488 | + } | |
| 489 | + | |
| 490 | + List<Long> fenid = new ArrayList<>(); | |
| 491 | + fenid.add(1L); | |
| 492 | + MonitoredStatusRequest request1 = MonitoredStatusRequest.buildServerRequest(tag, | |
| 493 | + StepService.serviceId, "yangshuai", fenid); | |
| 494 | + Handler handler = new Handler(); | |
| 495 | + Runnable runnable = new Runnable() { | |
| 496 | + @Override | |
| 497 | + public void run() { | |
| 498 | + StepService.mClient.queryMonitoredStatus(request1, onFenceListener); | |
| 499 | + } | |
| 500 | + }; | |
| 501 | + handler.postDelayed(runnable, 5000); | |
| 502 | + } | |
| 503 | + | |
| 504 | + public void query() { | |
| 505 | + /** | |
| 506 | + * 以查询服务端围栏为例 | |
| 507 | + * fenceIds:服务端围栏编号列表,List<Long>,如传入null,表示查询所有围栏 | |
| 508 | + */ | |
| 509 | +// FenceListRequest request = FenceListRequest.buildServerRequest(1, StepService.serviceId, "yangshuai", null, CoordType.gcj02); | |
| 510 | +// //发起查询围栏请求 | |
| 511 | +// if (StepService.mClient != null) { | |
| 512 | +// StepService.mClient.queryFenceList(request, fenceListener); | |
| 513 | +// } | |
| 514 | + } | |
| 515 | +} | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunMainFragmentView.java
0 → 100644
| 1 | +package com.cnlive.moudle.collectionTrace.frame.view; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.content.Intent; | |
| 5 | +import android.os.Handler; | |
| 6 | +import android.os.SystemClock; | |
| 7 | +import android.support.v4.content.ContextCompat; | |
| 8 | +import android.text.TextUtils; | |
| 9 | +import android.view.MotionEvent; | |
| 10 | +import android.view.View; | |
| 11 | +import android.widget.Chronometer; | |
| 12 | + | |
| 13 | +import com.baidu.location.BDAbstractLocationListener; | |
| 14 | +import com.baidu.location.BDLocation; | |
| 15 | +import com.baidu.location.LocationClient; | |
| 16 | +import com.baidu.location.LocationClientOption; | |
| 17 | +import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunMainFragment; | |
| 18 | +import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; | |
| 19 | +import com.cnlive.moudle.pedometer.model.Constant; | |
| 20 | +import com.cnlive.moudle.pedometer.model.MessageEvent; | |
| 21 | +import com.cnlive.moudle.pedometer.model.RunningFinishBean; | |
| 22 | +import com.cnlive.moudle.pedometer.model.RunningMapBean; | |
| 23 | +import com.cnlive.moudle.pedometer.service.StepService; | |
| 24 | +import com.cnlive.moudle.pedometer.sql.entity.UserStepEntity; | |
| 25 | +import com.cnlive.moudle.pedometer.ui.activity.RunningFinishActivity; | |
| 26 | +import com.cnlive.moudle.pedometer.ui.activity.RunningMapActivity; | |
| 27 | +import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment; | |
| 28 | +import com.cnlive.moudle.pedometer.ui.widget.SelectDialog; | |
| 29 | +import com.cnlive.moudle.pedometer.utils.ButtonAnimUtil; | |
| 30 | +import com.cnlive.moudle.pedometer.utils.StepUtil; | |
| 31 | +import com.cnlive.moudle.pedometer.utils.TimeUtil; | |
| 32 | +import com.example.moudle_pedometer.R; | |
| 33 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | |
| 34 | + | |
| 35 | +import org.greenrobot.eventbus.EventBus; | |
| 36 | + | |
| 37 | +public class CollRunMainFragmentView implements MvpView { | |
| 38 | + private final String TAG = "CollRunMainFragmentView"; | |
| 39 | + private CollRunMainFragment fragment; | |
| 40 | + private boolean stopStartFlag = false; | |
| 41 | + private boolean continueStartFlag = false; | |
| 42 | + private boolean pauseStartFlag = false; | |
| 43 | + private int stopIndex = 0;//停止按钮,计数 | |
| 44 | + private Handler handler; | |
| 45 | + private Runnable runnable; | |
| 46 | + private Runnable animRunnable; | |
| 47 | + private long mRecordTime;//计时时间 | |
| 48 | + private boolean firstTimeFlag;//是否是首次计时 | |
| 49 | + private int timeCountDown;//时间倒计时 | |
| 50 | + private String uid; | |
| 51 | + private boolean needWriteDataFlag = true;//是否需要将计时器基值写入到数据库 | |
| 52 | + // 定位相关 | |
| 53 | + private LocationClient mLocClient; | |
| 54 | + public MyLocationListenner myListener = new MyLocationListenner(); | |
| 55 | + | |
| 56 | + public CollRunMainFragmentView(CollRunMainFragment fragment) { | |
| 57 | + this.fragment = fragment; | |
| 58 | + } | |
| 59 | + | |
| 60 | + public Context getContext() { | |
| 61 | + return fragment == null ? null : fragment.getActivity(); | |
| 62 | + } | |
| 63 | + | |
| 64 | + private void initLocationClient() { | |
| 65 | + // 定位初始化 | |
| 66 | + mLocClient = new LocationClient(getContext()); | |
| 67 | + mLocClient.registerLocationListener(myListener); | |
| 68 | + LocationClientOption option = new LocationClientOption(); | |
| 69 | + option.setOpenGps(true); // 打开gps | |
| 70 | + //可选,设置返回经纬度坐标类型,默认GCJ02 | |
| 71 | + //GCJ02:国测局坐标; | |
| 72 | + //BD09ll:百度经纬度坐标; | |
| 73 | + //BD09:百度墨卡托坐标; | |
| 74 | + //海外地区定位,无需设置坐标类型,统一返回WGS84类型坐标 | |
| 75 | + option.setCoorType("gcj02"); // 设置坐标类型 | |
| 76 | + //可选,默认false,设置是否开启Gps定位 | |
| 77 | + option.setOpenGps(true); | |
| 78 | + //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者,该模式下开发者无需再关心定位间隔是多少,定位SDK本身发现位置变化就会及时回调给开发者 | |
| 79 | + option.setOpenAutoNotifyMode(); | |
| 80 | + //可选,默认高精度,设置定位模式,高精度,低功耗,仅设备 | |
| 81 | + //LocationMode.Hight_Accuracy:高精度; | |
| 82 | + //LocationMode. Battery_Saving:低功耗; | |
| 83 | + //LocationMode. Device_Sensors:仅使用设备; | |
| 84 | + option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); | |
| 85 | + //可选,设置是否需要地址信息,默认不需要 | |
| 86 | + option.setIsNeedAddress(false); | |
| 87 | + //可选,设置是否需要地址描述 | |
| 88 | + option.setIsNeedLocationDescribe(false); | |
| 89 | + //可选,设置是否需要设备方向结果 | |
| 90 | + option.setNeedDeviceDirect(false); | |
| 91 | + //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者 | |
| 92 | + //minTimeInterval - 最短定位时间间隔,单位毫秒,最小值0,开发者可以在设置希望的位置回调最短时间间隔 | |
| 93 | + //minDistance - 最短定位距离间隔,单位米,最小值0,开发者可以设置希望的位置回调距离间隔 | |
| 94 | + //locSensitivity - 定位变化敏感程度,LOC_SENSITIVITY_HIGHT,LOC_SENSITIVITY_MIDDLE,LOC_SENSITIVITY_LOW | |
| 95 | + option.setOpenAutoNotifyMode(3000, 1, LocationClientOption.LOC_SENSITIVITY_HIGHT); | |
| 96 | + //可选,定位SDK内部是一个service,并放到了独立进程。 | |
| 97 | + //设置是否在stop的时候杀死这个进程,默认(建议)不杀死,即setIgnoreKillProcess(true) | |
| 98 | + option.setIgnoreKillProcess(true); | |
| 99 | + | |
| 100 | + mLocClient.setLocOption(option); | |
| 101 | + mLocClient.start(); | |
| 102 | + } | |
| 103 | + | |
| 104 | + /** | |
| 105 | + * 初始化相关视图 | |
| 106 | + */ | |
| 107 | + public void initView() { | |
| 108 | + uid = "yangshuai"; | |
| 109 | + CommonInfo.setUserId(getContext(), uid); | |
| 110 | + initLocationClient(); | |
| 111 | + fragment.binding.llRunMainRoot.setVisibility(View.GONE); | |
| 112 | + ButtonAnimUtil.startAnimation(fragment.binding.llStartTimeTip, false); | |
| 113 | + firstTimeFlag = true; | |
| 114 | + handler = new Handler(); | |
| 115 | + timeCountDown = 4; | |
| 116 | + //开始时间倒计时 | |
| 117 | + runnable = new Runnable() { | |
| 118 | + @Override | |
| 119 | + public void run() { | |
| 120 | + if (fragment.getActivity() == null) { | |
| 121 | + return; | |
| 122 | + } | |
| 123 | + if (timeCountDown > 1) { | |
| 124 | + timeCountDown--; | |
| 125 | + fragment.binding.tvTimeCountDown.setVisibility(View.VISIBLE); | |
| 126 | + fragment.binding.tvTimeCountDown.setText(timeCountDown + ""); | |
| 127 | + ButtonAnimUtil.setTimeShowZoomIn(fragment.binding.tvTimeCountDown); | |
| 128 | + //依次倒计时 | |
| 129 | + handler.postDelayed(runnable, 1000); | |
| 130 | + } else { | |
| 131 | + ButtonAnimUtil.startAnimation(fragment.binding.llStartTimeTip, true); | |
| 132 | + fragment.binding.llRunMainRoot.setVisibility(View.VISIBLE); | |
| 133 | + new Handler().postDelayed(new Runnable() { | |
| 134 | + @Override | |
| 135 | + public void run() { | |
| 136 | + //开始计时 | |
| 137 | + if (firstTimeFlag) { | |
| 138 | + firstTimeFlag = false; | |
| 139 | + fragment.binding.chronometer.setFormat("00:00:01"); | |
| 140 | + fragment.binding.chronometer.setBase(SystemClock.elapsedRealtime()); | |
| 141 | + fragment.binding.chronometer.start(); | |
| 142 | + } | |
| 143 | + } | |
| 144 | + }, 10); | |
| 145 | + //开启计步服务 | |
| 146 | + startStepService(getContext(), uid); | |
| 147 | + } | |
| 148 | + } | |
| 149 | + }; | |
| 150 | + //设置计时监听 | |
| 151 | + fragment.binding.chronometer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() { | |
| 152 | + @Override | |
| 153 | + public void onChronometerTick(Chronometer chronometer) { | |
| 154 | + int hour = (int) ((SystemClock.elapsedRealtime() - chronometer.getBase()) / 1000 / 60 / 60); | |
| 155 | + int minute = (int) ((SystemClock.elapsedRealtime() - chronometer.getBase()) / 1000 / 60) % 60; | |
| 156 | + int second = (int) ((SystemClock.elapsedRealtime() - chronometer.getBase()) / 1000) % 60; | |
| 157 | + if (hour < 1) { | |
| 158 | + if (minute == 59 && second == 59) { | |
| 159 | + chronometer.setFormat("0" + "%s"); | |
| 160 | + } else { | |
| 161 | + chronometer.setFormat("0" + String.valueOf(hour) + ":%s"); | |
| 162 | + } | |
| 163 | + } else if (hour < 10) { | |
| 164 | + chronometer.setFormat("0" + "%s"); | |
| 165 | + } else { | |
| 166 | + chronometer.setFormat("%s"); | |
| 167 | + } | |
| 168 | + | |
| 169 | + } | |
| 170 | + }); | |
| 171 | + UserStepEntity userStepEntity = StepUtil.getUserStepData(getContext(), uid); | |
| 172 | + boolean isRunStep = CommonInfo.getIsRunStepService(getContext()); | |
| 173 | + //当前用户已经在运动 | |
| 174 | + if (!isRunStep) { | |
| 175 | + //依次倒计时 | |
| 176 | + handler.postDelayed(runnable, 1000); | |
| 177 | + } else { | |
| 178 | + //隐藏计时界面 | |
| 179 | + fragment.binding.llStartTimeTip.setVisibility(View.GONE); | |
| 180 | + fragment.binding.llRunMainRoot.setVisibility(View.VISIBLE); | |
| 181 | + new Handler().postDelayed(new Runnable() { | |
| 182 | + @Override | |
| 183 | + public void run() { | |
| 184 | + //开始计时 | |
| 185 | + if (firstTimeFlag) { | |
| 186 | + firstTimeFlag = false; | |
| 187 | + if (userStepEntity != null) { | |
| 188 | + if ((userStepEntity.getPauseTimeStamp() != 0) && (userStepEntity.getRecordTime() != 0)) { | |
| 189 | + fragment.binding.chronometer.setBase(userStepEntity.getPauseTimeStamp() + (SystemClock.elapsedRealtime() - userStepEntity.getRecordTime())); | |
| 190 | + } else { | |
| 191 | + fragment.binding.chronometer.setFormat("00:00:01"); | |
| 192 | + fragment.binding.chronometer.setBase(SystemClock.elapsedRealtime()); | |
| 193 | + } | |
| 194 | + } | |
| 195 | + fragment.binding.chronometer.start(); | |
| 196 | + } | |
| 197 | + } | |
| 198 | + }, 10); | |
| 199 | + //开启计步服务 | |
| 200 | + startStepService(getContext(), uid); | |
| 201 | + } | |
| 202 | + | |
| 203 | + //设置继续按钮,缩放效果 | |
| 204 | + fragment.binding.flContinue.setOnTouchListener(new View.OnTouchListener() { | |
| 205 | + @Override | |
| 206 | + public boolean onTouch(View view, MotionEvent motionEvent) { | |
| 207 | + //避免两个按钮事件同时响应 | |
| 208 | + if (stopStartFlag) { | |
| 209 | + return false; | |
| 210 | + } | |
| 211 | + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { | |
| 212 | + if (!continueStartFlag) { | |
| 213 | + ButtonAnimUtil.setViewZoomIn(fragment.binding.flContinue); | |
| 214 | + continueStartFlag = true; | |
| 215 | + | |
| 216 | + } | |
| 217 | + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { | |
| 218 | + ButtonAnimUtil.setViewZoomOut(fragment.binding.flContinue); | |
| 219 | + continueStartFlag = false; | |
| 220 | + } | |
| 221 | + return false; | |
| 222 | + } | |
| 223 | + }); | |
| 224 | + //设置继续按钮点击事件 | |
| 225 | + fragment.binding.flContinue.setOnClickListener(new View.OnClickListener() { | |
| 226 | + @Override | |
| 227 | + public void onClick(View view) { | |
| 228 | + //继续记录轨迹 | |
| 229 | + if (StepService.mClient != null && StepService.traceListener != null) { | |
| 230 | + StepService.mClient.startTrace(StepService.mTrace, StepService.traceListener); | |
| 231 | + } | |
| 232 | + needWriteDataFlag = true; | |
| 233 | + //将当前计时器时间戳写入数据库 | |
| 234 | + setSQLPauseTime(uid); | |
| 235 | + //为了点击时可以显示缩放动画,这里延迟一个动画时间进行(包括放大和缩小) | |
| 236 | + handler.postDelayed(new Runnable() { | |
| 237 | + @Override | |
| 238 | + public void run() { | |
| 239 | + // | |
| 240 | + //隐藏两个按钮 | |
| 241 | + fragment.binding.flStopTip.setVisibility(View.INVISIBLE); | |
| 242 | + fragment.binding.llTwoBottomButton.setVisibility(View.GONE); | |
| 243 | + ButtonAnimUtil.setViewShowZoomIn(fragment.binding.llPause); | |
| 244 | + //显示暂停按钮 | |
| 245 | + fragment.binding.llPause.setVisibility(View.VISIBLE); | |
| 246 | + // | |
| 247 | + } | |
| 248 | + }, ButtonAnimUtil.DEFAULT_ZOOM_DURATION * 2); | |
| 249 | + //继续计步 | |
| 250 | + EventBus.getDefault().post(new MessageEvent(Constant.SERVICE_STEP_COUNT_CONTINUE, "")); | |
| 251 | + //开始计时 | |
| 252 | + if (!firstTimeFlag) { | |
| 253 | + fragment.binding.chronometer.setBase(fragment.binding.chronometer.getBase() + (SystemClock.elapsedRealtime() - mRecordTime)); | |
| 254 | + } | |
| 255 | + fragment.binding.chronometer.start(); | |
| 256 | + | |
| 257 | + | |
| 258 | + } | |
| 259 | + }); | |
| 260 | + //设置停止按钮缩放特效 | |
| 261 | + fragment.binding.flStop.setOnTouchListener(new View.OnTouchListener() { | |
| 262 | + @Override | |
| 263 | + public boolean onTouch(View view, MotionEvent motionEvent) { | |
| 264 | + //避免两个按钮事件同时响应 | |
| 265 | + if (continueStartFlag) { | |
| 266 | + return false; | |
| 267 | + } | |
| 268 | + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { | |
| 269 | + if (!stopStartFlag) { | |
| 270 | + fragment.binding.cpCurrent.setProgress(0); | |
| 271 | + fragment.binding.cpCurrent.setMax(100); | |
| 272 | + fragment.binding.cpCurrent.setCircleWidth(5); | |
| 273 | + fragment.binding.cpCurrent.setBackgroundColor(getContext().getResources().getColor(R.color.circle_stop)); | |
| 274 | + fragment.binding.cpCurrent.setVisibility(View.VISIBLE); | |
| 275 | + | |
| 276 | + ButtonAnimUtil.setViewZoomIn(fragment.binding.flStop); | |
| 277 | + stopStartFlag = true; | |
| 278 | + animRunnable = new Runnable() { | |
| 279 | + @Override | |
| 280 | + public void run() { | |
| 281 | + if (stopStartFlag) { | |
| 282 | + stopIndex += 5; | |
| 283 | + if (stopIndex <= 100) { | |
| 284 | + handler.postDelayed(animRunnable, 20); | |
| 285 | + fragment.binding.cpCurrent.setProgress(stopIndex); | |
| 286 | + fragment.binding.flStopTip.setVisibility(View.VISIBLE); | |
| 287 | + if (stopIndex == 100) { | |
| 288 | + // | |
| 289 | + fragment.binding.flStopTip.setVisibility(View.INVISIBLE); | |
| 290 | + | |
| 291 | + | |
| 292 | + SelectDialog selectDialog = new SelectDialog(fragment.getActivity(), "确定结束运动吗?", "确定", new SelectDialog.DialogInterface() { | |
| 293 | + @Override | |
| 294 | + public void onClick(SelectDialog dialog) { | |
| 295 | + CommonInfo.setIsWriteUserStep(getContext(), false); | |
| 296 | + fragment.binding.cpCurrent.setVisibility(View.GONE); | |
| 297 | + ButtonAnimUtil.setViewDefault(fragment.binding.flStop); | |
| 298 | + //清空数据 | |
| 299 | + CommonInfo.reset(getContext()); | |
| 300 | + dialog.dismiss(); | |
| 301 | + if (StepService.mClient != null) { | |
| 302 | + StepService.mClient.stopGather(StepService.traceListener); | |
| 303 | + } | |
| 304 | + fragment.getActivity().stopService(new Intent(fragment.getActivity(), StepService.class)); | |
| 305 | + RunningFinishBean runningFinishBean = new RunningFinishBean(); | |
| 306 | + runningFinishBean.setStartPoint("开始地点"); | |
| 307 | + runningFinishBean.setEndPoint("结束地点"); | |
| 308 | + runningFinishBean.setRunDistance(fragment.binding.tvRunDistance.getText().toString()); | |
| 309 | + runningFinishBean.setSpeed(fragment.binding.tvSpeed.getText().toString()); | |
| 310 | + runningFinishBean.setStep(fragment.binding.tvStepCount.getText().toString()); | |
| 311 | + runningFinishBean.setTime(fragment.binding.chronometer.getText().toString()); | |
| 312 | + runningFinishBean.setDate(TimeUtil.getFormatNowTime()); | |
| 313 | + RunningFinishActivity.startActivity(fragment.getActivity(), runningFinishBean); | |
| 314 | + fragment.getActivity().finish(); | |
| 315 | + } | |
| 316 | + }, "取消", new SelectDialog.DialogInterface() { | |
| 317 | + @Override | |
| 318 | + public void onClick(SelectDialog dialog) { | |
| 319 | + fragment.binding.cpCurrent.setVisibility(View.GONE); | |
| 320 | + ButtonAnimUtil.setViewDefault(fragment.binding.flStop); | |
| 321 | + dialog.cancel(); | |
| 322 | + } | |
| 323 | + }); | |
| 324 | + selectDialog.setCancelable(false); | |
| 325 | + selectDialog.setCanceledOnTouchOutside(false); | |
| 326 | + selectDialog.show(); | |
| 327 | + // | |
| 328 | + } | |
| 329 | + } | |
| 330 | + } | |
| 331 | + } | |
| 332 | + }; | |
| 333 | + handler.postDelayed(animRunnable, 20); | |
| 334 | + | |
| 335 | + } | |
| 336 | + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { | |
| 337 | + ButtonAnimUtil.setViewZoomOut(fragment.binding.flStop); | |
| 338 | + stopStartFlag = false; | |
| 339 | + fragment.binding.cpCurrent.setVisibility(View.GONE); | |
| 340 | + stopIndex = 0; | |
| 341 | + } | |
| 342 | + return true; | |
| 343 | + } | |
| 344 | + }); | |
| 345 | + //设置暂停按钮,缩放效果 | |
| 346 | + fragment.binding.flPause.setOnTouchListener(new View.OnTouchListener() { | |
| 347 | + @Override | |
| 348 | + public boolean onTouch(View view, MotionEvent motionEvent) { | |
| 349 | + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { | |
| 350 | + if (!pauseStartFlag) { | |
| 351 | + ButtonAnimUtil.setViewZoomIn(fragment.binding.flPause); | |
| 352 | + pauseStartFlag = true; | |
| 353 | + | |
| 354 | + } | |
| 355 | + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { | |
| 356 | + ButtonAnimUtil.setViewZoomOut(fragment.binding.flPause); | |
| 357 | + pauseStartFlag = false; | |
| 358 | + } | |
| 359 | + return false; | |
| 360 | + } | |
| 361 | + }); | |
| 362 | + //设置暂停按钮点击事件 | |
| 363 | + fragment.binding.flPause.setOnClickListener(new View.OnClickListener() { | |
| 364 | + @Override | |
| 365 | + public void onClick(View view) { | |
| 366 | + //暂停轨迹记录 | |
| 367 | + if (StepService.mClient != null && StepService.traceListener != null) { | |
| 368 | + StepService.mClient.stopGather(StepService.traceListener); | |
| 369 | + } | |
| 370 | + //将当前计时器时间戳写入数据库 | |
| 371 | + setSQLPauseTime(uid); | |
| 372 | + needWriteDataFlag = false; | |
| 373 | + ButtonAnimUtil.setViewHideZoomOut(fragment.binding.llPause); | |
| 374 | + handler.postDelayed(new Runnable() { | |
| 375 | + @Override | |
| 376 | + public void run() { | |
| 377 | + //隐藏本身 | |
| 378 | + fragment.binding.llPause.setVisibility(View.GONE); | |
| 379 | + } | |
| 380 | + }, ButtonAnimUtil.HIDE_VIEW_ZOOM_DURATION); | |
| 381 | + //显示继续按钮 | |
| 382 | + fragment.binding.llTwoBottomButton.setVisibility(View.VISIBLE); | |
| 383 | + ButtonAnimUtil.setViewShowZoomIn(fragment.binding.flContinue); | |
| 384 | + ButtonAnimUtil.setViewShowZoomIn(fragment.binding.flStop); | |
| 385 | + //停止计时 | |
| 386 | + fragment.binding.chronometer.stop(); | |
| 387 | + mRecordTime = SystemClock.elapsedRealtime(); | |
| 388 | + //暂停计步 | |
| 389 | + EventBus.getDefault().post(new MessageEvent(Constant.SERVICE_STEP_COUNT_PAUSE, "")); | |
| 390 | + //重置速度 | |
| 391 | +// resetSpeed(); | |
| 392 | + } | |
| 393 | + }); | |
| 394 | + //gps点击事件 | |
| 395 | + fragment.binding.rlGps.setOnClickListener(new View.OnClickListener() { | |
| 396 | + @Override | |
| 397 | + public void onClick(View view) { | |
| 398 | + RunningMapBean runningMapBean = new RunningMapBean(); | |
| 399 | + runningMapBean.setTimeBase(fragment.binding.chronometer.getBase()); | |
| 400 | + //判断用户是否点击暂停按钮 | |
| 401 | + if (needWriteDataFlag) { | |
| 402 | + runningMapBean.setPause(false); | |
| 403 | + runningMapBean.setRecordTime(SystemClock.elapsedRealtime()); | |
| 404 | + } | |
| 405 | + //点击暂停 | |
| 406 | + else { | |
| 407 | + runningMapBean.setPause(true); | |
| 408 | + runningMapBean.setPauseShowTime(fragment.binding.chronometer.getText().toString()); | |
| 409 | + runningMapBean.setRecordTime(mRecordTime); | |
| 410 | + } | |
| 411 | + runningMapBean.setDistance(fragment.binding.tvRunDistance.getText().toString()); | |
| 412 | + runningMapBean.setCurrentSpeed(fragment.binding.tvSpeed.getText().toString()); | |
| 413 | + RunningMapActivity.startActivity(fragment.getActivity(), runningMapBean); | |
| 414 | + } | |
| 415 | + }); | |
| 416 | + | |
| 417 | + fragment.binding.rlClose.setOnClickListener(new View.OnClickListener() { | |
| 418 | + @Override | |
| 419 | + public void onClick(View view) { | |
| 420 | + fragment.getActivity().finish(); | |
| 421 | + } | |
| 422 | + }); | |
| 423 | + } | |
| 424 | + | |
| 425 | + public void setSQLPauseTime(String id) { | |
| 426 | + if (needWriteDataFlag) { | |
| 427 | + //将当前计时器时间戳写入数据库 | |
| 428 | +// String id = MySpHelper.getInstance(getContext(), Context.MODE_MULTI_PROCESS).getString("userId", ""); | |
| 429 | + if (!TextUtils.isEmpty(id)) { | |
| 430 | + UserStepEntity userStepEntity = StepUtil.getUserStepData(fragment.getActivity(), uid); | |
| 431 | + if (userStepEntity != null) { | |
| 432 | + userStepEntity.setPauseTimeStamp(fragment.binding.chronometer.getBase()); | |
| 433 | + //设置当前暂停的时间戳 | |
| 434 | + userStepEntity.setRecordTime(SystemClock.elapsedRealtime()); | |
| 435 | + //更新数据 | |
| 436 | + StepUtil.updateStepData(fragment.getActivity(), userStepEntity); | |
| 437 | + } | |
| 438 | + } | |
| 439 | + } | |
| 440 | + } | |
| 441 | + | |
| 442 | + /** | |
| 443 | + * 启动计步服务 | |
| 444 | + * | |
| 445 | + * @param userId | |
| 446 | + */ | |
| 447 | + public void startStepService(Context context, String userId) { | |
| 448 | + if (CommonInfo.getStepStartTime(context) == 0) { | |
| 449 | + CommonInfo.setStepStartTime(context, TimeUtil.getNowTimeStamp()); | |
| 450 | + } | |
| 451 | + Intent intent = new Intent(fragment.getActivity(), StepService.class); | |
| 452 | + intent.putExtra("userId", userId); | |
| 453 | + ContextCompat.startForegroundService(fragment.getActivity(), intent); | |
| 454 | + | |
| 455 | + } | |
| 456 | + | |
| 457 | + /** | |
| 458 | + * 更新行走距离 | |
| 459 | + * | |
| 460 | + * @param step | |
| 461 | + */ | |
| 462 | + public void updateRunDistance(int step) { | |
| 463 | + //设置行走公里 | |
| 464 | + fragment.binding.tvRunDistance.setText(StepUtil.getWalkDistanceKM(step) + ""); | |
| 465 | + //设置行走步数 | |
| 466 | + fragment.binding.tvStepCount.setText(step + ""); | |
| 467 | + //设置S速度 | |
| 468 | + int second = (int) ((SystemClock.elapsedRealtime() - fragment.binding.chronometer.getBase()) / 1000); | |
| 469 | + if (second != 0) { | |
| 470 | +// fragment.binding.tvSpeed.setText(StepUtil.getCurrentSpeed(second, StepUtil.getWalkDistanceKM(step) * 1000)+""); | |
| 471 | + fragment.binding.tvSpeed.setText(StepUtil.getPaceSpeed(second, StepUtil.getWalkDistanceKM(step))); | |
| 472 | + } else { | |
| 473 | + fragment.binding.tvSpeed.setText("--"); | |
| 474 | + | |
| 475 | + } | |
| 476 | + } | |
| 477 | + | |
| 478 | + public void resetSpeed() { | |
| 479 | + fragment.binding.tvSpeed.setText("--"); | |
| 480 | + } | |
| 481 | + | |
| 482 | + | |
| 483 | + /** | |
| 484 | + * //设置定位监听器,获取到用户当前位置 杨帅 | |
| 485 | + * 定位SDK监听函数 | |
| 486 | + */ | |
| 487 | + public class MyLocationListenner extends BDAbstractLocationListener { | |
| 488 | + | |
| 489 | + | |
| 490 | + @Override | |
| 491 | + public void onReceiveLocation(BDLocation location) { | |
| 492 | + if (location == null) { | |
| 493 | + return; | |
| 494 | + } | |
| 495 | + //正在搜索GPS信号 | |
| 496 | + if (location.getGpsAccuracyStatus() == BDLocation.GPS_ACCURACY_UNKNOWN) { | |
| 497 | + if (!getContext().getString(R.string.loc_gps_accuracy_unknown).equals(fragment.binding.tvLookTrace.getText().toString())) { | |
| 498 | + fragment.binding.tvLookTrace.setText(getContext().getString(R.string.loc_gps_accuracy_unknown)); | |
| 499 | + fragment.binding.tvLookTrace.setTextColor(getContext().getResources().getColor(R.color.red)); | |
| 500 | + } | |
| 501 | + if (fragment.binding.tvLookTrace.getVisibility() != View.VISIBLE) { | |
| 502 | + fragment.binding.tvLookTrace.setVisibility(View.VISIBLE); | |
| 503 | + } | |
| 504 | + if (fragment.binding.ivGps.getTag() == null || !fragment.binding.ivGps.getTag().toString().equals("rt_training_gps_0")) { | |
| 505 | + fragment.binding.ivGps.setTag("rt_training_gps_0"); | |
| 506 | + //设置图标 | |
| 507 | + fragment.binding.ivGps.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_0)); | |
| 508 | + } | |
| 509 | + | |
| 510 | + | |
| 511 | + } | |
| 512 | + //GPS 质量判断差 | |
| 513 | + else if (location.getGpsAccuracyStatus() == BDLocation.GPS_ACCURACY_BAD) { | |
| 514 | + if (!getContext().getString(R.string.loc_gps_accuracy_bad).equals(fragment.binding.tvLookTrace.getText().toString())) { | |
| 515 | + fragment.binding.tvLookTrace.setText(getContext().getString(R.string.loc_gps_accuracy_bad)); | |
| 516 | + fragment.binding.tvLookTrace.setTextColor(getContext().getResources().getColor(R.color.text_gray99)); | |
| 517 | + | |
| 518 | + } | |
| 519 | + if (fragment.binding.tvLookTrace.getVisibility() != View.VISIBLE) { | |
| 520 | + fragment.binding.tvLookTrace.setVisibility(View.VISIBLE); | |
| 521 | + } | |
| 522 | + if (fragment.binding.ivGps.getTag() == null || !fragment.binding.ivGps.getTag().toString().equals("GPS_ACCURACY_BAD")) { | |
| 523 | + fragment.binding.ivGps.setTag("GPS_ACCURACY_BAD"); | |
| 524 | + //设置图标 | |
| 525 | + fragment.binding.ivGps.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_1)); | |
| 526 | + } | |
| 527 | + } | |
| 528 | + //GPS 质量判断中等 | |
| 529 | + else if (location.getGpsAccuracyStatus() == BDLocation.GPS_ACCURACY_MID) { | |
| 530 | + if (fragment.binding.tvLookTrace.getVisibility() == View.VISIBLE) { | |
| 531 | + fragment.binding.tvLookTrace.setVisibility(View.GONE); | |
| 532 | + } | |
| 533 | + if (fragment.binding.ivGps.getTag() == null || !fragment.binding.ivGps.getTag().toString().equals("GPS_ACCURACY_MID")) { | |
| 534 | + fragment.binding.ivGps.setTag("GPS_ACCURACY_MID"); | |
| 535 | + //设置图标 | |
| 536 | + fragment.binding.ivGps.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_2)); | |
| 537 | + } | |
| 538 | + }//GPS 质量判断好 | |
| 539 | + else if (location.getGpsAccuracyStatus() == BDLocation.GPS_ACCURACY_GOOD) { | |
| 540 | + if (fragment.binding.tvLookTrace.getVisibility() == View.VISIBLE) { | |
| 541 | + fragment.binding.tvLookTrace.setVisibility(View.GONE); | |
| 542 | + } | |
| 543 | + if (fragment.binding.ivGps.getTag() == null || !fragment.binding.ivGps.getTag().toString().equals("GPS_ACCURACY_GOOD")) { | |
| 544 | + fragment.binding.ivGps.setTag("GPS_ACCURACY_GOOD"); | |
| 545 | + //设置图标 | |
| 546 | + fragment.binding.ivGps.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_3)); | |
| 547 | + } | |
| 548 | + } | |
| 549 | + } | |
| 550 | + } | |
| 551 | + | |
| 552 | + public void onDestroy() { | |
| 553 | + if (mLocClient != null) { | |
| 554 | + mLocClient.stop(); | |
| 555 | + } | |
| 556 | + } | |
| 557 | +} | |
| 558 | + | |
| 559 | + | |
| 560 | + | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunRaceDetailFragmentView.java
0 → 100644
| 1 | +package com.cnlive.moudle.collectionTrace.frame.view; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.content.Intent; | |
| 5 | +import android.graphics.Bitmap; | |
| 6 | +import android.graphics.BitmapFactory; | |
| 7 | +import android.hardware.Sensor; | |
| 8 | +import android.hardware.SensorEvent; | |
| 9 | +import android.hardware.SensorEventListener; | |
| 10 | +import android.hardware.SensorManager; | |
| 11 | +import android.text.TextUtils; | |
| 12 | +import android.util.Log; | |
| 13 | +import android.view.View; | |
| 14 | +import android.widget.LinearLayout; | |
| 15 | +import android.widget.Toast; | |
| 16 | + | |
| 17 | +import com.baidu.location.BDAbstractLocationListener; | |
| 18 | +import com.baidu.location.BDLocation; | |
| 19 | +import com.baidu.location.LocationClient; | |
| 20 | +import com.baidu.location.LocationClientOption; | |
| 21 | +import com.baidu.mapapi.map.BaiduMap; | |
| 22 | +import com.baidu.mapapi.map.BitmapDescriptor; | |
| 23 | +import com.baidu.mapapi.map.BitmapDescriptorFactory; | |
| 24 | +import com.baidu.mapapi.map.MapStatus; | |
| 25 | +import com.baidu.mapapi.map.MapStatusUpdateFactory; | |
| 26 | +import com.baidu.mapapi.map.MapView; | |
| 27 | +import com.baidu.mapapi.map.MarkerOptions; | |
| 28 | +import com.baidu.mapapi.map.MyLocationConfiguration; | |
| 29 | +import com.baidu.mapapi.map.MyLocationData; | |
| 30 | +import com.baidu.mapapi.map.Overlay; | |
| 31 | +import com.baidu.mapapi.map.OverlayOptions; | |
| 32 | +import com.baidu.mapapi.map.PolylineOptions; | |
| 33 | +import com.baidu.mapapi.map.UiSettings; | |
| 34 | +import com.baidu.mapapi.model.LatLng; | |
| 35 | +import com.baidu.mapapi.search.core.SearchResult; | |
| 36 | +import com.baidu.mapapi.search.route.BikingRouteResult; | |
| 37 | +import com.baidu.mapapi.search.route.DrivingRouteResult; | |
| 38 | +import com.baidu.mapapi.search.route.IndoorRouteResult; | |
| 39 | +import com.baidu.mapapi.search.route.MassTransitRouteResult; | |
| 40 | +import com.baidu.mapapi.search.route.OnGetRoutePlanResultListener; | |
| 41 | +import com.baidu.mapapi.search.route.PlanNode; | |
| 42 | +import com.baidu.mapapi.search.route.RoutePlanSearch; | |
| 43 | +import com.baidu.mapapi.search.route.TransitRouteResult; | |
| 44 | +import com.baidu.mapapi.search.route.WalkingRoutePlanOption; | |
| 45 | +import com.baidu.mapapi.search.route.WalkingRouteResult; | |
| 46 | +import com.baidu.mapapi.utils.DistanceUtil; | |
| 47 | +import com.baidu.trace.model.SortType; | |
| 48 | +import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunRaceDetailFragment; | |
| 49 | +import com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity; | |
| 50 | +import com.cnlive.moudle.pedometer.ui.activity.RaceRecordActivity; | |
| 51 | +import com.cnlive.moudle.pedometer.ui.activity.RegistrationInfoActivity; | |
| 52 | +import com.cnlive.moudle.pedometer.ui.activity.TakePartActivity; | |
| 53 | +import com.cnlive.moudle.pedometer.ui.fragment.RunRaceDetailFragment; | |
| 54 | +import com.cnlive.moudle.pedometer.ui.widget.TipDialog; | |
| 55 | +import com.cnlive.moudle.pedometer.utils.BitmapUtil; | |
| 56 | +import com.cnlive.moudle.pedometer.utils.GsonUtil; | |
| 57 | +import com.cnlive.moudle.pedometer.utils.MyMapUtil; | |
| 58 | +import com.cnlive.moudle.pedometer.utils.ScreenUtil; | |
| 59 | +import com.cnlive.moudle.pedometer.utils.TimeUtil; | |
| 60 | +import com.cnlive.strike.application.GlideApp; | |
| 61 | +import com.cnlive.strike.data.network.model.runAbout.RunRaceDetailInfo; | |
| 62 | +import com.example.moudle_pedometer.R; | |
| 63 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | |
| 64 | +import com.sothree.slidinguppanel.SlidingUpPanelLayout; | |
| 65 | + | |
| 66 | +import java.util.ArrayList; | |
| 67 | +import java.util.LinkedList; | |
| 68 | +import java.util.List; | |
| 69 | + | |
| 70 | +public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListener { | |
| 71 | + private static final String TAG = "RunRaceDetailView"; | |
| 72 | + | |
| 73 | + private CollRunRaceDetailFragment fragment; | |
| 74 | + private BaiduMap baiduMap; | |
| 75 | + private MapView mMapView; | |
| 76 | + private UiSettings mUiSettings; | |
| 77 | + private MyLocationConfiguration.LocationMode mCurrentMode;//定位模式 | |
| 78 | + private BitmapDescriptor mCurrentMarker;//定位图标 | |
| 79 | + private static int accuracyCircleFillColor; | |
| 80 | + private static int accuracyCircleStrokeColor; | |
| 81 | + private static MyLocationData followMyLocation; | |
| 82 | + boolean isFirstLoc = true; // 是否首次定位 | |
| 83 | + private MarkerOptions currentMark; | |
| 84 | + private MarkerOptions endMark; | |
| 85 | + private MarkerOptions startMark; | |
| 86 | + | |
| 87 | + private LatLng firstLatLng; | |
| 88 | + private Double lastX = 0.0; | |
| 89 | + private int mCurrentDirection = 0; | |
| 90 | + // private double mCurrentLat = 0.0; | |
| 91 | +// private double mCurrentLon = 0.0; | |
| 92 | + private float mCurrentAccracy; | |
| 93 | + // 定位相关 | |
| 94 | + private LocationClient mLocClient; | |
| 95 | + public MyLocationListenner myListener = new MyLocationListenner(); | |
| 96 | + private final int DEFULT_ZOOM = 17; | |
| 97 | + private RoutePlanSearch routePlanSearch = null; // 路线规划 | |
| 98 | + private LatLng endLatLng; | |
| 99 | + private final int START_MARK = 0;//起始点 | |
| 100 | + private final int END_MARK = 1;//终止点 | |
| 101 | + | |
| 102 | + private String startPoint = "首都师范大学南门"; | |
| 103 | + private String endPoint = "首都师范大学篮球场"; | |
| 104 | + 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}]"; | |
| 105 | + private LinkedList<LatLng> importLatLngs;//关键点 | |
| 106 | + private LatLng startLatLng = new LatLng(39.934733, 116.308646);//起始点 | |
| 107 | + private List<LatLng> trackPoints; | |
| 108 | + private RunRaceDetailInfo runRaceDetailInfo; | |
| 109 | + | |
| 110 | + public CollRunRaceDetailFragmentView(CollRunRaceDetailFragment fragment) { | |
| 111 | + this.fragment = fragment; | |
| 112 | + } | |
| 113 | + | |
| 114 | + public Context getContext() { | |
| 115 | + return fragment == null ? null : fragment.getActivity(); | |
| 116 | + } | |
| 117 | + | |
| 118 | + | |
| 119 | + public void initView(RunRaceDetailInfo runRaceDetailInfo) { | |
| 120 | + if (fragment.getActivity() == null) { | |
| 121 | + return; | |
| 122 | + } | |
| 123 | + this.runRaceDetailInfo = runRaceDetailInfo; | |
| 124 | +// //初始化地图点位 | |
| 125 | + if (runRaceDetailInfo.getLatLongitude() != null) { | |
| 126 | + Log.e(TAG, "initView: 长度:" + runRaceDetailInfo.getLatLongitude().length()); | |
| 127 | + trackPoints = GsonUtil.jsonToList(runRaceDetailInfo.getLatLongitude(), LatLng.class); | |
| 128 | + Log.e(TAG, "initView: trackPoints" + trackPoints.size()); | |
| 129 | + MyMapUtil.drawServerLineTrack(getContext(), baiduMap, trackPoints, SortType.asc, R.color.green_round, R.drawable.icon_start, R.drawable.icon_end); | |
| 130 | + //自动计算地图缩放 | |
| 131 | + MapStatus.Builder builder = new MapStatus.Builder(); | |
| 132 | + builder.target(MyMapUtil.getCenterZoomPosition(trackPoints)); | |
| 133 | + builder.zoom(MyMapUtil.getZoom(trackPoints)); | |
| 134 | + baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); | |
| 135 | + } | |
| 136 | + | |
| 137 | + //显示地图 | |
| 138 | + fragment.binding.mapView.setVisibility(View.VISIBLE); | |
| 139 | + //隐藏底部滑动卡片 | |
| 140 | + fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); | |
| 141 | + //隐藏空视图 | |
| 142 | + fragment.binding.emptyLayout.setVisibility(View.GONE); | |
| 143 | + //显示立即报名按钮 | |
| 144 | + fragment.binding.includeStreet.rlStartBtn.setVisibility(View.VISIBLE); | |
| 145 | + //设置底部卡片第一次可滑动的位置 | |
| 146 | + fragment.binding.slidingLayout.setAnchorPoint(0.6f); | |
| 147 | + fragment.binding.slidingLayout.addPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() { | |
| 148 | + @Override | |
| 149 | + public void onPanelSlide(View panel, float slideOffset) { | |
| 150 | + if (slideOffset >= 0 && slideOffset <= 1) { | |
| 151 | + int leakWidth = (int) (ScreenUtil.dip2px(getContext(), 15) / 0.6); | |
| 152 | + LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); | |
| 153 | + int current = (int) (leakWidth * slideOffset); | |
| 154 | +// Log.e(TAG, "current: " + current + ",leakWidth:" + leakWidth + ",ScreenUtil:" + ScreenUtil.dip2px(getContext(), 15)); | |
| 155 | + if (slideOffset == 0) { | |
| 156 | + layoutParams.setMargins(ScreenUtil.dip2px(getContext(), 15), 0, ScreenUtil.dip2px(getContext(), 15), 0); | |
| 157 | + fragment.binding.includeStreet.llFirstPanelRoot.setLayoutParams(layoutParams); | |
| 158 | + fragment.binding.includeStreet.llBottomPanel.setLayoutParams(layoutParams); | |
| 159 | + } | |
| 160 | + if (leakWidth - ScreenUtil.dip2px(getContext(), current) <= ScreenUtil.dip2px(getContext(), 15)) { | |
| 161 | + if (leakWidth - ScreenUtil.dip2px(getContext(), current) >= 0) { | |
| 162 | + layoutParams.setMargins(leakWidth - ScreenUtil.dip2px(getContext(), current), 0, leakWidth - ScreenUtil.dip2px(getContext(), current), 0); | |
| 163 | + } else { | |
| 164 | + layoutParams.setMargins(0, 0, 0, 0); | |
| 165 | + } | |
| 166 | + | |
| 167 | + fragment.binding.includeStreet.llFirstPanelRoot.setLayoutParams(layoutParams); | |
| 168 | + fragment.binding.includeStreet.llBottomPanel.setLayoutParams(layoutParams); | |
| 169 | + } | |
| 170 | + | |
| 171 | + } | |
| 172 | + | |
| 173 | + if (slideOffset == 0) { | |
| 174 | + //在初始位置 | |
| 175 | + if (fragment.binding.includeStreet.rlStartBtn.getVisibility() == View.GONE) { | |
| 176 | + fragment.binding.includeStreet.rlStartBtn.setVisibility(View.VISIBLE); | |
| 177 | + } | |
| 178 | + | |
| 179 | + } else { | |
| 180 | + //用户进行滑动 | |
| 181 | + if (fragment.binding.includeStreet.rlStartBtn.getVisibility() == View.VISIBLE) { | |
| 182 | + fragment.binding.includeStreet.rlStartBtn.setVisibility(View.GONE); | |
| 183 | + } | |
| 184 | + } | |
| 185 | + } | |
| 186 | + | |
| 187 | + @Override | |
| 188 | + public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) { | |
| 189 | + } | |
| 190 | + }); | |
| 191 | + /*************************设置相关页面数据***************************/ | |
| 192 | + //设置标题 | |
| 193 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getTitle())) { | |
| 194 | + fragment.binding.includeStreet.tvRaceTitle.setText(runRaceDetailInfo.getTitle()); | |
| 195 | + } | |
| 196 | + //设置活动地点 | |
| 197 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getAddress())) { | |
| 198 | + fragment.binding.includeStreet.tvAddress.setText(runRaceDetailInfo.getAddress()); | |
| 199 | + } | |
| 200 | + //设置活动距离 | |
| 201 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getMileage())) { | |
| 202 | + fragment.binding.includeStreet.tvMileage.setText(runRaceDetailInfo.getMileage()); | |
| 203 | + } | |
| 204 | + //设置起点 | |
| 205 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getStartLocation())) { | |
| 206 | + fragment.binding.includeStreet.tvStartAddr.setText(runRaceDetailInfo.getStartLocation()); | |
| 207 | + } | |
| 208 | + //设置终点 | |
| 209 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getEndLocation())) { | |
| 210 | + fragment.binding.includeStreet.tvEndAddr.setText(runRaceDetailInfo.getEndLocation()); | |
| 211 | + } | |
| 212 | + //设置起始报名时间 | |
| 213 | + if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_start_time(), "yyyy-MM-dd"))) { | |
| 214 | + fragment.binding.includeStreet.tvSignUpStartTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_start_time(), "yyyy-MM-dd")); | |
| 215 | + | |
| 216 | + } | |
| 217 | + //设置终止报名时间 | |
| 218 | + if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_end_time(), "yyyy-MM-dd"))) { | |
| 219 | + fragment.binding.includeStreet.tvSignUpEndTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_end_time(), "yyyy-MM-dd")); | |
| 220 | + } | |
| 221 | + //设置活动开始时间 | |
| 222 | + if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getStart_time(), "yyyy-MM-dd"))) { | |
| 223 | + fragment.binding.includeStreet.tvActiveStartTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getStart_time(), "yyyy-MM-dd")); | |
| 224 | + } | |
| 225 | + //设置活动结束时间 | |
| 226 | + if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getEnd_time(), "yyyy-MM-dd"))) { | |
| 227 | + fragment.binding.includeStreet.tvActiveEndTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getEnd_time(), "yyyy-MM-dd")); | |
| 228 | + } | |
| 229 | + //设置参加人数 | |
| 230 | + fragment.binding.includeStreet.tvSignPerson.setText(runRaceDetailInfo.getSignupNum() + ""); | |
| 231 | + //设置报名完成的头像 | |
| 232 | + List<String> joinFaceIcon = runRaceDetailInfo.getFaceUrl(); | |
| 233 | + if (joinFaceIcon != null && joinFaceIcon.size() > 0) { | |
| 234 | + fragment.binding.includeStreet.fiveJoinPerson.setVisibility(View.VISIBLE); | |
| 235 | + //设置头像数据 | |
| 236 | + fragment.binding.includeStreet.fiveJoinPerson.initIconData(joinFaceIcon); | |
| 237 | + } else { | |
| 238 | + fragment.binding.includeStreet.fiveJoinPerson.setVisibility(View.INVISIBLE); | |
| 239 | + } | |
| 240 | + | |
| 241 | + //判断是否显示个人排行榜 | |
| 242 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getUserMileage())) { | |
| 243 | + //显示 | |
| 244 | + fragment.binding.includePersonScore.llPersonScoreRoot.setVisibility(View.VISIBLE); | |
| 245 | + //设置个人行走距离 | |
| 246 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getUserMileage())) { | |
| 247 | + fragment.binding.includePersonScore.tvUserDistance.setText(runRaceDetailInfo.getUserMileage()); | |
| 248 | + } | |
| 249 | + //设置行走步数 | |
| 250 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getStep())) { | |
| 251 | + fragment.binding.includePersonScore.tvStep.setText(runRaceDetailInfo.getStep()); | |
| 252 | + } | |
| 253 | + //设置用时 | |
| 254 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getEmployTime())) { | |
| 255 | + fragment.binding.includePersonScore.tvEmployTime.setText(runRaceDetailInfo.getEmployTime()); | |
| 256 | + } | |
| 257 | + //设置配速 | |
| 258 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getPace())) { | |
| 259 | + fragment.binding.includePersonScore.tvSpeed.setText(runRaceDetailInfo.getPace()); | |
| 260 | + } | |
| 261 | + } else { | |
| 262 | + //隐藏 | |
| 263 | + fragment.binding.includePersonScore.llPersonScoreRoot.setVisibility(View.GONE); | |
| 264 | + } | |
| 265 | + //设置是否显示排行榜 | |
| 266 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getFirstFaceUrl())) { | |
| 267 | + fragment.binding.includeRank.llRankRoot.setVisibility(View.VISIBLE); | |
| 268 | + //设置第一名头像 | |
| 269 | + GlideApp.with(getContext()).load(runRaceDetailInfo.getFirstFaceUrl()).into(fragment.binding.includeRank.ivFirstPersonUrl); | |
| 270 | + //设置排行榜头像 | |
| 271 | + List<String> finishFaceUrl = runRaceDetailInfo.getFinishFaceUrl(); | |
| 272 | + if (finishFaceUrl != null && finishFaceUrl.size() > 0) { | |
| 273 | + fragment.binding.includeRank.fiveRankPerson.initIconData(finishFaceUrl); | |
| 274 | + } | |
| 275 | + //设置第一名昵称 | |
| 276 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getFirstName())) { | |
| 277 | + fragment.binding.includeRank.tvKingNickName.setText(runRaceDetailInfo.getFirstName()); | |
| 278 | + } | |
| 279 | + } else { | |
| 280 | + fragment.binding.includeRank.llRankRoot.setVisibility(View.GONE); | |
| 281 | + | |
| 282 | + } | |
| 283 | + //设置路线介绍的图片 | |
| 284 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getRoadmap())) { | |
| 285 | + //设置路线图 | |
| 286 | + GlideApp.with(getContext()).load(runRaceDetailInfo.getRoadmap()).into(fragment.binding.includeStreetIntroduce.ivRoadMao); | |
| 287 | + | |
| 288 | + } | |
| 289 | + //开始按钮点击事件(未滑动) | |
| 290 | + fragment.binding.includeStreet.rlStartBtn.setOnClickListener(new View.OnClickListener() { | |
| 291 | + @Override | |
| 292 | + public void onClick(View view) { | |
| 293 | + if (fragment.getActivity() == null) { | |
| 294 | + return; | |
| 295 | + } | |
| 296 | + //立即报名 | |
| 297 | + if ("0".equals(fragment.binding.includeStreet.rlStartBtn.getTag())) { | |
| 298 | + fragment.binding.includeStreet.rlStartBtn.setTag("1"); | |
| 299 | + fragment.binding.includeStreet.tvRunNow.setText(getContext().getResources().getString(R.string.run_race_btn_start_now)); | |
| 300 | + fragment.binding.includeStreet.tvGoTip.setVisibility(View.VISIBLE); | |
| 301 | + | |
| 302 | + //设置滑动 | |
| 303 | + fragment.binding.rlScrollViewStartBtn.setTag("1"); | |
| 304 | + fragment.binding.tvRunNow.setText(getContext().getResources().getString(R.string.run_race_btn_start_now)); | |
| 305 | + fragment.binding.tvGoTip.setVisibility(View.VISIBLE); | |
| 306 | + RegistrationInfoActivity.newInstance(fragment.getActivity(), 1001); | |
| 307 | + } else { | |
| 308 | + //计算当前位置与起点坐标距离 | |
| 309 | + if (firstLatLng != null && trackPoints != null && trackPoints.size() > 0) { | |
| 310 | + double distance = DistanceUtil.getDistance(firstLatLng, trackPoints.get(0)); | |
| 311 | + if (distance < 20) { | |
| 312 | + //开始运动 | |
| 313 | + fragment.binding.includeStreet.rlStartBtn.setTag("0"); | |
| 314 | + fragment.binding.includeStreet.tvRunNow.setText(getContext().getResources().getString(R.string.run_race_btn_sign_up)); | |
| 315 | + fragment.binding.includeStreet.tvGoTip.setVisibility(View.GONE); | |
| 316 | + fragment.getActivity().startActivity(new Intent(getContext(), PedometerMainActivity.class)); | |
| 317 | + //设置滑动 | |
| 318 | + fragment.binding.rlScrollViewStartBtn.setTag("0"); | |
| 319 | + fragment.binding.tvRunNow.setText(getContext().getResources().getString(R.string.run_race_btn_sign_up)); | |
| 320 | + fragment.binding.tvGoTip.setVisibility(View.GONE); | |
| 321 | + } else { | |
| 322 | + TipDialog tipDialog = new TipDialog(getContext(), getContext().getResources().getString(R.string.run_race_far_tip), "我知道了", R.color.green_round, new TipDialog.DialogInterface() { | |
| 323 | + @Override | |
| 324 | + public void onClick(TipDialog dialog) { | |
| 325 | + dialog.dismiss(); | |
| 326 | + } | |
| 327 | + }); | |
| 328 | + tipDialog.show(); | |
| 329 | + tipDialog.setCancelable(false); | |
| 330 | + tipDialog.setCanceledOnTouchOutside(false); | |
| 331 | + } | |
| 332 | + } | |
| 333 | + } | |
| 334 | + } | |
| 335 | + }); | |
| 336 | + //开始按钮点击事件(用户进行滑动滑动) | |
| 337 | + fragment.binding.rlScrollViewStartBtn.setOnClickListener(new View.OnClickListener() { | |
| 338 | + @Override | |
| 339 | + public void onClick(View view) { | |
| 340 | + //立即报名 | |
| 341 | + if ("0".equals(fragment.binding.rlScrollViewStartBtn.getTag())) { | |
| 342 | + fragment.binding.rlScrollViewStartBtn.setTag("1"); | |
| 343 | + fragment.binding.tvRunNow.setText("现在开始"); | |
| 344 | + fragment.binding.tvGoTip.setVisibility(View.VISIBLE); | |
| 345 | + //设置未滑动 | |
| 346 | + fragment.binding.includeStreet.rlStartBtn.setTag("1"); | |
| 347 | + fragment.binding.includeStreet.tvRunNow.setText("现在开始"); | |
| 348 | + fragment.binding.includeStreet.tvGoTip.setVisibility(View.VISIBLE); | |
| 349 | + RegistrationInfoActivity.newInstance(fragment.getActivity(), 1001); | |
| 350 | + } else { | |
| 351 | + //开始运动 | |
| 352 | + fragment.binding.rlScrollViewStartBtn.setTag("0"); | |
| 353 | + fragment.binding.tvRunNow.setText("立即报名"); | |
| 354 | + fragment.binding.tvGoTip.setVisibility(View.GONE); | |
| 355 | + fragment.getActivity().startActivity(new Intent(getContext(), PedometerMainActivity.class)); | |
| 356 | + //设置未滑动 | |
| 357 | + fragment.binding.includeStreet.rlStartBtn.setTag("0"); | |
| 358 | + fragment.binding.includeStreet.tvRunNow.setText("立即报名"); | |
| 359 | + fragment.binding.includeStreet.tvGoTip.setVisibility(View.GONE); | |
| 360 | + fragment.getActivity().startActivity(new Intent(getContext(), PedometerMainActivity.class)); | |
| 361 | + | |
| 362 | + } | |
| 363 | + } | |
| 364 | + }); | |
| 365 | + //查看全部成绩点击事件 | |
| 366 | + fragment.binding.includePersonScore.checkAllCord.setOnClickListener(v -> { | |
| 367 | + RaceRecordActivity.newInstance(fragment.getActivity()); | |
| 368 | + }); | |
| 369 | + | |
| 370 | + fragment.binding.includeStreet.fiveJoinPerson.setOnClickListener(v -> { | |
| 371 | + TakePartActivity.newInstance(fragment.getActivity()); | |
| 372 | + }); | |
| 373 | + //返回按钮 | |
| 374 | + fragment.binding.ivBack.setOnClickListener(new View.OnClickListener() { | |
| 375 | + @Override | |
| 376 | + public void onClick(View view) { | |
| 377 | + if (fragment.getActivity() == null) { | |
| 378 | + return; | |
| 379 | + } | |
| 380 | + fragment.getActivity().finish(); | |
| 381 | + } | |
| 382 | + }); | |
| 383 | + } | |
| 384 | + | |
| 385 | + public void initMap() { | |
| 386 | + List<String> icons = new ArrayList<>(); | |
| 387 | + icons.add("http://yweb0.cnliveimg.com/images/headImg/2019/0505/1557039035723_small.jpg"); | |
| 388 | + icons.add("http://yweb0.cnliveimg.com/images/headImg/2019/0505/1557034319038_small.jpg"); | |
| 389 | + icons.add("http://yweb0.cnliveimg.com/images/headImg/2018/0902/1535858459612_small.jpg"); | |
| 390 | + icons.add("http://yweb0.cnliveimg.com/images/headImg/2019/0523/1558599016203_small.jpg"); | |
| 391 | + icons.add("http://yweb0.cnliveimg.com/images/headImg/2019/0505/1557039035723_small.jpg"); | |
| 392 | + //隐藏底部滑动卡片 | |
| 393 | + fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN); | |
| 394 | + fragment.binding.includeStreet.fiveJoinPerson.initIconData(icons); | |
| 395 | + this.mMapView = fragment.binding.mapView; | |
| 396 | + if (baiduMap == null) { | |
| 397 | + baiduMap = mMapView.getMap(); | |
| 398 | + } | |
| 399 | + if (routePlanSearch == null) { | |
| 400 | + routePlanSearch = RoutePlanSearch.newInstance(); | |
| 401 | + } | |
| 402 | + if (mUiSettings == null) { | |
| 403 | + mUiSettings = baiduMap.getUiSettings(); | |
| 404 | + } | |
| 405 | + //设置定位模式, 默认为 LocationMode.NORMAL 普通态 | |
| 406 | + mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL; | |
| 407 | + // 设置定位图标修改为自定义marker | |
| 408 | + Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.rt_ic_location), 50, 50); | |
| 409 | + mCurrentMarker = BitmapDescriptorFactory.fromBitmap(pointBitmap); | |
| 410 | + //设置定位蓝点精度圆圈的填充颜色为透明色 | |
| 411 | + accuracyCircleFillColor = getContext().getResources().getColor(R.color.transparent); | |
| 412 | + //设置定位蓝点精度圆圈的边框颜色的为透明色 | |
| 413 | + accuracyCircleStrokeColor = getContext().getResources().getColor(R.color.transparent); | |
| 414 | + MyLocationConfiguration locationConfiguration = new MyLocationConfiguration(mCurrentMode, | |
| 415 | + true, mCurrentMarker, accuracyCircleFillColor, accuracyCircleStrokeColor); | |
| 416 | + //设置样式 | |
| 417 | + baiduMap.setMyLocationConfiguration(locationConfiguration); | |
| 418 | + //启动所有手势 | |
| 419 | + mUiSettings.setAllGesturesEnabled(true); | |
| 420 | + //通过设置enable为true或false 选择是否显示缩放按钮 | |
| 421 | + mMapView.showZoomControls(false); | |
| 422 | + mUiSettings.setEnlargeCenterWithDoubleClickEnable(true); | |
| 423 | + //隐藏自带的指南针,改用自定义指南针 杨帅 | |
| 424 | + baiduMap.getUiSettings().setCompassEnabled(true); | |
| 425 | + //显示定位图层 | |
| 426 | + baiduMap.setMyLocationEnabled(true); | |
| 427 | + // 定位初始化 | |
| 428 | + mLocClient = new LocationClient(getContext()); | |
| 429 | + mLocClient.registerLocationListener(myListener); | |
| 430 | + LocationClientOption option = new LocationClientOption(); | |
| 431 | + option.setOpenGps(true); // 打开gps | |
| 432 | + option.setCoorType("gcj02"); // 设置坐标类型 | |
| 433 | + //可选,默认false,设置是否开启Gps定位 | |
| 434 | + option.setOpenGps(true); | |
| 435 | + //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者,该模式下开发者无需再关心定位间隔是多少,定位SDK本身发现位置变化就会及时回调给开发者 | |
| 436 | + option.setOpenAutoNotifyMode(); | |
| 437 | + //可选,默认高精度,设置定位模式,高精度,低功耗,仅设备 | |
| 438 | + option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); | |
| 439 | + //可选,设置是否需要地址信息,默认不需要 | |
| 440 | + option.setIsNeedAddress(true); | |
| 441 | + //可选,设置是否需要地址描述 | |
| 442 | + option.setIsNeedLocationDescribe(true); | |
| 443 | + //可选,设置是否需要设备方向结果 | |
| 444 | + option.setNeedDeviceDirect(false); | |
| 445 | + //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者 | |
| 446 | + option.setOpenAutoNotifyMode(3000, 1, LocationClientOption.LOC_SENSITIVITY_HIGHT); | |
| 447 | + mLocClient.setLocOption(option); | |
| 448 | + mLocClient.start(); | |
| 449 | + //设置地图加载完毕监听 | |
| 450 | + baiduMap.setOnMapLoadedCallback(new BaiduMap.OnMapLoadedCallback() { | |
| 451 | + @Override | |
| 452 | + public void onMapLoaded() { | |
| 453 | +// | |
| 454 | + | |
| 455 | + } | |
| 456 | + }); | |
| 457 | + } | |
| 458 | + | |
| 459 | + /** | |
| 460 | + * 开始路线规划 | |
| 461 | + */ | |
| 462 | + public void searchRouteResult(LatLng StartPoint, LatLng EndPoint, int index, int listSize) { | |
| 463 | +// Log.e(TAG, "searchRouteResult: "); | |
| 464 | + float currentZoom = baiduMap.getMapStatus().zoom; | |
| 465 | + // 设置起终点信息,对于tranist search 来说,城市名无意义 | |
| 466 | + PlanNode stNode = PlanNode.withLocation(StartPoint); | |
| 467 | + PlanNode enNode = PlanNode.withLocation(EndPoint); | |
| 468 | + routePlanSearch.setOnGetRoutePlanResultListener(new OnGetRoutePlanResultListener() { | |
| 469 | + @Override | |
| 470 | + public void onGetWalkingRouteResult(WalkingRouteResult walkingRouteResult) { | |
| 471 | + if (fragment.getActivity() == null) { | |
| 472 | + return; | |
| 473 | + } | |
| 474 | + if (walkingRouteResult == null || walkingRouteResult.error != SearchResult.ERRORNO.NO_ERROR) { | |
| 475 | + Toast.makeText(fragment.getActivity(), "抱歉,无法获取路线!", Toast.LENGTH_SHORT).show(); | |
| 476 | + } | |
| 477 | + if (walkingRouteResult.error == SearchResult.ERRORNO.AMBIGUOUS_ROURE_ADDR) { | |
| 478 | + // 起终点或途经点地址有岐义,通过以下接口获取建议查询信息 | |
| 479 | + return; | |
| 480 | + } | |
| 481 | + List<LatLng> points = new ArrayList<LatLng>(); | |
| 482 | + if (walkingRouteResult.getRouteLines() != null) { | |
| 483 | + if (walkingRouteResult.getRouteLines().get(0).getAllStep().get(0).getWayPoints().size() > 0) { | |
| 484 | + //添加起点坐标 | |
| 485 | + if (index == 0) { | |
| 486 | + points.add(StartPoint); | |
| 487 | + } | |
| 488 | + for (int i = 0; i < walkingRouteResult.getRouteLines().get(0).getAllStep().size(); i++) { | |
| 489 | + for (int j = 0; j < walkingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().size(); j++) { | |
| 490 | + points.add(walkingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().get(j)); | |
| 491 | + } | |
| 492 | + } | |
| 493 | + } | |
| 494 | + //添加终点坐标 | |
| 495 | + if (endLatLng != null) { | |
| 496 | +// points.add(endLatLng); | |
| 497 | + } | |
| 498 | + | |
| 499 | + ArrayList<Integer> traffics = new ArrayList<Integer>(); | |
| 500 | + for (int i = 0; i < points.size(); i++) { | |
| 501 | + if (i % 2 == 0) { | |
| 502 | + traffics.add(i); | |
| 503 | + } | |
| 504 | + } | |
| 505 | + | |
| 506 | + | |
| 507 | + if (points.size() > 0) { | |
| 508 | +// if (baiduMap != null) { | |
| 509 | +// baiduMap.clear(); | |
| 510 | +// if (endLatLng != null) { | |
| 511 | +// markPoi(endLatLng.latitude, endLatLng.longitude); | |
| 512 | +// } | |
| 513 | +// } | |
| 514 | + | |
| 515 | + //设置折线的属性 | |
| 516 | +// OverlayOptions mOverlayOptions = new PolylineOptions() | |
| 517 | +// .width(10) | |
| 518 | +// .color(0xAAFF0000) | |
| 519 | +// .points(points); | |
| 520 | + //设置折线的属性 | |
| 521 | + OverlayOptions mOverlayOptions = new PolylineOptions() | |
| 522 | + .width(10) | |
| 523 | + .dottedLine(true) | |
| 524 | + .points(points) | |
| 525 | + .customTextureList(getCustomTextureList()) | |
| 526 | + .textureIndex(traffics);//设置纹理列表 | |
| 527 | + //在地图上绘制起点 | |
| 528 | + if (index == 0) { | |
| 529 | + //显示当前位置图标 | |
| 530 | + Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.icon_start), 30, 30); | |
| 531 | + startMark = new MarkerOptions() | |
| 532 | + .position(StartPoint) | |
| 533 | + .icon(BitmapDescriptorFactory.fromBitmap(pointBitmap)); | |
| 534 | +// startMark.anchor(0.5f, 0.55f); | |
| 535 | + baiduMap.addOverlay(startMark); | |
| 536 | + } else if (index == listSize - 1) { | |
| 537 | + //显示当前位置图标 | |
| 538 | + Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.icon_end), 30, 30); | |
| 539 | + endMark = new MarkerOptions() | |
| 540 | + .position(points.get(points.size() - 1)) | |
| 541 | + .icon(BitmapDescriptorFactory.fromBitmap(pointBitmap)) | |
| 542 | + .perspective(true) | |
| 543 | +// endMark.anchor(0.5f, 0.5f) | |
| 544 | + .perspective(true); | |
| 545 | + baiduMap.addOverlay(endMark); | |
| 546 | + } | |
| 547 | + //mPloyline 折线对象 | |
| 548 | + Overlay mPolyline = baiduMap.addOverlay(mOverlayOptions); | |
| 549 | + MapStatus.Builder builder = new MapStatus.Builder(); | |
| 550 | + builder.zoom(currentZoom); | |
| 551 | + baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); | |
| 552 | + | |
| 553 | + } | |
| 554 | + } | |
| 555 | + } | |
| 556 | + | |
| 557 | + @Override | |
| 558 | + public void onGetTransitRouteResult(TransitRouteResult transitRouteResult) { | |
| 559 | + | |
| 560 | + } | |
| 561 | + | |
| 562 | + @Override | |
| 563 | + public void onGetMassTransitRouteResult(MassTransitRouteResult massTransitRouteResult) { | |
| 564 | + | |
| 565 | + } | |
| 566 | + | |
| 567 | + @Override | |
| 568 | + public void onGetDrivingRouteResult(DrivingRouteResult drivingRouteResult) { | |
| 569 | + if (fragment.getActivity() == null) { | |
| 570 | + return; | |
| 571 | + } | |
| 572 | + | |
| 573 | + if (drivingRouteResult == null || drivingRouteResult.error != SearchResult.ERRORNO.NO_ERROR) { | |
| 574 | + Toast.makeText(fragment.getActivity(), "抱歉,无法获取路线!", Toast.LENGTH_SHORT).show(); | |
| 575 | + } | |
| 576 | + if (drivingRouteResult.error == SearchResult.ERRORNO.AMBIGUOUS_ROURE_ADDR) { | |
| 577 | + // 起终点或途经点地址有岐义,通过以下接口获取建议查询信息 | |
| 578 | + return; | |
| 579 | + } | |
| 580 | + List<LatLng> points = new ArrayList<LatLng>(); | |
| 581 | + if (drivingRouteResult.getRouteLines() != null) { | |
| 582 | + if (drivingRouteResult.getRouteLines().get(0).getAllStep().get(0).getWayPoints().size() > 0) { | |
| 583 | + //添加起点坐标 | |
| 584 | + if (followMyLocation != null) { | |
| 585 | + points.add(new LatLng(followMyLocation.latitude, followMyLocation.longitude)); | |
| 586 | + } | |
| 587 | + for (int i = 0; i < drivingRouteResult.getRouteLines().get(0).getAllStep().size(); i++) { | |
| 588 | + for (int j = 0; j < drivingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().size(); j++) { | |
| 589 | + points.add(drivingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().get(j)); | |
| 590 | + } | |
| 591 | + } | |
| 592 | + } | |
| 593 | + //添加终点坐标 | |
| 594 | + if (endLatLng != null) { | |
| 595 | + points.add(endLatLng); | |
| 596 | + } | |
| 597 | + if (points.size() > 0) { | |
| 598 | + if (baiduMap != null) { | |
| 599 | + baiduMap.clear(); | |
| 600 | + if (endLatLng != null) { | |
| 601 | + markPoi(endLatLng.latitude, endLatLng.longitude); | |
| 602 | + } | |
| 603 | + } | |
| 604 | + | |
| 605 | + //设置折线的属性 | |
| 606 | + OverlayOptions mOverlayOptions = new PolylineOptions() | |
| 607 | + .width(10) | |
| 608 | + .color(0xAAFF0000) | |
| 609 | + .points(points); | |
| 610 | + //在地图上绘制折线 | |
| 611 | + //mPloyline 折线对象 | |
| 612 | + Overlay mPolyline = baiduMap.addOverlay(mOverlayOptions); | |
| 613 | + MapStatus.Builder builder = new MapStatus.Builder(); | |
| 614 | + builder.zoom(currentZoom); | |
| 615 | + baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); | |
| 616 | + | |
| 617 | + } | |
| 618 | + } | |
| 619 | + } | |
| 620 | + | |
| 621 | + @Override | |
| 622 | + public void onGetIndoorRouteResult(IndoorRouteResult indoorRouteResult) { | |
| 623 | + | |
| 624 | + } | |
| 625 | + | |
| 626 | + @Override | |
| 627 | + public void onGetBikingRouteResult(BikingRouteResult bikingRouteResult) { | |
| 628 | + | |
| 629 | + } | |
| 630 | + }); | |
| 631 | + //开始检索 | |
| 632 | +// routePlanSearch.drivingSearch((new DrivingRoutePlanOption()) | |
| 633 | +// .from(stNode).to(enNode).policy(DrivingRoutePlanOption.DrivingPolicy.ECAR_DIS_FIRST) | |
| 634 | +// .trafficPolicy(DrivingRoutePlanOption.DrivingTrafficPolicy.ROUTE_PATH_AND_TRAFFIC)); | |
| 635 | + | |
| 636 | + //开始步行检索 | |
| 637 | + routePlanSearch.walkingSearch((new WalkingRoutePlanOption()) | |
| 638 | + .from(stNode) | |
| 639 | + .to(enNode)); | |
| 640 | + } | |
| 641 | +// showProgressDialog(); | |
| 642 | + | |
| 643 | + /** | |
| 644 | + * 设置终点标记 | |
| 645 | + * | |
| 646 | + * @param Latitude | |
| 647 | + * @param Longitude | |
| 648 | + */ | |
| 649 | + public void markPoi(double Latitude, double Longitude) { | |
| 650 | + if (fragment.getActivity() == null) { | |
| 651 | + return; | |
| 652 | + } | |
| 653 | + baiduMap.clear(); | |
| 654 | + currentMark = null; | |
| 655 | + LatLng ll = new LatLng(Latitude, Longitude); | |
| 656 | + //设置坐标 | |
| 657 | + //显示当前位置图标 | |
| 658 | + Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(fragment.getActivity(), BitmapFactory.decodeResource(fragment.getActivity().getResources(), R.drawable.run_map_icon_end), 22, 32); | |
| 659 | + currentMark = new MarkerOptions().position(ll).icon(BitmapDescriptorFactory.fromBitmap(pointBitmap)); | |
| 660 | + baiduMap.addOverlay(currentMark); | |
| 661 | + MapStatus.Builder builder = new MapStatus.Builder(); | |
| 662 | + builder.target(ll).zoom(16.0f); | |
| 663 | + baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); | |
| 664 | + } | |
| 665 | + | |
| 666 | + @Override | |
| 667 | + public void onSensorChanged(SensorEvent sensorEvent) { | |
| 668 | + double x = sensorEvent.values[SensorManager.DATA_X]; | |
| 669 | + if (Math.abs(x - lastX) > 1.0) { | |
| 670 | + mCurrentDirection = (int) x; | |
| 671 | + if (firstLatLng != null) { | |
| 672 | + followMyLocation = new MyLocationData.Builder() | |
| 673 | + .accuracy(mCurrentAccracy) | |
| 674 | + // 此处设置开发者获取到的方向信息,顺时针0-360 | |
| 675 | + .direction(mCurrentDirection).latitude(firstLatLng.latitude) | |
| 676 | + .longitude(firstLatLng.longitude).build(); | |
| 677 | + baiduMap.setMyLocationData(followMyLocation); | |
| 678 | + } | |
| 679 | + } | |
| 680 | + lastX = x; | |
| 681 | + } | |
| 682 | + | |
| 683 | + @Override | |
| 684 | + public void onAccuracyChanged(Sensor sensor, int i) { | |
| 685 | + | |
| 686 | + } | |
| 687 | + | |
| 688 | + /** | |
| 689 | + * 纹理图片 | |
| 690 | + * | |
| 691 | + * @return | |
| 692 | + */ | |
| 693 | + public List<BitmapDescriptor> getCustomTextureList() { | |
| 694 | + ArrayList<BitmapDescriptor> list = new ArrayList<BitmapDescriptor>(); | |
| 695 | + list.add(BitmapDescriptorFactory.fromAsset("Icon_road_blue_arrow.png")); | |
| 696 | +// list.add(BitmapDescriptorFactory.fromAsset("Icon_road_green_arrow.png")); | |
| 697 | +// list.add(BitmapDescriptorFactory.fromAsset("Icon_road_yellow_arrow.png")); | |
| 698 | +// list.add(BitmapDescriptorFactory.fromAsset("Icon_road_red_arrow.png")); | |
| 699 | +// list.add(BitmapDescriptorFactory.fromAsset("Icon_road_nofocus.png")); | |
| 700 | + return list; | |
| 701 | + } | |
| 702 | + | |
| 703 | + public void onResume() { | |
| 704 | + if (mMapView != null) { | |
| 705 | + mMapView.onResume(); | |
| 706 | + } | |
| 707 | + } | |
| 708 | + | |
| 709 | + public void onPause() { | |
| 710 | + if (mMapView != null) { | |
| 711 | + mMapView.onPause(); | |
| 712 | + } | |
| 713 | + } | |
| 714 | + | |
| 715 | + public void onDestroy() { | |
| 716 | + if (mMapView != null) { | |
| 717 | + mMapView.onDestroy(); | |
| 718 | + mMapView = null; | |
| 719 | + } | |
| 720 | + if (mLocClient != null) { | |
| 721 | + mLocClient.stop(); | |
| 722 | + } | |
| 723 | + } | |
| 724 | + | |
| 725 | + /** | |
| 726 | + * //设置定位监听器,获取到用户当前位置 杨帅 | |
| 727 | + * 定位SDK监听函数 | |
| 728 | + */ | |
| 729 | + public class MyLocationListenner extends BDAbstractLocationListener { | |
| 730 | + | |
| 731 | + @Override | |
| 732 | + public void onReceiveLocation(BDLocation location) { | |
| 733 | + // map view 销毁后不在处理新接收的位置 | |
| 734 | + if (location == null || mMapView == null) { | |
| 735 | + return; | |
| 736 | + } | |
| 737 | + if (isFirstLoc) { | |
| 738 | + isFirstLoc = false; | |
| 739 | + if (location.getRadius() > 20) { | |
| 740 | + Toast.makeText(getContext(), "当前定位精度为:" + location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show(); | |
| 741 | + } | |
| 742 | + } else { | |
| 743 | + //过滤定位精度 | |
| 744 | + if (location.getRadius() > 20) { | |
| 745 | + return; | |
| 746 | + } | |
| 747 | + } | |
| 748 | + followMyLocation = new MyLocationData.Builder() | |
| 749 | + .accuracy(location.getRadius()) | |
| 750 | + // 此处设置开发者获取到的方向信息,顺时针0-360 | |
| 751 | + .direction(location.getDirection()).latitude(location.getLatitude()) | |
| 752 | + .longitude(location.getLongitude()).build(); | |
| 753 | + if (followMyLocation == null || followMyLocation.latitude == 0 || followMyLocation.longitude == 0) { | |
| 754 | + return; | |
| 755 | + } | |
| 756 | + | |
| 757 | + MapStatus.Builder builder = new MapStatus.Builder(); | |
| 758 | + | |
| 759 | +// if (isFirstLoc) { | |
| 760 | +// isFirstLoc = false; | |
| 761 | + firstLatLng = new LatLng(location.getLatitude(), | |
| 762 | + location.getLongitude()); | |
| 763 | + baiduMap.setMyLocationData(followMyLocation); | |
| 764 | +// builder.target(firstLatLng).zoom(DEFULT_ZOOM); | |
| 765 | +// baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); | |
| 766 | + | |
| 767 | +// //显示当前位置图标 | |
| 768 | +// Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.rt_ic_location), 40, 40); | |
| 769 | +// currentMark = new MarkerOptions().position(firstLatLng).icon(BitmapDescriptorFactory.fromBitmap(pointBitmap)); | |
| 770 | +// baiduMap.addOverlay(currentMark); | |
| 771 | + | |
| 772 | + //根据几个关键点进行步行路径规划 | |
| 773 | +// if (importLatLngs != null) { | |
| 774 | +// if (importLatLngs.size() >= 1) { | |
| 775 | +// for (int index = 0; index < importLatLngs.size(); index++) { | |
| 776 | +// //开始分段规划路径 | |
| 777 | +// //第一个点 | |
| 778 | +// if (index == 0) { | |
| 779 | +// searchRouteResult(startLatLng, importLatLngs.get(index), 0, importLatLngs.size()); | |
| 780 | +// } else { | |
| 781 | +// searchRouteResult(importLatLngs.get(index - 1), importLatLngs.get(index), index, importLatLngs.size()); | |
| 782 | +// } | |
| 783 | +// } | |
| 784 | +// } else { | |
| 785 | +// searchRouteResult(startLatLng, endLatLng, 0, importLatLngs.size()); | |
| 786 | +// } | |
| 787 | +// } | |
| 788 | + | |
| 789 | +// } | |
| 790 | + } | |
| 791 | + } | |
| 792 | + | |
| 793 | + /** | |
| 794 | + * 显示loading | |
| 795 | + */ | |
| 796 | + public void showLoadingView() { | |
| 797 | + if (fragment.binding.emptyLayout == null) { | |
| 798 | + return; | |
| 799 | + } | |
| 800 | + fragment.binding.emptyLayout.show(true); | |
| 801 | + } | |
| 802 | + | |
| 803 | + /** | |
| 804 | + * 隐藏loading | |
| 805 | + */ | |
| 806 | + public void hideLoadingView() { | |
| 807 | + if (fragment.binding.emptyLayout == null) { | |
| 808 | + return; | |
| 809 | + } | |
| 810 | + fragment.binding.emptyLayout.hide(); | |
| 811 | + } | |
| 812 | + | |
| 813 | + /** | |
| 814 | + * 显示重试页面 | |
| 815 | + * | |
| 816 | + * @param errorCode | |
| 817 | + * @param listener | |
| 818 | + */ | |
| 819 | + public void showRetryView(int errorCode, View.OnClickListener listener) { | |
| 820 | + if (getContext() == null) { | |
| 821 | + return; | |
| 822 | + } | |
| 823 | + //隐藏地图 | |
| 824 | + fragment.binding.mapView.setVisibility(View.GONE); | |
| 825 | + //显示空视图 | |
| 826 | + fragment.binding.emptyLayout.setVisibility(View.VISIBLE); | |
| 827 | + //隐藏底部卡片 | |
| 828 | + fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN); | |
| 829 | + if (fragment.binding.emptyLayout == null) return; | |
| 830 | + String titleText = ""; | |
| 831 | + String detailText = ""; | |
| 832 | + if (errorCode == -3) { | |
| 833 | + titleText = getContext().getString(R.string.msg_failed_network_title); | |
| 834 | + detailText = getContext().getString(R.string.msg_failed_network_detail); | |
| 835 | + } else { | |
| 836 | + titleText = getContext().getString(R.string.msg_failed_other_title); | |
| 837 | + detailText = getContext().getString(R.string.msg_failed_other_detail); | |
| 838 | + } | |
| 839 | + fragment.binding.emptyLayout.show(false, titleText, detailText, getContext().getString(R.string.retry), R.drawable.wufalianjie, listener); | |
| 840 | + } | |
| 841 | + | |
| 842 | +} | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunningFinishFragmentView.java
0 → 100644
| 1 | +package com.cnlive.moudle.collectionTrace.frame.view; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.view.View; | |
| 5 | + | |
| 6 | +import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunningFinishFragment; | |
| 7 | +import com.cnlive.moudle.pedometer.model.RunningFinishBean; | |
| 8 | +import com.cnlive.moudle.pedometer.ui.fragment.RunningFinishFragment; | |
| 9 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | |
| 10 | + | |
| 11 | +public class CollRunningFinishFragmentView implements MvpView { | |
| 12 | + private CollRunningFinishFragment fragment; | |
| 13 | + | |
| 14 | + public CollRunningFinishFragmentView(CollRunningFinishFragment fragment) { | |
| 15 | + this.fragment = fragment; | |
| 16 | + } | |
| 17 | + | |
| 18 | + public Context getContext() { | |
| 19 | + return fragment == null ? null : fragment.getActivity(); | |
| 20 | + } | |
| 21 | + | |
| 22 | + public void initView(RunningFinishBean runningFinishBean) { | |
| 23 | + //设置距离 | |
| 24 | + fragment.binding.includeFinishUserInfo.tvDistance.setText(runningFinishBean.getRunDistance()); | |
| 25 | + //设置配速 | |
| 26 | + fragment.binding.includeFinishUserInfo.tvSpeed.setText(runningFinishBean.getSpeed()); | |
| 27 | + //设置用时 | |
| 28 | + fragment.binding.includeFinishUserInfo.tvTimer.setText(runningFinishBean.getTime()); | |
| 29 | + //设置日期 | |
| 30 | + fragment.binding.includeFinishUserInfo.tvDate.setText(runningFinishBean.getDate()); | |
| 31 | + //设置步数 | |
| 32 | + fragment.binding.includeFinishStep.tvStep.setText(runningFinishBean.getStep()); | |
| 33 | + //设置起点位置 | |
| 34 | + fragment.binding.includeFinishRunRoute.tvStartPoint.setText(runningFinishBean.getStartPoint()); | |
| 35 | + //设置终点位置 | |
| 36 | + fragment.binding.includeFinishRunRoute.tvEndPoint.setText(runningFinishBean.getEndPoint()); | |
| 37 | + //设置时间 | |
| 38 | + fragment.binding.includeFinishRunRoute.tvTimer.setText(runningFinishBean.getTime()); | |
| 39 | + //返回按钮点击 | |
| 40 | + fragment.binding.flBack.setOnClickListener(new View.OnClickListener() { | |
| 41 | + @Override | |
| 42 | + public void onClick(View view) { | |
| 43 | + if (fragment.getActivity() == null) { | |
| 44 | + return; | |
| 45 | + } | |
| 46 | + fragment.getActivity().finish(); | |
| 47 | + } | |
| 48 | + }); | |
| 49 | + } | |
| 50 | +} | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunningMapFragmentView.java
0 → 100644
| 1 | +package com.cnlive.moudle.collectionTrace.frame.view; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.graphics.Bitmap; | |
| 5 | +import android.graphics.BitmapFactory; | |
| 6 | +import android.hardware.Sensor; | |
| 7 | +import android.hardware.SensorEvent; | |
| 8 | +import android.hardware.SensorEventListener; | |
| 9 | +import android.hardware.SensorManager; | |
| 10 | +import android.os.Handler; | |
| 11 | +import android.os.SystemClock; | |
| 12 | +import android.util.Log; | |
| 13 | +import android.view.MotionEvent; | |
| 14 | +import android.view.View; | |
| 15 | +import android.widget.Chronometer; | |
| 16 | +import android.widget.Toast; | |
| 17 | + | |
| 18 | +import com.baidu.location.BDAbstractLocationListener; | |
| 19 | +import com.baidu.location.BDLocation; | |
| 20 | +import com.baidu.location.LocationClient; | |
| 21 | +import com.baidu.location.LocationClientOption; | |
| 22 | +import com.baidu.mapapi.map.BaiduMap; | |
| 23 | +import com.baidu.mapapi.map.BitmapDescriptor; | |
| 24 | +import com.baidu.mapapi.map.BitmapDescriptorFactory; | |
| 25 | +import com.baidu.mapapi.map.MapStatus; | |
| 26 | +import com.baidu.mapapi.map.MapStatusUpdateFactory; | |
| 27 | +import com.baidu.mapapi.map.MapView; | |
| 28 | +import com.baidu.mapapi.map.MarkerOptions; | |
| 29 | +import com.baidu.mapapi.map.MyLocationConfiguration; | |
| 30 | +import com.baidu.mapapi.map.MyLocationData; | |
| 31 | +import com.baidu.mapapi.map.Overlay; | |
| 32 | +import com.baidu.mapapi.map.UiSettings; | |
| 33 | +import com.baidu.mapapi.model.LatLng; | |
| 34 | +import com.baidu.mapapi.utils.DistanceUtil; | |
| 35 | +import com.baidu.trace.model.SortType; | |
| 36 | +import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunningMapFragment; | |
| 37 | +import com.cnlive.moudle.pedometer.model.RunningMapBean; | |
| 38 | +import com.cnlive.moudle.pedometer.ui.fragment.RunningMapFragment; | |
| 39 | +import com.cnlive.moudle.pedometer.utils.BitmapUtil; | |
| 40 | +import com.cnlive.moudle.pedometer.utils.ButtonAnimUtil; | |
| 41 | +import com.cnlive.moudle.pedometer.utils.MyMapUtil; | |
| 42 | +import com.cnlive.moudle.pedometer.utils.StepUtil; | |
| 43 | +import com.example.moudle_pedometer.R; | |
| 44 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | |
| 45 | + | |
| 46 | +import java.util.ArrayList; | |
| 47 | +import java.util.List; | |
| 48 | + | |
| 49 | +public class CollRunningMapFragmentView implements MvpView, SensorEventListener { | |
| 50 | + private static final String TAG = "CollRunningMapFragmentView"; | |
| 51 | + private CollRunningMapFragment fragment; | |
| 52 | + public BaiduMap baiduMap; | |
| 53 | + private MapView mMapView; | |
| 54 | + private UiSettings mUiSettings; | |
| 55 | + private MyLocationConfiguration.LocationMode mCurrentMode;//定位模式 | |
| 56 | + private BitmapDescriptor mCurrentMarker;//定位图标 | |
| 57 | + private static int accuracyCircleFillColor; | |
| 58 | + private static int accuracyCircleStrokeColor; | |
| 59 | + private static MyLocationData mylocation; | |
| 60 | + boolean isFirstLoc = true; // 是否首次定位 | |
| 61 | + private MarkerOptions currentMark; | |
| 62 | + private LatLng myCurLatLng; | |
| 63 | + private Double lastX = 0.0; | |
| 64 | + private int mCurrentDirection = 0; | |
| 65 | + private double mCurrentLat = 0.0; | |
| 66 | + private double mCurrentLon = 0.0; | |
| 67 | + private float mCurrentAccracy; | |
| 68 | + // 定位相关 | |
| 69 | + private LocationClient mLocClient; | |
| 70 | + public MyLocationListenner myListener = new MyLocationListenner(); | |
| 71 | + private final int DEFULT_ZOOM = 17; | |
| 72 | + private boolean isFirstLoadMap = true; | |
| 73 | + private List<LatLng> trackPoints; | |
| 74 | + private Overlay currentLine; | |
| 75 | + private List<LatLng> currentPoints; | |
| 76 | + | |
| 77 | + public CollRunningMapFragmentView(CollRunningMapFragment fragment) { | |
| 78 | + this.fragment = fragment; | |
| 79 | + } | |
| 80 | + | |
| 81 | + public Context getContext() { | |
| 82 | + return fragment == null ? null : fragment.getActivity(); | |
| 83 | + } | |
| 84 | + | |
| 85 | + public void initView(List<LatLng> trackPoints) { | |
| 86 | + currentPoints = new ArrayList<>(); | |
| 87 | + this.trackPoints = trackPoints; | |
| 88 | + this.mMapView = fragment.binding.mapView; | |
| 89 | + if (baiduMap == null) { | |
| 90 | + baiduMap = mMapView.getMap(); | |
| 91 | + } | |
| 92 | + if (mUiSettings == null) { | |
| 93 | + mUiSettings = baiduMap.getUiSettings(); | |
| 94 | + } | |
| 95 | + //设置定位模式, 默认为 LocationMode.NORMAL 普通态 | |
| 96 | + mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL; | |
| 97 | + // 设置定位图标修改为自定义marker | |
| 98 | + Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.rt_ic_location), 40, 40); | |
| 99 | + mCurrentMarker = BitmapDescriptorFactory.fromBitmap(pointBitmap); | |
| 100 | + //设置定位蓝点精度圆圈的填充颜色为透明色 | |
| 101 | + accuracyCircleFillColor = getContext().getResources().getColor(R.color.transparent); | |
| 102 | + //设置定位蓝点精度圆圈的边框颜色的为透明色 | |
| 103 | + accuracyCircleStrokeColor = getContext().getResources().getColor(R.color.transparent); | |
| 104 | + MyLocationConfiguration locationConfiguration = new MyLocationConfiguration(mCurrentMode, | |
| 105 | + true, mCurrentMarker, accuracyCircleFillColor, accuracyCircleStrokeColor); | |
| 106 | + //设置样式 | |
| 107 | + baiduMap.setMyLocationConfiguration(locationConfiguration); | |
| 108 | + //启动所有手势 | |
| 109 | + mUiSettings.setAllGesturesEnabled(true); | |
| 110 | + //通过设置enable为true或false 选择是否显示缩放按钮 | |
| 111 | + mMapView.showZoomControls(false); | |
| 112 | + mUiSettings.setEnlargeCenterWithDoubleClickEnable(true); | |
| 113 | + //隐藏自带的指南针,改用自定义指南针 杨帅 | |
| 114 | + mUiSettings.setCompassEnabled(false); | |
| 115 | + //显示定位图层 | |
| 116 | + baiduMap.setMyLocationEnabled(true); | |
| 117 | + // 定位初始化 | |
| 118 | + mLocClient = new LocationClient(getContext()); | |
| 119 | + mLocClient.registerLocationListener(myListener); | |
| 120 | + LocationClientOption option = new LocationClientOption(); | |
| 121 | + option.setOpenGps(true); // 打开gps | |
| 122 | + //可选,设置返回经纬度坐标类型,默认GCJ02 | |
| 123 | + //GCJ02:国测局坐标; | |
| 124 | + //BD09ll:百度经纬度坐标; | |
| 125 | + //BD09:百度墨卡托坐标; | |
| 126 | + //海外地区定位,无需设置坐标类型,统一返回WGS84类型坐标 | |
| 127 | + option.setCoorType("gcj02"); // 设置坐标类型 | |
| 128 | + //可选,默认false,设置是否开启Gps定位 | |
| 129 | + option.setOpenGps(true); | |
| 130 | + //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者,该模式下开发者无需再关心定位间隔是多少,定位SDK本身发现位置变化就会及时回调给开发者 | |
| 131 | + option.setOpenAutoNotifyMode(); | |
| 132 | + //可选,默认高精度,设置定位模式,高精度,低功耗,仅设备 | |
| 133 | + //LocationMode.Hight_Accuracy:高精度; | |
| 134 | + //LocationMode. Battery_Saving:低功耗; | |
| 135 | + //LocationMode. Device_Sensors:仅使用设备; | |
| 136 | + option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); | |
| 137 | + //可选,设置是否需要地址信息,默认不需要 | |
| 138 | + option.setIsNeedAddress(false); | |
| 139 | + //可选,设置是否需要地址描述 | |
| 140 | + option.setIsNeedLocationDescribe(false); | |
| 141 | + //可选,设置是否需要设备方向结果 | |
| 142 | + option.setNeedDeviceDirect(false); | |
| 143 | + //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者 | |
| 144 | + //minTimeInterval - 最短定位时间间隔,单位毫秒,最小值0,开发者可以在设置希望的位置回调最短时间间隔 | |
| 145 | + //minDistance - 最短定位距离间隔,单位米,最小值0,开发者可以设置希望的位置回调距离间隔 | |
| 146 | + //locSensitivity - 定位变化敏感程度,LOC_SENSITIVITY_HIGHT,LOC_SENSITIVITY_MIDDLE,LOC_SENSITIVITY_LOW | |
| 147 | + option.setOpenAutoNotifyMode(3000, 1, LocationClientOption.LOC_SENSITIVITY_HIGHT); | |
| 148 | + //可选,定位SDK内部是一个service,并放到了独立进程。 | |
| 149 | + //设置是否在stop的时候杀死这个进程,默认(建议)不杀死,即setIgnoreKillProcess(true) | |
| 150 | + option.setIgnoreKillProcess(true); | |
| 151 | + | |
| 152 | + mLocClient.setLocOption(option); | |
| 153 | + mLocClient.start(); | |
| 154 | + //地图加载完毕监听 | |
| 155 | + baiduMap.setOnMapLoadedCallback(new BaiduMap.OnMapLoadedCallback() { | |
| 156 | + @Override | |
| 157 | + public void onMapLoaded() { | |
| 158 | + //自动计算地图缩放 | |
| 159 | + MapStatus.Builder builder = new MapStatus.Builder(); | |
| 160 | + builder.target(MyMapUtil.getCenterZoomPosition(trackPoints)); | |
| 161 | + builder.zoom(MyMapUtil.getZoom(trackPoints)); | |
| 162 | + baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); | |
| 163 | + if (isFirstLoadMap) { | |
| 164 | + isFirstLoadMap = false; | |
| 165 | + new Handler().postDelayed(new Runnable() { | |
| 166 | + @Override | |
| 167 | + public void run() { | |
| 168 | + //绘制赛道轨迹 | |
| 169 | + if (getContext() == null) { | |
| 170 | + return; | |
| 171 | + } | |
| 172 | + MyMapUtil.drawServerLineTrack(getContext(), baiduMap, trackPoints, SortType.asc, R.color.green_50, R.drawable.icon_start, R.drawable.icon_end); | |
| 173 | + } | |
| 174 | + }, 1500); | |
| 175 | + } | |
| 176 | + } | |
| 177 | + }); | |
| 178 | + //返回键 | |
| 179 | + fragment.binding.flBack.setOnTouchListener(new View.OnTouchListener() { | |
| 180 | + @Override | |
| 181 | + public boolean onTouch(View view, MotionEvent motionEvent) { | |
| 182 | + Log.e(TAG, "onTouch: " + motionEvent.getAction()); | |
| 183 | + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { | |
| 184 | + ButtonAnimUtil.setViewZoomIn(fragment.binding.flBack); | |
| 185 | + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { | |
| 186 | + ButtonAnimUtil.setViewZoomOut(fragment.binding.flBack); | |
| 187 | + } | |
| 188 | + return false; | |
| 189 | + } | |
| 190 | + }); | |
| 191 | + //返回键点击事件 | |
| 192 | + fragment.binding.flBack.setOnClickListener(new View.OnClickListener() { | |
| 193 | + @Override | |
| 194 | + public void onClick(View view) { | |
| 195 | + fragment.getActivity().finish(); | |
| 196 | + } | |
| 197 | + }); | |
| 198 | + //重新定位 | |
| 199 | + fragment.binding.flLocation.setOnTouchListener(new View.OnTouchListener() { | |
| 200 | + @Override | |
| 201 | + public boolean onTouch(View view, MotionEvent motionEvent) { | |
| 202 | + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { | |
| 203 | + ButtonAnimUtil.setViewZoomIn(fragment.binding.flLocation); | |
| 204 | + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { | |
| 205 | + ButtonAnimUtil.setViewZoomOut(fragment.binding.flLocation); | |
| 206 | + } | |
| 207 | + return false; | |
| 208 | + } | |
| 209 | + }); | |
| 210 | + //重新定位功能 | |
| 211 | + fragment.binding.flLocation.setOnClickListener(new View.OnClickListener() { | |
| 212 | + @Override | |
| 213 | + public void onClick(View view) { | |
| 214 | + mLocClient.restart(); | |
| 215 | + isFirstLoc = true; | |
| 216 | + } | |
| 217 | + }); | |
| 218 | + | |
| 219 | + } | |
| 220 | + | |
| 221 | + | |
| 222 | + /** | |
| 223 | + * //设置定位监听器,获取到用户当前位置 杨帅 | |
| 224 | + * 定位SDK监听函数 | |
| 225 | + */ | |
| 226 | + public class MyLocationListenner extends BDAbstractLocationListener { | |
| 227 | + @Override | |
| 228 | + public void onLocDiagnosticMessage(int i, int i1, String s) { | |
| 229 | + super.onLocDiagnosticMessage(i, i1, s); | |
| 230 | + if (getContext() == null) { | |
| 231 | + return; | |
| 232 | + } | |
| 233 | + if (i == 67) { | |
| 234 | + Toast.makeText(getContext(), getContext().getString(R.string.loc_check_internet), Toast.LENGTH_SHORT).show(); | |
| 235 | + } else if (i == 161 && i1 == 1) { | |
| 236 | + Toast.makeText(getContext(), getContext().getString(R.string.loc_open_gps), Toast.LENGTH_SHORT).show(); | |
| 237 | + } else if (i == 161 && i1 == 2) { | |
| 238 | + Toast.makeText(getContext(), getContext().getString(R.string.loc_open_wifi), Toast.LENGTH_SHORT).show(); | |
| 239 | + } | |
| 240 | + } | |
| 241 | + | |
| 242 | + @Override | |
| 243 | + public void onReceiveLocation(BDLocation location) { | |
| 244 | + // map view 销毁后不在处理新接收的位置 | |
| 245 | + if (location == null || mMapView == null) { | |
| 246 | + return; | |
| 247 | + } | |
| 248 | + | |
| 249 | + //正在搜索GPS信号 | |
| 250 | + if (location.getGpsAccuracyStatus() == BDLocation.GPS_ACCURACY_UNKNOWN) { | |
| 251 | + if (fragment.binding.tvGpsPopBg.getVisibility() != View.VISIBLE) { | |
| 252 | + fragment.binding.tvGpsPopBg.setVisibility(View.VISIBLE); | |
| 253 | + } | |
| 254 | + if (!getContext().getResources().getString(R.string.loc_gps_accuracy_unknown).equals(fragment.binding.tvGpsPopBg.getText().toString())) { | |
| 255 | + fragment.binding.tvGpsPopBg.setText(getContext().getResources().getString(R.string.loc_gps_accuracy_unknown)); | |
| 256 | + } | |
| 257 | + //设置图标 | |
| 258 | + if (fragment.binding.ivGpsState.getTag() == null || !"GPS_ACCURACY_UNKNOWN".equals(fragment.binding.ivGpsState.getTag().toString())) { | |
| 259 | + fragment.binding.ivGpsState.setTag("GPS_ACCURACY_UNKNOWN"); | |
| 260 | + fragment.binding.ivGpsState.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_0)); | |
| 261 | + } | |
| 262 | + } | |
| 263 | + //GPS 质量判断差 | |
| 264 | + else if (location.getGpsAccuracyStatus() == BDLocation.GPS_ACCURACY_BAD) { | |
| 265 | + if (fragment.binding.tvGpsPopBg.getVisibility() != View.VISIBLE) { | |
| 266 | + fragment.binding.tvGpsPopBg.setVisibility(View.VISIBLE); | |
| 267 | + } | |
| 268 | + if (!getContext().getResources().getString(R.string.loc_gps_accuracy_bad).equals(fragment.binding.tvGpsPopBg.getText().toString())) { | |
| 269 | + fragment.binding.tvGpsPopBg.setText(getContext().getResources().getString(R.string.loc_gps_accuracy_bad)); | |
| 270 | + } | |
| 271 | + //设置图标 | |
| 272 | + if (fragment.binding.ivGpsState.getTag() == null || !"GPS_ACCURACY_BAD".equals(fragment.binding.ivGpsState.getTag().toString())) { | |
| 273 | + fragment.binding.ivGpsState.setTag("GPS_ACCURACY_BAD"); | |
| 274 | + fragment.binding.ivGpsState.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_1)); | |
| 275 | + } | |
| 276 | + } | |
| 277 | + //GPS 质量判断中等 | |
| 278 | + else if (location.getGpsAccuracyStatus() == BDLocation.GPS_ACCURACY_MID) { | |
| 279 | + if (fragment.binding.tvGpsPopBg.getVisibility() != View.GONE) { | |
| 280 | + fragment.binding.tvGpsPopBg.setVisibility(View.GONE); | |
| 281 | + } | |
| 282 | + //设置图标 | |
| 283 | + if (fragment.binding.ivGpsState.getTag() == null || !"GPS_ACCURACY_MID".equals(fragment.binding.ivGpsState.getTag().toString())) { | |
| 284 | + fragment.binding.ivGpsState.setTag("GPS_ACCURACY_MID"); | |
| 285 | + fragment.binding.ivGpsState.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_2)); | |
| 286 | + } | |
| 287 | + }//GPS 质量判断好 | |
| 288 | + else if (location.getGpsAccuracyStatus() == BDLocation.GPS_ACCURACY_GOOD) { | |
| 289 | + if (fragment.binding.tvGpsPopBg.getVisibility() != View.GONE) { | |
| 290 | + fragment.binding.tvGpsPopBg.setVisibility(View.GONE); | |
| 291 | + } | |
| 292 | + //设置图标 | |
| 293 | + if (fragment.binding.ivGpsState.getTag() == null || !"GPS_ACCURACY_GOOD".equals(fragment.binding.ivGpsState.getTag().toString())) { | |
| 294 | + fragment.binding.ivGpsState.setTag("GPS_ACCURACY_GOOD"); | |
| 295 | + fragment.binding.ivGpsState.setBackground(getContext().getResources().getDrawable(R.drawable.rt_training_gps_3)); | |
| 296 | + } | |
| 297 | + } | |
| 298 | + | |
| 299 | + if (isFirstLoc) { | |
| 300 | + isFirstLoc = false; | |
| 301 | + if (location.getRadius() > 20) { | |
| 302 | + Toast.makeText(getContext(), "当前定位精度为:" + location.getRadius() + "米,请您移动至空旷地带!", Toast.LENGTH_SHORT).show(); | |
| 303 | + } | |
| 304 | + | |
| 305 | + | |
| 306 | + } else { | |
| 307 | + //过滤定位精度 | |
| 308 | + if (location.getRadius() > 20) { | |
| 309 | + return; | |
| 310 | + } | |
| 311 | + } | |
| 312 | + mCurrentAccracy = location.getRadius(); | |
| 313 | + mylocation = new MyLocationData.Builder() | |
| 314 | + .accuracy(location.getRadius()) | |
| 315 | + // 此处设置开发者获取到的方向信息,顺时针0-360 | |
| 316 | + .direction(mCurrentDirection).latitude(location.getLatitude()) | |
| 317 | + .longitude(location.getLongitude()).build(); | |
| 318 | + if (mylocation == null || mylocation.latitude == 0 || mylocation.longitude == 0) { | |
| 319 | + return; | |
| 320 | + } | |
| 321 | + MapStatus.Builder builder = new MapStatus.Builder(); | |
| 322 | + //不是第一次定位状态 | |
| 323 | + if (!isFirstLoc) { | |
| 324 | + if (currentPoints.size() > 0) { | |
| 325 | + //进行判断 | |
| 326 | + LatLng lastLatLng = currentPoints.get(currentPoints.size() - 1); | |
| 327 | + LatLng curLatLng = new LatLng(location.getLatitude(), | |
| 328 | + location.getLongitude()); | |
| 329 | + if (DistanceUtil.getDistance(lastLatLng, curLatLng) > 0.5) { | |
| 330 | + currentPoints.add(curLatLng); | |
| 331 | + } | |
| 332 | + } else { | |
| 333 | + currentPoints.add(new LatLng(location.getLatitude(), | |
| 334 | + location.getLongitude())); | |
| 335 | + } | |
| 336 | + | |
| 337 | + //判断当前集合列表是否可以划线(至少两个点) | |
| 338 | + if (currentPoints != null && currentPoints.size() > 1) { | |
| 339 | + //判断当前是否已经在地图上画点 | |
| 340 | + if (currentLine != null) { | |
| 341 | + currentLine.remove(); | |
| 342 | + } | |
| 343 | + //开始划线 | |
| 344 | + if (getContext() == null) { | |
| 345 | + return; | |
| 346 | + } | |
| 347 | + currentLine = MyMapUtil.drawMapLine(getContext(), baiduMap, currentPoints, R.color.red); | |
| 348 | + } | |
| 349 | + | |
| 350 | + } | |
| 351 | + myCurLatLng = new LatLng(location.getLatitude(), | |
| 352 | + location.getLongitude()); | |
| 353 | + baiduMap.setMyLocationData(mylocation); | |
| 354 | + } | |
| 355 | + } | |
| 356 | + | |
| 357 | + | |
| 358 | + /** | |
| 359 | + * 同步计时器 | |
| 360 | + */ | |
| 361 | + public void updateChronometer(RunningMapBean runningMapBean) { | |
| 362 | + //设置计时监听 | |
| 363 | + fragment.binding.chronometer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() { | |
| 364 | + @Override | |
| 365 | + public void onChronometerTick(Chronometer chronometer) { | |
| 366 | + int hour = (int) ((SystemClock.elapsedRealtime() - chronometer.getBase()) / 1000 / 60 / 60); | |
| 367 | + int minute = (int) ((SystemClock.elapsedRealtime() - chronometer.getBase()) / 1000 / 60) % 60; | |
| 368 | + int second = (int) ((SystemClock.elapsedRealtime() - chronometer.getBase()) / 1000) % 60; | |
| 369 | + if (hour < 1) { | |
| 370 | + if (minute == 59 && second == 59) { | |
| 371 | + chronometer.setFormat("0" + "%s"); | |
| 372 | + } else { | |
| 373 | + chronometer.setFormat("0" + String.valueOf(hour) + ":%s"); | |
| 374 | + } | |
| 375 | + } else if (hour < 10) { | |
| 376 | + chronometer.setFormat("0" + "%s"); | |
| 377 | + } else { | |
| 378 | + chronometer.setFormat("%s"); | |
| 379 | + } | |
| 380 | + | |
| 381 | + } | |
| 382 | + }); | |
| 383 | + fragment.binding.chronometer.setBase(runningMapBean.getTimeBase() + (SystemClock.elapsedRealtime() - runningMapBean.getRecordTime())); | |
| 384 | + //判断是否点击暂停按钮 | |
| 385 | + if (runningMapBean.isPause()) { | |
| 386 | + //点击暂停按钮,那么就只显示文本 | |
| 387 | + fragment.binding.chronometer.setText(runningMapBean.getPauseShowTime()); | |
| 388 | + } else { | |
| 389 | + fragment.binding.chronometer.start(); | |
| 390 | + } | |
| 391 | + //设置速度 | |
| 392 | + fragment.binding.tvCurrentSpeed.setText(runningMapBean.getCurrentSpeed()); | |
| 393 | + //设置距离 | |
| 394 | + fragment.binding.tvCurrentDiatance.setText(runningMapBean.getDistance()); | |
| 395 | + } | |
| 396 | + | |
| 397 | + /** | |
| 398 | + * 更新行走距离 | |
| 399 | + * | |
| 400 | + * @param step | |
| 401 | + */ | |
| 402 | + public void updateRunDistance(int step) { | |
| 403 | + //设置行走公里 | |
| 404 | + fragment.binding.tvCurrentDiatance.setText(StepUtil.getWalkDistanceKM(step) + ""); | |
| 405 | + //设置行走步数 | |
| 406 | + fragment.binding.tvCurrentSpeed.setText(step + "步"); | |
| 407 | + //设置S速度 | |
| 408 | + int second = (int) ((SystemClock.elapsedRealtime() - fragment.binding.chronometer.getBase()) / 1000); | |
| 409 | + if (second != 0) { | |
| 410 | +// fragment.binding.tvCurrentSpeed.setText(StepUtil.getCurrentSpeed(second, StepUtil.getWalkDistanceKM(step) * 1000) + ""); | |
| 411 | + fragment.binding.tvCurrentSpeed.setText(StepUtil.getPaceSpeed(second, StepUtil.getWalkDistanceKM(step))); | |
| 412 | + } else { | |
| 413 | + fragment.binding.tvCurrentSpeed.setText("--"); | |
| 414 | + } | |
| 415 | + } | |
| 416 | + | |
| 417 | + public void resetSpeed() { | |
| 418 | + fragment.binding.tvCurrentSpeed.setText("--"); | |
| 419 | + } | |
| 420 | + | |
| 421 | + @Override | |
| 422 | + public void onSensorChanged(SensorEvent sensorEvent) { | |
| 423 | + double x = sensorEvent.values[SensorManager.DATA_X]; | |
| 424 | + if (Math.abs(x - lastX) > 1.0) { | |
| 425 | + mCurrentDirection = (int) x; | |
| 426 | + if (mylocation != null) { | |
| 427 | + mylocation = new MyLocationData.Builder() | |
| 428 | + .accuracy(mCurrentAccracy) | |
| 429 | + // 此处设置开发者获取到的方向信息,顺时针0-360 | |
| 430 | + .direction(mCurrentDirection).latitude(mylocation.latitude) | |
| 431 | + .longitude(mylocation.longitude).build(); | |
| 432 | + baiduMap.setMyLocationData(mylocation); | |
| 433 | + } | |
| 434 | + } | |
| 435 | + lastX = x; | |
| 436 | + } | |
| 437 | + | |
| 438 | + @Override | |
| 439 | + public void onAccuracyChanged(Sensor sensor, int i) { | |
| 440 | + | |
| 441 | + } | |
| 442 | + | |
| 443 | + | |
| 444 | + public void onResume() { | |
| 445 | + if (mMapView != null) { | |
| 446 | + mMapView.onResume(); | |
| 447 | + } | |
| 448 | + } | |
| 449 | + | |
| 450 | + public void onPause() { | |
| 451 | + if (mMapView != null) { | |
| 452 | + mMapView.onPause(); | |
| 453 | + } | |
| 454 | + } | |
| 455 | + | |
| 456 | + public void onDestroy() { | |
| 457 | + if (mMapView != null) { | |
| 458 | + mMapView.onDestroy(); | |
| 459 | + mMapView = null; | |
| 460 | + } | |
| 461 | + if (mLocClient != null) { | |
| 462 | + mLocClient.stop(); | |
| 463 | + } | |
| 464 | + } | |
| 465 | + | |
| 466 | + | |
| 467 | +} | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/activity/CollPedometerMainActivity.java
0 → 100644
| 1 | +package com.cnlive.moudle.collectionTrace.ui.activity; | |
| 2 | + | |
| 3 | +import android.Manifest; | |
| 4 | +import android.content.Intent; | |
| 5 | +import android.content.pm.PackageInfo; | |
| 6 | +import android.content.pm.PackageManager; | |
| 7 | +import android.os.Build; | |
| 8 | +import android.os.Bundle; | |
| 9 | +import android.provider.Settings; | |
| 10 | +import android.support.annotation.NonNull; | |
| 11 | +import android.support.v4.app.NotificationManagerCompat; | |
| 12 | +import android.support.v4.content.ContextCompat; | |
| 13 | +import android.util.Log; | |
| 14 | +import android.widget.Toast; | |
| 15 | + | |
| 16 | +import com.alibaba.android.arouter.facade.annotation.Route; | |
| 17 | +import com.cnlive.libs.base.ui.QMUIFragmentActivity; | |
| 18 | +import com.cnlive.libs.base.util.StatusBarUtil2; | |
| 19 | +import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunMainFragment; | |
| 20 | +import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment; | |
| 21 | +import com.cnlive.moudle.pedometer.utils.MyMapUtil; | |
| 22 | +import com.cnlive.moudle.pedometer.utils.lib_permisshelper.PermissionsListener; | |
| 23 | +import com.cnlive.moudle.pedometer.utils.lib_permisshelper.PermissionsUtils; | |
| 24 | +import com.example.moudle_pedometer.R; | |
| 25 | + | |
| 26 | +import static android.app.Notification.EXTRA_CHANNEL_ID; | |
| 27 | +import static android.provider.Settings.EXTRA_APP_PACKAGE; | |
| 28 | + | |
| 29 | +/** | |
| 30 | + * 计步器主activity | |
| 31 | + */ | |
| 32 | +@Route(path = "/moudle_pedometer/InterestActivity") | |
| 33 | +public class CollPedometerMainActivity extends QMUIFragmentActivity { | |
| 34 | + private static final String TAG = "CollPedometerMainActivity"; | |
| 35 | + | |
| 36 | + private NotificationManagerCompat notificationManagerCompat; | |
| 37 | + private boolean isOpen; | |
| 38 | + private PermissionsUtils mPermissionsUtils = new PermissionsUtils();//权限申请 | |
| 39 | + private CollRunMainFragment fragment; | |
| 40 | + | |
| 41 | + @Override | |
| 42 | + protected int getContextViewId() { | |
| 43 | + return R.id.fragment_run_main; | |
| 44 | + } | |
| 45 | + | |
| 46 | + @Override | |
| 47 | + protected void onCreate(Bundle savedInstanceState) { | |
| 48 | + super.onCreate(savedInstanceState); | |
| 49 | + StatusBarUtil2.setColor(this, getResources().getColor(R.color.run_main_bg), 0); | |
| 50 | +// setContentView(R.layout.activity_pedometer_main); | |
| 51 | + | |
| 52 | + } | |
| 53 | + | |
| 54 | + | |
| 55 | + @Override | |
| 56 | + protected void onDestroy() { | |
| 57 | + super.onDestroy(); | |
| 58 | + } | |
| 59 | + | |
| 60 | + private void check() { | |
| 61 | + | |
| 62 | + //监测通知权限是否打开 | |
| 63 | + notificationManagerCompat = NotificationManagerCompat.from(this); | |
| 64 | + isOpen = notificationManagerCompat.areNotificationsEnabled(); | |
| 65 | + if (isOpen) { | |
| 66 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |
| 67 | +// ContextCompat.startForegroundService(CollPedometerMainActivity.this, new Intent(CollPedometerMainActivity.this, StepService.class)); | |
| 68 | + } | |
| 69 | + } else { | |
| 70 | + goToSettingNo(); | |
| 71 | + } | |
| 72 | + } | |
| 73 | + | |
| 74 | + private void goToSettingNo() { | |
| 75 | + Intent intent1 = new Intent(); | |
| 76 | + try { | |
| 77 | + // 根据isOpened结果,判断是否需要提醒用户跳转AppInfo页面,去打开App通知权限 | |
| 78 | + intent1.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS); | |
| 79 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |
| 80 | + //这种方案适用于 API 26, 即8.0(含8.0)以上可以用 | |
| 81 | + intent1.putExtra(EXTRA_APP_PACKAGE, getPackageName()); | |
| 82 | + intent1.putExtra(EXTRA_CHANNEL_ID, getApplicationInfo().uid); | |
| 83 | + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | |
| 84 | + //这种方案适用于 API21——25,即 5.0——7.1 之间的版本可以使用 | |
| 85 | + intent1.putExtra("app_package", getPackageName()); | |
| 86 | + intent1.putExtra("app_uid", getApplicationInfo().uid); | |
| 87 | + } | |
| 88 | + | |
| 89 | + // 小米6 -MIUI9.6-8.0.0系统,是个特例,通知设置界面只能控制"允许使用通知圆点"——然而这个玩意并没有卵用,我想对雷布斯说:I'm not ok!!! | |
| 90 | + // if ("MI 6".equals(Build.MODEL)) { | |
| 91 | + // intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); | |
| 92 | + // Uri uri = Uri.fromParts("package", getPackageName(), null); | |
| 93 | + // intent.setData(uri); | |
| 94 | + // // intent.setAction("com.android.settings/.SubSettings"); | |
| 95 | + // } | |
| 96 | + startActivity(intent1); | |
| 97 | + } catch (Exception e) { | |
| 98 | + //其他低版本或者异常情况,走该节点。进入APP设置界面 | |
| 99 | + intent1.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); | |
| 100 | + intent1.putExtra("package", getPackageName()); | |
| 101 | + startActivity(intent1); | |
| 102 | + } | |
| 103 | + Toast.makeText(getApplicationContext(), "您尚未开启通知权限,无法进行计步", Toast.LENGTH_LONG).show(); | |
| 104 | + } | |
| 105 | + | |
| 106 | + @Override | |
| 107 | + protected void onRestart() { | |
| 108 | + super.onRestart(); | |
| 109 | + | |
| 110 | + } | |
| 111 | + | |
| 112 | + @Override | |
| 113 | + protected void onResume() { | |
| 114 | + | |
| 115 | + boolean result = false; | |
| 116 | + if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECEIVE_BOOT_COMPLETED) == PackageManager.PERMISSION_GRANTED) { | |
| 117 | + result = true; | |
| 118 | + } | |
| 119 | + Log.e("i", "" + result + "," + getPackageName()); | |
| 120 | + PackageManager pm = getPackageManager(); | |
| 121 | + pm.checkPermission("android.permission.RECEIVE_BOOT_COMPLETED", getPackageName()); | |
| 122 | + try { | |
| 123 | + PackageInfo packageInfo = pm.getPackageInfo(getPackageName(), PackageManager.GET_PERMISSIONS); | |
| 124 | + for (int i = 0; i < packageInfo.requestedPermissions.length; i++) { | |
| 125 | + } | |
| 126 | +// Log.e("i", "" + packageInfo.requestedPermissions[i]); | |
| 127 | + } catch (PackageManager.NameNotFoundException e) { | |
| 128 | + e.printStackTrace(); | |
| 129 | + } | |
| 130 | + | |
| 131 | + super.onResume(); | |
| 132 | + check(); | |
| 133 | +// PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE); | |
| 134 | + | |
| 135 | +// if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { | |
| 136 | +// boolean hasIgnored = powerManager.isIgnoringBatteryOptimizations(getPackageName()); | |
| 137 | +// if (!hasIgnored) { | |
| 138 | +// Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); | |
| 139 | +// intent.setData(Uri.parse("package:" + getPackageName())); | |
| 140 | +// PackageManager pm = getPackageManager(); | |
| 141 | +// if (intent.resolveActivity(pm) != null) { | |
| 142 | +// startActivity(intent); | |
| 143 | +// } | |
| 144 | +// } | |
| 145 | +// } | |
| 146 | + getPermissionsWithTip(); | |
| 147 | + } | |
| 148 | + | |
| 149 | + private void addFragment() { | |
| 150 | + fragment = new CollRunMainFragment(); | |
| 151 | + getSupportFragmentManager().beginTransaction() | |
| 152 | + .add(getContextViewId(), fragment, fragment.getClass().getSimpleName()) | |
| 153 | + .addToBackStack(fragment.getClass().getSimpleName()) | |
| 154 | + .commit(); | |
| 155 | + } | |
| 156 | + | |
| 157 | + | |
| 158 | + /** | |
| 159 | + * 一次申请一组权限(使用拒绝弹框)点击事件 | |
| 160 | + */ | |
| 161 | + public void getPermissionsWithTip() { | |
| 162 | + mPermissionsUtils | |
| 163 | + .setPermissionsListener(new PermissionsListener() { | |
| 164 | + @Override | |
| 165 | + public void onDenied(String[] deniedPermissions) { | |
| 166 | + getPermissionsWithTip(); | |
| 167 | + Log.e(TAG, "onDenied: "); | |
| 168 | + } | |
| 169 | + | |
| 170 | + @Override | |
| 171 | + public void onGranted() { | |
| 172 | + | |
| 173 | + //判断GPS是否开启 | |
| 174 | + if (!MyMapUtil.isOPenGps(getApplicationContext())) { | |
| 175 | + //开启GPS | |
| 176 | + Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); | |
| 177 | + startActivityForResult(intent, 10); | |
| 178 | + Toast.makeText(getApplicationContext(), getString(R.string.open_gps_tip), Toast.LENGTH_LONG).show(); | |
| 179 | + } else { | |
| 180 | + addFragment(); | |
| 181 | + } | |
| 182 | + } | |
| 183 | + }) | |
| 184 | + .withActivity(CollPedometerMainActivity.this) | |
| 185 | + .getPermissions(CollPedometerMainActivity.this | |
| 186 | + , 100 | |
| 187 | + , Manifest.permission.INTERNET | |
| 188 | + , Manifest.permission.READ_EXTERNAL_STORAGE | |
| 189 | + , Manifest.permission.WRITE_EXTERNAL_STORAGE | |
| 190 | + , Manifest.permission.ACCESS_FINE_LOCATION | |
| 191 | + , Manifest.permission.ACCESS_COARSE_LOCATION | |
| 192 | + ); | |
| 193 | +// .getPermissionsWithTips(MainActivity.this | |
| 194 | +// ,100 | |
| 195 | +// , new String[]{"人家要录音","我们需要读取你的信息,磨磨唧唧的","我要上网","我要读内存卡","我要看日历","我要定位"} | |
| 196 | +// , Manifest.permission.RECORD_AUDIO | |
| 197 | +// , Manifest.permission.READ_SMS | |
| 198 | +// , Manifest.permission.INTERNET | |
| 199 | +// , Manifest.permission.READ_EXTERNAL_STORAGE | |
| 200 | +// , Manifest.permission.READ_CALENDAR | |
| 201 | +// , Manifest.permission.ACCESS_FINE_LOCATION); | |
| 202 | + } | |
| 203 | + | |
| 204 | + | |
| 205 | + /** | |
| 206 | + * 权限回调 | |
| 207 | + * | |
| 208 | + * @param requestCode | |
| 209 | + * @param permissions | |
| 210 | + * @param grantResults | |
| 211 | + */ | |
| 212 | + @Override | |
| 213 | + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, | |
| 214 | + @NonNull int[] grantResults) { | |
| 215 | + super.onRequestPermissionsResult(requestCode, permissions, grantResults); | |
| 216 | + mPermissionsUtils.dealResult(requestCode, permissions, grantResults); | |
| 217 | + } | |
| 218 | + | |
| 219 | + | |
| 220 | + @Override | |
| 221 | + public void onBackPressed() { | |
| 222 | + return; | |
| 223 | + } | |
| 224 | + | |
| 225 | +} | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/activity/CollRunRaceDetailActivity.java
0 → 100644
| 1 | +package com.cnlive.moudle.collectionTrace.ui.activity; | |
| 2 | + | |
| 3 | +import android.content.Intent; | |
| 4 | +import android.os.Bundle; | |
| 5 | +import android.support.annotation.Nullable; | |
| 6 | + | |
| 7 | +import com.alibaba.android.arouter.facade.annotation.Route; | |
| 8 | +import com.cnlive.libs.base.ui.QMUIFragment; | |
| 9 | +import com.cnlive.libs.base.ui.QMUIFragmentActivity; | |
| 10 | +import com.cnlive.libs.base.util.StatusBarUtil2; | |
| 11 | +import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunRaceDetailFragment; | |
| 12 | +import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; | |
| 13 | +import com.cnlive.moudle.pedometer.ui.fragment.RunMainFragment; | |
| 14 | +import com.cnlive.moudle.pedometer.ui.fragment.RunRaceDetailFragment; | |
| 15 | +import com.example.moudle_pedometer.R; | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * 活动赛事详情页 | |
| 19 | + * | |
| 20 | + * @author ShinnyYang | |
| 21 | + */ | |
| 22 | +@Route(path = "/moudle_pedometer/CollRunRaceDetailActivity") | |
| 23 | +public class CollRunRaceDetailActivity extends QMUIFragmentActivity { | |
| 24 | + private QMUIFragment fragment; | |
| 25 | + | |
| 26 | + @Override | |
| 27 | + protected int getContextViewId() { | |
| 28 | + return R.id.fragment_finish_run_map; | |
| 29 | + } | |
| 30 | + | |
| 31 | + @Override | |
| 32 | + protected void onCreate(Bundle savedInstanceState) { | |
| 33 | + super.onCreate(savedInstanceState); | |
| 34 | + StatusBarUtil2.setColor(this, getResources().getColor(R.color.run_main_bg), 0); | |
| 35 | + //判断用户是否结束运动 | |
| 36 | + boolean isRunStep = CommonInfo.getIsRunStepService(this); | |
| 37 | + //没有找到相关记录 | |
| 38 | + if (!isRunStep) { | |
| 39 | + fragment = new CollRunRaceDetailFragment(); | |
| 40 | + } | |
| 41 | + //找到记录 | |
| 42 | + else { | |
| 43 | + fragment = new RunMainFragment(); | |
| 44 | + } | |
| 45 | + if (fragment != null) { | |
| 46 | + addFragment(fragment); | |
| 47 | + } | |
| 48 | + } | |
| 49 | + | |
| 50 | + private void addFragment(QMUIFragment fragment) { | |
| 51 | + getSupportFragmentManager().beginTransaction() | |
| 52 | + .add(getContextViewId(), fragment, fragment.getClass().getSimpleName()) | |
| 53 | + .addToBackStack(fragment.getClass().getSimpleName()) | |
| 54 | + .commit(); | |
| 55 | + } | |
| 56 | + | |
| 57 | + @Override | |
| 58 | + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | |
| 59 | + super.onActivityResult(requestCode, resultCode, data); | |
| 60 | + if (resultCode == 1002) { | |
| 61 | + | |
| 62 | + } | |
| 63 | + } | |
| 64 | + | |
| 65 | + @Override | |
| 66 | + public void onBackPressed() { | |
| 67 | + super.onBackPressed(); | |
| 68 | + if (fragment != null) { | |
| 69 | + if (fragment instanceof RunMainFragment) { | |
| 70 | + return; | |
| 71 | + } | |
| 72 | + } | |
| 73 | + } | |
| 74 | +} | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/activity/CollRunningFinishActivity.java
0 → 100644
| 1 | +package com.cnlive.moudle.collectionTrace.ui.activity; | |
| 2 | + | |
| 3 | +import android.app.Activity; | |
| 4 | +import android.content.Intent; | |
| 5 | +import android.os.Bundle; | |
| 6 | +import android.support.annotation.Nullable; | |
| 7 | + | |
| 8 | +import com.alibaba.android.arouter.facade.annotation.Route; | |
| 9 | +import com.cnlive.libs.base.ui.QMUIFragment; | |
| 10 | +import com.cnlive.libs.base.ui.QMUIFragmentActivity; | |
| 11 | +import com.cnlive.libs.base.util.StatusBarUtil2; | |
| 12 | +import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunningFinishFragment; | |
| 13 | +import com.cnlive.moudle.pedometer.model.RunningFinishBean; | |
| 14 | +import com.cnlive.moudle.pedometer.ui.fragment.RunningFinishFragment; | |
| 15 | +import com.example.moudle_pedometer.R; | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * 跑步结束 | |
| 19 | + * | |
| 20 | + * @author ShinnyYang | |
| 21 | + */ | |
| 22 | +@Route(path = "/moudle_pedometer/CollRunningFinishActivity") | |
| 23 | +public class CollRunningFinishActivity extends QMUIFragmentActivity { | |
| 24 | + | |
| 25 | + @Override | |
| 26 | + protected int getContextViewId() { | |
| 27 | + return R.id.fragment_run_trace_detail; | |
| 28 | + } | |
| 29 | + | |
| 30 | + @Override | |
| 31 | + protected void onCreate(Bundle savedInstanceState) { | |
| 32 | + super.onCreate(savedInstanceState); | |
| 33 | + StatusBarUtil2.setColor(this, getResources().getColor(R.color.run_main_bg), 0); | |
| 34 | + if (getIntent().getSerializableExtra("runningFinishBean") != null) { | |
| 35 | + addFragment((RunningFinishBean) getIntent().getSerializableExtra("runningFinishBean")); | |
| 36 | + } | |
| 37 | + | |
| 38 | + | |
| 39 | + } | |
| 40 | + | |
| 41 | + private void addFragment(RunningFinishBean runningFinishBean) { | |
| 42 | + QMUIFragment fragment = CollRunningFinishFragment.instance(runningFinishBean); | |
| 43 | + getSupportFragmentManager().beginTransaction() | |
| 44 | + .add(getContextViewId(), fragment, fragment.getClass().getSimpleName()) | |
| 45 | + .addToBackStack(fragment.getClass().getSimpleName()) | |
| 46 | + .commit(); | |
| 47 | + } | |
| 48 | + | |
| 49 | + @Override | |
| 50 | + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | |
| 51 | + super.onActivityResult(requestCode, resultCode, data); | |
| 52 | + if (resultCode == 1002) { | |
| 53 | + | |
| 54 | + } | |
| 55 | + } | |
| 56 | + | |
| 57 | + public static void startActivity(Activity activity, RunningFinishBean runningFinishBean) { | |
| 58 | + Intent intent = new Intent(activity, CollRunningFinishActivity.class); | |
| 59 | + intent.putExtra("runningFinishBean", runningFinishBean); | |
| 60 | + activity.startActivity(intent); | |
| 61 | + } | |
| 62 | +} | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/activity/CollRunningMapActivity.java
0 → 100644
| 1 | +package com.cnlive.moudle.collectionTrace.ui.activity; | |
| 2 | + | |
| 3 | +import android.app.Activity; | |
| 4 | +import android.content.Intent; | |
| 5 | +import android.os.Bundle; | |
| 6 | + | |
| 7 | +import com.cnlive.libs.base.ui.QMUIFragment; | |
| 8 | +import com.cnlive.libs.base.ui.QMUIFragmentActivity; | |
| 9 | +import com.cnlive.libs.base.util.StatusBarUtil2; | |
| 10 | +import com.cnlive.moudle.collectionTrace.ui.fragment.CollRunningMapFragment; | |
| 11 | +import com.cnlive.moudle.pedometer.model.RunningMapBean; | |
| 12 | +import com.cnlive.moudle.pedometer.ui.fragment.RunningMapFragment; | |
| 13 | +import com.example.moudle_pedometer.R; | |
| 14 | + | |
| 15 | +public class CollRunningMapActivity extends QMUIFragmentActivity { | |
| 16 | + private static final String TAG = "CollRunningMapActivity"; | |
| 17 | + | |
| 18 | + @Override | |
| 19 | + protected void onCreate(Bundle savedInstanceState) { | |
| 20 | + super.onCreate(savedInstanceState); | |
| 21 | + | |
| 22 | + StatusBarUtil2.setColor(this, getResources().getColor(R.color.run_main_bg), 0); | |
| 23 | + RunningMapBean chronometerBean = (RunningMapBean) getIntent().getExtras().getSerializable("runningMapBean"); | |
| 24 | + if (chronometerBean != null) { | |
| 25 | + addFragment(chronometerBean); | |
| 26 | + } | |
| 27 | + } | |
| 28 | + | |
| 29 | + | |
| 30 | + @Override | |
| 31 | + protected int getContextViewId() { | |
| 32 | + return R.id.fragment_running_map; | |
| 33 | + } | |
| 34 | + | |
| 35 | + private void addFragment(RunningMapBean chronometerBean) { | |
| 36 | + QMUIFragment fragment = CollRunningMapFragment.getInstance(chronometerBean); | |
| 37 | + getSupportFragmentManager().beginTransaction() | |
| 38 | + .add(getContextViewId(), fragment, fragment.getClass().getSimpleName()) | |
| 39 | + .addToBackStack(fragment.getClass().getSimpleName()) | |
| 40 | + .commit(); | |
| 41 | + } | |
| 42 | + | |
| 43 | + public static void startActivity(Activity activity, RunningMapBean runningMapBean) { | |
| 44 | + Intent intent = new Intent(activity, CollRunningMapActivity.class); | |
| 45 | + intent.putExtra("runningMapBean", runningMapBean); | |
| 46 | + activity.startActivity(intent); | |
| 47 | + } | |
| 48 | +} | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/fragment/CollRunMainFragment.java
0 → 100644
| 1 | +package com.cnlive.moudle.collectionTrace.ui.fragment; | |
| 2 | + | |
| 3 | +import android.os.Bundle; | |
| 4 | +import android.os.Handler; | |
| 5 | +import android.support.annotation.Nullable; | |
| 6 | +import android.text.TextUtils; | |
| 7 | +import android.view.View; | |
| 8 | + | |
| 9 | +import com.cnlive.libs.base.ui.QMUIFragment; | |
| 10 | +import com.cnlive.moudle.pedometer.frame.presenter.RunMainFragmentPresenter; | |
| 11 | +import com.cnlive.moudle.pedometer.frame.view.RunMainFragmentView; | |
| 12 | +import com.cnlive.moudle.pedometer.model.Constant; | |
| 13 | +import com.cnlive.moudle.pedometer.model.MessageEvent; | |
| 14 | +import com.example.moudle_pedometer.R; | |
| 15 | +import com.example.moudle_pedometer.databinding.FragmentRunMainBinding; | |
| 16 | + | |
| 17 | +import org.greenrobot.eventbus.EventBus; | |
| 18 | +import org.greenrobot.eventbus.Subscribe; | |
| 19 | +import org.greenrobot.eventbus.ThreadMode; | |
| 20 | + | |
| 21 | +public class CollRunMainFragment extends QMUIFragment<RunMainFragmentView, RunMainFragmentPresenter, FragmentRunMainBinding> { | |
| 22 | + private final String TAG = "CollRunMainFragment"; | |
| 23 | + private String userId = "yangshuai"; | |
| 24 | + | |
| 25 | + @Override | |
| 26 | + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | |
| 27 | + super.onViewCreated(view, savedInstanceState); | |
| 28 | + EventBus.getDefault().register(this); | |
| 29 | + if (getMvpView() != null) { | |
| 30 | + new Handler().postDelayed(new Runnable() { | |
| 31 | + @Override | |
| 32 | + public void run() { | |
| 33 | + getMvpView().initView(); | |
| 34 | + } | |
| 35 | + }, 5); | |
| 36 | + } | |
| 37 | + | |
| 38 | + // | |
| 39 | + | |
| 40 | + | |
| 41 | + } | |
| 42 | + | |
| 43 | + @Override | |
| 44 | + public void onActivityCreated(@Nullable Bundle savedInstanceState) { | |
| 45 | + super.onActivityCreated(savedInstanceState); | |
| 46 | + | |
| 47 | + } | |
| 48 | + | |
| 49 | + @Override | |
| 50 | + public void onPause() { | |
| 51 | + super.onPause(); | |
| 52 | + //记录当前计时器相关数据 | |
| 53 | + if (getMvpView() != null) { | |
| 54 | + if (!TextUtils.isEmpty(userId)) { | |
| 55 | + getMvpView().setSQLPauseTime(userId); | |
| 56 | + } | |
| 57 | + } | |
| 58 | + } | |
| 59 | + | |
| 60 | + @Override | |
| 61 | + public void onDestroy() { | |
| 62 | + | |
| 63 | + super.onDestroy(); | |
| 64 | + if (EventBus.getDefault().isRegistered(this)) { | |
| 65 | + EventBus.getDefault().unregister(this); | |
| 66 | + } | |
| 67 | + if (getMvpView() != null) { | |
| 68 | + getMvpView().onDestroy(); | |
| 69 | + } | |
| 70 | + } | |
| 71 | + | |
| 72 | + @Override | |
| 73 | + protected int getToolbarId() { | |
| 74 | + return 0; | |
| 75 | + } | |
| 76 | + | |
| 77 | + @Override | |
| 78 | + public String getTitle() { | |
| 79 | + return null; | |
| 80 | + } | |
| 81 | + | |
| 82 | + @Override | |
| 83 | + protected int getLayoutId() { | |
| 84 | + return R.layout.fragment_run_main; | |
| 85 | + } | |
| 86 | + | |
| 87 | + @Subscribe(threadMode = ThreadMode.MAIN) | |
| 88 | + public void Event(MessageEvent messageEvent) { | |
| 89 | + //更新步数 | |
| 90 | + if (messageEvent.getMessageType() == Constant.SERVICE_STEP_COUNT_UPDATE) { | |
| 91 | + if (getMvpView() != null) { | |
| 92 | + getMvpView().updateRunDistance((Integer) messageEvent.getMessageContent()); | |
| 93 | + } | |
| 94 | + } | |
| 95 | + //重置速度 | |
| 96 | + else if (messageEvent.getMessageType() == Constant.SERVICE_STEP_COUNT_RESET_SPEED) { | |
| 97 | + if (getMvpView() != null) { | |
| 98 | + getMvpView().resetSpeed(); | |
| 99 | + } | |
| 100 | + } | |
| 101 | + } | |
| 102 | +} | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/fragment/CollRunRaceDetailFragment.java
0 → 100644
| 1 | +package com.cnlive.moudle.collectionTrace.ui.fragment; | |
| 2 | + | |
| 3 | +import android.hardware.Sensor; | |
| 4 | +import android.hardware.SensorManager; | |
| 5 | +import android.os.Bundle; | |
| 6 | +import android.support.annotation.Nullable; | |
| 7 | +import android.view.View; | |
| 8 | + | |
| 9 | +import com.cnlive.libs.base.ui.QMUIFragment; | |
| 10 | +import com.cnlive.moudle.pedometer.frame.presenter.RunRaceDetailFragmentPresenter; | |
| 11 | +import com.cnlive.moudle.pedometer.frame.view.RunRaceDetailFragmentView; | |
| 12 | +import com.example.moudle_pedometer.R; | |
| 13 | +import com.example.moudle_pedometer.databinding.FragmentRunRaceDetailBinding; | |
| 14 | + | |
| 15 | +import static android.content.Context.SENSOR_SERVICE; | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * 活动赛事详情页 | |
| 19 | + * | |
| 20 | + * @author ShinnyYang | |
| 21 | + */ | |
| 22 | +public class CollRunRaceDetailFragment extends QMUIFragment<RunRaceDetailFragmentView, RunRaceDetailFragmentPresenter, FragmentRunRaceDetailBinding> { | |
| 23 | + private static final String TAG = "CollRunRaceDetailFragment"; | |
| 24 | + private SensorManager mSensorManager; | |
| 25 | + | |
| 26 | + @Override | |
| 27 | + protected int getToolbarId() { | |
| 28 | + return 0; | |
| 29 | + } | |
| 30 | + | |
| 31 | + @Override | |
| 32 | + public String getTitle() { | |
| 33 | + return null; | |
| 34 | + } | |
| 35 | + | |
| 36 | + @Override | |
| 37 | + protected int getLayoutId() { | |
| 38 | + return R.layout.fragment_run_race_detail; | |
| 39 | + } | |
| 40 | + | |
| 41 | + @Override | |
| 42 | + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | |
| 43 | + super.onViewCreated(view, savedInstanceState); | |
| 44 | + | |
| 45 | + mSensorManager = (SensorManager) getActivity().getSystemService(SENSOR_SERVICE);//获取传感器管理服务 | |
| 46 | + if (getMvpView() != null) { | |
| 47 | + getMvpView().initMap();; | |
| 48 | + } | |
| 49 | + if (getPresenter()!=null){ | |
| 50 | + getPresenter().getRunRaceDetailInfo(getActivity(),"116","10513196"); | |
| 51 | + } | |
| 52 | + | |
| 53 | + } | |
| 54 | + | |
| 55 | + @Override | |
| 56 | + public void onResume() { | |
| 57 | + super.onResume(); | |
| 58 | + if (getMvpView() != null) { | |
| 59 | + getMvpView().onResume(); | |
| 60 | + } | |
| 61 | + if (getMvpView() != null) { | |
| 62 | + //为系统的方向传感器注册监听器 | |
| 63 | + mSensorManager.registerListener(getMvpView(), mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), | |
| 64 | + SensorManager.SENSOR_DELAY_UI); | |
| 65 | + } | |
| 66 | + } | |
| 67 | + | |
| 68 | + @Override | |
| 69 | + public void onStop() { | |
| 70 | + super.onStop(); | |
| 71 | + if (getMvpView() != null) { | |
| 72 | + //取消注册传感器监听 | |
| 73 | + mSensorManager.unregisterListener(getMvpView()); | |
| 74 | + } | |
| 75 | + } | |
| 76 | + | |
| 77 | + @Override | |
| 78 | + public void onPause() { | |
| 79 | + super.onPause(); | |
| 80 | + if (getMvpView() != null) { | |
| 81 | + getMvpView().onPause(); | |
| 82 | + } | |
| 83 | + } | |
| 84 | + | |
| 85 | + @Override | |
| 86 | + public void onDestroy() { | |
| 87 | + super.onDestroy(); | |
| 88 | + if (getMvpView() != null) { | |
| 89 | + getMvpView().onDestroy(); | |
| 90 | + } | |
| 91 | + | |
| 92 | + } | |
| 93 | +// private void test() { | |
| 94 | +// BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(getActivity()); | |
| 95 | +// View view = getLayoutInflater().inflate(R.layout.bottom_sheet_dialog_run_race_detail, null); | |
| 96 | +// LinearLayout ll_end_point = view.findViewById(R.id.ll_end_point); | |
| 97 | +// bottomSheetDialog.setContentView(view); | |
| 98 | +// bottomSheetDialog.show(); | |
| 99 | +// bottomSheetDialog.setCancelable(false); | |
| 100 | +// bottomSheetDialog.setCanceledOnTouchOutside(false); | |
| 101 | +// //以下设置是为了解决:下滑隐藏dialog后,再次调用show方法显示时,不能弹出Dialog----在真机测试时不写下面的方法也未发现问题 | |
| 102 | +// View delegateView = bottomSheetDialog.getDelegate().findViewById(android.support.design.R.id.design_bottom_sheet); | |
| 103 | +// final BottomSheetBehavior<View> sheetBehavior = BottomSheetBehavior.from(delegateView); | |
| 104 | +// sheetBehavior.setPeekHeight(ScreenUtil.getScreenHeight(getActivity()) / 3); | |
| 105 | +// sheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() { | |
| 106 | +// //在下滑隐藏结束时才会触发 | |
| 107 | +// @Override | |
| 108 | +// public void onStateChanged(@NonNull View bottomSheet, int newState) { | |
| 109 | +// if (newState == BottomSheetBehavior.STATE_HIDDEN) { | |
| 110 | +// Log.e(TAG, "onStateChanged: "); | |
| 111 | +// bottomSheetDialog.dismiss(); | |
| 112 | +// sheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); | |
| 113 | +// } | |
| 114 | +// } | |
| 115 | +// | |
| 116 | +// //每次滑动都会触发 | |
| 117 | +// @Override | |
| 118 | +// public void onSlide(@NonNull View bottomSheet, float slideOffset) { | |
| 119 | +// Log.e(TAG, "onSlide: "); | |
| 120 | +// System.out.println("onSlide = [" + bottomSheet + "], slideOffset = [" + slideOffset + "]"); | |
| 121 | +// } | |
| 122 | +// }); | |
| 123 | +// | |
| 124 | +// String aa = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1559215229357&di=5db17f5fec9e9a221cc189778172e1cc&imgtype=0&src=http%3A%2F%2Fi0.hdslb.com%2Fbfs%2Farticle%2Fa8c6df0dd7455fdb133575965d0719ee17aab281.png"; | |
| 125 | +// String bb = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1559215229356&di=0c69b8c0c4c9ababe6cbaad6baab7daa&imgtype=0&src=http%3A%2F%2Fi0.hdslb.com%2Fbfs%2Farticle%2Fd680da563ff3eef98ed0ed9ecaf77a9723d6cab1.jpg"; | |
| 126 | +// String cc = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1559215229355&di=1f10e593f204a31eff3f731c3979897f&imgtype=0&src=http%3A%2F%2Fclubimg.club.vmall.com%2Fdata%2Fattachment%2Fforum%2F201904%2F19%2F072347eaumvasbmf6ugayz.png"; | |
| 127 | +// String dd = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1559215229355&di=4626e51f57b8afd118b85b11670f5ad4&imgtype=0&src=http%3A%2F%2Fi0.hdslb.com%2Fbfs%2Farticle%2Fa66a2c06579a89860860a9b340da7441aafc8ad9.jpg"; | |
| 128 | +// String ee = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1559215229355&di=a211d0b0a13ed984a660a2d567e43694&imgtype=0&src=http%3A%2F%2Fi0.hdslb.com%2Fbfs%2Farticle%2F43d728f77e3df78155ed81c95efc49f0ef34fd6a.jpg"; | |
| 129 | +// List<String> data = new ArrayList<>(); | |
| 130 | +// data.add(aa); | |
| 131 | +// data.add(bb); | |
| 132 | +// data.add(cc); | |
| 133 | +// data.add(dd); | |
| 134 | +// data.add(ee); | |
| 135 | +// FivePersonIconView fivePersonIconView = view.findViewById(R.id.five_join_person); | |
| 136 | +// fivePersonIconView.initIconData(data); | |
| 137 | +// } | |
| 138 | +} | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/fragment/CollRunningFinishFragment.java
0 → 100644
| 1 | +package com.cnlive.moudle.collectionTrace.ui.fragment; | |
| 2 | + | |
| 3 | +import android.os.Bundle; | |
| 4 | +import android.support.annotation.Nullable; | |
| 5 | +import android.view.View; | |
| 6 | + | |
| 7 | +import com.cnlive.libs.base.ui.QMUIFragment; | |
| 8 | +import com.cnlive.moudle.pedometer.frame.presenter.RunningFinishFragmetPresenter; | |
| 9 | +import com.cnlive.moudle.pedometer.frame.view.RunningFinishFragmentView; | |
| 10 | +import com.cnlive.moudle.pedometer.model.RunningFinishBean; | |
| 11 | +import com.example.moudle_pedometer.R; | |
| 12 | +import com.example.moudle_pedometer.databinding.FragmentFinishRunMapBinding; | |
| 13 | + | |
| 14 | +public class CollRunningFinishFragment extends QMUIFragment<RunningFinishFragmentView, RunningFinishFragmetPresenter, FragmentFinishRunMapBinding> { | |
| 15 | + private RunningFinishBean runningFinishBean; | |
| 16 | + | |
| 17 | + public static CollRunningFinishFragment instance(RunningFinishBean runningFinishBean) { | |
| 18 | + CollRunningFinishFragment fragment = new CollRunningFinishFragment(); | |
| 19 | + Bundle bundle = null; | |
| 20 | + if (runningFinishBean != null) { | |
| 21 | + bundle = new Bundle(); | |
| 22 | + bundle.putSerializable("runningFinishBean", runningFinishBean); | |
| 23 | + } | |
| 24 | + fragment.setArguments(bundle); | |
| 25 | + return fragment; | |
| 26 | + } | |
| 27 | + | |
| 28 | + @Override | |
| 29 | + protected int getToolbarId() { | |
| 30 | + return 0; | |
| 31 | + } | |
| 32 | + | |
| 33 | + @Override | |
| 34 | + public String getTitle() { | |
| 35 | + return null; | |
| 36 | + } | |
| 37 | + | |
| 38 | + @Override | |
| 39 | + protected int getLayoutId() { | |
| 40 | + return R.layout.fragment_finish_run_map; | |
| 41 | + } | |
| 42 | + | |
| 43 | + @Override | |
| 44 | + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | |
| 45 | + super.onViewCreated(view, savedInstanceState); | |
| 46 | + if (getArguments() != null) { | |
| 47 | + runningFinishBean = (RunningFinishBean) getArguments().getSerializable("runningFinishBean"); | |
| 48 | + if (runningFinishBean != null) { | |
| 49 | + if (getMvpView() != null) { | |
| 50 | + getMvpView().initView(runningFinishBean); | |
| 51 | + } | |
| 52 | + } | |
| 53 | + } | |
| 54 | + } | |
| 55 | +} | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/ui/fragment/CollRunningMapFragment.java
0 → 100644
| 1 | +package com.cnlive.moudle.collectionTrace.ui.fragment; | |
| 2 | + | |
| 3 | +import android.app.Service; | |
| 4 | +import android.hardware.Sensor; | |
| 5 | +import android.hardware.SensorManager; | |
| 6 | +import android.os.Bundle; | |
| 7 | +import android.os.Vibrator; | |
| 8 | +import android.support.annotation.Nullable; | |
| 9 | +import android.text.TextUtils; | |
| 10 | +import android.util.Log; | |
| 11 | +import android.view.View; | |
| 12 | + | |
| 13 | +import com.baidu.mapapi.model.LatLng; | |
| 14 | +import com.cnlive.libs.base.ui.QMUIFragment; | |
| 15 | +import com.cnlive.libs.base.util.StatusBarUtil2; | |
| 16 | +import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; | |
| 17 | +import com.cnlive.moudle.pedometer.frame.presenter.RunningMapFragmentPresenter; | |
| 18 | +import com.cnlive.moudle.pedometer.frame.view.RunningMapFragmentView; | |
| 19 | +import com.cnlive.moudle.pedometer.model.Constant; | |
| 20 | +import com.cnlive.moudle.pedometer.model.MessageEvent; | |
| 21 | +import com.cnlive.moudle.pedometer.model.RunningMapBean; | |
| 22 | +import com.cnlive.moudle.pedometer.service.StepService; | |
| 23 | +import com.cnlive.moudle.pedometer.ui.widget.TipDialog; | |
| 24 | +import com.cnlive.moudle.pedometer.utils.ChineseToSpeechUtil; | |
| 25 | +import com.cnlive.moudle.pedometer.utils.GsonUtil; | |
| 26 | +import com.cnlive.moudle.pedometer.utils.TimeUtil; | |
| 27 | +import com.example.moudle_pedometer.R; | |
| 28 | +import com.example.moudle_pedometer.databinding.FragmentRunningMapBinding; | |
| 29 | + | |
| 30 | +import org.greenrobot.eventbus.EventBus; | |
| 31 | +import org.greenrobot.eventbus.Subscribe; | |
| 32 | +import org.greenrobot.eventbus.ThreadMode; | |
| 33 | + | |
| 34 | +import java.util.ArrayList; | |
| 35 | +import java.util.List; | |
| 36 | + | |
| 37 | +import static android.content.Context.SENSOR_SERVICE; | |
| 38 | + | |
| 39 | +/** | |
| 40 | + * 正在跑步的地图界面 | |
| 41 | + * | |
| 42 | + * @author ShinnyYang | |
| 43 | + */ | |
| 44 | +public class CollRunningMapFragment extends QMUIFragment<RunningMapFragmentView, RunningMapFragmentPresenter, FragmentRunningMapBinding> { | |
| 45 | + private static final String TAG = "CollRunningMapFragment"; | |
| 46 | + private RunningMapBean runningMapBean; | |
| 47 | + private SensorManager mSensorManager; | |
| 48 | + 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}]"; | |
| 49 | + //创建震动服务对象 | |
| 50 | + private Vibrator mVibrator; | |
| 51 | + private TipDialog tipDialog; | |
| 52 | + | |
| 53 | + @Override | |
| 54 | + protected int getToolbarId() { | |
| 55 | + return 0; | |
| 56 | + } | |
| 57 | + | |
| 58 | + @Override | |
| 59 | + public String getTitle() { | |
| 60 | + return null; | |
| 61 | + } | |
| 62 | + | |
| 63 | + @Override | |
| 64 | + protected int getLayoutId() { | |
| 65 | + return R.layout.fragment_running_map; | |
| 66 | + } | |
| 67 | + | |
| 68 | + public static CollRunningMapFragment getInstance(RunningMapBean runningMapBean) { | |
| 69 | + CollRunningMapFragment fragment = new CollRunningMapFragment(); | |
| 70 | + Bundle bundle = new Bundle(); | |
| 71 | + if (runningMapBean != null) { | |
| 72 | + bundle.putSerializable("runningMapBean", runningMapBean); | |
| 73 | + } | |
| 74 | + fragment.setArguments(bundle); | |
| 75 | + return fragment; | |
| 76 | + } | |
| 77 | + | |
| 78 | + @Override | |
| 79 | + public void onActivityCreated(@Nullable Bundle savedInstanceState) { | |
| 80 | + super.onActivityCreated(savedInstanceState); | |
| 81 | + StatusBarUtil2.setColor(getActivity(), getResources().getColor(R.color.run_main_bg), 0); | |
| 82 | + } | |
| 83 | + | |
| 84 | + @Override | |
| 85 | + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | |
| 86 | + super.onViewCreated(view, savedInstanceState); | |
| 87 | + EventBus.getDefault().register(this); | |
| 88 | + //获取传感器管理服务 | |
| 89 | + mSensorManager = (SensorManager) getActivity().getSystemService(SENSOR_SERVICE); | |
| 90 | + //获取手机震动服务 | |
| 91 | + mVibrator = (Vibrator) getActivity().getSystemService(Service.VIBRATOR_SERVICE); | |
| 92 | + //初始化提示框 | |
| 93 | + initTipDialog(); | |
| 94 | + List<LatLng> trackPoints = GsonUtil.jsonToList(test, LatLng.class); | |
| 95 | + | |
| 96 | + if (getArguments() != null) { | |
| 97 | + runningMapBean = (RunningMapBean) getArguments().getSerializable("runningMapBean"); | |
| 98 | + } | |
| 99 | + if (getMvpView() != null) { | |
| 100 | + getMvpView().initView(trackPoints); | |
| 101 | + if (runningMapBean != null) { | |
| 102 | + getMvpView().updateChronometer(runningMapBean); | |
| 103 | + } | |
| 104 | + } | |
| 105 | + //开始进行历史轨迹查询 | |
| 106 | + if (getPresenter() != null && !TextUtils.isEmpty(StepService.entityName)) { | |
| 107 | + long stepStartTime = CommonInfo.getStepStartTime(getActivity()); | |
| 108 | + Log.e(TAG, "onViewCreated: 时间"+stepStartTime ); | |
| 109 | + long startTime = 0; | |
| 110 | + if (stepStartTime != 0) { | |
| 111 | + startTime = stepStartTime; | |
| 112 | + } else { | |
| 113 | + startTime = (int) (System.currentTimeMillis() / 1000 -12 * 60 * 60); | |
| 114 | + } | |
| 115 | + long current = TimeUtil.getCurrentTime(); | |
| 116 | +// long startTime = current - hour * 3600 * 1000 - minute * 60 * 1000 - second * 1000; | |
| 117 | + long endTime = current; | |
| 118 | +// Log.e(TAG, "onViewCreated: " + "hour:" + hour + ",minute" + minute + ",second:" + second); | |
| 119 | + getPresenter().queryHistoryTrace(getActivity(), StepService.entityName, startTime, endTime); | |
| 120 | + //查询实时轨迹 | |
| 121 | + getPresenter().queryRealTimeTrace(getActivity(), StepService.entityName, startTime); | |
| 122 | + | |
| 123 | + } | |
| 124 | + | |
| 125 | + | |
| 126 | + List<com.baidu.trace.model.LatLng> fenceLatLngs = new ArrayList<>(); | |
| 127 | + for (LatLng latLng : trackPoints) { | |
| 128 | + com.baidu.trace.model.LatLng tempLatLng = new com.baidu.trace.model.LatLng(latLng.latitude, latLng.longitude); | |
| 129 | + fenceLatLngs.add(tempLatLng); | |
| 130 | + } | |
| 131 | + getPresenter().createFence(getActivity(), fenceLatLngs); | |
| 132 | + } | |
| 133 | + | |
| 134 | + @Override | |
| 135 | + public void onResume() { | |
| 136 | + super.onResume(); | |
| 137 | + if (getMvpView() != null) { | |
| 138 | + getMvpView().onResume(); | |
| 139 | + } | |
| 140 | + if (getMvpView() != null) { | |
| 141 | + //为系统的方向传感器注册监听器 | |
| 142 | + mSensorManager.registerListener(getMvpView(), mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION), | |
| 143 | + SensorManager.SENSOR_DELAY_UI); | |
| 144 | + } | |
| 145 | + } | |
| 146 | + | |
| 147 | + @Override | |
| 148 | + public void onStop() { | |
| 149 | + super.onStop(); | |
| 150 | + if (getMvpView() != null) { | |
| 151 | + //取消注册传感器监听 | |
| 152 | + mSensorManager.unregisterListener(getMvpView()); | |
| 153 | + } | |
| 154 | + ChineseToSpeechUtil.destroy(); | |
| 155 | + | |
| 156 | + } | |
| 157 | + | |
| 158 | + @Override | |
| 159 | + public void onPause() { | |
| 160 | + super.onPause(); | |
| 161 | + if (getMvpView() != null) { | |
| 162 | + getMvpView().onPause(); | |
| 163 | + } | |
| 164 | + | |
| 165 | + } | |
| 166 | + | |
| 167 | + @Override | |
| 168 | + public void onDestroy() { | |
| 169 | + super.onDestroy(); | |
| 170 | + if (getMvpView() != null) { | |
| 171 | + getMvpView().onDestroy(); | |
| 172 | + } | |
| 173 | + if (EventBus.getDefault().isRegistered(this)) { | |
| 174 | + EventBus.getDefault().unregister(this); | |
| 175 | + } | |
| 176 | + | |
| 177 | + } | |
| 178 | + | |
| 179 | + @Subscribe(threadMode = ThreadMode.MAIN) | |
| 180 | + public void Event(MessageEvent messageEvent) { | |
| 181 | + //更新步数 | |
| 182 | + if (messageEvent.getMessageType() == Constant.SERVICE_STEP_COUNT_UPDATE) { | |
| 183 | + if (getMvpView() != null) { | |
| 184 | + getMvpView().updateRunDistance((Integer) messageEvent.getMessageContent()); | |
| 185 | + } | |
| 186 | + } | |
| 187 | + //重置速度 | |
| 188 | + else if (messageEvent.getMessageType() == Constant.SERVICE_STEP_COUNT_RESET_SPEED) { | |
| 189 | + if (getMvpView() != null) { | |
| 190 | + getMvpView().resetSpeed(); | |
| 191 | + } | |
| 192 | + } | |
| 193 | + //超出范围 | |
| 194 | + else if (messageEvent.getMessageType() == Constant.EXIT_RANGE) { | |
| 195 | + ChineseToSpeechUtil.speech(getActivity().getApplicationContext(), "您已偏离预定轨迹!"); | |
| 196 | + if (mVibrator != null) { | |
| 197 | + //设置震动周期,数组表示时间:等待+执行,单位是毫秒,下面操作代表:等待100,执行100,等待100,执行1000, | |
| 198 | + //后面的数字如果为-1代表不重复,之执行一次,其他代表会重复,0代表从数组的第0个位置开始 | |
| 199 | + mVibrator.vibrate(new long[]{100, 1000, 100, 1000}, -1); | |
| 200 | + } | |
| 201 | + if (tipDialog != null) { | |
| 202 | + tipDialog.show(); | |
| 203 | + } | |
| 204 | + } | |
| 205 | + } | |
| 206 | + | |
| 207 | + private void initTipDialog() { | |
| 208 | + if (tipDialog == null) { | |
| 209 | + tipDialog = new TipDialog(getActivity(), "您已偏离预定轨迹!", "我知道了", R.color.green_round, new TipDialog.DialogInterface() { | |
| 210 | + @Override | |
| 211 | + public void onClick(TipDialog dialog) { | |
| 212 | + dialog.dismiss(); | |
| 213 | + } | |
| 214 | + }); | |
| 215 | + tipDialog.setCancelable(false); | |
| 216 | + tipDialog.setCanceledOnTouchOutside(false); | |
| 217 | + } | |
| 218 | + } | |
| 219 | + | |
| 220 | + | |
| 221 | +} | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/presenter/RunRaceDetailFragmentPresenter.java
| 1 | 1 | package com.cnlive.moudle.pedometer.frame.presenter; |
| 2 | 2 | |
| 3 | 3 | import android.content.Context; |
| 4 | +import android.view.View; | |
| 5 | +import android.widget.Toast; | |
| 4 | 6 | |
| 7 | +import com.cnlive.libs.base.logic.Config; | |
| 5 | 8 | import com.cnlive.libs.base.logic.Logic; |
| 9 | +import com.cnlive.libs.base.logic.callback.DataCallback; | |
| 6 | 10 | import com.cnlive.libs.base.logic.callback.FailureCallback; |
| 11 | +import com.cnlive.libs.base.logic.callback.StateCallback; | |
| 12 | +import com.cnlive.libs.base.logic.callback.SuccessCallback; | |
| 7 | 13 | import com.cnlive.libs.data.network.model.IBaseInfo; |
| 8 | 14 | import com.cnlive.moudle.pedometer.frame.view.RunRaceDetailFragmentView; |
| 9 | 15 | import com.cnlive.moudle.pedometer.frame.view.RunningMapFragmentView; |
| 16 | +import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil; | |
| 17 | +import com.cnlive.strike.data.network.api.ApiRequest; | |
| 18 | +import com.cnlive.strike.data.network.api.ApiServiceDaren; | |
| 19 | +import com.cnlive.strike.data.network.model.BaseInfo; | |
| 20 | +import com.cnlive.strike.data.network.model.runAbout.RunRaceDetailInfo; | |
| 10 | 21 | import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; |
| 11 | 22 | |
| 12 | 23 | import java.util.HashMap; |
| ... | ... | @@ -14,6 +25,9 @@ import java.util.Map; |
| 14 | 25 | |
| 15 | 26 | import io.reactivex.disposables.Disposable; |
| 16 | 27 | |
| 28 | +import static com.cnlive.libs.base.logic.Config.STATE_IDLE; | |
| 29 | +import static com.cnlive.libs.base.logic.Config.STATE_LOAD; | |
| 30 | + | |
| 17 | 31 | public class RunRaceDetailFragmentPresenter extends MvpBasePresenter<RunRaceDetailFragmentView> { |
| 18 | 32 | |
| 19 | 33 | public void getRunRaceDetailInfo(Context context, String id, String userId) { |
| ... | ... | @@ -21,41 +35,87 @@ public class RunRaceDetailFragmentPresenter extends MvpBasePresenter<RunRaceDeta |
| 21 | 35 | Map<String, String> paramsMap = new HashMap<>(); |
| 22 | 36 | //赛事id |
| 23 | 37 | paramsMap.put("id", id); |
| 24 | - paramsMap.put("userId", userId); | |
| 38 | + paramsMap.put("sid", userId); | |
| 25 | 39 | |
| 26 | 40 | // Logic.create(paramsMap) |
| 27 | -// .action(new Logic.Action<Map<String, String>, BaseInfo>() { | |
| 41 | +// .action(new Logic.Action<Map<String, String>, BaseInfo<RunRaceDetailInfo>>() { | |
| 28 | 42 | // @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); | |
| 43 | +// public Disposable action(Map<String, String> paramsMap, DataCallback<BaseInfo<RunRaceDetailInfo>> dataCallback) { | |
| 44 | +// return ApiRequest.service(ApiServiceDaren.class, api -> api.getRunRaceDetail(paramsMap)).subscribe(context, dataCallback); | |
| 31 | 45 | // } |
| 32 | -// }).<SubscriptionBaseInfo>event() | |
| 33 | -// .setSuccessCallback(new SuccessCallback<SubscriptionBaseInfo>() { | |
| 46 | +// }).<BaseInfo<RunRaceDetailInfo>>event() | |
| 47 | +// .setStateCallback(new StateCallback() { | |
| 34 | 48 | // @Override |
| 35 | -// public void onSuccess(SubscriptionBaseInfo subscriptionBaseInfo) { | |
| 36 | -// if (getView() != null) { | |
| 37 | -// getView().hideQmuiDialog(); | |
| 49 | +// public void onState(int i) { | |
| 50 | +// if (getView() == null) { | |
| 51 | +// return; | |
| 52 | +// } | |
| 53 | +// if (i == STATE_LOAD) { | |
| 54 | +// QMUITipDialogUtil.loadingDialog(context, "正在获取赛事详情", false); | |
| 55 | +// } else if (i == STATE_IDLE) { | |
| 38 | 56 | // } |
| 39 | -// callBack.onSuccess(); | |
| 40 | -// } | |
| 41 | 57 | // |
| 58 | +// } | |
| 42 | 59 | // }) |
| 43 | -// .setFailureCallback(new FailureCallback() { | |
| 60 | +// .setSuccessCallback(new SuccessCallback<BaseInfo<RunRaceDetailInfo>>() { | |
| 44 | 61 | // @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 | -// } | |
| 62 | +// public void onSuccess(BaseInfo<RunRaceDetailInfo> runRaceDetailInfoBaseInfo) { | |
| 63 | +// if (getView() == null) { | |
| 64 | +// return; | |
| 54 | 65 | // } |
| 55 | 66 | // } |
| 56 | -// }) | |
| 57 | -// | |
| 58 | -// .start(); | |
| 67 | +// }).setFailureCallback(new FailureCallback() { | |
| 68 | +// @Override | |
| 69 | +// public void onFailure(int i, String s) { | |
| 70 | +// if (getView() == null) { | |
| 71 | +// return; | |
| 72 | +// } | |
| 73 | +// } | |
| 74 | +// }).start(); | |
| 75 | + Logic.create(paramsMap).action(new Logic.Action<Map<String, String>, BaseInfo<RunRaceDetailInfo>>() { | |
| 76 | + @Override | |
| 77 | + public Disposable action(Map<String, String> stringStringMap, DataCallback<BaseInfo<RunRaceDetailInfo>> dataCallback) { | |
| 78 | + return ApiRequest.observable(ApiServiceDaren.class, api -> api.getRunRaceDetail(stringStringMap)).subscribe(context, dataCallback); | |
| 79 | + } | |
| 80 | + }).<BaseInfo<RunRaceDetailInfo>>event() | |
| 81 | + .setStateCallback(new StateCallback() { | |
| 82 | + @Override | |
| 83 | + public void onState(int i) { | |
| 84 | + if (getView() == null) { | |
| 85 | + return; | |
| 86 | + } | |
| 87 | + if (i == STATE_LOAD) { | |
| 88 | + getView().showLoadingView(); | |
| 89 | + } else if (i == STATE_IDLE) { | |
| 90 | + getView().hideLoadingView(); | |
| 91 | + } | |
| 92 | + } | |
| 93 | + }) | |
| 94 | + .setFailureCallback(new FailureCallback() { | |
| 95 | + @Override | |
| 96 | + public void onFailure(int code, String message) { | |
| 97 | + if (getView() == null) { | |
| 98 | + return; | |
| 99 | + } | |
| 100 | + getView().hideLoadingView(); | |
| 101 | + getView().showRetryView(code, new View.OnClickListener() { | |
| 102 | + @Override | |
| 103 | + public void onClick(View view) { | |
| 104 | + getRunRaceDetailInfo(context, id, userId); | |
| 105 | + } | |
| 106 | + }); | |
| 107 | + } | |
| 108 | + }).setSuccessCallback(new SuccessCallback<BaseInfo<RunRaceDetailInfo>>() { | |
| 109 | + @Override | |
| 110 | + public void onSuccess(BaseInfo<RunRaceDetailInfo> baseInfo) { | |
| 111 | + if (getView() == null) { | |
| 112 | + return; | |
| 113 | + } | |
| 114 | + if (baseInfo.getData() != null) { | |
| 115 | + getView().initView(baseInfo.getData()); | |
| 116 | + } | |
| 117 | + } | |
| 118 | + }).start(); | |
| 59 | 119 | |
| 60 | 120 | } |
| 61 | 121 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunMainFragmentView.java
| ... | ... | @@ -44,7 +44,7 @@ import com.hannesdorfmann.mosby3.mvp.MvpView; |
| 44 | 44 | import org.greenrobot.eventbus.EventBus; |
| 45 | 45 | |
| 46 | 46 | public class RunMainFragmentView implements MvpView { |
| 47 | - private final String TAG = "RunMainFragmentView"; | |
| 47 | + private final String TAG = "CollRunMainFragmentView"; | |
| 48 | 48 | private RunMainFragment fragment; |
| 49 | 49 | private boolean stopStartFlag = false; |
| 50 | 50 | private boolean continueStartFlag = false; | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
| ... | ... | @@ -9,6 +9,7 @@ import android.hardware.Sensor; |
| 9 | 9 | import android.hardware.SensorEvent; |
| 10 | 10 | import android.hardware.SensorEventListener; |
| 11 | 11 | import android.hardware.SensorManager; |
| 12 | +import android.text.TextUtils; | |
| 12 | 13 | import android.util.Log; |
| 13 | 14 | import android.view.LayoutInflater; |
| 14 | 15 | import android.view.View; |
| ... | ... | @@ -63,6 +64,9 @@ import com.cnlive.moudle.pedometer.utils.BitmapUtil; |
| 63 | 64 | import com.cnlive.moudle.pedometer.utils.GsonUtil; |
| 64 | 65 | import com.cnlive.moudle.pedometer.utils.MyMapUtil; |
| 65 | 66 | import com.cnlive.moudle.pedometer.utils.ScreenUtil; |
| 67 | +import com.cnlive.moudle.pedometer.utils.TimeUtil; | |
| 68 | +import com.cnlive.strike.application.GlideApp; | |
| 69 | +import com.cnlive.strike.data.network.model.runAbout.RunRaceDetailInfo; | |
| 66 | 70 | import com.example.moudle_pedometer.R; |
| 67 | 71 | import com.hannesdorfmann.mosby3.mvp.MvpView; |
| 68 | 72 | import com.sothree.slidinguppanel.SlidingUpPanelLayout; |
| ... | ... | @@ -110,6 +114,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 110 | 114 | private LinkedList<LatLng> importLatLngs;//关键点 |
| 111 | 115 | private LatLng startLatLng = new LatLng(39.934733, 116.308646);//起始点 |
| 112 | 116 | private List<LatLng> trackPoints; |
| 117 | + private RunRaceDetailInfo runRaceDetailInfo; | |
| 113 | 118 | |
| 114 | 119 | public RunRaceDetailFragmentView(RunRaceDetailFragment fragment) { |
| 115 | 120 | this.fragment = fragment; |
| ... | ... | @@ -119,19 +124,35 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 119 | 124 | return fragment == null ? null : fragment.getActivity(); |
| 120 | 125 | } |
| 121 | 126 | |
| 122 | - public void initView() { | |
| 127 | + | |
| 128 | + public void initView(RunRaceDetailInfo runRaceDetailInfo) { | |
| 123 | 129 | if (fragment.getActivity() == null) { |
| 124 | 130 | return; |
| 125 | 131 | } |
| 126 | - //初始化运营人员所选的关键点 | |
| 127 | - trackPoints = GsonUtil.jsonToList(test, LatLng.class); | |
| 128 | - initMap(); | |
| 129 | - MyMapUtil.drawServerLineTrack(getContext(), baiduMap, trackPoints, SortType.asc, R.color.green_round, R.drawable.icon_start, R.drawable.icon_end); | |
| 132 | + this.runRaceDetailInfo = runRaceDetailInfo; | |
| 133 | +// //初始化地图点位 | |
| 134 | + if (runRaceDetailInfo.getLatLongitude() != null) { | |
| 135 | + Log.e(TAG, "initView: 长度:" + runRaceDetailInfo.getLatLongitude().length()); | |
| 136 | + trackPoints = GsonUtil.jsonToList(runRaceDetailInfo.getLatLongitude(), LatLng.class); | |
| 137 | + Log.e(TAG, "initView: trackPoints" + trackPoints.size()); | |
| 138 | + MyMapUtil.drawServerLineTrack(getContext(), baiduMap, trackPoints, SortType.asc, R.color.green_round, R.drawable.icon_start, R.drawable.icon_end); | |
| 139 | + //自动计算地图缩放 | |
| 140 | + MapStatus.Builder builder = new MapStatus.Builder(); | |
| 141 | + builder.target(MyMapUtil.getCenterZoomPosition(trackPoints)); | |
| 142 | + builder.zoom(MyMapUtil.getZoom(trackPoints)); | |
| 143 | + baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); | |
| 144 | + } | |
| 145 | + | |
| 146 | + //显示地图 | |
| 147 | + fragment.binding.mapView.setVisibility(View.VISIBLE); | |
| 148 | + //隐藏底部滑动卡片 | |
| 149 | + fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); | |
| 150 | + //隐藏空视图 | |
| 151 | + fragment.binding.emptyLayout.setVisibility(View.GONE); | |
| 152 | + //显示立即报名按钮 | |
| 153 | + fragment.binding.includeStreet.rlStartBtn.setVisibility(View.VISIBLE); | |
| 130 | 154 | //设置底部卡片第一次可滑动的位置 |
| 131 | 155 | fragment.binding.slidingLayout.setAnchorPoint(0.6f); |
| 132 | - //设置底部卡片初始位置 | |
| 133 | -// fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(fragment.getActivity(), 140)); | |
| 134 | - fragment.binding.includeStreet.rlStartBtn.setVisibility(View.VISIBLE); | |
| 135 | 156 | fragment.binding.slidingLayout.addPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() { |
| 136 | 157 | @Override |
| 137 | 158 | public void onPanelSlide(View panel, float slideOffset) { |
| ... | ... | @@ -176,6 +197,104 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 176 | 197 | public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) { |
| 177 | 198 | } |
| 178 | 199 | }); |
| 200 | + /*************************设置相关页面数据***************************/ | |
| 201 | + //设置标题 | |
| 202 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getTitle())) { | |
| 203 | + fragment.binding.includeStreet.tvRaceTitle.setText(runRaceDetailInfo.getTitle()); | |
| 204 | + } | |
| 205 | + //设置活动地点 | |
| 206 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getAddress())) { | |
| 207 | + fragment.binding.includeStreet.tvAddress.setText(runRaceDetailInfo.getAddress()); | |
| 208 | + } | |
| 209 | + //设置活动距离 | |
| 210 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getMileage())) { | |
| 211 | + fragment.binding.includeStreet.tvMileage.setText(runRaceDetailInfo.getMileage()); | |
| 212 | + } | |
| 213 | + //设置起点 | |
| 214 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getStartLocation())) { | |
| 215 | + fragment.binding.includeStreet.tvStartAddr.setText(runRaceDetailInfo.getStartLocation()); | |
| 216 | + } | |
| 217 | + //设置终点 | |
| 218 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getEndLocation())) { | |
| 219 | + fragment.binding.includeStreet.tvEndAddr.setText(runRaceDetailInfo.getEndLocation()); | |
| 220 | + } | |
| 221 | + //设置起始报名时间 | |
| 222 | + if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_start_time(), "yyyy-MM-dd"))) { | |
| 223 | + fragment.binding.includeStreet.tvSignUpStartTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_start_time(), "yyyy-MM-dd")); | |
| 224 | + | |
| 225 | + } | |
| 226 | + //设置终止报名时间 | |
| 227 | + if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_end_time(), "yyyy-MM-dd"))) { | |
| 228 | + fragment.binding.includeStreet.tvSignUpEndTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getSign_up_end_time(), "yyyy-MM-dd")); | |
| 229 | + } | |
| 230 | + //设置活动开始时间 | |
| 231 | + if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getStart_time(), "yyyy-MM-dd"))) { | |
| 232 | + fragment.binding.includeStreet.tvActiveStartTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getStart_time(), "yyyy-MM-dd")); | |
| 233 | + } | |
| 234 | + //设置活动结束时间 | |
| 235 | + if (!TextUtils.isEmpty(TimeUtil.getStampToTime(runRaceDetailInfo.getEnd_time(), "yyyy-MM-dd"))) { | |
| 236 | + fragment.binding.includeStreet.tvActiveEndTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getEnd_time(), "yyyy-MM-dd")); | |
| 237 | + } | |
| 238 | + //设置参加人数 | |
| 239 | + fragment.binding.includeStreet.tvSignPerson.setText(runRaceDetailInfo.getSignupNum() + ""); | |
| 240 | + //设置报名完成的头像 | |
| 241 | + List<String> joinFaceIcon = runRaceDetailInfo.getFaceUrl(); | |
| 242 | + if (joinFaceIcon != null && joinFaceIcon.size() > 0) { | |
| 243 | + fragment.binding.includeStreet.fiveJoinPerson.setVisibility(View.VISIBLE); | |
| 244 | + //设置头像数据 | |
| 245 | + fragment.binding.includeStreet.fiveJoinPerson.initIconData(joinFaceIcon); | |
| 246 | + } else { | |
| 247 | + fragment.binding.includeStreet.fiveJoinPerson.setVisibility(View.INVISIBLE); | |
| 248 | + } | |
| 249 | + | |
| 250 | + //判断是否显示个人排行榜 | |
| 251 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getUserMileage())) { | |
| 252 | + //显示 | |
| 253 | + fragment.binding.includePersonScore.llPersonScoreRoot.setVisibility(View.VISIBLE); | |
| 254 | + //设置个人行走距离 | |
| 255 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getUserMileage())) { | |
| 256 | + fragment.binding.includePersonScore.tvUserDistance.setText(runRaceDetailInfo.getUserMileage()); | |
| 257 | + } | |
| 258 | + //设置行走步数 | |
| 259 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getStep())) { | |
| 260 | + fragment.binding.includePersonScore.tvStep.setText(runRaceDetailInfo.getStep()); | |
| 261 | + } | |
| 262 | + //设置用时 | |
| 263 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getEmployTime())) { | |
| 264 | + fragment.binding.includePersonScore.tvEmployTime.setText(runRaceDetailInfo.getEmployTime()); | |
| 265 | + } | |
| 266 | + //设置配速 | |
| 267 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getPace())) { | |
| 268 | + fragment.binding.includePersonScore.tvSpeed.setText(runRaceDetailInfo.getPace()); | |
| 269 | + } | |
| 270 | + } else { | |
| 271 | + //隐藏 | |
| 272 | + fragment.binding.includePersonScore.llPersonScoreRoot.setVisibility(View.GONE); | |
| 273 | + } | |
| 274 | + //设置是否显示排行榜 | |
| 275 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getFirstFaceUrl())) { | |
| 276 | + fragment.binding.includeRank.llRankRoot.setVisibility(View.VISIBLE); | |
| 277 | + //设置第一名头像 | |
| 278 | + GlideApp.with(getContext()).load(runRaceDetailInfo.getFirstFaceUrl()).into(fragment.binding.includeRank.ivFirstPersonUrl); | |
| 279 | + //设置排行榜头像 | |
| 280 | + List<String> finishFaceUrl = runRaceDetailInfo.getFinishFaceUrl(); | |
| 281 | + if (finishFaceUrl != null && finishFaceUrl.size() > 0) { | |
| 282 | + fragment.binding.includeRank.fiveRankPerson.initIconData(finishFaceUrl); | |
| 283 | + } | |
| 284 | + //设置第一名昵称 | |
| 285 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getFirstName())) { | |
| 286 | + fragment.binding.includeRank.tvKingNickName.setText(runRaceDetailInfo.getFirstName()); | |
| 287 | + } | |
| 288 | + } else { | |
| 289 | + fragment.binding.includeRank.llRankRoot.setVisibility(View.GONE); | |
| 290 | + | |
| 291 | + } | |
| 292 | + //设置路线介绍的图片 | |
| 293 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getRoadmap())) { | |
| 294 | + //设置路线图 | |
| 295 | + GlideApp.with(getContext()).load(runRaceDetailInfo.getRoadmap()).into(fragment.binding.includeStreetIntroduce.ivRoadMao); | |
| 296 | + | |
| 297 | + } | |
| 179 | 298 | //开始按钮点击事件(未滑动) |
| 180 | 299 | fragment.binding.includeStreet.rlStartBtn.setOnClickListener(new View.OnClickListener() { |
| 181 | 300 | @Override |
| ... | ... | @@ -253,7 +372,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 253 | 372 | } |
| 254 | 373 | }); |
| 255 | 374 | //查看全部成绩点击事件 |
| 256 | - fragment.binding.includePersonScore.findViewById(R.id.check_all_cord).setOnClickListener(v -> { | |
| 375 | + fragment.binding.includePersonScore.checkAllCord.setOnClickListener(v -> { | |
| 257 | 376 | RaceRecordActivity.newInstance(fragment.getActivity()); |
| 258 | 377 | }); |
| 259 | 378 | |
| ... | ... | @@ -272,14 +391,15 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 272 | 391 | }); |
| 273 | 392 | } |
| 274 | 393 | |
| 275 | - private void initMap() { | |
| 394 | + public void initMap() { | |
| 276 | 395 | List<String> icons = new ArrayList<>(); |
| 277 | 396 | icons.add("http://yweb0.cnliveimg.com/images/headImg/2019/0505/1557039035723_small.jpg"); |
| 278 | 397 | icons.add("http://yweb0.cnliveimg.com/images/headImg/2019/0505/1557034319038_small.jpg"); |
| 279 | 398 | icons.add("http://yweb0.cnliveimg.com/images/headImg/2018/0902/1535858459612_small.jpg"); |
| 280 | 399 | icons.add("http://yweb0.cnliveimg.com/images/headImg/2019/0523/1558599016203_small.jpg"); |
| 281 | 400 | icons.add("http://yweb0.cnliveimg.com/images/headImg/2019/0505/1557039035723_small.jpg"); |
| 282 | - | |
| 401 | + //隐藏底部滑动卡片 | |
| 402 | + fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN); | |
| 283 | 403 | fragment.binding.includeStreet.fiveJoinPerson.initIconData(icons); |
| 284 | 404 | this.mMapView = fragment.binding.mapView; |
| 285 | 405 | if (baiduMap == null) { |
| ... | ... | @@ -295,13 +415,6 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 295 | 415 | mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL; |
| 296 | 416 | // 设置定位图标修改为自定义marker |
| 297 | 417 | 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); | |
| 305 | 418 | mCurrentMarker = BitmapDescriptorFactory.fromBitmap(pointBitmap); |
| 306 | 419 | //设置定位蓝点精度圆圈的填充颜色为透明色 |
| 307 | 420 | accuracyCircleFillColor = getContext().getResources().getColor(R.color.transparent); |
| ... | ... | @@ -346,11 +459,7 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 346 | 459 | baiduMap.setOnMapLoadedCallback(new BaiduMap.OnMapLoadedCallback() { |
| 347 | 460 | @Override |
| 348 | 461 | public void onMapLoaded() { |
| 349 | - //自动计算地图缩放 | |
| 350 | - MapStatus.Builder builder = new MapStatus.Builder(); | |
| 351 | - builder.target(MyMapUtil.getCenterZoomPosition(trackPoints)); | |
| 352 | - builder.zoom(MyMapUtil.getZoom(trackPoints)); | |
| 353 | - baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); | |
| 462 | +// | |
| 354 | 463 | |
| 355 | 464 | } |
| 356 | 465 | }); |
| ... | ... | @@ -689,4 +798,54 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 689 | 798 | // } |
| 690 | 799 | } |
| 691 | 800 | } |
| 801 | + | |
| 802 | + /** | |
| 803 | + * 显示loading | |
| 804 | + */ | |
| 805 | + public void showLoadingView() { | |
| 806 | + if (fragment.binding.emptyLayout == null) { | |
| 807 | + return; | |
| 808 | + } | |
| 809 | + fragment.binding.emptyLayout.show(true); | |
| 810 | + } | |
| 811 | + | |
| 812 | + /** | |
| 813 | + * 隐藏loading | |
| 814 | + */ | |
| 815 | + public void hideLoadingView() { | |
| 816 | + if (fragment.binding.emptyLayout == null) { | |
| 817 | + return; | |
| 818 | + } | |
| 819 | + fragment.binding.emptyLayout.hide(); | |
| 820 | + } | |
| 821 | + | |
| 822 | + /** | |
| 823 | + * 显示重试页面 | |
| 824 | + * | |
| 825 | + * @param errorCode | |
| 826 | + * @param listener | |
| 827 | + */ | |
| 828 | + public void showRetryView(int errorCode, View.OnClickListener listener) { | |
| 829 | + if (getContext() == null) { | |
| 830 | + return; | |
| 831 | + } | |
| 832 | + //隐藏地图 | |
| 833 | + fragment.binding.mapView.setVisibility(View.GONE); | |
| 834 | + //显示空视图 | |
| 835 | + fragment.binding.emptyLayout.setVisibility(View.VISIBLE); | |
| 836 | + //隐藏底部卡片 | |
| 837 | + fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN); | |
| 838 | + if (fragment.binding.emptyLayout == null) return; | |
| 839 | + String titleText = ""; | |
| 840 | + String detailText = ""; | |
| 841 | + if (errorCode == -3) { | |
| 842 | + titleText = getContext().getString(R.string.msg_failed_network_title); | |
| 843 | + detailText = getContext().getString(R.string.msg_failed_network_detail); | |
| 844 | + } else { | |
| 845 | + titleText = getContext().getString(R.string.msg_failed_other_title); | |
| 846 | + detailText = getContext().getString(R.string.msg_failed_other_detail); | |
| 847 | + } | |
| 848 | + fragment.binding.emptyLayout.show(false, titleText, detailText, getContext().getString(R.string.retry), R.drawable.wufalianjie, listener); | |
| 849 | + } | |
| 850 | + | |
| 692 | 851 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunningMapFragmentView.java
| ... | ... | @@ -48,7 +48,7 @@ import java.util.HashMap; |
| 48 | 48 | import java.util.List; |
| 49 | 49 | |
| 50 | 50 | public class RunningMapFragmentView implements MvpView, SensorEventListener { |
| 51 | - private static final String TAG = "RunningMapFragmentView"; | |
| 51 | + private static final String TAG = "CollRunningMapFragmentView"; | |
| 52 | 52 | private RunningMapFragment fragment; |
| 53 | 53 | public BaiduMap baiduMap; |
| 54 | 54 | private MapView mMapView; | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/service/StepService.java
| ... | ... | @@ -566,7 +566,7 @@ public class StepService extends Service implements SensorEventListener { |
| 566 | 566 | // channel.setSound(null, null); |
| 567 | 567 | // mNM.createNotificationChannel(channel); |
| 568 | 568 | // } |
| 569 | -// Intent notificationIntent = new Intent(this, PedometerMainActivity.class); | |
| 569 | +// Intent notificationIntent = new Intent(this, CollPedometerMainActivity.class); | |
| 570 | 570 | // notification = new NotificationCompat.Builder(this, CHANNEL_ONE_ID) |
| 571 | 571 | // .setContentIntent(PendingIntent.getActivity(this, 0, notificationIntent, 0)) |
| 572 | 572 | // .setSmallIcon(R.mipmap.ic_launcher) |
| ... | ... | @@ -597,7 +597,7 @@ public class StepService extends Service implements SensorEventListener { |
| 597 | 597 | // mNM.createNotificationChannel(channel); |
| 598 | 598 | // } |
| 599 | 599 | // |
| 600 | -// Intent notificationIntent = new Intent(this, PedometerMainActivity.class); | |
| 600 | +// Intent notificationIntent = new Intent(this, CollPedometerMainActivity.class); | |
| 601 | 601 | // notification = new NotificationCompat.Builder(this, CHANNEL_ONE_ID) |
| 602 | 602 | // .setContentIntent(PendingIntent.getActivity(this, 0, notificationIntent, 0)) |
| 603 | 603 | // .setSmallIcon(R.mipmap.ic_launcher) | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/dao/UserStepEntityDao.java
| ... | ... | @@ -31,6 +31,7 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { |
| 31 | 31 | public final static Property PauseTimeStamp = new Property(4, long.class, "pauseTimeStamp", false, "PAUSE_TIME_STAMP"); |
| 32 | 32 | public final static Property RecordTime = new Property(5, long.class, "recordTime", false, "RECORD_TIME"); |
| 33 | 33 | public final static Property CaloriesCount = new Property(6, double.class, "caloriesCount", false, "CALORIES_COUNT"); |
| 34 | + public final static Property ServerTraceData = new Property(7, String.class, "serverTraceData", false, "SERVER_TRACE_DATA"); | |
| 34 | 35 | } |
| 35 | 36 | |
| 36 | 37 | |
| ... | ... | @@ -52,7 +53,8 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { |
| 52 | 53 | "\"STEP_COUNT\" TEXT," + // 3: stepCount |
| 53 | 54 | "\"PAUSE_TIME_STAMP\" INTEGER NOT NULL ," + // 4: pauseTimeStamp |
| 54 | 55 | "\"RECORD_TIME\" INTEGER NOT NULL ," + // 5: recordTime |
| 55 | - "\"CALORIES_COUNT\" REAL NOT NULL );"); // 6: caloriesCount | |
| 56 | + "\"CALORIES_COUNT\" REAL NOT NULL ," + // 6: caloriesCount | |
| 57 | + "\"SERVER_TRACE_DATA\" TEXT);"); // 7: serverTraceData | |
| 56 | 58 | } |
| 57 | 59 | |
| 58 | 60 | /** Drops the underlying database table. */ |
| ... | ... | @@ -87,6 +89,11 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { |
| 87 | 89 | stmt.bindLong(5, entity.getPauseTimeStamp()); |
| 88 | 90 | stmt.bindLong(6, entity.getRecordTime()); |
| 89 | 91 | stmt.bindDouble(7, entity.getCaloriesCount()); |
| 92 | + | |
| 93 | + String serverTraceData = entity.getServerTraceData(); | |
| 94 | + if (serverTraceData != null) { | |
| 95 | + stmt.bindString(8, serverTraceData); | |
| 96 | + } | |
| 90 | 97 | } |
| 91 | 98 | |
| 92 | 99 | @Override |
| ... | ... | @@ -115,6 +122,11 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { |
| 115 | 122 | stmt.bindLong(5, entity.getPauseTimeStamp()); |
| 116 | 123 | stmt.bindLong(6, entity.getRecordTime()); |
| 117 | 124 | stmt.bindDouble(7, entity.getCaloriesCount()); |
| 125 | + | |
| 126 | + String serverTraceData = entity.getServerTraceData(); | |
| 127 | + if (serverTraceData != null) { | |
| 128 | + stmt.bindString(8, serverTraceData); | |
| 129 | + } | |
| 118 | 130 | } |
| 119 | 131 | |
| 120 | 132 | @Override |
| ... | ... | @@ -131,7 +143,8 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { |
| 131 | 143 | cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // stepCount |
| 132 | 144 | cursor.getLong(offset + 4), // pauseTimeStamp |
| 133 | 145 | cursor.getLong(offset + 5), // recordTime |
| 134 | - cursor.getDouble(offset + 6) // caloriesCount | |
| 146 | + cursor.getDouble(offset + 6), // caloriesCount | |
| 147 | + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // serverTraceData | |
| 135 | 148 | ); |
| 136 | 149 | return entity; |
| 137 | 150 | } |
| ... | ... | @@ -145,6 +158,7 @@ public class UserStepEntityDao extends AbstractDao<UserStepEntity, String> { |
| 145 | 158 | entity.setPauseTimeStamp(cursor.getLong(offset + 4)); |
| 146 | 159 | entity.setRecordTime(cursor.getLong(offset + 5)); |
| 147 | 160 | entity.setCaloriesCount(cursor.getDouble(offset + 6)); |
| 161 | + entity.setServerTraceData(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); | |
| 148 | 162 | } |
| 149 | 163 | |
| 150 | 164 | @Override | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/sql/entity/UserStepEntity.java
| ... | ... | @@ -14,10 +14,12 @@ public class UserStepEntity { |
| 14 | 14 | private long pauseTimeStamp;//暂停时间戳 |
| 15 | 15 | private long recordTime;//暂停时间 |
| 16 | 16 | private double caloriesCount;//卡路里 |
| 17 | + private String serverTraceData;//服务端赛道数据 | |
| 17 | 18 | |
| 18 | - @Generated(hash = 1583539776) | |
| 19 | + @Generated(hash = 1521646580) | |
| 19 | 20 | public UserStepEntity(String uuid, String userId, String date, String stepCount, |
| 20 | - long pauseTimeStamp, long recordTime, double caloriesCount) { | |
| 21 | + long pauseTimeStamp, long recordTime, double caloriesCount, | |
| 22 | + String serverTraceData) { | |
| 21 | 23 | this.uuid = uuid; |
| 22 | 24 | this.userId = userId; |
| 23 | 25 | this.date = date; |
| ... | ... | @@ -25,6 +27,7 @@ public class UserStepEntity { |
| 25 | 27 | this.pauseTimeStamp = pauseTimeStamp; |
| 26 | 28 | this.recordTime = recordTime; |
| 27 | 29 | this.caloriesCount = caloriesCount; |
| 30 | + this.serverTraceData = serverTraceData; | |
| 28 | 31 | } |
| 29 | 32 | |
| 30 | 33 | @Generated(hash = 273857141) |
| ... | ... | @@ -87,6 +90,13 @@ public class UserStepEntity { |
| 87 | 90 | this.recordTime = recordTime; |
| 88 | 91 | } |
| 89 | 92 | |
| 93 | + public String getServerTraceData() { | |
| 94 | + return this.serverTraceData; | |
| 95 | + } | |
| 96 | + | |
| 97 | + public void setServerTraceData(String serverTraceData) { | |
| 98 | + this.serverTraceData = serverTraceData; | |
| 99 | + } | |
| 90 | 100 | |
| 91 | 101 | |
| 92 | 102 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/PedometerMainActivity.java
| ... | ... | @@ -38,7 +38,7 @@ import static android.provider.Settings.EXTRA_APP_PACKAGE; |
| 38 | 38 | */ |
| 39 | 39 | @Route(path = "/moudle_pedometer/InterestActivity") |
| 40 | 40 | public class PedometerMainActivity extends QMUIFragmentActivity { |
| 41 | - private static final String TAG = "PedometerMainActivity"; | |
| 41 | + private static final String TAG = "CollPedometerMainActivity"; | |
| 42 | 42 | |
| 43 | 43 | private NotificationManagerCompat notificationManagerCompat; |
| 44 | 44 | private boolean isOpen; |
| ... | ... | @@ -71,7 +71,7 @@ public class PedometerMainActivity extends QMUIFragmentActivity { |
| 71 | 71 | isOpen = notificationManagerCompat.areNotificationsEnabled(); |
| 72 | 72 | if (isOpen) { |
| 73 | 73 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { |
| 74 | -// ContextCompat.startForegroundService(PedometerMainActivity.this, new Intent(PedometerMainActivity.this, StepService.class)); | |
| 74 | +// ContextCompat.startForegroundService(CollPedometerMainActivity.this, new Intent(CollPedometerMainActivity.this, StepService.class)); | |
| 75 | 75 | } |
| 76 | 76 | } else { |
| 77 | 77 | goToSettingNo(); | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/RunLineActivity.java
| ... | ... | @@ -23,7 +23,7 @@ public class RunLineActivity extends AppCompatActivity { |
| 23 | 23 | setContentView(R.layout.activity_run_line); |
| 24 | 24 | |
| 25 | 25 | getSupportFragmentManager().beginTransaction().replace(R.id.run_line_container, new RunLineFragment()).commit(); |
| 26 | -// getSupportFragmentManager().beginTransaction().replace(R.id.run_line_container, new RunningFinishFragment()).commit(); | |
| 26 | +// getSupportFragmentManager().beginTransaction().replace(R.id.run_line_container, new CollRunningFinishFragment()).commit(); | |
| 27 | 27 | |
| 28 | 28 | } |
| 29 | 29 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/RunRaceDetailActivity.java
| ... | ... | @@ -33,7 +33,7 @@ import java.util.List; |
| 33 | 33 | * |
| 34 | 34 | * @author ShinnyYang |
| 35 | 35 | */ |
| 36 | -@Route(path = "/moudle_pedometer/RunRaceDetailActivity") | |
| 36 | +@Route(path = "/moudle_pedometer/CollRunRaceDetailActivity") | |
| 37 | 37 | public class RunRaceDetailActivity extends QMUIFragmentActivity { |
| 38 | 38 | private QMUIFragment fragment; |
| 39 | 39 | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/RunningFinishActivity.java
| ... | ... | @@ -20,7 +20,7 @@ import com.example.moudle_pedometer.R; |
| 20 | 20 | * |
| 21 | 21 | * @author ShinnyYang |
| 22 | 22 | */ |
| 23 | -@Route(path = "/moudle_pedometer/RunningFinishActivity") | |
| 23 | +@Route(path = "/moudle_pedometer/CollRunningFinishActivity") | |
| 24 | 24 | public class RunningFinishActivity extends QMUIFragmentActivity { |
| 25 | 25 | |
| 26 | 26 | @Override | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/RunningMapActivity.java
| ... | ... | @@ -20,7 +20,7 @@ import com.cnlive.moudle.pedometer.ui.fragment.RunningMapFragment; |
| 20 | 20 | import com.example.moudle_pedometer.R; |
| 21 | 21 | |
| 22 | 22 | public class RunningMapActivity extends QMUIFragmentActivity { |
| 23 | - private static final String TAG = "RunningMapActivity"; | |
| 23 | + private static final String TAG = "CollRunningMapActivity"; | |
| 24 | 24 | |
| 25 | 25 | @Override |
| 26 | 26 | protected void onCreate(Bundle savedInstanceState) { | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunMainFragment.java
| ... | ... | @@ -23,7 +23,7 @@ import org.greenrobot.eventbus.Subscribe; |
| 23 | 23 | import org.greenrobot.eventbus.ThreadMode; |
| 24 | 24 | |
| 25 | 25 | public class RunMainFragment extends QMUIFragment<RunMainFragmentView, RunMainFragmentPresenter, FragmentRunMainBinding> { |
| 26 | - private final String TAG = "RunMainFragment"; | |
| 26 | + private final String TAG = "CollRunMainFragment"; | |
| 27 | 27 | private String userId = "yangshuai"; |
| 28 | 28 | |
| 29 | 29 | @Override | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunRaceDetailFragment.java
| ... | ... | @@ -37,7 +37,7 @@ import static android.content.Context.SENSOR_SERVICE; |
| 37 | 37 | * @author ShinnyYang |
| 38 | 38 | */ |
| 39 | 39 | public class RunRaceDetailFragment extends QMUIFragment<RunRaceDetailFragmentView, RunRaceDetailFragmentPresenter, FragmentRunRaceDetailBinding> { |
| 40 | - private static final String TAG = "RunRaceDetailFragment"; | |
| 40 | + private static final String TAG = "CollRunRaceDetailFragment"; | |
| 41 | 41 | private SensorManager mSensorManager; |
| 42 | 42 | |
| 43 | 43 | @Override |
| ... | ... | @@ -61,7 +61,10 @@ public class RunRaceDetailFragment extends QMUIFragment<RunRaceDetailFragmentVie |
| 61 | 61 | |
| 62 | 62 | mSensorManager = (SensorManager) getActivity().getSystemService(SENSOR_SERVICE);//获取传感器管理服务 |
| 63 | 63 | if (getMvpView() != null) { |
| 64 | - getMvpView().initView(); | |
| 64 | + getMvpView().initMap();; | |
| 65 | + } | |
| 66 | + if (getPresenter()!=null){ | |
| 67 | + getPresenter().getRunRaceDetailInfo(getActivity(),"116","10513196"); | |
| 65 | 68 | } |
| 66 | 69 | |
| 67 | 70 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RunningMapFragment.java
| ... | ... | @@ -47,7 +47,7 @@ import static android.content.Context.SENSOR_SERVICE; |
| 47 | 47 | * @author ShinnyYang |
| 48 | 48 | */ |
| 49 | 49 | public class RunningMapFragment extends QMUIFragment<RunningMapFragmentView, RunningMapFragmentPresenter, FragmentRunningMapBinding> { |
| 50 | - private static final String TAG = "RunningMapFragment"; | |
| 50 | + private static final String TAG = "CollRunningMapFragment"; | |
| 51 | 51 | private RunningMapBean runningMapBean; |
| 52 | 52 | private SensorManager mSensorManager; |
| 53 | 53 | 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}]"; | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/QMUITipDialogUtil.java
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/StepUtil.java
| ... | ... | @@ -101,6 +101,13 @@ public class StepUtil { |
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | + /** | |
| 105 | + * 获取用户数据 | |
| 106 | + * | |
| 107 | + * @param context | |
| 108 | + * @param uid | |
| 109 | + * @return | |
| 110 | + */ | |
| 104 | 111 | public static UserStepEntity getUserStepData(Context context, String uid) { |
| 105 | 112 | if (!TextUtils.isEmpty(uid)) { |
| 106 | 113 | DbCore.init(context, dbName); |
| ... | ... | @@ -119,6 +126,22 @@ public class StepUtil { |
| 119 | 126 | } |
| 120 | 127 | |
| 121 | 128 | /** |
| 129 | + * 获取用户数据 | |
| 130 | + * | |
| 131 | + * @param context | |
| 132 | + * @param uid | |
| 133 | + * @return | |
| 134 | + */ | |
| 135 | + public static void setServerTraceData(Context context, String uid, UserStepEntity userStepEntity) { | |
| 136 | + if (getUserStepData(context, uid) != null) { | |
| 137 | + UserStepEntity entity = getUserStepData(context, uid); | |
| 138 | +// entity.setServerTraceData(); | |
| 139 | + } else { | |
| 140 | + | |
| 141 | + } | |
| 142 | + } | |
| 143 | + | |
| 144 | + /** | |
| 122 | 145 | * 获取当天日期 |
| 123 | 146 | * |
| 124 | 147 | * @return | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/TimeUtil.java
moudle_pedometer/src/main/res/layout/fragment_run_race_detail.xml
| ... | ... | @@ -17,6 +17,7 @@ |
| 17 | 17 | |
| 18 | 18 | <!-- MAIN CONTENT --> |
| 19 | 19 | <FrameLayout |
| 20 | + android:id="@+id/fl_root" | |
| 20 | 21 | android:layout_width="match_parent" |
| 21 | 22 | android:layout_height="match_parent"> |
| 22 | 23 | |
| ... | ... | @@ -50,7 +51,14 @@ |
| 50 | 51 | android:layout_margin="10dp" |
| 51 | 52 | android:background="@drawable/xqt_share" /> |
| 52 | 53 | <!----> |
| 53 | - | |
| 54 | + <com.cnlive.strike.ui.widget.UIEmptyView | |
| 55 | + android:id="@+id/empty_layout" | |
| 56 | + android:layout_width="match_parent" | |
| 57 | + android:layout_height="match_parent" | |
| 58 | + android:focusable="true" | |
| 59 | + android:focusableInTouchMode="true" | |
| 60 | + android:background="@color/color_fff" | |
| 61 | + android:visibility="gone" /> | |
| 54 | 62 | |
| 55 | 63 | </FrameLayout> |
| 56 | 64 | ... | ... |
moudle_pedometer/src/main/res/layout/layout_run_detail_person_score.xml
| 1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | - android:layout_width="match_parent" | |
| 4 | - android:layout_height="wrap_content" | |
| 5 | - android:background="@color/white"> | |
| 6 | - <!--个人最佳成绩--> | |
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android"> | |
| 3 | + | |
| 7 | 4 | <LinearLayout |
| 5 | + android:id="@+id/ll_person_score_root" | |
| 8 | 6 | android:layout_width="match_parent" |
| 9 | - android:layout_height="180dp" | |
| 10 | - android:background="@drawable/white_shadow_bg" | |
| 11 | - android:orientation="vertical" | |
| 12 | - android:paddingLeft="15dp" | |
| 13 | - android:paddingTop="5dp" | |
| 14 | - android:paddingRight="15dp" | |
| 15 | - android:paddingBottom="15dp"> | |
| 16 | - | |
| 17 | - <LinearLayout | |
| 18 | - android:layout_width="match_parent" | |
| 19 | - android:layout_height="wrap_content" | |
| 20 | - android:layout_marginTop="15dp" | |
| 21 | - android:gravity="bottom"> | |
| 22 | - | |
| 23 | - <TextView | |
| 24 | - android:id="@+id/tv_score_title" | |
| 25 | - android:layout_width="0dp" | |
| 26 | - android:layout_height="wrap_content" | |
| 27 | - android:layout_marginLeft="10dp" | |
| 28 | - android:layout_weight="1" | |
| 29 | - android:text="个人最佳成绩" | |
| 30 | - android:textColor="@color/text_black" | |
| 31 | - android:textSize="18sp" | |
| 32 | - android:textStyle="bold" /> | |
| 33 | - | |
| 34 | - <TextView | |
| 35 | - android:id="@+id/check_all_cord" | |
| 36 | - android:layout_width="wrap_content" | |
| 37 | - android:layout_height="wrap_content" | |
| 38 | - android:layout_marginRight="10dp" | |
| 39 | - android:text="查看全部成绩 >" | |
| 40 | - android:textColor="@color/text_black" | |
| 41 | - android:textSize="13sp" /> | |
| 42 | - </LinearLayout> | |
| 43 | - <!----> | |
| 7 | + android:layout_height="wrap_content" | |
| 8 | + android:background="@color/white"> | |
| 9 | + <!--个人最佳成绩--> | |
| 44 | 10 | <LinearLayout |
| 45 | 11 | android:layout_width="match_parent" |
| 46 | - android:layout_height="wrap_content" | |
| 47 | - android:layout_marginTop="10dp"> | |
| 12 | + android:layout_height="180dp" | |
| 13 | + android:background="@drawable/white_shadow_bg" | |
| 14 | + android:orientation="vertical" | |
| 15 | + android:paddingLeft="15dp" | |
| 16 | + android:paddingTop="5dp" | |
| 17 | + android:paddingRight="15dp" | |
| 18 | + android:paddingBottom="15dp"> | |
| 48 | 19 | |
| 49 | 20 | <LinearLayout |
| 50 | - android:layout_width="0dp" | |
| 51 | - android:layout_height="match_parent" | |
| 52 | - android:layout_weight="1" | |
| 53 | - android:gravity="left|bottom"> | |
| 21 | + android:layout_width="match_parent" | |
| 22 | + android:layout_height="wrap_content" | |
| 23 | + android:layout_marginTop="15dp" | |
| 24 | + android:gravity="bottom"> | |
| 54 | 25 | |
| 55 | 26 | <TextView |
| 56 | - android:layout_width="wrap_content" | |
| 27 | + android:id="@+id/tv_score_title" | |
| 28 | + android:layout_width="0dp" | |
| 57 | 29 | android:layout_height="wrap_content" |
| 58 | - android:layout_marginLeft="15dp" | |
| 59 | - android:text="1.53" | |
| 60 | - android:textColor="@color/black" | |
| 61 | - android:textSize="30sp" | |
| 30 | + android:layout_marginLeft="10dp" | |
| 31 | + android:layout_weight="1" | |
| 32 | + android:text="个人最佳成绩" | |
| 33 | + android:textColor="@color/text_black" | |
| 34 | + android:textSize="18sp" | |
| 62 | 35 | android:textStyle="bold" /> |
| 63 | 36 | |
| 64 | 37 | <TextView |
| 38 | + android:id="@+id/check_all_cord" | |
| 65 | 39 | android:layout_width="wrap_content" |
| 66 | 40 | android:layout_height="wrap_content" |
| 67 | - android:layout_marginLeft="5dp" | |
| 68 | - android:text="公里" | |
| 41 | + android:layout_marginRight="10dp" | |
| 42 | + android:text="查看全部成绩 >" | |
| 69 | 43 | android:textColor="@color/text_black" |
| 70 | - android:textSize="12sp" /> | |
| 44 | + android:textSize="13sp" /> | |
| 71 | 45 | </LinearLayout> |
| 72 | - </LinearLayout> | |
| 73 | - | |
| 74 | - <LinearLayout | |
| 75 | - android:layout_width="match_parent" | |
| 76 | - android:layout_height="wrap_content" | |
| 77 | - android:layout_marginTop="10dp" | |
| 78 | - android:layout_marginBottom="10dp"> | |
| 79 | - | |
| 46 | + <!----> | |
| 80 | 47 | <LinearLayout |
| 81 | - android:layout_width="0dp" | |
| 82 | - android:layout_height="match_parent" | |
| 83 | - android:layout_weight="1" | |
| 84 | - android:gravity="center" | |
| 85 | - android:orientation="vertical"> | |
| 86 | - | |
| 87 | - <TextView | |
| 88 | - android:layout_width="wrap_content" | |
| 89 | - android:layout_height="wrap_content" | |
| 90 | - android:text="步数" | |
| 91 | - android:textColor="@color/text_black" | |
| 92 | - android:textSize="12sp" /> | |
| 93 | - | |
| 94 | - <TextView | |
| 95 | - android:layout_width="wrap_content" | |
| 96 | - android:layout_height="wrap_content" | |
| 97 | - android:layout_marginTop="5dp" | |
| 98 | - android:text="1234" | |
| 99 | - android:textColor="@color/text_black" | |
| 100 | - android:textSize="20sp" | |
| 101 | - android:textStyle="bold" /> | |
| 102 | - | |
| 103 | - | |
| 104 | - </LinearLayout> | |
| 105 | - | |
| 106 | - <LinearLayout | |
| 107 | - android:layout_width="0dp" | |
| 108 | - android:layout_height="match_parent" | |
| 109 | - android:layout_weight="1.5" | |
| 110 | - android:gravity="center" | |
| 111 | - android:orientation="vertical"> | |
| 112 | - | |
| 113 | - <TextView | |
| 114 | - android:layout_width="wrap_content" | |
| 115 | - android:layout_height="wrap_content" | |
| 116 | - android:text="用时" | |
| 117 | - android:textColor="@color/text_black" | |
| 118 | - android:textSize="12sp" /> | |
| 119 | - | |
| 120 | - <TextView | |
| 121 | - android:layout_width="wrap_content" | |
| 122 | - android:layout_height="wrap_content" | |
| 123 | - android:layout_marginTop="5dp" | |
| 124 | - android:text="00:27:23" | |
| 125 | - android:textColor="@color/black" | |
| 126 | - android:textSize="20sp" | |
| 127 | - android:textStyle="bold" /> | |
| 128 | - | |
| 129 | - | |
| 48 | + android:layout_width="match_parent" | |
| 49 | + android:layout_height="wrap_content" | |
| 50 | + android:layout_marginTop="10dp"> | |
| 51 | + | |
| 52 | + <LinearLayout | |
| 53 | + android:layout_width="0dp" | |
| 54 | + android:layout_height="match_parent" | |
| 55 | + android:layout_weight="1" | |
| 56 | + android:gravity="left|bottom"> | |
| 57 | + | |
| 58 | + <TextView | |
| 59 | + android:id="@+id/tv_user_distance" | |
| 60 | + android:layout_width="wrap_content" | |
| 61 | + android:layout_height="wrap_content" | |
| 62 | + android:layout_marginLeft="15dp" | |
| 63 | + android:text="--" | |
| 64 | + android:textColor="@color/black" | |
| 65 | + android:textSize="30sp" | |
| 66 | + android:textStyle="bold" /> | |
| 67 | + | |
| 68 | + <TextView | |
| 69 | + android:layout_width="wrap_content" | |
| 70 | + android:layout_height="wrap_content" | |
| 71 | + android:layout_marginLeft="5dp" | |
| 72 | + android:text="公里" | |
| 73 | + android:textColor="@color/text_black" | |
| 74 | + android:textSize="12sp" /> | |
| 75 | + </LinearLayout> | |
| 130 | 76 | </LinearLayout> |
| 131 | 77 | |
| 132 | 78 | <LinearLayout |
| 133 | - android:layout_width="0dp" | |
| 134 | - android:layout_height="match_parent" | |
| 135 | - android:layout_weight="1" | |
| 136 | - android:gravity="center" | |
| 137 | - android:orientation="vertical"> | |
| 138 | - | |
| 139 | - <TextView | |
| 140 | - android:layout_width="wrap_content" | |
| 141 | - android:layout_height="wrap_content" | |
| 142 | - android:text="配速" | |
| 143 | - android:textColor="@color/text_black" | |
| 144 | - android:textSize="12sp" /> | |
| 145 | - | |
| 146 | - <TextView | |
| 147 | - android:layout_width="wrap_content" | |
| 148 | - android:layout_height="wrap_content" | |
| 149 | - android:layout_marginTop="5dp" | |
| 150 | - android:text="22'22''" | |
| 151 | - android:textColor="@color/text_black" | |
| 152 | - android:textSize="20sp" | |
| 153 | - android:textStyle="bold" /> | |
| 154 | - | |
| 155 | - | |
| 79 | + android:layout_width="match_parent" | |
| 80 | + android:layout_height="wrap_content" | |
| 81 | + android:layout_marginTop="10dp" | |
| 82 | + android:layout_marginBottom="15dp"> | |
| 83 | + | |
| 84 | + <LinearLayout | |
| 85 | + android:layout_width="0dp" | |
| 86 | + android:layout_height="match_parent" | |
| 87 | + android:layout_weight="1" | |
| 88 | + android:gravity="center" | |
| 89 | + android:orientation="vertical"> | |
| 90 | + | |
| 91 | + <TextView | |
| 92 | + android:layout_width="wrap_content" | |
| 93 | + android:layout_height="wrap_content" | |
| 94 | + android:text="步数" | |
| 95 | + android:textColor="@color/text_black" | |
| 96 | + android:textSize="12sp" /> | |
| 97 | + | |
| 98 | + <TextView | |
| 99 | + android:id="@+id/tv_step" | |
| 100 | + android:layout_width="wrap_content" | |
| 101 | + android:layout_height="wrap_content" | |
| 102 | + android:layout_marginTop="5dp" | |
| 103 | + android:text="--" | |
| 104 | + android:textColor="@color/text_black" | |
| 105 | + android:textSize="20sp" | |
| 106 | + android:textStyle="bold" /> | |
| 107 | + | |
| 108 | + | |
| 109 | + </LinearLayout> | |
| 110 | + | |
| 111 | + <LinearLayout | |
| 112 | + android:layout_width="0dp" | |
| 113 | + android:layout_height="match_parent" | |
| 114 | + android:layout_weight="1.5" | |
| 115 | + android:gravity="center" | |
| 116 | + android:orientation="vertical"> | |
| 117 | + | |
| 118 | + <TextView | |
| 119 | + android:layout_width="wrap_content" | |
| 120 | + android:layout_height="wrap_content" | |
| 121 | + android:text="用时" | |
| 122 | + android:textColor="@color/text_black" | |
| 123 | + android:textSize="12sp" /> | |
| 124 | + | |
| 125 | + <TextView | |
| 126 | + android:id="@+id/tv_employTime" | |
| 127 | + android:layout_width="wrap_content" | |
| 128 | + android:layout_height="wrap_content" | |
| 129 | + android:layout_marginTop="5dp" | |
| 130 | + android:text="--" | |
| 131 | + android:textColor="@color/black" | |
| 132 | + android:textSize="20sp" | |
| 133 | + android:textStyle="bold" /> | |
| 134 | + | |
| 135 | + | |
| 136 | + </LinearLayout> | |
| 137 | + | |
| 138 | + <LinearLayout | |
| 139 | + android:layout_width="0dp" | |
| 140 | + android:layout_height="match_parent" | |
| 141 | + android:layout_weight="1" | |
| 142 | + android:gravity="center" | |
| 143 | + android:orientation="vertical"> | |
| 144 | + | |
| 145 | + <TextView | |
| 146 | + android:layout_width="wrap_content" | |
| 147 | + android:layout_height="wrap_content" | |
| 148 | + android:text="配速" | |
| 149 | + android:textColor="@color/text_black" | |
| 150 | + android:textSize="12sp" /> | |
| 151 | + | |
| 152 | + <TextView | |
| 153 | + android:id="@+id/tv_speed" | |
| 154 | + android:layout_width="wrap_content" | |
| 155 | + android:layout_height="wrap_content" | |
| 156 | + android:layout_marginTop="5dp" | |
| 157 | + android:text="--" | |
| 158 | + android:textColor="@color/text_black" | |
| 159 | + android:textSize="20sp" | |
| 160 | + android:textStyle="bold" /> | |
| 161 | + | |
| 162 | + | |
| 163 | + </LinearLayout> | |
| 156 | 164 | </LinearLayout> |
| 157 | 165 | </LinearLayout> |
| 158 | 166 | </LinearLayout> |
| 159 | -</LinearLayout> | |
| 160 | 167 | \ No newline at end of file |
| 168 | +</layout> | |
| 161 | 169 | \ No newline at end of file | ... | ... |
moudle_pedometer/src/main/res/layout/layout_run_detail_rank.xml
| 1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android"> | |
| 2 | 3 | |
| 3 | -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 4 | - xmlns:FivePersonIconView="http://schemas.android.com/apk/res-auto" | |
| 5 | - xmlns:app="http://schemas.android.com/apk/res-auto" | |
| 6 | - android:id="@+id/ll_rank_root" | |
| 7 | - android:layout_width="match_parent" | |
| 8 | - android:layout_height="wrap_content" | |
| 9 | - android:background="@color/white"> | |
| 10 | - <!--排行榜--> | |
| 11 | - <LinearLayout | |
| 4 | + <LinearLayout xmlns:FivePersonIconView="http://schemas.android.com/apk/res-auto" | |
| 5 | + xmlns:app="http://schemas.android.com/apk/res-auto" | |
| 6 | + android:id="@+id/ll_rank_root" | |
| 12 | 7 | android:layout_width="match_parent" |
| 13 | - android:layout_height="150dp" | |
| 14 | - android:paddingLeft="15dp" | |
| 15 | - android:paddingTop="5dp" | |
| 16 | - android:paddingRight="15dp" | |
| 17 | - android:paddingBottom="15dp" | |
| 18 | - android:background="@drawable/white_shadow_bg" | |
| 19 | - android:orientation="vertical"> | |
| 20 | - | |
| 21 | - <LinearLayout | |
| 22 | - android:layout_width="match_parent" | |
| 23 | - android:layout_height="wrap_content" | |
| 24 | - android:layout_marginTop="15dp" | |
| 25 | - android:gravity="bottom"> | |
| 26 | - | |
| 27 | - <TextView | |
| 28 | - android:id="@+id/tv_rank_title" | |
| 29 | - android:layout_width="0dp" | |
| 30 | - android:layout_height="wrap_content" | |
| 31 | - android:layout_marginLeft="10dp" | |
| 32 | - android:layout_weight="1" | |
| 33 | - android:text="@string/layout_run_detail_rank_title" | |
| 34 | - android:textColor="@color/black" | |
| 35 | - android:textSize="18sp" | |
| 36 | - android:textStyle="bold" /> | |
| 37 | - | |
| 38 | - <TextView | |
| 39 | - android:layout_width="wrap_content" | |
| 40 | - android:layout_height="wrap_content" | |
| 41 | - android:layout_marginRight="10dp" | |
| 42 | - android:text="@string/layout_run_detail_rank_see_rank" | |
| 43 | - android:textColor="@color/black" | |
| 44 | - android:textSize="13sp" /> | |
| 45 | - </LinearLayout> | |
| 46 | - <!----> | |
| 8 | + android:layout_height="wrap_content" | |
| 9 | + android:background="@color/white"> | |
| 10 | + <!--排行榜--> | |
| 47 | 11 | <LinearLayout |
| 48 | 12 | android:layout_width="match_parent" |
| 49 | - android:layout_height="match_parent"> | |
| 13 | + android:layout_height="150dp" | |
| 14 | + android:background="@drawable/white_shadow_bg" | |
| 15 | + android:orientation="vertical" | |
| 16 | + android:paddingLeft="15dp" | |
| 17 | + android:paddingTop="5dp" | |
| 18 | + android:paddingRight="15dp" | |
| 19 | + android:paddingBottom="15dp"> | |
| 50 | 20 | |
| 51 | 21 | <LinearLayout |
| 52 | - android:layout_width="0dp" | |
| 53 | - android:layout_height="match_parent" | |
| 54 | - android:layout_weight="1.2" | |
| 55 | - android:gravity="center" | |
| 56 | - android:orientation="vertical"> | |
| 57 | - | |
| 58 | - <com.cnlive.moudle.pedometer.ui.widget.FivePersonIconView | |
| 59 | - android:id="@+id/five_rank_person" | |
| 60 | - android:layout_width="wrap_content" | |
| 61 | - android:layout_height="35dp" | |
| 62 | - FivePersonIconView:showRightFlag="false"></com.cnlive.moudle.pedometer.ui.widget.FivePersonIconView> | |
| 22 | + android:layout_width="match_parent" | |
| 23 | + android:layout_height="wrap_content" | |
| 24 | + android:layout_marginTop="15dp" | |
| 25 | + android:gravity="bottom"> | |
| 63 | 26 | |
| 64 | - <LinearLayout | |
| 27 | + <TextView | |
| 28 | + android:id="@+id/tv_rank_title" | |
| 29 | + android:layout_width="0dp" | |
| 30 | + android:layout_height="wrap_content" | |
| 31 | + android:layout_marginLeft="10dp" | |
| 32 | + android:layout_weight="1" | |
| 33 | + android:text="@string/layout_run_detail_rank_title" | |
| 34 | + android:textColor="@color/black" | |
| 35 | + android:textSize="18sp" | |
| 36 | + android:textStyle="bold" /> | |
| 37 | + | |
| 38 | + <TextView | |
| 65 | 39 | android:layout_width="wrap_content" |
| 66 | 40 | android:layout_height="wrap_content" |
| 67 | - android:layout_marginTop="5dp" | |
| 68 | - android:gravity="bottom"> | |
| 69 | - | |
| 70 | - <TextView | |
| 71 | - android:layout_width="wrap_content" | |
| 72 | - android:layout_height="wrap_content" | |
| 73 | - android:text="1234" | |
| 74 | - android:textColor="@color/black" | |
| 75 | - android:textSize="15sp" | |
| 76 | - android:textStyle="bold" /> | |
| 77 | - | |
| 78 | - <TextView | |
| 79 | - android:layout_width="wrap_content" | |
| 80 | - android:layout_height="wrap_content" | |
| 81 | - android:layout_marginTop="5dp" | |
| 82 | - android:text="@string/layout_run_detail_rank_person_finish" | |
| 83 | - android:textColor="@color/text_gray" | |
| 84 | - android:textSize="12sp" /> | |
| 85 | - </LinearLayout> | |
| 41 | + android:layout_marginRight="10dp" | |
| 42 | + android:text="@string/layout_run_detail_rank_see_rank" | |
| 43 | + android:textColor="@color/black" | |
| 44 | + android:textSize="13sp" /> | |
| 86 | 45 | </LinearLayout> |
| 87 | - <!--右侧--> | |
| 46 | + <!----> | |
| 88 | 47 | <LinearLayout |
| 89 | - android:layout_width="0dp" | |
| 90 | - android:layout_height="match_parent" | |
| 91 | - android:layout_weight="1.2" | |
| 92 | - android:gravity="center|right"> | |
| 48 | + android:layout_width="match_parent" | |
| 49 | + android:layout_height="match_parent"> | |
| 93 | 50 | |
| 94 | 51 | <LinearLayout |
| 95 | - android:layout_width="wrap_content" | |
| 52 | + android:layout_width="0dp" | |
| 96 | 53 | android:layout_height="match_parent" |
| 54 | + android:layout_weight="1.2" | |
| 97 | 55 | android:gravity="center" |
| 98 | 56 | android:orientation="vertical"> |
| 99 | 57 | |
| 100 | - | |
| 101 | - <TextView | |
| 58 | + <com.cnlive.moudle.pedometer.ui.widget.FivePersonIconView | |
| 59 | + android:id="@+id/five_rank_person" | |
| 102 | 60 | android:layout_width="wrap_content" |
| 103 | - android:layout_height="wrap_content" | |
| 104 | - android:text="00:27:23" | |
| 105 | - android:textColor="@color/text_black" | |
| 106 | - android:textSize="18sp" | |
| 107 | - android:textStyle="bold" /> | |
| 61 | + android:layout_height="35dp" | |
| 62 | + FivePersonIconView:showRightFlag="false"></com.cnlive.moudle.pedometer.ui.widget.FivePersonIconView> | |
| 108 | 63 | |
| 109 | - <TextView | |
| 64 | + <LinearLayout | |
| 110 | 65 | android:layout_width="wrap_content" |
| 111 | 66 | android:layout_height="wrap_content" |
| 112 | 67 | android:layout_marginTop="5dp" |
| 113 | - android:text="用户昵称" | |
| 114 | - android:textColor="@color/text_gray" | |
| 115 | - android:textSize="12sp" /> | |
| 68 | + android:gravity="bottom"> | |
| 69 | + | |
| 70 | + <TextView | |
| 71 | + android:id="@+id/tv_finish_person" | |
| 72 | + android:layout_width="wrap_content" | |
| 73 | + android:layout_height="wrap_content" | |
| 74 | + android:text="--" | |
| 75 | + android:textColor="@color/black" | |
| 76 | + android:textSize="15sp" | |
| 77 | + android:textStyle="bold" /> | |
| 78 | + | |
| 79 | + <TextView | |
| 80 | + android:layout_width="wrap_content" | |
| 81 | + android:layout_height="wrap_content" | |
| 82 | + android:layout_marginTop="5dp" | |
| 83 | + android:text="@string/layout_run_detail_rank_person_finish" | |
| 84 | + android:textColor="@color/text_gray" | |
| 85 | + android:textSize="12sp" /> | |
| 86 | + </LinearLayout> | |
| 87 | + </LinearLayout> | |
| 88 | + <!--右侧--> | |
| 89 | + <LinearLayout | |
| 90 | + android:layout_width="0dp" | |
| 91 | + android:layout_height="match_parent" | |
| 92 | + android:layout_weight="1.2" | |
| 93 | + android:gravity="center|right"> | |
| 116 | 94 | |
| 95 | + <LinearLayout | |
| 96 | + android:layout_width="wrap_content" | |
| 97 | + android:layout_height="match_parent" | |
| 98 | + android:gravity="center" | |
| 99 | + android:orientation="vertical"> | |
| 100 | + | |
| 101 | + | |
| 102 | + <TextView | |
| 103 | + android:layout_width="wrap_content" | |
| 104 | + android:layout_height="wrap_content" | |
| 105 | + android:text="--" | |
| 106 | + android:textColor="@color/text_black" | |
| 107 | + android:textSize="18sp" | |
| 108 | + android:textStyle="bold" /> | |
| 109 | + | |
| 110 | + <TextView | |
| 111 | + android:id="@+id/tv_king_nick_name" | |
| 112 | + android:layout_width="wrap_content" | |
| 113 | + android:layout_height="wrap_content" | |
| 114 | + android:layout_marginTop="5dp" | |
| 115 | + android:layout_marginBottom="5dp" | |
| 116 | + android:text="用户昵称" | |
| 117 | + android:textColor="@color/text_gray" | |
| 118 | + android:textSize="12sp" /> | |
| 119 | + | |
| 120 | + <!----> | |
| 121 | + </LinearLayout> | |
| 122 | + | |
| 123 | + <FrameLayout | |
| 124 | + android:layout_width="wrap_content" | |
| 125 | + android:layout_height="match_parent"> | |
| 126 | + | |
| 127 | + <com.qmuiteam.qmui.widget.QMUIRadiusImageView | |
| 128 | + android:id="@+id/iv_first_person_url" | |
| 129 | + android:layout_width="60dp" | |
| 130 | + android:layout_height="60dp" | |
| 131 | + android:layout_gravity="center" | |
| 132 | + android:layout_marginLeft="10dp" | |
| 133 | + android:layout_marginRight="15dp" | |
| 134 | + android:layout_marginBottom="5dp" | |
| 135 | + android:background="@drawable/tc_ic_workout_level_adjust_coach" | |
| 136 | + app:qmui_corner_radius="100dp" /> | |
| 137 | + | |
| 138 | + <ImageView | |
| 139 | + android:layout_width="16dp" | |
| 140 | + android:layout_height="17dp" | |
| 141 | + android:layout_gravity="right" | |
| 142 | + android:layout_marginTop="10dp" | |
| 143 | + android:layout_marginRight="10dp" | |
| 144 | + android:background="@drawable/crown" /> | |
| 145 | + </FrameLayout> | |
| 117 | 146 | <!----> |
| 118 | 147 | </LinearLayout> |
| 119 | 148 | |
| 120 | - <FrameLayout | |
| 121 | - android:layout_width="wrap_content" | |
| 122 | - android:layout_height="match_parent"> | |
| 123 | - | |
| 124 | - <com.qmuiteam.qmui.widget.QMUIRadiusImageView | |
| 125 | - android:layout_width="60dp" | |
| 126 | - android:layout_height="60dp" | |
| 127 | - android:layout_gravity="center" | |
| 128 | - android:layout_marginLeft="10dp" | |
| 129 | - android:layout_marginRight="15dp" | |
| 130 | - android:background="@drawable/tc_ic_workout_level_adjust_coach" | |
| 131 | - app:qmui_corner_radius="100dp" /> | |
| 132 | - | |
| 133 | - <ImageView | |
| 134 | - android:layout_width="16dp" | |
| 135 | - android:layout_height="17dp" | |
| 136 | - android:layout_gravity="right" | |
| 137 | - android:layout_marginTop="10dp" | |
| 138 | - android:layout_marginRight="10dp" | |
| 139 | - android:background="@drawable/crown" /> | |
| 140 | - </FrameLayout> | |
| 141 | - <!----> | |
| 142 | 149 | </LinearLayout> |
| 143 | - | |
| 144 | 150 | </LinearLayout> |
| 145 | 151 | </LinearLayout> |
| 146 | -</LinearLayout> | |
| 147 | 152 | \ No newline at end of file |
| 153 | +</layout> | |
| 148 | 154 | \ No newline at end of file | ... | ... |
moudle_pedometer/src/main/res/layout/layout_run_detail_street.xml
| ... | ... | @@ -33,7 +33,7 @@ |
| 33 | 33 | android:layout_height="wrap_content" |
| 34 | 34 | android:layout_marginLeft="10dp" |
| 35 | 35 | android:layout_marginTop="10dp" |
| 36 | - android:text="奥森南园跑道" | |
| 36 | + android:text="--" | |
| 37 | 37 | android:textColor="@color/text_black" |
| 38 | 38 | android:textSize="18sp" |
| 39 | 39 | android:textStyle="bold" /> |
| ... | ... | @@ -66,27 +66,22 @@ |
| 66 | 66 | android:layout_marginTop="10dp" |
| 67 | 67 | android:layout_marginBottom="10dp"> |
| 68 | 68 | |
| 69 | - <TextView | |
| 70 | - android:layout_width="wrap_content" | |
| 71 | - android:layout_height="wrap_content" | |
| 72 | - android:layout_marginLeft="25dp" | |
| 73 | - android:text="北京" | |
| 74 | - android:textColor="@color/text_black" | |
| 75 | - android:textSize="15sp" /> | |
| 76 | 69 | |
| 77 | 70 | <TextView |
| 71 | + android:id="@+id/tv_address" | |
| 78 | 72 | android:layout_width="wrap_content" |
| 79 | 73 | android:layout_height="wrap_content" |
| 80 | 74 | android:layout_marginLeft="25dp" |
| 81 | - android:text="首都师范大学" | |
| 75 | + android:text="--" | |
| 82 | 76 | android:textColor="@color/text_black" |
| 83 | 77 | android:textSize="15sp" /> |
| 84 | 78 | |
| 85 | 79 | <TextView |
| 80 | + android:id="@+id/tv_mileage" | |
| 86 | 81 | android:layout_width="wrap_content" |
| 87 | 82 | android:layout_height="wrap_content" |
| 88 | 83 | android:layout_marginLeft="25dp" |
| 89 | - android:text="全长4.42公里" | |
| 84 | + android:text="-" | |
| 90 | 85 | android:textColor="@color/text_black" |
| 91 | 86 | android:textSize="15sp" /> |
| 92 | 87 | </LinearLayout> |
| ... | ... | @@ -154,10 +149,11 @@ |
| 154 | 149 | android:textSize="14sp" /> |
| 155 | 150 | |
| 156 | 151 | <TextView |
| 152 | + android:id="@+id/tv_start_addr" | |
| 157 | 153 | android:layout_width="wrap_content" |
| 158 | 154 | android:layout_height="wrap_content" |
| 159 | 155 | android:layout_marginLeft="10dp" |
| 160 | - android:text="首都师范大学操场东门" | |
| 156 | + android:text="--" | |
| 161 | 157 | android:textColor="@color/text_black" |
| 162 | 158 | android:textSize="15sp" /> |
| 163 | 159 | </LinearLayout> |
| ... | ... | @@ -185,10 +181,11 @@ |
| 185 | 181 | android:textSize="14sp" /> |
| 186 | 182 | |
| 187 | 183 | <TextView |
| 184 | + android:id="@+id/tv_end_addr" | |
| 188 | 185 | android:layout_width="wrap_content" |
| 189 | 186 | android:layout_height="wrap_content" |
| 190 | 187 | android:layout_marginLeft="10dp" |
| 191 | - android:text="首都师范大学操场西门" | |
| 188 | + android:text="--" | |
| 192 | 189 | android:textColor="@color/text_black" |
| 193 | 190 | android:textSize="15sp" /> |
| 194 | 191 | </LinearLayout> |
| ... | ... | @@ -223,10 +220,11 @@ |
| 223 | 220 | android:layout_marginTop="10dp"> |
| 224 | 221 | |
| 225 | 222 | <TextView |
| 223 | + android:id="@+id/tv_sign_up_start_time" | |
| 226 | 224 | android:layout_width="wrap_content" |
| 227 | 225 | android:layout_height="wrap_content" |
| 228 | 226 | android:layout_marginLeft="25dp" |
| 229 | - android:text="2019.05.01" | |
| 227 | + android:text="--" | |
| 230 | 228 | android:textColor="@color/text_black" |
| 231 | 229 | android:textSize="15sp" /> |
| 232 | 230 | |
| ... | ... | @@ -239,10 +237,11 @@ |
| 239 | 237 | android:textSize="15sp" /> |
| 240 | 238 | |
| 241 | 239 | <TextView |
| 240 | + android:id="@+id/tv_sign_up_end_time" | |
| 242 | 241 | android:layout_width="wrap_content" |
| 243 | 242 | android:layout_height="wrap_content" |
| 244 | 243 | android:layout_marginLeft="5dp" |
| 245 | - android:text="2019.09.01" | |
| 244 | + android:text="--" | |
| 246 | 245 | android:textColor="@color/text_black" |
| 247 | 246 | android:textSize="15sp" /> |
| 248 | 247 | </LinearLayout> |
| ... | ... | @@ -283,10 +282,11 @@ |
| 283 | 282 | android:layout_marginTop="10dp"> |
| 284 | 283 | |
| 285 | 284 | <TextView |
| 285 | + android:id="@+id/tv_active_start_time" | |
| 286 | 286 | android:layout_width="wrap_content" |
| 287 | 287 | android:layout_height="wrap_content" |
| 288 | 288 | android:layout_marginLeft="25dp" |
| 289 | - android:text="2019.05.01" | |
| 289 | + android:text="--" | |
| 290 | 290 | android:textColor="@color/text_black" |
| 291 | 291 | android:textSize="15sp" /> |
| 292 | 292 | |
| ... | ... | @@ -299,10 +299,11 @@ |
| 299 | 299 | android:textSize="15sp" /> |
| 300 | 300 | |
| 301 | 301 | <TextView |
| 302 | + android:id="@+id/tv_active_end_time" | |
| 302 | 303 | android:layout_width="wrap_content" |
| 303 | 304 | android:layout_height="wrap_content" |
| 304 | 305 | android:layout_marginLeft="5dp" |
| 305 | - android:text="2019.09.01" | |
| 306 | + android:text="--" | |
| 306 | 307 | android:textColor="@color/text_black" |
| 307 | 308 | android:textSize="15sp" /> |
| 308 | 309 | </LinearLayout> |
| ... | ... | @@ -348,8 +349,8 @@ |
| 348 | 349 | android:layout_marginLeft="25dp" |
| 349 | 350 | android:text="徒步" |
| 350 | 351 | android:textColor="@color/text_black" |
| 351 | - android:textStyle="bold" | |
| 352 | - android:textSize="15sp" /> | |
| 352 | + android:textSize="15sp" | |
| 353 | + android:textStyle="bold" /> | |
| 353 | 354 | |
| 354 | 355 | </LinearLayout> |
| 355 | 356 | <!--参与人数--> |
| ... | ... | @@ -386,10 +387,11 @@ |
| 386 | 387 | android:layout_weight="1"> |
| 387 | 388 | |
| 388 | 389 | <TextView |
| 390 | + android:id="@+id/tv_sign_person" | |
| 389 | 391 | android:layout_width="wrap_content" |
| 390 | 392 | android:layout_height="wrap_content" |
| 391 | 393 | android:layout_marginLeft="33dp" |
| 392 | - android:text="123" | |
| 394 | + android:text="0" | |
| 393 | 395 | android:textColor="@color/text_black" |
| 394 | 396 | android:textSize="17sp" |
| 395 | 397 | android:textStyle="bold" /> | ... | ... |
moudle_pedometer/src/main/res/layout/layout_run_detail_street_introduce.xml
| 1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | - android:layout_width="match_parent" | |
| 4 | - android:layout_height="wrap_content" | |
| 5 | - android:background="@color/white" | |
| 6 | - android:orientation="vertical" | |
| 7 | - android:paddingLeft="10dp" | |
| 8 | - android:paddingRight="10dp"> | |
| 9 | - <!--路线介绍--> | |
| 10 | - <TextView | |
| 11 | - android:id="@+id/tv_race_title" | |
| 12 | - android:layout_width="wrap_content" | |
| 13 | - android:layout_height="wrap_content" | |
| 14 | - android:layout_marginTop="10dp" | |
| 15 | - android:text="@string/layout_run_detail_street_introduce_title" | |
| 16 | - android:textSize="18sp" | |
| 17 | - android:textStyle="bold" /> | |
| 2 | +<layout xmlns:android="http://schemas.android.com/apk/res/android"> | |
| 18 | 3 | |
| 19 | - <TextView | |
| 20 | - android:layout_width="wrap_content" | |
| 4 | + <LinearLayout | |
| 5 | + android:layout_width="match_parent" | |
| 21 | 6 | android:layout_height="wrap_content" |
| 22 | - android:layout_marginTop="10dp" | |
| 23 | - android:text="路线介绍路线介绍路线介绍路线介绍路线介绍路线介绍路线介绍路线介绍路线介绍路线介绍路线介绍路线介绍路线介绍路线介绍路线介绍路线介绍路线介绍路线介绍路线介绍" | |
| 24 | - android:textColor="@color/text_black" | |
| 25 | - android:textSize="15sp" /> | |
| 7 | + android:background="@color/white" | |
| 8 | + android:orientation="vertical" | |
| 9 | + android:paddingLeft="10dp" | |
| 10 | + android:paddingRight="10dp"> | |
| 11 | + <!--路线介绍--> | |
| 12 | + <TextView | |
| 13 | + android:id="@+id/tv_race_title" | |
| 14 | + android:layout_width="wrap_content" | |
| 15 | + android:layout_height="wrap_content" | |
| 16 | + android:layout_marginTop="10dp" | |
| 17 | + android:text="@string/layout_run_detail_street_introduce_title" | |
| 18 | + android:textSize="18sp" | |
| 19 | + android:textStyle="bold" /> | |
| 26 | 20 | |
| 27 | - <!--地图--> | |
| 28 | - <TextView | |
| 29 | - android:layout_width="wrap_content" | |
| 30 | - android:layout_height="wrap_content" | |
| 31 | - android:layout_marginTop="10dp" | |
| 32 | - android:text="@string/layout_run_detail_street_introduce_map" | |
| 33 | - android:textSize="18sp" | |
| 34 | - android:textStyle="bold" /> | |
| 21 | + <TextView | |
| 22 | + android:layout_width="wrap_content" | |
| 23 | + android:layout_height="wrap_content" | |
| 24 | + android:layout_marginTop="10dp" | |
| 25 | + android:text="--" | |
| 26 | + android:textColor="@color/text_black" | |
| 27 | + android:textSize="15sp" /> | |
| 35 | 28 | |
| 36 | - <ImageView | |
| 37 | - android:layout_width="match_parent" | |
| 38 | - android:layout_height="500dp" | |
| 39 | - android:layout_marginTop="10dp" | |
| 40 | - android:layout_marginBottom="60dp" | |
| 41 | - android:background="@drawable/map" | |
| 42 | - android:scaleType="center" /> | |
| 43 | -</LinearLayout> | |
| 44 | 29 | \ No newline at end of file |
| 30 | + <!--地图--> | |
| 31 | + <TextView | |
| 32 | + android:layout_width="wrap_content" | |
| 33 | + android:layout_height="wrap_content" | |
| 34 | + android:layout_marginTop="10dp" | |
| 35 | + android:text="@string/layout_run_detail_street_introduce_map" | |
| 36 | + android:textSize="18sp" | |
| 37 | + android:textStyle="bold" /> | |
| 38 | + | |
| 39 | + <ImageView | |
| 40 | + android:id="@+id/iv_road_mao" | |
| 41 | + android:layout_width="match_parent" | |
| 42 | + android:layout_height="500dp" | |
| 43 | + android:layout_marginTop="10dp" | |
| 44 | + android:layout_marginBottom="60dp" | |
| 45 | + android:background="@drawable/map" | |
| 46 | + android:scaleType="center" /> | |
| 47 | + </LinearLayout> | |
| 48 | +</layout> | |
| 45 | 49 | \ No newline at end of file | ... | ... |
moudle_pedometer/src/main/res/values/strings.xml