mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-28 21:33:53 +01:00
Fix crash(es) caused by failing to dispose Rx observables (#2669)
This commit is contained in:
parent
38d39e08ac
commit
8474c04c64
21 changed files with 121 additions and 86 deletions
|
|
@ -61,7 +61,6 @@ import fr.free.nrw.commons.utils.ViewUtil;
|
|||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import timber.log.Timber;
|
||||
|
||||
|
|
@ -101,7 +100,6 @@ public class ContributionsFragment
|
|||
@BindView(R.id.card_view_nearby) public NearbyNotificationCardView nearbyNotificationCardView;
|
||||
@BindView(R.id.campaigns_view) CampaignView campaignView;
|
||||
|
||||
private Disposable placesDisposable;
|
||||
private LatLng curLatLng;
|
||||
|
||||
private boolean firstLocationUpdate = true;
|
||||
|
|
@ -592,7 +590,7 @@ public class ContributionsFragment
|
|||
private void updateClosestNearbyCardViewInfo() {
|
||||
curLatLng = locationManager.getLastLocation();
|
||||
|
||||
placesDisposable = Observable.fromCallable(() -> nearbyController
|
||||
compositeDisposable.add(Observable.fromCallable(() -> nearbyController
|
||||
.loadAttractionsFromLocation(curLatLng, curLatLng, true, false)) // thanks to boolean, it will only return closest result
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
|
@ -600,7 +598,7 @@ public class ContributionsFragment
|
|||
throwable -> {
|
||||
Timber.d(throwable);
|
||||
updateNearbyNotification(null);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
private void updateNearbyNotification(@Nullable NearbyController.NearbyPlacesInfo nearbyPlacesInfo) {
|
||||
|
|
@ -635,10 +633,6 @@ public class ContributionsFragment
|
|||
isUploadServiceConnected = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (placesDisposable != null) {
|
||||
placesDisposable.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -307,11 +307,11 @@ public class MainActivity extends AuthenticatedActivity implements FragmentManag
|
|||
|
||||
@SuppressLint("CheckResult")
|
||||
private void setNotificationCount() {
|
||||
Observable.fromCallable(() -> notificationController.getNotifications(false))
|
||||
compositeDisposable.add(Observable.fromCallable(() -> notificationController.getNotifications(false))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::initNotificationViews,
|
||||
throwable -> Timber.e(throwable, "Error occurred while loading notifications"));
|
||||
throwable -> Timber.e(throwable, "Error occurred while loading notifications")));
|
||||
}
|
||||
|
||||
private void initNotificationViews(List<Notification> notificationList) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue