diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2014-06-11 21:22:06 +0200 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2014-06-11 21:22:06 +0200 |
| commit | 210e8778ce82fb56e0fd683d04f69b6b7ee8a6ef (patch) | |
| tree | f3a1a25bd96d0b75387920f607463b5512c27b92 /main/src/cgeo/geocaching/export/ExportFactory.java | |
| parent | 6cba3b0a9ec95436bd10259975112a8b17755e11 (diff) | |
| download | cgeo-210e8778ce82fb56e0fd683d04f69b6b7ee8a6ef.zip cgeo-210e8778ce82fb56e0fd683d04f69b6b7ee8a6ef.tar.gz cgeo-210e8778ce82fb56e0fd683d04f69b6b7ee8a6ef.tar.bz2 | |
new: make import/export top level menu items
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 |
