Merge pull request #2050 from mfietz/issue/2049-missing-onerror
OnlineFeedViewActivity: Add onError and refactor
This commit is contained in:
commit
88516d29ca
|
@ -119,9 +119,12 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
||||||
updater = Observable.fromCallable(() -> DBReader.getFeedList())
|
updater = Observable.fromCallable(() -> DBReader.getFeedList())
|
||||||
.subscribeOn(Schedulers.newThread())
|
.subscribeOn(Schedulers.newThread())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(feeds -> {
|
.subscribe(
|
||||||
|
feeds -> {
|
||||||
OnlineFeedViewActivity.this.feeds = feeds;
|
OnlineFeedViewActivity.this.feeds = feeds;
|
||||||
setSubscribeButtonState(feed);
|
setSubscribeButtonState(feed);
|
||||||
|
}, error -> {
|
||||||
|
Log.e(TAG, Log.getStackTraceString(error));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else if ((arg & EVENTS) != 0) {
|
} else if ((arg & EVENTS) != 0) {
|
||||||
|
@ -281,30 +284,33 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
||||||
})
|
})
|
||||||
.subscribeOn(Schedulers.newThread())
|
.subscribeOn(Schedulers.newThread())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(status -> {
|
.subscribe(status -> checkDownloadResult(status),
|
||||||
if (status != null) {
|
error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||||
if (!status.isCancelled()) {
|
}
|
||||||
if (status.isSuccessful()) {
|
|
||||||
parseFeed();
|
private void checkDownloadResult(DownloadStatus status) {
|
||||||
} else if (status.getReason() == DownloadError.ERROR_UNAUTHORIZED) {
|
if (status == null) {
|
||||||
if (!isFinishing() && !isPaused) {
|
Log.wtf(TAG, "DownloadStatus returned by Downloader was null");
|
||||||
dialog = new FeedViewAuthenticationDialog(OnlineFeedViewActivity.this,
|
finish();
|
||||||
R.string.authentication_notification_title, downloader.getDownloadRequest().getSource());
|
}
|
||||||
dialog.show();
|
if (status.isCancelled()) {
|
||||||
}
|
return;
|
||||||
} else {
|
}
|
||||||
String errorMsg = status.getReason().getErrorString(OnlineFeedViewActivity.this);
|
if (status.isSuccessful()) {
|
||||||
if (errorMsg != null && status.getReasonDetailed() != null) {
|
parseFeed();
|
||||||
errorMsg += " (" + status.getReasonDetailed() + ")";
|
} else if (status.getReason() == DownloadError.ERROR_UNAUTHORIZED) {
|
||||||
}
|
if (!isFinishing() && !isPaused) {
|
||||||
showErrorDialog(errorMsg);
|
dialog = new FeedViewAuthenticationDialog(OnlineFeedViewActivity.this,
|
||||||
}
|
R.string.authentication_notification_title, downloader.getDownloadRequest().getSource());
|
||||||
}
|
dialog.show();
|
||||||
} else {
|
}
|
||||||
Log.wtf(TAG, "DownloadStatus returned by Downloader was null");
|
} else {
|
||||||
finish();
|
String errorMsg = status.getReason().getErrorString(OnlineFeedViewActivity.this);
|
||||||
}
|
if (errorMsg != null && status.getReasonDetailed() != null) {
|
||||||
});
|
errorMsg += " (" + status.getReasonDetailed() + ")";
|
||||||
|
}
|
||||||
|
showErrorDialog(errorMsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseFeed() {
|
private void parseFeed() {
|
||||||
|
|
Loading…
Reference in New Issue