Exemplo n.º 1
0
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {

    if (!isSelectFavoriteMode()) {
      QuickAction qa = new QuickAction(v);
      FavouritePoint point = favouritesAdapter.getItem(position);
      String name = getString(R.string.favorite) + ": " + point.getName();
      LatLon location = new LatLon(point.getLatitude(), point.getLongitude());
      View.OnClickListener onshow =
          new View.OnClickListener() {

            @Override
            public void onClick(View v) {
              settings.SHOW_FAVORITES.set(true);
            }
          };
      MapActivityActions.createDirectionsActions(
          qa, location, point, name, settings.getLastKnownMapZoom(), this, true, onshow);
      qa.show();
    } else {
      Intent intent = getIntent();
      intent.putExtra(SELECT_FAVORITE_POINT_INTENT_KEY, favouritesAdapter.getItem(position));
      setResult(SELECT_FAVORITE_POINT_RESULT_OK, intent);
      finish();
    }
  }
Exemplo n.º 2
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View row = convertView;
      if (row == null) {
        LayoutInflater inflater = getLayoutInflater();
        row = inflater.inflate(R.layout.favourites_list_item, parent, false);
      }

      TextView label = (TextView) row.findViewById(R.id.favourite_label);
      TextView distanceLabel = (TextView) row.findViewById(R.id.favouritedistance_label);
      ImageView icon = (ImageView) row.findViewById(R.id.favourite_icon);
      final FavouritePoint model = getItem(position);
      if (model.isStored()) {
        icon.setImageResource(R.drawable.favorites);
      } else {
        icon.setImageResource(R.drawable.opened_poi);
      }
      if (location != null) {
        int dist =
            (int)
                (MapUtils.getDistance(
                    model.getLatitude(),
                    model.getLongitude(),
                    location.getLatitude(),
                    location.getLongitude()));
        distanceLabel.setText(
            OsmAndFormatter.getFormattedDistance(dist, FavouritesListActivity.this));
        distanceLabel.setVisibility(View.VISIBLE);
      } else {
        distanceLabel.setVisibility(View.GONE);
      }

      label.setText(getName(model));
      final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
      row.findViewById(R.id.favourite_icon).setVisibility(View.VISIBLE);
      ch.setVisibility(View.GONE);
      return row;
    }