use of de.danoeh.antennapod.core.export.ExportWriter in project AntennaPod by AntennaPod.
the class PreferenceController method export.
private boolean export(ExportWriter exportWriter) {
Context context = ui.getActivity();
final ProgressDialog progressDialog = new ProgressDialog(context);
progressDialog.setMessage(context.getString(R.string.exporting_label));
progressDialog.setIndeterminate(true);
progressDialog.show();
final AlertDialog.Builder alert = new AlertDialog.Builder(context).setNeutralButton(android.R.string.ok, (dialog, which) -> dialog.dismiss());
Observable<File> observable = new ExportWorker(exportWriter).exportObservable();
subscription = observable.subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe(output -> {
alert.setTitle(R.string.opml_export_success_title);
String message = context.getString(R.string.opml_export_success_sum) + output.toString();
alert.setMessage(message);
alert.setPositiveButton(R.string.send_label, (dialog, which) -> {
Uri outputUri = Uri.fromFile(output);
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getResources().getText(R.string.opml_export_label));
sendIntent.putExtra(Intent.EXTRA_STREAM, outputUri);
sendIntent.setType("text/plain");
context.startActivity(Intent.createChooser(sendIntent, context.getResources().getText(R.string.send_label)));
});
alert.create().show();
}, error -> {
alert.setTitle(R.string.export_error_label);
alert.setMessage(error.getMessage());
alert.show();
}, () -> progressDialog.dismiss());
return true;
}
use of de.danoeh.antennapod.core.export.ExportWriter in project AntennaPod by AntennaPod.
the class ImportExportPreferencesFragment method exportWithWriter.
private void exportWithWriter(ExportWriter exportWriter, final Uri uri) {
Context context = getActivity();
progressDialog.show();
if (uri == null) {
Observable<File> observable = new ExportWorker(exportWriter, getContext()).exportObservable();
disposable = observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(output -> {
Uri fileUri = FileProvider.getUriForFile(context.getApplicationContext(), context.getString(R.string.provider_authority), output);
showExportSuccessDialog(output.toString(), fileUri);
}, this::showExportErrorDialog, progressDialog::dismiss);
} else {
DocumentFileExportWorker worker = new DocumentFileExportWorker(exportWriter, context, uri);
disposable = worker.exportObservable().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(output -> showExportSuccessDialog(output.getUri().toString(), output.getUri()), this::showExportErrorDialog, progressDialog::dismiss);
}
}
Aggregations