diff options
Diffstat (limited to 'main/src/cgeo/geocaching/export/ExportFactory.java')
| -rw-r--r-- | main/src/cgeo/geocaching/export/ExportFactory.java | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/main/src/cgeo/geocaching/export/ExportFactory.java b/main/src/cgeo/geocaching/export/ExportFactory.java deleted file mode 100644 index e743eb2..0000000 --- a/main/src/cgeo/geocaching/export/ExportFactory.java +++ /dev/null @@ -1,67 +0,0 @@ -package cgeo.geocaching.export; - -import cgeo.geocaching.Geocache; -import cgeo.geocaching.R; -import cgeo.geocaching.utils.Log; - -import android.app.Activity; -import android.app.AlertDialog; -import android.content.DialogInterface; -import android.widget.ArrayAdapter; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Factory to create a dialog with all available exporters. - */ -public abstract class ExportFactory { - - /** - * Contains instances of all available exporter classes. - */ - private static final List<Class<? extends Export>> exporterClasses; - - static { - final ArrayList<Class<? extends Export>> temp = new ArrayList<Class<? extends Export>>(); - temp.add(FieldnoteExport.class); - temp.add(GpxExport.class); - exporterClasses = Collections.unmodifiableList(temp); - } - - /** - * Creates a dialog so that the user can select an exporter. - * - * @param caches - * The {@link List} of {@link cgeo.geocaching.Geocache} to be exported - * @param activity - * The {@link Activity} in whose context the dialog should be shown - */ - public static void showExportMenu(final List<Geocache> caches, final Activity activity) { - final AlertDialog.Builder builder = new AlertDialog.Builder(activity); - builder.setTitle(R.string.export).setIcon(R.drawable.ic_menu_share); - - final ArrayList<Export> export = new ArrayList<Export>(); - for (Class<? extends Export> exporterClass : exporterClasses) { - try { - export.add(exporterClass.newInstance()); - } catch (Exception ex) { - Log.e("showExportMenu", ex); - } - } - - final ArrayAdapter<Export> adapter = new ArrayAdapter<Export>(activity, android.R.layout.select_dialog_item, export); - - builder.setAdapter(adapter, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int item) { - dialog.dismiss(); - final Export selectedExport = adapter.getItem(item); - selectedExport.export(caches, activity); - } - }); - - builder.create().show(); - } -}
\ No newline at end of file |
