mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 05:43:55 +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
|
|
@ -30,6 +30,7 @@ import fr.free.nrw.commons.utils.NetworkUtils;
|
|||
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.schedulers.Schedulers;
|
||||
import timber.log.Timber;
|
||||
|
||||
|
|
@ -41,6 +42,7 @@ public class BookmarkPicturesFragment extends DaggerFragment {
|
|||
private static final int TIMEOUT_SECONDS = 15;
|
||||
|
||||
private GridViewAdapter gridAdapter;
|
||||
private CompositeDisposable compositeDisposable = new CompositeDisposable();
|
||||
|
||||
@BindView(R.id.statusMessage) TextView statusTextView;
|
||||
@BindView(R.id.loadingImagesProgressBar) ProgressBar progressBar;
|
||||
|
|
@ -82,6 +84,12 @@ public class BookmarkPicturesFragment extends DaggerFragment {
|
|||
controller.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
compositeDisposable.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
|
@ -113,11 +121,11 @@ public class BookmarkPicturesFragment extends DaggerFragment {
|
|||
progressBar.setVisibility(VISIBLE);
|
||||
statusTextView.setVisibility(GONE);
|
||||
|
||||
Observable.fromCallable(() -> controller.loadBookmarkedPictures())
|
||||
compositeDisposable.add(Observable.fromCallable(() -> controller.loadBookmarkedPictures())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.timeout(TIMEOUT_SECONDS, TimeUnit.SECONDS)
|
||||
.subscribe(this::handleSuccess, this::handleError);
|
||||
.subscribe(this::handleSuccess, this::handleError));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue