Exemplo n.º 1
0
 private StringBuilder buildPoiInformation(StringBuilder res, Amenity n) {
   String format =
       OsmAndFormatter.getPoiSimpleFormat(
           n, view.getContext(), view.getSettings().USE_ENGLISH_NAMES.get());
   res.append(" " + format);
   if (n.getOpeningHours() != null) {
     res.append("\n")
         .append(view.getContext().getString(R.string.opening_hours))
         .append(" : ")
         .append(n.getOpeningHours()); // $NON-NLS-1$ //$NON-NLS-2$
   }
   if (n.getPhone() != null) {
     res.append("\n")
         .append(view.getContext().getString(R.string.phone))
         .append(" : ")
         .append(n.getPhone()); // $NON-NLS-1$ //$NON-NLS-2$
   }
   if (n.getSite() != null && n.getType() != AmenityType.OSMWIKI) {
     res.append("\n")
         .append(view.getContext().getString(R.string.website))
         .append(" : ")
         .append(n.getSite()); // $NON-NLS-1$ //$NON-NLS-2$
   }
   return res;
 }
Exemplo n.º 2
0
  @Override
  public OnClickListener getActionListener(List<String> actionsList, Object o) {
    final Amenity a = (Amenity) o;
    int ind = 0;
    final int phoneIndex = a.getPhone() != null ? ind++ : -1;
    final int siteIndex = a.getSite() != null ? ind++ : -1;
    final int descriptionIndex = a.getDescription() != null ? ind++ : -1;
    if (a.getPhone() != null) {
      actionsList.add(this.view.getResources().getString(R.string.poi_context_menu_call));
    }
    if (a.getSite() != null) {
      actionsList.add(this.view.getResources().getString(R.string.poi_context_menu_website));
    }
    if (a.getDescription() != null) {
      actionsList.add(
          this.view.getResources().getString(R.string.poi_context_menu_showdescription));
    }
    final int modifyInd = ind++;
    actionsList.add(this.view.getResources().getString(R.string.poi_context_menu_modify));
    final int deleteInd = ind++;
    actionsList.add(this.view.getResources().getString(R.string.poi_context_menu_delete));

    final EditingPOIActivity edit = activity.getPoiActions();
    return new DialogInterface.OnClickListener() {

      @Override
      public void onClick(DialogInterface dialog, int which) {
        if (which == modifyInd) {
          edit.showEditDialog(a);
        } else if (which == deleteInd) {
          edit.showDeleteDialog(a);
        } else if (which == phoneIndex) {
          try {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse("tel:" + a.getPhone())); // $NON-NLS-1$
            view.getContext().startActivity(intent);
          } catch (RuntimeException e) {
            log.error("Failed to invoke call", e); // $NON-NLS-1$
            AccessibleToast.makeText(view.getContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
          }
        } else if (which == siteIndex) {
          try {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(a.getSite()));
            view.getContext().startActivity(intent);
          } catch (RuntimeException e) {
            log.error("Failed to invoke call", e); // $NON-NLS-1$
            AccessibleToast.makeText(view.getContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
          }
        } else if (which == descriptionIndex) {
          showDescriptionDialog(a);
        } else {
        }
      }
    };
  }