use of de.danoeh.antennapod.core.export.opml.OpmlReader in project AntennaPod by AntennaPod.
the class OpmlImportWorker method doInBackground.
@Override
protected ArrayList<OpmlElement> doInBackground(Void... params) {
Log.d(TAG, "Starting background work");
if (mReader == null) {
return null;
}
OpmlReader opmlReader = new OpmlReader();
try {
ArrayList<OpmlElement> result = opmlReader.readDocument(mReader);
mReader.close();
return result;
} catch (XmlPullParserException e) {
e.printStackTrace();
exception = e;
return null;
} catch (IOException e) {
e.printStackTrace();
exception = e;
return null;
}
}
use of de.danoeh.antennapod.core.export.opml.OpmlReader in project AntennaPod by AntennaPod.
the class OpmlImportActivity method startImport.
/**
* Starts the import process.
*/
private void startImport() {
viewBinding.progressBar.setVisibility(View.VISIBLE);
Observable.fromCallable(() -> {
InputStream opmlFileStream = getContentResolver().openInputStream(uri);
BOMInputStream bomInputStream = new BOMInputStream(opmlFileStream);
ByteOrderMark bom = bomInputStream.getBOM();
String charsetName = (bom == null) ? "UTF-8" : bom.getCharsetName();
Reader reader = new InputStreamReader(bomInputStream, charsetName);
OpmlReader opmlReader = new OpmlReader();
ArrayList<OpmlElement> result = opmlReader.readDocument(reader);
reader.close();
return result;
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(result -> {
viewBinding.progressBar.setVisibility(View.GONE);
Log.d(TAG, "Parsing was successful");
readElements = result;
listAdapter = new ArrayAdapter<>(OpmlImportActivity.this, android.R.layout.simple_list_item_multiple_choice, getTitleList());
viewBinding.feedlist.setAdapter(listAdapter);
}, e -> {
viewBinding.progressBar.setVisibility(View.GONE);
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle(R.string.error_label);
alert.setMessage(getString(R.string.opml_reader_error) + e.getMessage());
alert.setNeutralButton(android.R.string.ok, (dialog, which) -> dialog.dismiss());
alert.create().show();
});
}
Aggregations