@Override protected void onDisplay(Bundle savedInstanceState, PluginController controller) { mController = (MapMainController) controller; mModel = (MapModel) controller.getModel(); mLayout = new StandardLayout(this); mLayout.setText(getString(R.string.map_searching)); setContentView(mLayout); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); mLayout.addView(inflater.inflate(R.layout.map_search_result, null)); setActionBarTitle(getString(R.string.map_plugin_title)); }
/** * Parses the result from JSON and then displays the list of results * * @param results A list containing the results title * @param results2 Beans of the items */ private void parseAndDisplayResult(ArrayAdapter<String> results, final List<MapItem> results2) { if (results != null && results.getCount() == 1 && results2 != null && results2.size() > 0) { startMapActivity(results2.get(0)); finish(); } ListView lv = getListView(); lv.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (results2 != null && results2.size() > 0) { try { MapItem meb = results2.get(position); startMapActivity(meb); } catch (Exception e) { } } } }); mLayout.hideText(); setListAdapter(results); }
@Override public void searchResultsUpdated() { List<MapItem> results = mModel.getSearchResults(); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.map_list); if (results.size() > 0) { for (MapItem meb : results) { adapter.add(meb.getTitle()); } parseAndDisplayResult(adapter, results); } else { mLayout.setText(getString(R.string.map_search_no_results)); } }