Search in sources :

Example 1 with ExportWorker

use of de.danoeh.antennapod.asynctask.ExportWorker 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;
}
Also used : Context(android.content.Context) AlertDialog(android.support.v7.app.AlertDialog) Arrays(java.util.Arrays) DateUtils(android.text.format.DateUtils) PackageManager(android.content.pm.PackageManager) Uri(android.net.Uri) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) FlattrUtils(de.danoeh.antennapod.core.util.flattr.FlattrUtils) PreferenceScreen(android.preference.PreferenceScreen) EditTextPreference(android.preference.EditTextPreference) UserPreferences(de.danoeh.antennapod.core.preferences.UserPreferences) Manifest(android.Manifest) ExportWorker(de.danoeh.antennapod.asynctask.ExportWorker) Schedulers(rx.schedulers.Schedulers) PreferenceManager(android.preference.PreferenceManager) GpodnetSyncService(de.danoeh.antennapod.core.service.GpodnetSyncService) Log(android.util.Log) WifiConfiguration(android.net.wifi.WifiConfiguration) GpodnetSetHostnameDialog(de.danoeh.antennapod.dialog.GpodnetSetHostnameDialog) GregorianCalendar(java.util.GregorianCalendar) ContextCompat(android.support.v4.content.ContextCompat) ActivityCompat(android.support.v4.app.ActivityCompat) DateFormat(android.text.format.DateFormat) ListPreference(android.preference.ListPreference) List(java.util.List) MainActivity(de.danoeh.antennapod.activity.MainActivity) HtmlWriter(de.danoeh.antennapod.core.export.html.HtmlWriter) ActivityNotFoundException(android.content.ActivityNotFoundException) Html(android.text.Html) AutoFlattrPreferenceDialog(de.danoeh.antennapod.dialog.AutoFlattrPreferenceDialog) ListView(android.widget.ListView) Snackbar(android.support.design.widget.Snackbar) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Subscription(rx.Subscription) TextWatcher(android.text.TextWatcher) Converter(de.danoeh.antennapod.core.util.Converter) Context(android.content.Context) TimePickerDialog(android.app.TimePickerDialog) AboutActivity(de.danoeh.antennapod.activity.AboutActivity) AuthenticationDialog(de.danoeh.antennapod.dialog.AuthenticationDialog) ExportWriter(de.danoeh.antennapod.core.export.ExportWriter) Intent(android.content.Intent) CheckBoxPreference(android.preference.CheckBoxPreference) ArrayUtils(org.apache.commons.lang3.ArrayUtils) Editable(android.text.Editable) ArrayList(java.util.ArrayList) Observable(rx.Observable) StatisticsActivity(de.danoeh.antennapod.activity.StatisticsActivity) SuppressLint(android.annotation.SuppressLint) OpmlWriter(de.danoeh.antennapod.core.export.opml.OpmlWriter) Calendar(java.util.Calendar) PreferenceActivity(de.danoeh.antennapod.activity.PreferenceActivity) Toast(android.widget.Toast) CrashReportWriter(de.danoeh.antennapod.CrashReportWriter) StorageUtils(de.danoeh.antennapod.core.util.StorageUtils) Build(android.os.Build) ProxyDialog(de.danoeh.antennapod.dialog.ProxyDialog) R(de.danoeh.antennapod.R) PreferenceActivityGingerbread(de.danoeh.antennapod.activity.PreferenceActivityGingerbread) VariableSpeedDialog(de.danoeh.antennapod.dialog.VariableSpeedDialog) ProgressDialog(android.app.ProgressDialog) File(java.io.File) DirectoryChooserActivity(de.danoeh.antennapod.activity.DirectoryChooserActivity) TimeUnit(java.util.concurrent.TimeUnit) WifiManager(android.net.wifi.WifiManager) AlertDialog(android.support.v7.app.AlertDialog) SharedPreferences(android.content.SharedPreferences) Preference(android.preference.Preference) GpodnetPreferences(de.danoeh.antennapod.core.preferences.GpodnetPreferences) Comparator(java.util.Comparator) Activity(android.app.Activity) Collections(java.util.Collections) EditText(android.widget.EditText) Resources(android.content.res.Resources) ExportWorker(de.danoeh.antennapod.asynctask.ExportWorker) Intent(android.content.Intent) ProgressDialog(android.app.ProgressDialog) File(java.io.File) Uri(android.net.Uri)

Aggregations

Manifest (android.Manifest)1 SuppressLint (android.annotation.SuppressLint)1 Activity (android.app.Activity)1 ProgressDialog (android.app.ProgressDialog)1 TimePickerDialog (android.app.TimePickerDialog)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 Context (android.content.Context)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 PackageManager (android.content.pm.PackageManager)1 Resources (android.content.res.Resources)1 Uri (android.net.Uri)1 WifiConfiguration (android.net.wifi.WifiConfiguration)1 WifiManager (android.net.wifi.WifiManager)1 Build (android.os.Build)1 CheckBoxPreference (android.preference.CheckBoxPreference)1 EditTextPreference (android.preference.EditTextPreference)1 ListPreference (android.preference.ListPreference)1 Preference (android.preference.Preference)1 PreferenceManager (android.preference.PreferenceManager)1