Merge pull request #2050 from mfietz/issue/2049-missing-onerror

OnlineFeedViewActivity: Add onError and refactor
This commit is contained in:
Martin Fietz 2016-07-02 12:32:57 +02:00 committed by GitHub
commit 88516d29ca
1 changed files with 31 additions and 25 deletions

View File

@ -119,9 +119,12 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
updater = Observable.fromCallable(() -> DBReader.getFeedList())
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(feeds -> {
.subscribe(
feeds -> {
OnlineFeedViewActivity.this.feeds = feeds;
setSubscribeButtonState(feed);
}, error -> {
Log.e(TAG, Log.getStackTraceString(error));
}
);
} else if ((arg & EVENTS) != 0) {
@ -281,9 +284,18 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
})
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(status -> {
if (status != null) {
if (!status.isCancelled()) {
.subscribe(status -> checkDownloadResult(status),
error -> Log.e(TAG, Log.getStackTraceString(error)));
}
private void checkDownloadResult(DownloadStatus status) {
if (status == null) {
Log.wtf(TAG, "DownloadStatus returned by Downloader was null");
finish();
}
if (status.isCancelled()) {
return;
}
if (status.isSuccessful()) {
parseFeed();
} else if (status.getReason() == DownloadError.ERROR_UNAUTHORIZED) {
@ -300,12 +312,6 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
showErrorDialog(errorMsg);
}
}
} else {
Log.wtf(TAG, "DownloadStatus returned by Downloader was null");
finish();
}
});
}
private void parseFeed() {
if (feed == null || feed.getFile_url() == null && feed.isDownloaded()) {