@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ListView lv = new ListView(this);
    lv.setId(android.R.id.list);

    setContentView(lv);

    helper = SearchHistoryHelper.getInstance();

    clearButton = new Button(this);
    clearButton.setText(R.string.clear_all);
    clearButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            helper.removeAll(SearchHistoryActivity.this);
            setListAdapter(
                new HistoryAdapter(helper.getHistoryEntries(SearchHistoryActivity.this)));
          }
        });
    lv.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) {
            return SearchHistoryActivity.this.onItemLongClick(pos);
          }
        });
  }
  @Override
  protected void onResume() {
    super.onResume();
    Intent intent = getIntent();
    if (intent != null) {
      double lat = intent.getDoubleExtra(SEARCH_LAT, 0);
      double lon = intent.getDoubleExtra(SEARCH_LON, 0);
      if (lat != 0 || lon != 0) {
        location = new LatLon(lat, lon);
      }
    }
    if (location == null && getParent() instanceof SearchActivity) {
      location = ((SearchActivity) getParent()).getSearchPoint();
    }
    if (location == null) {
      location = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation();
    }

    List<HistoryEntry> historyEntries = helper.getHistoryEntries(this);

    getListView().removeFooterView(clearButton);
    if (!historyEntries.isEmpty()) {
      getListView().addFooterView(clearButton);
    }
    setListAdapter(new HistoryAdapter(historyEntries));
  }
 private void selectModel(HistoryEntry model) {
   helper.selectEntry(model, this);
   OsmandSettings settings = OsmandSettings.getOsmandSettings(SearchHistoryActivity.this);
   settings.setMapLocationToShow(
       model.getLat(), model.getLon(), settings.getLastKnownMapZoom(), null, model.getName());
   MapActivity.launchMapActivityMoveToTop(this);
 }