Search in sources :

Example 1 with FeedDiscoverer

use of de.danoeh.antennapod.core.util.syndication.FeedDiscoverer in project AntennaPod by AntennaPod.

the class OnlineFeedViewActivity method showFeedDiscoveryDialog.

private void showFeedDiscoveryDialog(File feedFile, String baseUrl) {
    FeedDiscoverer fd = new FeedDiscoverer();
    final Map<String, String> urlsMap;
    try {
        urlsMap = fd.findLinks(feedFile, baseUrl);
        if (urlsMap == null || urlsMap.isEmpty()) {
            return;
        }
    } catch (IOException e) {
        e.printStackTrace();
        return;
    }
    if (isPaused || isFinishing()) {
        return;
    }
    final List<String> titles = new ArrayList<>();
    final List<String> urls = new ArrayList<>();
    urls.addAll(urlsMap.keySet());
    for (String url : urls) {
        titles.add(urlsMap.get(url));
    }
    final ArrayAdapter<String> adapter = new ArrayAdapter<>(OnlineFeedViewActivity.this, R.layout.ellipsize_start_listitem, R.id.txtvTitle, titles);
    DialogInterface.OnClickListener onClickListener = (dialog, which) -> {
        String selectedUrl = urls.get(which);
        dialog.dismiss();
        resetIntent(selectedUrl, titles.get(which));
        FeedPreferences prefs = feed.getPreferences();
        if (prefs != null) {
            startFeedDownload(selectedUrl, prefs.getUsername(), prefs.getPassword());
        } else {
            startFeedDownload(selectedUrl, null, null);
        }
    };
    AlertDialog.Builder ab = new AlertDialog.Builder(OnlineFeedViewActivity.this).setTitle(R.string.feeds_label).setCancelable(true).setOnCancelListener(dialog -> finish()).setAdapter(adapter, onClickListener);
    runOnUiThread(() -> {
        if (dialog != null && dialog.isShowing()) {
            dialog.dismiss();
        }
        dialog = ab.show();
    });
}
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) FeedPreferences(de.danoeh.antennapod.core.feed.FeedPreferences) AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) FeedDiscoverer(de.danoeh.antennapod.core.util.syndication.FeedDiscoverer) IOException(java.io.IOException) ArrayAdapter(android.widget.ArrayAdapter)

Example 2 with FeedDiscoverer

use of de.danoeh.antennapod.core.util.syndication.FeedDiscoverer in project AntennaPod by AntennaPod.

the class FeedDiscovererTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    fd = new FeedDiscoverer();
    testDir = getInstrumentation().getTargetContext().getExternalFilesDir("FeedDiscovererTest");
    testDir.mkdir();
    assertTrue(testDir.exists());
}
Also used : FeedDiscoverer(de.danoeh.antennapod.core.util.syndication.FeedDiscoverer)

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