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();
});
}
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());
}
Aggregations