Replace deprecated method

This commit is contained in:
Martin Fietz 2018-01-10 22:15:47 +01:00
parent 5bacbff10b
commit 74b2d439c3
1 changed files with 25 additions and 27 deletions

View File

@ -314,35 +314,33 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
}
Log.d(TAG, "Parsing feed");
parser = Observable.create(new Observable.OnSubscribe<FeedHandlerResult>() {
@Override
public void call(Subscriber<? super FeedHandlerResult> subscriber) {
parser = Observable.fromCallable(() -> {
FeedHandler handler = new FeedHandler();
try {
FeedHandlerResult result = handler.parseFeed(feed);
subscriber.onNext(result);
return handler.parseFeed(feed);
} catch (UnsupportedFeedtypeException e) {
Log.d(TAG, "Unsupported feed type detected");
if (TextUtils.equals("html", e.getRootElement().toLowerCase())) {
showFeedDiscoveryDialog(new File(feed.getFile_url()), feed.getDownload_url());
return null;
} else {
subscriber.onError(e);
throw e;
}
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
subscriber.onError(e);
throw e;
} finally {
boolean rc = new File(feed.getFile_url()).delete();
Log.d(TAG, "Deleted feed source file. Result: " + rc);
subscriber.onCompleted();
}
}
})
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(result -> {
if(result != null) {
beforeShowFeedInformation(result.feed);
showFeedInformation(result.feed, result.alternateFeedUrls);
}
}, error -> {
String errorMsg = DownloadError.ERROR_PARSER_EXCEPTION.getErrorString(
OnlineFeedViewActivity.this) + " (" + error.getMessage() + ")";