我使用具有对话框的可观察方法,并且我想在失败时发送重试消息。但是单击按钮后,它不会发送重试消息。我该怎么做?
getCompositeDisposable().add(repository.method().flatMap(resource -> {
getNavigator().showDialog(new Fragment.Listener() {
@Override
public void onPositiveButtonClicked() {
//observable method
}
@Override
public void onNegativeButtonClicked() {
getNavigator().finishActivity();
}
}).retryWhen(throwableFlowable -> {
AtomicInteger counter = new AtomicInteger();
return throwableFlowable.takeWhile(e -> {
return counter.getAndIncrement() != 4;
}).doOnNext(throwable -> getNavigator().showMessage("Again"));
})
}));