Commit 627219f87e253c11c8fc52ff79dc902cf9a00a4e
1 parent
0c3099bb
1 修复用户报名逻辑
Showing
5 changed files
with
42 additions
and
23 deletions
app/src/main/java/com/example/modulepedometer/MainActivity.java
| ... | ... | @@ -20,23 +20,23 @@ public class MainActivity extends AppCompatActivity { |
| 20 | 20 | protected void onCreate(Bundle savedInstanceState) { |
| 21 | 21 | super.onCreate(savedInstanceState); |
| 22 | 22 | setContentView(R.layout.activity_main); |
| 23 | - | |
| 23 | + String uid = "358916"; | |
| 24 | 24 | findViewById(R.id.recordd).setOnClickListener(new View.OnClickListener() { |
| 25 | 25 | @Override |
| 26 | 26 | public void onClick(View v) { |
| 27 | - RunLineActivity.newInstance(MainActivity.this,"358916",null,null,null); | |
| 27 | + RunLineActivity.newInstance(MainActivity.this, uid, null, null, null); | |
| 28 | 28 | } |
| 29 | 29 | }); |
| 30 | 30 | findViewById(R.id.tooll).setOnClickListener(new View.OnClickListener() { |
| 31 | 31 | @Override |
| 32 | 32 | public void onClick(View v) { |
| 33 | - RaceListActivity.newInstance(MainActivity.this,"358916",null,null); | |
| 33 | + RaceListActivity.newInstance(MainActivity.this, uid, null, null); | |
| 34 | 34 | } |
| 35 | 35 | }); |
| 36 | 36 | findViewById(R.id.tool2).setOnClickListener(new View.OnClickListener() { |
| 37 | 37 | @Override |
| 38 | 38 | public void onClick(View v) { |
| 39 | - SelfRecordActivity.newInstance(MainActivity.this, "358916",null,null,null); | |
| 39 | + SelfRecordActivity.newInstance(MainActivity.this, uid, null, null, null); | |
| 40 | 40 | } |
| 41 | 41 | }); |
| 42 | 42 | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/collectionTrace/frame/view/CollRunRaceDetailFragmentView.java
| ... | ... | @@ -79,12 +79,9 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen |
| 79 | 79 | private MarkerOptions currentMark; |
| 80 | 80 | private MarkerOptions endMark; |
| 81 | 81 | private MarkerOptions startMark; |
| 82 | - | |
| 83 | 82 | private LatLng firstLatLng; |
| 84 | 83 | private Double lastX = 0.0; |
| 85 | 84 | private int mCurrentDirection = 0; |
| 86 | - // private double mCurrentLat = 0.0; | |
| 87 | -// private double mCurrentLon = 0.0; | |
| 88 | 85 | private float mCurrentAccracy; |
| 89 | 86 | // 定位相关 |
| 90 | 87 | private LocationClient mLocClient; |
| ... | ... | @@ -282,7 +279,7 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen |
| 282 | 279 | fragment.binding.includeStreet.tvActiveEndTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getEnd_time(), "yyyy.MM.dd")); |
| 283 | 280 | } |
| 284 | 281 | //设置活动类型 |
| 285 | - if (!TextUtils.isEmpty(runRaceDetailInfo.getEventType())){ | |
| 282 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getEventType())) { | |
| 286 | 283 | fragment.binding.includeStreet.tvEventType.setText(runRaceDetailInfo.getEventType()); |
| 287 | 284 | } |
| 288 | 285 | |
| ... | ... | @@ -293,7 +290,7 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen |
| 293 | 290 | |
| 294 | 291 | } |
| 295 | 292 | //设置路线介绍 |
| 296 | - if(!TextUtils.isEmpty(runRaceDetailInfo.getDescription())){ | |
| 293 | + if (!TextUtils.isEmpty(runRaceDetailInfo.getDescription())) { | |
| 297 | 294 | fragment.binding.includeStreetIntroduce.tvStreetIntroduce.setText(runRaceDetailInfo.getDescription()); |
| 298 | 295 | } |
| 299 | 296 | |
| ... | ... | @@ -592,6 +589,9 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen |
| 592 | 589 | |
| 593 | 590 | @Override |
| 594 | 591 | public void onSensorChanged(SensorEvent sensorEvent) { |
| 592 | + if (null == getContext()) { | |
| 593 | + return; | |
| 594 | + } | |
| 595 | 595 | double x = sensorEvent.values[SensorManager.DATA_X]; |
| 596 | 596 | if (Math.abs(x - lastX) > 1.0) { |
| 597 | 597 | mCurrentDirection = (int) x; |
| ... | ... | @@ -620,26 +620,31 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen |
| 620 | 620 | public List<BitmapDescriptor> getCustomTextureList() { |
| 621 | 621 | ArrayList<BitmapDescriptor> list = new ArrayList<BitmapDescriptor>(); |
| 622 | 622 | list.add(BitmapDescriptorFactory.fromAsset("Icon_road_blue_arrow.png")); |
| 623 | -// list.add(BitmapDescriptorFactory.fromAsset("Icon_road_green_arrow.png")); | |
| 624 | -// list.add(BitmapDescriptorFactory.fromAsset("Icon_road_yellow_arrow.png")); | |
| 625 | -// list.add(BitmapDescriptorFactory.fromAsset("Icon_road_red_arrow.png")); | |
| 626 | -// list.add(BitmapDescriptorFactory.fromAsset("Icon_road_nofocus.png")); | |
| 627 | 623 | return list; |
| 628 | 624 | } |
| 629 | 625 | |
| 630 | 626 | public void onResume() { |
| 627 | + if (null == getContext()) { | |
| 628 | + return; | |
| 629 | + } | |
| 631 | 630 | if (mMapView != null) { |
| 632 | 631 | mMapView.onResume(); |
| 633 | 632 | } |
| 634 | 633 | } |
| 635 | 634 | |
| 636 | 635 | public void onPause() { |
| 636 | + if (null == getContext()) { | |
| 637 | + return; | |
| 638 | + } | |
| 637 | 639 | if (mMapView != null) { |
| 638 | 640 | mMapView.onPause(); |
| 639 | 641 | } |
| 640 | 642 | } |
| 641 | 643 | |
| 642 | 644 | public void onDestroy() { |
| 645 | + if (null == getContext()) { | |
| 646 | + return; | |
| 647 | + } | |
| 643 | 648 | if (mMapView != null) { |
| 644 | 649 | mMapView.onDestroy(); |
| 645 | 650 | mMapView = null; |
| ... | ... | @@ -658,7 +663,7 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen |
| 658 | 663 | @Override |
| 659 | 664 | public void onReceiveLocation(BDLocation location) { |
| 660 | 665 | // map view 销毁后不在处理新接收的位置 |
| 661 | - if (location == null || mMapView == null) { | |
| 666 | + if (location == null || mMapView == null || null == getContext()) { | |
| 662 | 667 | return; |
| 663 | 668 | } |
| 664 | 669 | if (isFirstLoc) { |
| ... | ... | @@ -686,7 +691,7 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen |
| 686 | 691 | location.getLongitude()); |
| 687 | 692 | baiduMap.setMyLocationData(followMyLocation); |
| 688 | 693 | |
| 689 | - if ((null == queryResultPoints||queryResultPoints.size()<1) && null != firstLatLng) { | |
| 694 | + if ((null == queryResultPoints || queryResultPoints.size() < 1) && null != firstLatLng) { | |
| 690 | 695 | builder.target(firstLatLng).zoom(DEFULT_ZOOM); |
| 691 | 696 | baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); |
| 692 | 697 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
| ... | ... | @@ -514,7 +514,9 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 514 | 514 | public void onClick(View view) { |
| 515 | 515 | //立即报名 |
| 516 | 516 | if ("0".equals(fragment.binding.rlScrollViewStartBtn.getTag())) { |
| 517 | - RegistrationInfoActivity.newInstance(fragment.getActivity()); | |
| 517 | + if (null != runRaceDetailInfo) { | |
| 518 | + RegistrationInfoActivity.newInstance(fragment.getActivity(), runRaceDetailInfo.getFenceId()); | |
| 519 | + } | |
| 518 | 520 | } |
| 519 | 521 | //现在开始 |
| 520 | 522 | else if ("1".equals(fragment.binding.rlScrollViewStartBtn.getTag())) { | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/RegistrationInfoActivity.java
| ... | ... | @@ -11,13 +11,14 @@ import com.cnlive.moudle.pedometer.ui.fragment.RegistrationInfoFragment; |
| 11 | 11 | import com.example.moudle_pedometer.R; |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - *填写报名信息 | |
| 14 | + * 填写报名信息 | |
| 15 | 15 | * Created by hanyayun 019/05/29. |
| 16 | 16 | */ |
| 17 | 17 | public class RegistrationInfoActivity extends AppCompatActivity { |
| 18 | 18 | |
| 19 | - public static void newInstance(Activity context){ | |
| 20 | - Intent intent = new Intent(context,RegistrationInfoActivity.class); | |
| 19 | + public static void newInstance(Activity context, String fenceId) { | |
| 20 | + Intent intent = new Intent(context, RegistrationInfoActivity.class); | |
| 21 | + intent.putExtra("fenceId", fenceId); | |
| 21 | 22 | context.startActivity(intent); |
| 22 | 23 | } |
| 23 | 24 | |
| ... | ... | @@ -27,6 +28,7 @@ public class RegistrationInfoActivity extends AppCompatActivity { |
| 27 | 28 | StatusBarUtil.setStatusBarWrite(this); |
| 28 | 29 | StatusBarUtil2.setColor(this, getResources().getColor(R.color.color_fff), 0); |
| 29 | 30 | setContentView(R.layout.activity_registration_info); |
| 30 | - getSupportFragmentManager().beginTransaction().replace(R.id.container, RegistrationInfoFragment.newInstance()).commit(); | |
| 31 | + String fenceId = getIntent().getExtras().getString("fenceId"); | |
| 32 | + getSupportFragmentManager().beginTransaction().replace(R.id.container, RegistrationInfoFragment.newInstance(fenceId)).commit(); | |
| 31 | 33 | } |
| 32 | 34 | } | ... | ... |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/fragment/RegistrationInfoFragment.java
| ... | ... | @@ -4,6 +4,7 @@ package com.cnlive.moudle.pedometer.ui.fragment; |
| 4 | 4 | import android.os.Bundle; |
| 5 | 5 | import android.support.annotation.NonNull; |
| 6 | 6 | import android.support.annotation.Nullable; |
| 7 | +import android.text.TextUtils; | |
| 7 | 8 | import android.view.View; |
| 8 | 9 | |
| 9 | 10 | import com.baidu.trace.LBSTraceClient; |
| ... | ... | @@ -42,9 +43,13 @@ public class RegistrationInfoFragment extends MvpBindingFragment<RegistrationInf |
| 42 | 43 | |
| 43 | 44 | |
| 44 | 45 | public TimePickerDialog pickerDialog; |
| 46 | + public String fenceId; | |
| 45 | 47 | |
| 46 | - public static RegistrationInfoFragment newInstance() { | |
| 48 | + public static RegistrationInfoFragment newInstance(String fenceId) { | |
| 47 | 49 | RegistrationInfoFragment fragment = new RegistrationInfoFragment(); |
| 50 | + Bundle bundle = new Bundle(); | |
| 51 | + bundle.putString("fenceId", fenceId); | |
| 52 | + fragment.setArguments(bundle); | |
| 48 | 53 | return fragment; |
| 49 | 54 | } |
| 50 | 55 | |
| ... | ... | @@ -56,11 +61,16 @@ public class RegistrationInfoFragment extends MvpBindingFragment<RegistrationInf |
| 56 | 61 | @Override |
| 57 | 62 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
| 58 | 63 | super.onViewCreated(view, savedInstanceState); |
| 64 | + if (null != getArguments()) { | |
| 65 | + fenceId = getArguments().getString("fenceId"); | |
| 66 | + } | |
| 59 | 67 | if (getMvpView() != null) getMvpView().initView(); |
| 60 | 68 | } |
| 61 | 69 | |
| 62 | 70 | public void commitInfo() { |
| 63 | - addMonitorToFence(1); | |
| 71 | + if (!TextUtils.isEmpty(fenceId)) { | |
| 72 | + addMonitorToFence((int) (Double.parseDouble(fenceId))); | |
| 73 | + } | |
| 64 | 74 | } |
| 65 | 75 | |
| 66 | 76 | /** |
| ... | ... | @@ -156,7 +166,7 @@ public class RegistrationInfoFragment extends MvpBindingFragment<RegistrationInf |
| 156 | 166 | if (0 == state || 3005 == state) { |
| 157 | 167 | //将设备添加到围栏中 |
| 158 | 168 | mClient.addFenceMonitoredPerson(addMonitoredPersonRequest, onFenceListener); |
| 159 | - }else { | |
| 169 | + } else { | |
| 160 | 170 | AlertUtil.showDeftToast(getContext(), msg); |
| 161 | 171 | } |
| 162 | 172 | } | ... | ... |