|
62 | 62 | import io.reactivex.Observable;
|
63 | 63 | import io.reactivex.android.schedulers.AndroidSchedulers;
|
64 | 64 | import io.reactivex.disposables.CompositeDisposable;
|
65 |
| -import io.reactivex.disposables.Disposable; |
66 | 65 | import io.reactivex.schedulers.Schedulers;
|
67 | 66 | import timber.log.Timber;
|
68 | 67 |
|
@@ -101,7 +100,6 @@ public class ContributionsFragment
|
101 | 100 | @BindView(R.id.card_view_nearby) public NearbyNotificationCardView nearbyNotificationCardView;
|
102 | 101 | @BindView(R.id.campaigns_view) CampaignView campaignView;
|
103 | 102 |
|
104 |
| - private Disposable placesDisposable; |
105 | 103 | private LatLng curLatLng;
|
106 | 104 |
|
107 | 105 | private boolean firstLocationUpdate = true;
|
@@ -603,15 +601,15 @@ private void displayYouWontSeeNearbyMessage() {
|
603 | 601 | private void updateClosestNearbyCardViewInfo() {
|
604 | 602 | curLatLng = locationManager.getLastLocation();
|
605 | 603 |
|
606 |
| - placesDisposable = Observable.fromCallable(() -> nearbyController |
| 604 | + compositeDisposable.add(Observable.fromCallable(() -> nearbyController |
607 | 605 | .loadAttractionsFromLocation(curLatLng, curLatLng, true, false)) // thanks to boolean, it will only return closest result
|
608 | 606 | .subscribeOn(Schedulers.io())
|
609 | 607 | .observeOn(AndroidSchedulers.mainThread())
|
610 | 608 | .subscribe(this::updateNearbyNotification,
|
611 | 609 | throwable -> {
|
612 | 610 | Timber.d(throwable);
|
613 | 611 | updateNearbyNotification(null);
|
614 |
| - }); |
| 612 | + })); |
615 | 613 | }
|
616 | 614 |
|
617 | 615 | private void updateNearbyNotification(@Nullable NearbyController.NearbyPlacesInfo nearbyPlacesInfo) {
|
@@ -648,10 +646,6 @@ public void onDestroy() {
|
648 | 646 | isUploadServiceConnected = false;
|
649 | 647 | }
|
650 | 648 | }
|
651 |
| - |
652 |
| - if (placesDisposable != null) { |
653 |
| - placesDisposable.dispose(); |
654 |
| - } |
655 | 649 | }
|
656 | 650 |
|
657 | 651 | @Override
|
|
0 commit comments