Dispose of RxViews disposable in BaseStateFragment.
This commit is contained in:
parent
8bcf0c6498
commit
e98d3423e4
1 changed files with 12 additions and 1 deletions
|
@ -35,6 +35,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import icepick.State;
|
import icepick.State;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.Disposable;
|
||||||
|
|
||||||
import static org.schabi.newpipe.util.AnimationUtils.animateView;
|
import static org.schabi.newpipe.util.AnimationUtils.animateView;
|
||||||
|
|
||||||
|
@ -48,6 +49,8 @@ public abstract class BaseStateFragment<I> extends BaseFragment implements ViewC
|
||||||
@Nullable
|
@Nullable
|
||||||
private ProgressBar loadingProgressBar;
|
private ProgressBar loadingProgressBar;
|
||||||
|
|
||||||
|
private Disposable errorDisposable;
|
||||||
|
|
||||||
protected View errorPanelRoot;
|
protected View errorPanelRoot;
|
||||||
private Button errorButtonRetry;
|
private Button errorButtonRetry;
|
||||||
private TextView errorTextView;
|
private TextView errorTextView;
|
||||||
|
@ -64,6 +67,14 @@ public abstract class BaseStateFragment<I> extends BaseFragment implements ViewC
|
||||||
wasLoading.set(isLoading.get());
|
wasLoading.set(isLoading.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
if (errorDisposable != null) {
|
||||||
|
errorDisposable.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// Init
|
// Init
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
@ -83,7 +94,7 @@ public abstract class BaseStateFragment<I> extends BaseFragment implements ViewC
|
||||||
@Override
|
@Override
|
||||||
protected void initListeners() {
|
protected void initListeners() {
|
||||||
super.initListeners();
|
super.initListeners();
|
||||||
RxView.clicks(errorButtonRetry)
|
errorDisposable = RxView.clicks(errorButtonRetry)
|
||||||
.debounce(300, TimeUnit.MILLISECONDS)
|
.debounce(300, TimeUnit.MILLISECONDS)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(o -> onRetryButtonClicked());
|
.subscribe(o -> onRetryButtonClicked());
|
||||||
|
|
Loading…
Reference in a new issue