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,23 +20,23 @@ public class MainActivity extends AppCompatActivity { | ||
| 20 | protected void onCreate(Bundle savedInstanceState) { | 20 | protected void onCreate(Bundle savedInstanceState) { |
| 21 | super.onCreate(savedInstanceState); | 21 | super.onCreate(savedInstanceState); |
| 22 | setContentView(R.layout.activity_main); | 22 | setContentView(R.layout.activity_main); |
| 23 | - | 23 | + String uid = "358916"; |
| 24 | findViewById(R.id.recordd).setOnClickListener(new View.OnClickListener() { | 24 | findViewById(R.id.recordd).setOnClickListener(new View.OnClickListener() { |
| 25 | @Override | 25 | @Override |
| 26 | public void onClick(View v) { | 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 | findViewById(R.id.tooll).setOnClickListener(new View.OnClickListener() { | 30 | findViewById(R.id.tooll).setOnClickListener(new View.OnClickListener() { |
| 31 | @Override | 31 | @Override |
| 32 | public void onClick(View v) { | 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 | findViewById(R.id.tool2).setOnClickListener(new View.OnClickListener() { | 36 | findViewById(R.id.tool2).setOnClickListener(new View.OnClickListener() { |
| 37 | @Override | 37 | @Override |
| 38 | public void onClick(View v) { | 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,12 +79,9 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen | ||
| 79 | private MarkerOptions currentMark; | 79 | private MarkerOptions currentMark; |
| 80 | private MarkerOptions endMark; | 80 | private MarkerOptions endMark; |
| 81 | private MarkerOptions startMark; | 81 | private MarkerOptions startMark; |
| 82 | - | ||
| 83 | private LatLng firstLatLng; | 82 | private LatLng firstLatLng; |
| 84 | private Double lastX = 0.0; | 83 | private Double lastX = 0.0; |
| 85 | private int mCurrentDirection = 0; | 84 | private int mCurrentDirection = 0; |
| 86 | - // private double mCurrentLat = 0.0; | ||
| 87 | -// private double mCurrentLon = 0.0; | ||
| 88 | private float mCurrentAccracy; | 85 | private float mCurrentAccracy; |
| 89 | // 定位相关 | 86 | // 定位相关 |
| 90 | private LocationClient mLocClient; | 87 | private LocationClient mLocClient; |
| @@ -282,7 +279,7 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen | @@ -282,7 +279,7 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen | ||
| 282 | fragment.binding.includeStreet.tvActiveEndTime.setText(TimeUtil.getStampToTime(runRaceDetailInfo.getEnd_time(), "yyyy.MM.dd")); | 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 | fragment.binding.includeStreet.tvEventType.setText(runRaceDetailInfo.getEventType()); | 283 | fragment.binding.includeStreet.tvEventType.setText(runRaceDetailInfo.getEventType()); |
| 287 | } | 284 | } |
| 288 | 285 | ||
| @@ -293,7 +290,7 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen | @@ -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 | fragment.binding.includeStreetIntroduce.tvStreetIntroduce.setText(runRaceDetailInfo.getDescription()); | 294 | fragment.binding.includeStreetIntroduce.tvStreetIntroduce.setText(runRaceDetailInfo.getDescription()); |
| 298 | } | 295 | } |
| 299 | 296 | ||
| @@ -592,6 +589,9 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen | @@ -592,6 +589,9 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen | ||
| 592 | 589 | ||
| 593 | @Override | 590 | @Override |
| 594 | public void onSensorChanged(SensorEvent sensorEvent) { | 591 | public void onSensorChanged(SensorEvent sensorEvent) { |
| 592 | + if (null == getContext()) { | ||
| 593 | + return; | ||
| 594 | + } | ||
| 595 | double x = sensorEvent.values[SensorManager.DATA_X]; | 595 | double x = sensorEvent.values[SensorManager.DATA_X]; |
| 596 | if (Math.abs(x - lastX) > 1.0) { | 596 | if (Math.abs(x - lastX) > 1.0) { |
| 597 | mCurrentDirection = (int) x; | 597 | mCurrentDirection = (int) x; |
| @@ -620,26 +620,31 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen | @@ -620,26 +620,31 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen | ||
| 620 | public List<BitmapDescriptor> getCustomTextureList() { | 620 | public List<BitmapDescriptor> getCustomTextureList() { |
| 621 | ArrayList<BitmapDescriptor> list = new ArrayList<BitmapDescriptor>(); | 621 | ArrayList<BitmapDescriptor> list = new ArrayList<BitmapDescriptor>(); |
| 622 | list.add(BitmapDescriptorFactory.fromAsset("Icon_road_blue_arrow.png")); | 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 | return list; | 623 | return list; |
| 628 | } | 624 | } |
| 629 | 625 | ||
| 630 | public void onResume() { | 626 | public void onResume() { |
| 627 | + if (null == getContext()) { | ||
| 628 | + return; | ||
| 629 | + } | ||
| 631 | if (mMapView != null) { | 630 | if (mMapView != null) { |
| 632 | mMapView.onResume(); | 631 | mMapView.onResume(); |
| 633 | } | 632 | } |
| 634 | } | 633 | } |
| 635 | 634 | ||
| 636 | public void onPause() { | 635 | public void onPause() { |
| 636 | + if (null == getContext()) { | ||
| 637 | + return; | ||
| 638 | + } | ||
| 637 | if (mMapView != null) { | 639 | if (mMapView != null) { |
| 638 | mMapView.onPause(); | 640 | mMapView.onPause(); |
| 639 | } | 641 | } |
| 640 | } | 642 | } |
| 641 | 643 | ||
| 642 | public void onDestroy() { | 644 | public void onDestroy() { |
| 645 | + if (null == getContext()) { | ||
| 646 | + return; | ||
| 647 | + } | ||
| 643 | if (mMapView != null) { | 648 | if (mMapView != null) { |
| 644 | mMapView.onDestroy(); | 649 | mMapView.onDestroy(); |
| 645 | mMapView = null; | 650 | mMapView = null; |
| @@ -658,7 +663,7 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen | @@ -658,7 +663,7 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen | ||
| 658 | @Override | 663 | @Override |
| 659 | public void onReceiveLocation(BDLocation location) { | 664 | public void onReceiveLocation(BDLocation location) { |
| 660 | // map view 销毁后不在处理新接收的位置 | 665 | // map view 销毁后不在处理新接收的位置 |
| 661 | - if (location == null || mMapView == null) { | 666 | + if (location == null || mMapView == null || null == getContext()) { |
| 662 | return; | 667 | return; |
| 663 | } | 668 | } |
| 664 | if (isFirstLoc) { | 669 | if (isFirstLoc) { |
| @@ -686,7 +691,7 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen | @@ -686,7 +691,7 @@ public class CollRunRaceDetailFragmentView implements MvpView, SensorEventListen | ||
| 686 | location.getLongitude()); | 691 | location.getLongitude()); |
| 687 | baiduMap.setMyLocationData(followMyLocation); | 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 | builder.target(firstLatLng).zoom(DEFULT_ZOOM); | 695 | builder.target(firstLatLng).zoom(DEFULT_ZOOM); |
| 691 | baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); | 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,7 +514,9 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | ||
| 514 | public void onClick(View view) { | 514 | public void onClick(View view) { |
| 515 | //立即报名 | 515 | //立即报名 |
| 516 | if ("0".equals(fragment.binding.rlScrollViewStartBtn.getTag())) { | 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 | else if ("1".equals(fragment.binding.rlScrollViewStartBtn.getTag())) { | 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,13 +11,14 @@ import com.cnlive.moudle.pedometer.ui.fragment.RegistrationInfoFragment; | ||
| 11 | import com.example.moudle_pedometer.R; | 11 | import com.example.moudle_pedometer.R; |
| 12 | 12 | ||
| 13 | /** | 13 | /** |
| 14 | - *填写报名信息 | 14 | + * 填写报名信息 |
| 15 | * Created by hanyayun 019/05/29. | 15 | * Created by hanyayun 019/05/29. |
| 16 | */ | 16 | */ |
| 17 | public class RegistrationInfoActivity extends AppCompatActivity { | 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 | context.startActivity(intent); | 22 | context.startActivity(intent); |
| 22 | } | 23 | } |
| 23 | 24 | ||
| @@ -27,6 +28,7 @@ public class RegistrationInfoActivity extends AppCompatActivity { | @@ -27,6 +28,7 @@ public class RegistrationInfoActivity extends AppCompatActivity { | ||
| 27 | StatusBarUtil.setStatusBarWrite(this); | 28 | StatusBarUtil.setStatusBarWrite(this); |
| 28 | StatusBarUtil2.setColor(this, getResources().getColor(R.color.color_fff), 0); | 29 | StatusBarUtil2.setColor(this, getResources().getColor(R.color.color_fff), 0); |
| 29 | setContentView(R.layout.activity_registration_info); | 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,6 +4,7 @@ package com.cnlive.moudle.pedometer.ui.fragment; | ||
| 4 | import android.os.Bundle; | 4 | import android.os.Bundle; |
| 5 | import android.support.annotation.NonNull; | 5 | import android.support.annotation.NonNull; |
| 6 | import android.support.annotation.Nullable; | 6 | import android.support.annotation.Nullable; |
| 7 | +import android.text.TextUtils; | ||
| 7 | import android.view.View; | 8 | import android.view.View; |
| 8 | 9 | ||
| 9 | import com.baidu.trace.LBSTraceClient; | 10 | import com.baidu.trace.LBSTraceClient; |
| @@ -42,9 +43,13 @@ public class RegistrationInfoFragment extends MvpBindingFragment<RegistrationInf | @@ -42,9 +43,13 @@ public class RegistrationInfoFragment extends MvpBindingFragment<RegistrationInf | ||
| 42 | 43 | ||
| 43 | 44 | ||
| 44 | public TimePickerDialog pickerDialog; | 45 | public TimePickerDialog pickerDialog; |
| 46 | + public String fenceId; | ||
| 45 | 47 | ||
| 46 | - public static RegistrationInfoFragment newInstance() { | 48 | + public static RegistrationInfoFragment newInstance(String fenceId) { |
| 47 | RegistrationInfoFragment fragment = new RegistrationInfoFragment(); | 49 | RegistrationInfoFragment fragment = new RegistrationInfoFragment(); |
| 50 | + Bundle bundle = new Bundle(); | ||
| 51 | + bundle.putString("fenceId", fenceId); | ||
| 52 | + fragment.setArguments(bundle); | ||
| 48 | return fragment; | 53 | return fragment; |
| 49 | } | 54 | } |
| 50 | 55 | ||
| @@ -56,11 +61,16 @@ public class RegistrationInfoFragment extends MvpBindingFragment<RegistrationInf | @@ -56,11 +61,16 @@ public class RegistrationInfoFragment extends MvpBindingFragment<RegistrationInf | ||
| 56 | @Override | 61 | @Override |
| 57 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { | 62 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
| 58 | super.onViewCreated(view, savedInstanceState); | 63 | super.onViewCreated(view, savedInstanceState); |
| 64 | + if (null != getArguments()) { | ||
| 65 | + fenceId = getArguments().getString("fenceId"); | ||
| 66 | + } | ||
| 59 | if (getMvpView() != null) getMvpView().initView(); | 67 | if (getMvpView() != null) getMvpView().initView(); |
| 60 | } | 68 | } |
| 61 | 69 | ||
| 62 | public void commitInfo() { | 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,7 +166,7 @@ public class RegistrationInfoFragment extends MvpBindingFragment<RegistrationInf | ||
| 156 | if (0 == state || 3005 == state) { | 166 | if (0 == state || 3005 == state) { |
| 157 | //将设备添加到围栏中 | 167 | //将设备添加到围栏中 |
| 158 | mClient.addFenceMonitoredPerson(addMonitoredPersonRequest, onFenceListener); | 168 | mClient.addFenceMonitoredPerson(addMonitoredPersonRequest, onFenceListener); |
| 159 | - }else { | 169 | + } else { |
| 160 | AlertUtil.showDeftToast(getContext(), msg); | 170 | AlertUtil.showDeftToast(getContext(), msg); |
| 161 | } | 171 | } |
| 162 | } | 172 | } |