Commit 13527623c29e13977d306757be4b23308bf1fe70
1 parent
8b47b0b7
1 修改我的活动,item跳转逻辑
Showing
8 changed files
with
283 additions
and
33 deletions
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/presenter/OnGoingFragmentPresenter.java
| 1 | 1 | package com.cnlive.moudle.pedometer.frame.presenter; |
| 2 | 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; | |
| 3 | 11 | import com.cnlive.moudle.pedometer.frame.view.OnGoingFragmentView; |
| 12 | +import com.cnlive.moudle.pedometer.net.ApiServiceRunLin; | |
| 13 | +import com.cnlive.moudle.pedometer.net.SubscriptionRequest; | |
| 14 | +import com.cnlive.moudle.pedometer.net.bean.BaseInfo; | |
| 15 | +import com.cnlive.moudle.pedometer.net.bean.RunRaceDetailInfo; | |
| 4 | 16 | import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; |
| 5 | 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 | + | |
| 6 | 26 | public class OnGoingFragmentPresenter extends MvpBasePresenter<OnGoingFragmentView> { |
| 27 | + public void getRunRaceDetailInfo(Context context, String id, String userId, String state) { | |
| 28 | + //设置请求参数 | |
| 29 | + Map<String, String> paramsMap = new HashMap<>(); | |
| 30 | + //赛事id | |
| 31 | + paramsMap.put("id", id); | |
| 32 | + paramsMap.put("sid", userId); | |
| 33 | +// 0-用户使用 1-运营使用 | |
| 34 | + paramsMap.put("state", state); | |
| 35 | + Logic.create(paramsMap).action(new Logic.Action<Map<String, String>, BaseInfo<RunRaceDetailInfo>>() { | |
| 36 | + @Override | |
| 37 | + public Disposable action(Map<String, String> stringStringMap, DataCallback<BaseInfo<RunRaceDetailInfo>> dataCallback) { | |
| 38 | + return SubscriptionRequest.service(ApiServiceRunLin.class, api -> api.getRunRaceDetail(stringStringMap)).subscribe(context, dataCallback); | |
| 39 | + } | |
| 40 | + }).<BaseInfo<RunRaceDetailInfo>>event() | |
| 41 | + .setStateCallback(new StateCallback() { | |
| 42 | + @Override | |
| 43 | + public void onState(int i) { | |
| 44 | + if (getView() == null) { | |
| 45 | + return; | |
| 46 | + } | |
| 47 | + if (i == STATE_LOAD) { | |
| 48 | + getView().showLoadingView(); | |
| 49 | + } else if (i == STATE_IDLE) { | |
| 50 | + getView().hideLoadingView(); | |
| 51 | + } | |
| 52 | + } | |
| 53 | + }) | |
| 54 | + .setFailureCallback(new FailureCallback() { | |
| 55 | + @Override | |
| 56 | + public void onFailure(int code, String message) { | |
| 57 | + if (getView() == null) { | |
| 58 | + return; | |
| 59 | + } | |
| 60 | + getView().hideLoadingView(); | |
| 61 | + getView().showRetryView(code, new View.OnClickListener() { | |
| 62 | + @Override | |
| 63 | + public void onClick(View view) { | |
| 64 | + getRunRaceDetailInfo(context, id, userId,state); | |
| 65 | + } | |
| 66 | + }); | |
| 67 | + } | |
| 68 | + }).setSuccessCallback(new SuccessCallback<BaseInfo<RunRaceDetailInfo>>() { | |
| 69 | + @Override | |
| 70 | + public void onSuccess(BaseInfo<RunRaceDetailInfo> baseInfo) { | |
| 71 | + if (getView() == null) { | |
| 72 | + return; | |
| 73 | + } | |
| 74 | + if (baseInfo.getData() != null) { | |
| 75 | + getView().initView(baseInfo.getData()); | |
| 76 | + } | |
| 77 | + } | |
| 78 | + }).start(); | |
| 79 | + | |
| 80 | + } | |
| 7 | 81 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/presenter/RunningFinishFragmetPresenter.java
| ... | ... | @@ -88,8 +88,7 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter<RunningFinis |
| 88 | 88 | pace = runningFinishBean.getSpeed(); |
| 89 | 89 | } |
| 90 | 90 | // 路线图 |
| 91 | - String roadmap = runningFinishBean.getRoadmap(); | |
| 92 | - roadmap = ""; | |
| 91 | + String roadmap = ""; | |
| 93 | 92 | //经纬度 |
| 94 | 93 | String latLongitude = ""; |
| 95 | 94 | // 开始时间 |
| ... | ... | @@ -104,7 +103,7 @@ public class RunningFinishFragmetPresenter extends MvpBasePresenter<RunningFinis |
| 104 | 103 | isPause = "1"; |
| 105 | 104 | } |
| 106 | 105 | //继续时间 |
| 107 | - String continueTime = ""; | |
| 106 | + String continueTime = userStepEntity.getContinueTime()+""; | |
| 108 | 107 | //是否完成 |
| 109 | 108 | String completeStatus = runningFinishBean.getIsFinish(); |
| 110 | 109 | //设置步数 | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/MyRecordView.java
| ... | ... | @@ -7,6 +7,7 @@ import com.cnlive.libs.base.util.AlertUtil; |
| 7 | 7 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 8 | 8 | import com.cnlive.moudle.pedometer.net.bean.BaseInfo; |
| 9 | 9 | import com.cnlive.moudle.pedometer.net.bean.MyRecordInfo; |
| 10 | +import com.cnlive.moudle.pedometer.ui.activity.OnGoingActivity; | |
| 10 | 11 | import com.cnlive.moudle.pedometer.ui.activity.RunRaceDetailActivity; |
| 11 | 12 | import com.cnlive.moudle.pedometer.ui.adapter.MyRecordAdapter; |
| 12 | 13 | import com.cnlive.moudle.pedometer.ui.fragment.MyRecordFragment; |
| ... | ... | @@ -28,6 +29,7 @@ public class MyRecordView implements MvpView { |
| 28 | 29 | public QMUITipDialog loadingDiaog; |
| 29 | 30 | private List<MyRecordInfo.ListBean> list = new ArrayList<>(); |
| 30 | 31 | private MyRecordAdapter adapter; |
| 32 | + | |
| 31 | 33 | public MyRecordView(MyRecordFragment fragment) { |
| 32 | 34 | this.fragment = fragment; |
| 33 | 35 | loadingDiaog = new QMUITipDialog.Builder(fragment.getActivity()) |
| ... | ... | @@ -37,39 +39,44 @@ public class MyRecordView implements MvpView { |
| 37 | 39 | } |
| 38 | 40 | |
| 39 | 41 | |
| 40 | - public void onSuccess(BaseInfo<MyRecordInfo> myRecordInfoBaseInfo){ | |
| 42 | + public void onSuccess(BaseInfo<MyRecordInfo> myRecordInfoBaseInfo) { | |
| 41 | 43 | hideLoading(); |
| 42 | - if(fragment.currentPage == 1){ | |
| 44 | + if (fragment.currentPage == 1) { | |
| 43 | 45 | list.clear(); |
| 44 | 46 | list.addAll(myRecordInfoBaseInfo.getData().getList()); |
| 45 | - if(adapter == null){ | |
| 46 | - adapter = new MyRecordAdapter(list,fragment.state,fragment.getActivity()); | |
| 47 | + if (adapter == null) { | |
| 48 | + adapter = new MyRecordAdapter(list, fragment.state, fragment.getActivity()); | |
| 47 | 49 | fragment.binding.myRecordRecy.setAdapter(adapter); |
| 48 | 50 | adapter.setClickListener(new MyRecordAdapter.OnClickListener() { |
| 49 | 51 | @Override |
| 50 | 52 | public void onClickListener(MyRecordInfo.ListBean bean, int position) { |
| 51 | - RunRaceDetailActivity.startActivity(fragment.getActivity(),bean.getId()+"",null,null,null,null); | |
| 53 | + if ("0".equals(fragment.state)) { | |
| 54 | + RunRaceDetailActivity.startActivity(fragment.getActivity(), bean.getId() + "", null, null, null, null); | |
| 55 | + } else { | |
| 56 | + OnGoingActivity.startActivity(fragment.getActivity(), bean.getId() + "", null, null, null, null); | |
| 57 | + | |
| 58 | + } | |
| 52 | 59 | } |
| 53 | 60 | }); |
| 54 | - }else { | |
| 61 | + } else { | |
| 55 | 62 | adapter.notifyDataSetChanged(); |
| 56 | 63 | } |
| 57 | 64 | } |
| 58 | 65 | |
| 59 | - if(list.size() != 0){ | |
| 66 | + if (list.size() != 0) { | |
| 60 | 67 | fragment.binding.empty.setVisibility(View.GONE); |
| 61 | 68 | fragment.binding.emptyRy.setVisibility(View.GONE); |
| 62 | 69 | fragment.binding.refreshLayout.setVisibility(View.VISIBLE); |
| 63 | - }else { | |
| 70 | + } else { | |
| 64 | 71 | showEmpty(); |
| 65 | 72 | } |
| 66 | 73 | |
| 67 | - if(myRecordInfoBaseInfo.getData().getList().size() < fragment.pageSize){ | |
| 74 | + if (myRecordInfoBaseInfo.getData().getList().size() < fragment.pageSize) { | |
| 68 | 75 | fragment.binding.refreshLayout.setEnableLoadMore(false); |
| 69 | - }else { | |
| 76 | + } else { | |
| 70 | 77 | fragment.binding.refreshLayout.setEnableLoadMore(true); |
| 71 | 78 | } |
| 72 | - if(fragment.currentPage > 1){ | |
| 79 | + if (fragment.currentPage > 1) { | |
| 73 | 80 | list.addAll(myRecordInfoBaseInfo.getData().getList()); |
| 74 | 81 | adapter.notifyDataSetChanged(); |
| 75 | 82 | } |
| ... | ... | @@ -77,13 +84,13 @@ public class MyRecordView implements MvpView { |
| 77 | 84 | fragment.binding.refreshLayout.finishLoadMore(); |
| 78 | 85 | } |
| 79 | 86 | |
| 80 | - public void initView(){ | |
| 87 | + public void initView() { | |
| 81 | 88 | fragment.binding.refreshLayout.setRefreshHeader(new ClassicsHeader(fragment.getActivity())); |
| 82 | 89 | fragment.binding.refreshLayout.setRefreshFooter(new ClassicsFooter(fragment.getActivity())); |
| 83 | 90 | fragment.binding.myRecordRecy.setLayoutManager(new LinearLayoutManager(fragment.getActivity())); |
| 84 | 91 | } |
| 85 | 92 | |
| 86 | - public void showErr(String msg){ | |
| 93 | + public void showErr(String msg) { | |
| 87 | 94 | fragment.binding.refreshLayout.finishRefresh(); |
| 88 | 95 | fragment.binding.refreshLayout.finishLoadMore(); |
| 89 | 96 | if (list.size() == 0) { |
| ... | ... | @@ -96,7 +103,7 @@ public class MyRecordView implements MvpView { |
| 96 | 103 | @Override |
| 97 | 104 | public void onClick(View v) { |
| 98 | 105 | fragment.currentPage = 1; |
| 99 | - fragment.getPresenter().setData(fragment.getActivity(), CommonInfo.getUserId(fragment.getActivity()),fragment.state,fragment.currentPage,fragment.pageSize); | |
| 106 | + fragment.getPresenter().setData(fragment.getActivity(), CommonInfo.getUserId(fragment.getActivity()), fragment.state, fragment.currentPage, fragment.pageSize); | |
| 100 | 107 | } |
| 101 | 108 | }); |
| 102 | 109 | fragment.binding.empty.setLoadingShowing(false); |
| ... | ... | @@ -114,7 +121,7 @@ public class MyRecordView implements MvpView { |
| 114 | 121 | AlertUtil.showDeftToast(fragment.getActivity(), message); |
| 115 | 122 | } |
| 116 | 123 | |
| 117 | - public void showEmpty(){ | |
| 124 | + public void showEmpty() { | |
| 118 | 125 | fragment.binding.empty.setVisibility(View.GONE); |
| 119 | 126 | fragment.binding.refreshLayout.setVisibility(View.GONE); |
| 120 | 127 | fragment.binding.emptyRy.setVisibility(View.VISIBLE); | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/OnGoingFragmentView.java
| ... | ... | @@ -2,16 +2,23 @@ package com.cnlive.moudle.pedometer.frame.view; |
| 2 | 2 | |
| 3 | 3 | import android.app.Activity; |
| 4 | 4 | import android.content.Context; |
| 5 | +import android.graphics.Bitmap; | |
| 6 | +import android.graphics.BitmapFactory; | |
| 5 | 7 | import android.text.TextUtils; |
| 6 | 8 | import android.util.Log; |
| 7 | 9 | import android.view.View; |
| 8 | 10 | import android.widget.LinearLayout; |
| 9 | 11 | |
| 10 | 12 | import com.alibaba.android.arouter.launcher.ARouter; |
| 13 | +import com.baidu.location.LocationClient; | |
| 14 | +import com.baidu.location.LocationClientOption; | |
| 11 | 15 | import com.baidu.mapapi.map.BaiduMap; |
| 16 | +import com.baidu.mapapi.map.BitmapDescriptorFactory; | |
| 12 | 17 | import com.baidu.mapapi.map.MapView; |
| 18 | +import com.baidu.mapapi.map.MyLocationConfiguration; | |
| 13 | 19 | import com.baidu.mapapi.map.UiSettings; |
| 14 | 20 | import com.baidu.mapapi.model.LatLng; |
| 21 | +import com.baidu.mapapi.search.route.RoutePlanSearch; | |
| 15 | 22 | import com.baidu.mapapi.utils.DistanceUtil; |
| 16 | 23 | import com.baidu.trace.LBSTraceClient; |
| 17 | 24 | import com.baidu.trace.model.SortType; |
| ... | ... | @@ -25,6 +32,7 @@ import com.cnlive.moudle.pedometer.ui.activity.TakePartActivity; |
| 25 | 32 | import com.cnlive.moudle.pedometer.ui.fragment.OnGoingFragment; |
| 26 | 33 | import com.cnlive.moudle.pedometer.ui.widget.SelectDialog; |
| 27 | 34 | import com.cnlive.moudle.pedometer.ui.widget.TipDialog; |
| 35 | +import com.cnlive.moudle.pedometer.utils.BitmapUtil; | |
| 28 | 36 | import com.cnlive.moudle.pedometer.utils.GsonUtil; |
| 29 | 37 | import com.cnlive.moudle.pedometer.utils.MyMapUtil; |
| 30 | 38 | import com.cnlive.moudle.pedometer.utils.QMUITipDialogUtil; |
| ... | ... | @@ -45,6 +53,7 @@ public class OnGoingFragmentView implements MvpView { |
| 45 | 53 | private MapView mMapView; |
| 46 | 54 | private UiSettings mUiSettings; |
| 47 | 55 | public RunRaceDetailInfo runRaceDetailInfo; |
| 56 | + private LBSTraceClient mClient = null; | |
| 48 | 57 | |
| 49 | 58 | public OnGoingFragmentView(OnGoingFragment fragment) { |
| 50 | 59 | this.fragment = fragment; |
| ... | ... | @@ -68,7 +77,22 @@ public class OnGoingFragmentView implements MvpView { |
| 68 | 77 | startTime = Long.parseLong(runRaceDetailInfo.getStartTime()); |
| 69 | 78 | endTime = Long.parseLong(runRaceDetailInfo.getEndTime()); |
| 70 | 79 | //todo 注意后续查询历史轨迹的时候,必须查数据库中的时间,因为涉及到历史运动恢复,所以不能用这个sp文件中的,这里设置,只是为了在服务启动成功后, |
| 80 | + mClient = new LBSTraceClient(getContext()); | |
| 81 | + //获取轨迹 | |
| 82 | + if (mClient != null) { | |
| 83 | + MyMapUtil.queryHistoryTrace(getContext(), mClient, runRaceDetailInfo.getEntityName(), startTime, endTime, new MyMapUtil.CallBack() { | |
| 84 | + @Override | |
| 85 | + public void success(List<LatLng> resultPoints) { | |
| 86 | + if (resultPoints != null && resultPoints.size() > 1) { | |
| 87 | + MyMapUtil.drawServerLineTrack(getContext(), baiduMap, resultPoints, SortType.asc, R.color.green_round, R.drawable.icon_start, R.drawable.icon_end); | |
| 88 | + //设置地图自动缩放 | |
| 89 | + MyMapUtil.setMapAutoZoom(baiduMap, resultPoints, -1.5f); | |
| 71 | 90 | |
| 91 | + } | |
| 92 | + } | |
| 93 | + }); | |
| 94 | + | |
| 95 | + } | |
| 72 | 96 | //显示地图 |
| 73 | 97 | fragment.binding.mapView.setVisibility(View.VISIBLE); |
| 74 | 98 | //显示底部滑动卡片 |
| ... | ... | @@ -83,15 +107,16 @@ public class OnGoingFragmentView implements MvpView { |
| 83 | 107 | @Override |
| 84 | 108 | public void onPanelSlide(View panel, float slideOffset) { |
| 85 | 109 | //设置顶层卡片特效 |
| 86 | -// if (slideOffset > 0.6) { | |
| 87 | -// fragment.binding.llTop.setVisibility(View.VISIBLE); | |
| 88 | -//// ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) fragment.binding.scrollView.getLayoutParams(); | |
| 89 | -//// params.topMargin = ScreenUtil.dip2px(getContext(), 50); | |
| 90 | -//// fragment.binding.scrollView.setLayoutParams(params); | |
| 91 | -// } else { | |
| 92 | -// fragment.binding.llTop.setVisibility(View.GONE); | |
| 93 | -// } | |
| 94 | - if (slideOffset <= 0.6) { | |
| 110 | + if (slideOffset > 0.7) { | |
| 111 | + double alpha = (255 / (1 - 0.6)) * (slideOffset - 0.6); | |
| 112 | + if (alpha > 60) { | |
| 113 | + fragment.binding.flTop.getBackground().setAlpha((int) alpha); | |
| 114 | + fragment.binding.flTop.setVisibility(View.VISIBLE); | |
| 115 | + QMUIStatusBarHelper.setStatusBarDarkMode(fragment.getActivity()); | |
| 116 | + StatusBarUtil2.setColor(fragment.getActivity(), getContext().getResources().getColor(R.color.run_main_bg), 0); | |
| 117 | + | |
| 118 | + } | |
| 119 | + } else { | |
| 95 | 120 | if (fragment.binding.flTop.getVisibility() == View.VISIBLE) { |
| 96 | 121 | QMUIStatusBarHelper.setStatusBarLightMode(fragment.getActivity()); |
| 97 | 122 | StatusBarUtil2.setColor(fragment.getActivity(), getContext().getResources().getColor(R.color.white), 0); |
| ... | ... | @@ -147,6 +172,7 @@ public class OnGoingFragmentView implements MvpView { |
| 147 | 172 | |
| 148 | 173 | } |
| 149 | 174 | } else if (previousState == SlidingUpPanelLayout.PanelState.DRAGGING && newState == SlidingUpPanelLayout.PanelState.EXPANDED) { |
| 175 | + | |
| 150 | 176 | if (fragment.binding.flTop.getVisibility() != View.VISIBLE) { |
| 151 | 177 | QMUIStatusBarHelper.setStatusBarDarkMode(fragment.getActivity()); |
| 152 | 178 | StatusBarUtil2.setColor(fragment.getActivity(), getContext().getResources().getColor(R.color.run_main_bg), 0); |
| ... | ... | @@ -156,14 +182,12 @@ public class OnGoingFragmentView implements MvpView { |
| 156 | 182 | } else if (previousState == SlidingUpPanelLayout.PanelState.EXPANDED && newState == SlidingUpPanelLayout.PanelState.DRAGGING) { |
| 157 | 183 | QMUIStatusBarHelper.setStatusBarLightMode(fragment.getActivity()); |
| 158 | 184 | StatusBarUtil2.setColor(fragment.getActivity(), getContext().getResources().getColor(R.color.white), 0); |
| 159 | - | |
| 160 | 185 | if (fragment.binding.flTop.getVisibility() != View.GONE) { |
| 161 | 186 | fragment.binding.flTop.setVisibility(View.GONE); |
| 162 | 187 | } |
| 163 | 188 | } else if (previousState == SlidingUpPanelLayout.PanelState.DRAGGING && newState == SlidingUpPanelLayout.PanelState.ANCHORED) { |
| 164 | 189 | QMUIStatusBarHelper.setStatusBarLightMode(fragment.getActivity()); |
| 165 | 190 | StatusBarUtil2.setColor(fragment.getActivity(), getContext().getResources().getColor(R.color.white), 0); |
| 166 | - | |
| 167 | 191 | if (fragment.binding.flTop.getVisibility() != View.GONE) { |
| 168 | 192 | fragment.binding.flTop.setVisibility(View.GONE); |
| 169 | 193 | } |
| ... | ... | @@ -191,9 +215,9 @@ public class OnGoingFragmentView implements MvpView { |
| 191 | 215 | fragment.binding.includeStreet.tvRaceTitle.setText(runRaceDetailInfo.getTitle()); |
| 192 | 216 | //根据标题字数动态设置卡片高度 |
| 193 | 217 | if (runRaceDetailInfo.getTitle().length() > 19) { |
| 194 | - fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 200)); | |
| 218 | + fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 162)); | |
| 195 | 219 | } else { |
| 196 | - fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 181)); | |
| 220 | + fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 140)); | |
| 197 | 221 | } |
| 198 | 222 | fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED); |
| 199 | 223 | } |
| ... | ... | @@ -336,4 +360,75 @@ public class OnGoingFragmentView implements MvpView { |
| 336 | 360 | }); |
| 337 | 361 | } |
| 338 | 362 | } |
| 363 | + | |
| 364 | + public void initMap() { | |
| 365 | + //隐藏底部滑动卡片 | |
| 366 | + fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN); | |
| 367 | + this.mMapView = fragment.binding.mapView; | |
| 368 | + if (baiduMap == null) { | |
| 369 | + baiduMap = mMapView.getMap(); | |
| 370 | + } | |
| 371 | + if (mUiSettings == null) { | |
| 372 | + mUiSettings = baiduMap.getUiSettings(); | |
| 373 | + } | |
| 374 | + //启动所有手势 | |
| 375 | + mUiSettings.setAllGesturesEnabled(true); | |
| 376 | + //通过设置enable为true或false 选择是否显示缩放按钮 | |
| 377 | + mMapView.showZoomControls(false); | |
| 378 | + mUiSettings.setEnlargeCenterWithDoubleClickEnable(true); | |
| 379 | + //隐藏自带的指南针,改用自定义指南针 杨帅 | |
| 380 | + baiduMap.getUiSettings().setCompassEnabled(true); | |
| 381 | + //显示定位图层 | |
| 382 | + baiduMap.setMyLocationEnabled(false); | |
| 383 | + } | |
| 384 | + | |
| 385 | + /** | |
| 386 | + * 显示loading | |
| 387 | + */ | |
| 388 | + public void showLoadingView() { | |
| 389 | + if (fragment.binding.emptyLayout == null) { | |
| 390 | + return; | |
| 391 | + } | |
| 392 | + fragment.binding.emptyLayout.show(true); | |
| 393 | + } | |
| 394 | + | |
| 395 | + /** | |
| 396 | + * 隐藏loading | |
| 397 | + */ | |
| 398 | + public void hideLoadingView() { | |
| 399 | + if (fragment.binding.emptyLayout == null) { | |
| 400 | + return; | |
| 401 | + } | |
| 402 | + fragment.binding.emptyLayout.hide(); | |
| 403 | + } | |
| 404 | + | |
| 405 | + /** | |
| 406 | + * 显示重试页面 | |
| 407 | + * | |
| 408 | + * @param errorCode | |
| 409 | + * @param listener | |
| 410 | + */ | |
| 411 | + public void showRetryView(int errorCode, View.OnClickListener listener) { | |
| 412 | + if (getContext() == null) { | |
| 413 | + return; | |
| 414 | + } | |
| 415 | + //隐藏地图 | |
| 416 | + fragment.binding.mapView.setVisibility(View.GONE); | |
| 417 | + //显示空视图 | |
| 418 | + fragment.binding.emptyLayout.setVisibility(View.VISIBLE); | |
| 419 | + //隐藏底部卡片 | |
| 420 | + fragment.binding.slidingLayout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN); | |
| 421 | + if (fragment.binding.emptyLayout == null) return; | |
| 422 | + String titleText = ""; | |
| 423 | + String detailText = ""; | |
| 424 | + if (errorCode == -3) { | |
| 425 | + titleText = getContext().getString(R.string.msg_failed_network_title); | |
| 426 | + detailText = getContext().getString(R.string.msg_failed_network_detail); | |
| 427 | + } else { | |
| 428 | + titleText = getContext().getString(R.string.msg_failed_other_title); | |
| 429 | + detailText = getContext().getString(R.string.msg_failed_other_detail); | |
| 430 | + } | |
| 431 | + fragment.binding.emptyLayout.show(false, titleText, detailText, getContext().getString(R.string.retry), R.drawable.wufalianjie, listener); | |
| 432 | + } | |
| 433 | + | |
| 339 | 434 | } |
| 340 | 435 | \ No newline at end of file | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
| ... | ... | @@ -15,6 +15,7 @@ import android.text.TextUtils; |
| 15 | 15 | import android.util.Log; |
| 16 | 16 | import android.view.View; |
| 17 | 17 | import android.view.ViewGroup; |
| 18 | +import android.view.ViewTreeObserver; | |
| 18 | 19 | import android.widget.LinearLayout; |
| 19 | 20 | import android.widget.Toast; |
| 20 | 21 | |
| ... | ... | @@ -352,6 +353,14 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 352 | 353 | //设置标题 |
| 353 | 354 | if (!TextUtils.isEmpty(runRaceDetailInfo.getTitle())) { |
| 354 | 355 | fragment.binding.includeStreet.tvRaceTitle.setText(runRaceDetailInfo.getTitle()); |
| 356 | + fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { | |
| 357 | + @Override | |
| 358 | + public boolean onPreDraw() { | |
| 359 | + Log.e(TAG, "initView: "+ fragment.binding.includeStreet.tvRaceTitle.getLineCount() ); | |
| 360 | + fragment.binding.includeStreet.tvRaceTitle.getViewTreeObserver().removeOnPreDrawListener(this); | |
| 361 | + return false; | |
| 362 | + } | |
| 363 | + }); | |
| 355 | 364 | //根据标题字数动态设置卡片高度 |
| 356 | 365 | if (runRaceDetailInfo.getTitle().length() > 19) { |
| 357 | 366 | fragment.binding.slidingLayout.setPanelHeight(ScreenUtil.dip2px(getContext(), 200)); | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/OnGoingActivity.java
| 1 | 1 | package com.cnlive.moudle.pedometer.ui.activity; |
| 2 | 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; | |
| 3 | 8 | import com.cnlive.libs.base.ui.QMUIFragmentActivity; |
| 9 | +import com.cnlive.moudle.pedometer.ui.fragment.OnGoingFragment; | |
| 10 | +import com.cnlive.moudle.pedometer.ui.fragment.RunRaceDetailFragment; | |
| 4 | 11 | import com.example.moudle_pedometer.R; |
| 5 | 12 | |
| 6 | 13 | /** |
| ... | ... | @@ -11,4 +18,32 @@ public class OnGoingActivity extends QMUIFragmentActivity { |
| 11 | 18 | protected int getContextViewId() { |
| 12 | 19 | return R.id.fragment_ongoing; |
| 13 | 20 | } |
| 21 | + | |
| 22 | + @Override | |
| 23 | + protected void onCreate(Bundle savedInstanceState) { | |
| 24 | + super.onCreate(savedInstanceState); | |
| 25 | + String eventId = getIntent().getExtras().getString("eventId"); | |
| 26 | + if (null != eventId) { | |
| 27 | + addFragment(OnGoingFragment.newInstance(eventId)); | |
| 28 | + } | |
| 29 | + } | |
| 30 | + | |
| 31 | + public static void startActivity(Activity activity, String eventId, String userId, String userIcon, String userName, String userPhone) { | |
| 32 | + Intent intent = new Intent(activity, OnGoingActivity.class); | |
| 33 | + intent.putExtra("eventId", eventId); | |
| 34 | + intent.putExtra("userId", userId); | |
| 35 | + intent.putExtra("userIcon", userIcon); | |
| 36 | + intent.putExtra("userName", userName); | |
| 37 | + intent.putExtra("userPhone", userPhone); | |
| 38 | + activity.startActivity(intent); | |
| 39 | + } | |
| 40 | + | |
| 41 | + private void addFragment(QMUIFragment fragment) { | |
| 42 | + getSupportFragmentManager().beginTransaction() | |
| 43 | + .add(getContextViewId(), fragment, fragment.getClass().getSimpleName()) | |
| 44 | + .addToBackStack(fragment.getClass().getSimpleName()) | |
| 45 | + .commit(); | |
| 46 | + } | |
| 47 | + | |
| 48 | + | |
| 14 | 49 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/OnGoingFragment.java
| ... | ... | @@ -2,14 +2,29 @@ package com.cnlive.moudle.pedometer.ui.fragment; |
| 2 | 2 | |
| 3 | 3 | import android.os.Bundle; |
| 4 | 4 | import android.support.annotation.Nullable; |
| 5 | +import android.text.TextUtils; | |
| 5 | 6 | import android.view.View; |
| 6 | 7 | |
| 7 | 8 | import com.cnlive.libs.base.ui.QMUIFragment; |
| 9 | +import com.cnlive.libs.base.util.StatusBarUtil2; | |
| 10 | +import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; | |
| 8 | 11 | import com.cnlive.moudle.pedometer.frame.presenter.OnGoingFragmentPresenter; |
| 9 | 12 | import com.cnlive.moudle.pedometer.frame.view.OnGoingFragmentView; |
| 13 | +import com.example.moudle_pedometer.R; | |
| 10 | 14 | import com.example.moudle_pedometer.databinding.FragmentRunRaceDetailBinding; |
| 15 | +import com.qmuiteam.qmui.util.QMUIStatusBarHelper; | |
| 11 | 16 | |
| 12 | 17 | public class OnGoingFragment extends QMUIFragment<OnGoingFragmentView, OnGoingFragmentPresenter, FragmentRunRaceDetailBinding> { |
| 18 | + private String eventId; | |
| 19 | + | |
| 20 | + public static OnGoingFragment newInstance(String eventId) { | |
| 21 | + OnGoingFragment fragment = new OnGoingFragment(); | |
| 22 | + Bundle bundle = new Bundle(); | |
| 23 | + bundle.putString("eventId", eventId); | |
| 24 | + fragment.setArguments(bundle); | |
| 25 | + return fragment; | |
| 26 | + } | |
| 27 | + | |
| 13 | 28 | @Override |
| 14 | 29 | protected int getToolbarId() { |
| 15 | 30 | return 0; |
| ... | ... | @@ -22,11 +37,27 @@ public class OnGoingFragment extends QMUIFragment<OnGoingFragmentView, OnGoingFr |
| 22 | 37 | |
| 23 | 38 | @Override |
| 24 | 39 | protected int getLayoutId() { |
| 25 | - return 0; | |
| 40 | + return R.layout.fragment_run_race_detail; | |
| 26 | 41 | } |
| 27 | 42 | |
| 28 | 43 | @Override |
| 29 | 44 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { |
| 30 | 45 | super.onViewCreated(view, savedInstanceState); |
| 46 | + QMUIStatusBarHelper.setStatusBarLightMode(getActivity()); | |
| 47 | + StatusBarUtil2.setColor(getActivity(), getResources().getColor(R.color.white), 0); | |
| 48 | + if (getMvpView() != null) { | |
| 49 | + getMvpView().initMap(); | |
| 50 | + } | |
| 51 | + if (null!=getArguments()){ | |
| 52 | + eventId=getArguments().getString("eventId"); | |
| 53 | + if (!TextUtils.isEmpty(eventId)){ | |
| 54 | + if (getPresenter() != null) { | |
| 55 | + if (!TextUtils.isEmpty(CommonInfo.getStreetId(getActivity()))) { | |
| 56 | + getPresenter().getRunRaceDetailInfo(getActivity(), eventId, CommonInfo.getUserId(getActivity()), "0"); | |
| 57 | + } | |
| 58 | + } | |
| 59 | + } | |
| 60 | + } | |
| 61 | + | |
| 31 | 62 | } |
| 32 | 63 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/utils/StepUtil.java