Search in sources :

Example 1 with UnsupportedFeedtypeException

use of de.danoeh.antennapod.core.syndication.handler.UnsupportedFeedtypeException in project AntennaPod by AntennaPod.

the class OnlineFeedViewActivity method parseFeed.

private void parseFeed() {
    if (feed == null || feed.getFile_url() == null && feed.isDownloaded()) {
        throw new IllegalStateException("feed must be non-null and downloaded when parseFeed is called");
    }
    Log.d(TAG, "Parsing feed");
    parser = Observable.create(new Observable.OnSubscribe<FeedHandlerResult>() {

        @Override
        public void call(Subscriber<? super FeedHandlerResult> subscriber) {
            FeedHandler handler = new FeedHandler();
            try {
                FeedHandlerResult result = handler.parseFeed(feed);
                subscriber.onNext(result);
            } 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());
                } else {
                    subscriber.onError(e);
                }
            } catch (Exception e) {
                Log.e(TAG, Log.getStackTraceString(e));
                subscriber.onError(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 -> {
        beforeShowFeedInformation(result.feed);
        showFeedInformation(result.feed, result.alternateFeedUrls);
    }, error -> {
        String errorMsg = DownloadError.ERROR_PARSER_EXCEPTION.getErrorString(OnlineFeedViewActivity.this) + " (" + error.getMessage() + ")";
        showErrorDialog(errorMsg);
    });
}
Also used : LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) ProgressBar(android.widget.ProgressBar) DownloadRequestException(de.danoeh.antennapod.core.storage.DownloadRequestException) ImageView(android.widget.ImageView) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) StringUtils(org.apache.commons.lang3.StringUtils) DownloadRequestErrorDialogCreator(de.danoeh.antennapod.core.dialog.DownloadRequestErrorDialogCreator) NavUtils(android.support.v4.app.NavUtils) UserPreferences(de.danoeh.antennapod.core.preferences.UserPreferences) FeedItemlistDescriptionAdapter(de.danoeh.antennapod.adapter.FeedItemlistDescriptionAdapter) Looper(android.os.Looper) Map(java.util.Map) HtmlToPlainText(de.danoeh.antennapod.core.util.syndication.HtmlToPlainText) Schedulers(rx.schedulers.Schedulers) View(android.view.View) Button(android.widget.Button) AdapterView(android.widget.AdapterView) DownloadStatus(de.danoeh.antennapod.core.service.download.DownloadStatus) Log(android.util.Log) DownloadError(de.danoeh.antennapod.core.util.DownloadError) FileNameGenerator(de.danoeh.antennapod.core.util.FileNameGenerator) FeedDiscoverer(de.danoeh.antennapod.core.util.syndication.FeedDiscoverer) AppCompatActivity(android.support.v7.app.AppCompatActivity) FeedPreferences(de.danoeh.antennapod.core.feed.FeedPreferences) List(java.util.List) TextView(android.widget.TextView) DownloadEvent(de.danoeh.antennapod.core.event.DownloadEvent) Document(org.jsoup.nodes.Document) UnsupportedFeedtypeException(de.danoeh.antennapod.core.syndication.handler.UnsupportedFeedtypeException) RelativeLayout(android.widget.RelativeLayout) ListView(android.widget.ListView) Jsoup(org.jsoup.Jsoup) Subscription(rx.Subscription) FeedHandlerResult(de.danoeh.antennapod.core.syndication.handler.FeedHandlerResult) Context(android.content.Context) EventBus(de.greenrobot.event.EventBus) AuthenticationDialog(de.danoeh.antennapod.dialog.AuthenticationDialog) Dialog(android.app.Dialog) Intent(android.content.Intent) ApGlideSettings(de.danoeh.antennapod.core.glide.ApGlideSettings) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) Observable(rx.Observable) HttpDownloader(de.danoeh.antennapod.core.service.download.HttpDownloader) FeedHandler(de.danoeh.antennapod.core.syndication.handler.FeedHandler) DownloadRequest(de.danoeh.antennapod.core.service.download.DownloadRequest) Feed(de.danoeh.antennapod.core.feed.Feed) StorageUtils(de.danoeh.antennapod.core.util.StorageUtils) DialogInterface(android.content.DialogInterface) Downloader(de.danoeh.antennapod.core.service.download.Downloader) Subscriber(rx.Subscriber) LayoutInflater(android.view.LayoutInflater) R(de.danoeh.antennapod.R) TextUtils(android.text.TextUtils) IOException(java.io.IOException) EventDistributor(de.danoeh.antennapod.core.feed.EventDistributor) File(java.io.File) Spinner(android.widget.Spinner) FeedItem(de.danoeh.antennapod.core.feed.FeedItem) ArrayAdapter(android.widget.ArrayAdapter) AlertDialog(android.support.v7.app.AlertDialog) Glide(com.bumptech.glide.Glide) URLChecker(de.danoeh.antennapod.core.util.URLChecker) DBReader(de.danoeh.antennapod.core.storage.DBReader) DownloadRequester(de.danoeh.antennapod.core.storage.DownloadRequester) UnsupportedFeedtypeException(de.danoeh.antennapod.core.syndication.handler.UnsupportedFeedtypeException) FeedHandler(de.danoeh.antennapod.core.syndication.handler.FeedHandler) FeedHandlerResult(de.danoeh.antennapod.core.syndication.handler.FeedHandlerResult) File(java.io.File) Observable(rx.Observable) DownloadRequestException(de.danoeh.antennapod.core.storage.DownloadRequestException) UnsupportedFeedtypeException(de.danoeh.antennapod.core.syndication.handler.UnsupportedFeedtypeException) IOException(java.io.IOException)

Aggregations

Dialog (android.app.Dialog)1 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 Looper (android.os.Looper)1 NavUtils (android.support.v4.app.NavUtils)1 AlertDialog (android.support.v7.app.AlertDialog)1 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 TextUtils (android.text.TextUtils)1 Log (android.util.Log)1 LayoutInflater (android.view.LayoutInflater)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ArrayAdapter (android.widget.ArrayAdapter)1 Button (android.widget.Button)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 ListView (android.widget.ListView)1