@@ -0,0 +1,2097 @@
+package org.azavea.otm.ui;%0A%0Aimport java.util.LinkedHashMap;%0Aimport java.util.Map;%0A%0Aimport org.azavea.otm.App;%0Aimport org.azavea.otm.R;%0Aimport org.azavea.otm.FilterManager;%0Aimport org.azavea.otm.adapters.SpeciesAdapter;%0Aimport org.azavea.otm.data.Species;%0Aimport org.json.JSONException;%0A%0Aimport android.app.ListActivity;%0Aimport android.content.Intent;%0Aimport android.os.Bundle;%0Aimport android.os.Handler.Callback;%0Aimport android.os.Message;%0Aimport android.util.Log;%0Aimport android.view.View;%0Aimport android.widget.ListView;%0Aimport android.widget.Toast;%0A%0Apublic class SpeciesListDisplay extends ListActivity %7B%0A%09public void onCreate(Bundle icicle) %7B%0A%09%09super.onCreate(icicle);%0A%09%09FilterManager search = App.getFilterManager();%0A%09%09%0A%09%09if (search.getSpecies().size() %3E 0) %7B%0A%09%09%09renderSpeciesList();%0A%09%09%7D else %7B%0A%09%09%09search.loadSpeciesList(new Callback() %7B%0A%0A%09%09%09%09@Override%0A%09%09%09%09public boolean handleMessage(Message msg) %7B%0A%09%09%09%09%09if (msg.getData().getBoolean(%22success%22)) %7B%0A%09%09%09%09%09%09renderSpeciesList();%0A%09%09%09%09%09%7D else %7B%0A%09%09%09%09%09%09Toast.makeText(App.getInstance(), %22Could not get species list%22, %0A%09%09%09%09%09%09%09%09Toast.LENGTH_SHORT).show();%0A%09%09%09%09%09%7D%0A%09%09%09%09%09return true;%0A%09%09%09%09%7D%0A%09%09%09%09%0A%09%09%09%7D);%0A%09%09%7D%0A%09%7D%0A%09%0A%09private void renderSpeciesList() %7B%0A%09%09LinkedHashMap%3CInteger, Species%3E list = App.getFilterManager().getSpecies();%0A%09%09Species%5B%5D species = new Species%5Blist.size()%5D;%0A%09%09int i = 0;%0A%09%09for (Map.Entry%3CInteger,Species%3E entry : list.entrySet()) %7B%0A%09%09%09species%5Bi%5D = entry.getValue();%0A%09%09%09i++;%0A%09%09%7D%0A%09%09SpeciesAdapter adapter = new SpeciesAdapter(this, R.layout.species_list_row, %0A%09%09%09%09species);%0A%09%09Log.d(App.LOG_TAG, list.size() + %22 species loaded%22);%0A%09%09setListAdapter(adapter);%0A%09%09%0A%09%7D%0A%09%0A%09@Override%0A%09protected void onListItemClick(ListView l, View v, int position, long id) %7B%0A%09%09Species selection = (Species)l.getItemAtPosition(position);%0A%09%09Intent result = new Intent();%0A%09%09// The underlying JSONObject of Species is not serializable, so just %0A%09%09// return the information to use for querying%0A%09%09try %7B%0A%09%09%09result.putExtra(%22species_id%22, selection.getId());%0A%09%09%7D catch (JSONException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%09%09setResult(RESULT_OK, result);%0A%09%09finish();%0A%09%7D%09    %0A  %7D%0A

Add list display for species selector