Exemple #1
0
 @Override
 protected boolean onTap(int index) {
   OverlayItem item = mOverlays.get(index);
   AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
   dialog.setTitle(item.getTitle());
   final String snippet = item.getSnippet();
   if (snippet.toString().length() > 0) {
     dialog.setMessage(snippet);
     dialog.setPositiveButton(
         "More Info",
         new OnClickListener() {
           @Override
           public void onClick(DialogInterface arg0, int arg1) {
             String[] snippetArray = snippet.replace(" ", "+").split("\n");
             Uri uri =
                 Uri.parse(
                     "https://www.google.com/search?q=" + snippetArray[0] + "+" + snippetArray[1]);
             Intent intent = new Intent(Intent.ACTION_VIEW, uri);
             mContext.startActivity(intent);
           }
         });
   }
   dialog.show();
   return true;
 }
  @Override
  public boolean onTap(int index) {
    OverlayItem item = overlayItemList.get(index);
    Log.d("CBOverlay", item.getTitle() + ": " + item.getSnippet());
    AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
    dialog.setTitle(item.getTitle());
    dialog.setMessage(item.getSnippet());

    dialog.setPositiveButton(
        "Apply!",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
            // Apply to CB Job
            try {
              String response = CurrentUser.sendApplication();
              Toast.makeText(mContext, "Posted Job Successfully!", Toast.LENGTH_SHORT).show();
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        });
    dialog.setNegativeButton(
        "Cancel",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            // Disregard
            dialog.dismiss();
          }
        });

    dialog.show();
    return true;
  }
Exemple #3
0
	@Override
	protected boolean onTap(int i) {
		OverlayItem overlayItem = imagens.get(i);
		String texto = overlayItem.getTitle() + " - " + overlayItem.getSnippet();
		Toast.makeText(context, texto,Toast.LENGTH_SHORT).show();
		return(true);
	}
  private void setZoomLevel() {
    Object[] keys = map.keySet().toArray();
    OverlayItem item;
    if (keys.length > 1) {
      int minLatitude = Integer.MAX_VALUE;
      int maxLatitude = Integer.MIN_VALUE;
      int minLongitude = Integer.MAX_VALUE;
      int maxLongitude = Integer.MIN_VALUE;

      for (Object key : keys) {
        item = map.get((String) key);
        GeoPoint p = item.getPoint();
        int lati = p.getLatitudeE6();
        int lon = p.getLongitudeE6();

        maxLatitude = Math.max(lati, maxLatitude);
        minLatitude = Math.min(lati, minLatitude);
        maxLongitude = Math.max(lon, maxLongitude);
        minLongitude = Math.min(lon, minLongitude);
      }
      mapController.zoomToSpan(
          Math.abs(maxLatitude - minLatitude), Math.abs(maxLongitude - minLongitude));
      mapController.animateTo(
          new GeoPoint((maxLatitude + minLatitude) / 2, (maxLongitude + minLongitude) / 2));

    } else {
      String key = (String) keys[0];
      item = map.get(key);
      mapController.animateTo(item.getPoint());
      while (mapController.zoomIn()) {}

      mapController.zoomOut();
    }
  }
Exemple #5
0
  @Override
  protected boolean onTap(int index) {
    final OverlayItem overlayItem = overlays.get(index);
    String name = overlayItem.getTitle();

    String currentTarget = map.getPointsProvider().getStatus(DataProvider.CURRENT_TARGET);
    final Clue clue = map.getPointsProvider().getClue(name);
    Log.d(LOG_TAG, "Tapped on clue: " + clue);
    Clue currentTargetClue = null;
    if (currentTarget != null) {
      currentTargetClue = map.getPointsProvider().getClue(currentTarget);
    }

    if (clue.getFound() != null) {
      //		  handleResetFoundMenu();
      return true;
    }
    if (clue.getName().equals(currentTarget)) {
      // handleWisselNaarEindpuntMenu
      return true;
    }

    handleGaNaarMenu(clue, currentTargetClue);

    Log.d(LOG_TAG, clue.toString());

    return true;
  }
    @Override
    protected boolean onTap(int index) {

      final OverlayItem item = mOverlays.get(index);
      AlertDialog.Builder dialog = new AlertDialog.Builder(MapsScience.this);
      dialog.setTitle(item.getTitle());
      dialog.setMessage(item.getSnippet());

      dialog.setNegativeButton(
          "Navigate",
          new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int id) {
              startActivity(
                  new Intent(
                      Intent.ACTION_VIEW, Uri.parse("google.navigation:q=" + item.getSnippet())));
            }
          });

      dialog.setPositiveButton(
          "Ok",
          new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int id) {
              dialog.cancel();
            }
          });
      dialog.show();

      return true;
    }
 @Override
 protected boolean onTap(int i) {
   OverlayItem item = items.get(i);
   String text = item.getTitle() + " - " + item.getSnippet();
   Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
   return true;
 }
Exemple #8
0
  @Override
  protected boolean onTap(int index) {
    item = mOverlays.get(index);
    AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
    dialog.setTitle(item.getTitle());
    dialog.setMessage(item.getSnippet());
    dialog.setPositiveButton(
        "Details",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {
            Intent intent = new Intent(mContext, TabBar.class);
            Bundle b = new Bundle();
            b.putString("assetname", asset.name);
            b.putString("modelname", asset.model);

            intent.putExtras(b);
            mContext.startActivity(intent);
          }
        });
    dialog.setNegativeButton(
        "Cancel",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int id) {}
        });
    dialog.show();

    return true;
  }
    @Override
    protected boolean onTap(int i) {

      OverlayItem item = getItem(i);
      GeoPoint geo = item.getPoint();

      JSONObject place = places.get(i);
      if (selectedPlace == place) {
        // user tapped on the same pin again, this will remove the baloon
        map.removeView(noteBaloon);
        selectedPlace = null;
        return true;
      }
      selectedPlace = place;

      map.removeView(noteBaloon);
      map.getController().animateTo(geo);

      try {
        ((TextView) noteBaloon.findViewById(R.id.placeName)).setText(place.getString("name"));
      } catch (JSONException e) {
        e.printStackTrace();
      }
      try {
        ((TextView) noteBaloon.findViewById(R.id.placeAddress)).setText(place.getString("address"));
      } catch (JSONException e) {
        e.printStackTrace();
      }
      map.addView(
          noteBaloon,
          new MapView.LayoutParams(
              MapView.LayoutParams.WRAP_CONTENT, 70, geo, MapView.LayoutParams.BOTTOM_CENTER));

      return (true);
    }
Exemple #10
0
  /**
   * Called when the user clicks on one of the icons in the map. It uses a Toast to say hello.
   *
   * @param pIndex is the Find's index in the ArrayList
   */
  @Override
  protected boolean onTap(int pIndex) {
    Dialog dialog = new Dialog(mContext);
    dialog.setCanceledOnTouchOutside(true);

    OverlayItem item = mOverlays.get(pIndex);
    dialog.setContentView(R.layout.custom_dialog);
    dialog.setTitle(item.getTitle());

    TextView text = (TextView) dialog.findViewById(R.id.text);
    text.setText(item.getSnippet());
    ImageView image = (ImageView) dialog.findViewById(R.id.image);

    image.setImageResource(R.drawable.small_letter);
    dialog.show();

    // Get contact
    StringTokenizer st = new StringTokenizer(item.getTitle(), "  ,      ");
    String temp = st.nextToken();
    final String contact = st.nextToken();

    final Button button = (Button) dialog.findViewById(R.id.more_info_button);
    button.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent myIntent = new Intent();
            myIntent.setClassName("edu.stanford.jdiprete", "edu.stanford.jdiprete.DialogOnclick");
            myIntent.putExtra("contact", contact);
            myIntent.putExtra("captureId", captureId);
            mContext.startActivity(myIntent);
          }
        });
    return true;
  }
Exemple #11
0
 protected boolean OnTap(int index) {
   OverlayItem item = mapOverlays.get(index);
   AlertDialog.Builder dialog = new AlertDialog.Builder(context);
   dialog.setTitle(item.getTitle());
   dialog.setMessage(item.getSnippet());
   dialog.show();
   return true;
 }
  @Override
  protected boolean onTap(int index) {
    OverlayItem item = mOverlays.get(index);
    String station = item.getTitle();
    String city = item.getSnippet();

    prompt_confirm(station, city, mSetResult);
    return true;
  }
  /**
   * Add an item overlay
   *
   * @param overlay
   */
  public void addOverlay(OverlayItem overlay) {
    Drawable d = overlay.getMarker(0);

    if (d != null) {
      overlay.setMarker(boundCenterBottom(d));
    }

    mOverlays.add(overlay);
    populate(); // Called to prepare each item to be drawn
  }
Exemple #14
0
    @Override
    protected boolean onTap(int i) {
      if (item.getSnippet() == null) {
        // Show toast message with current location string
        Toast.makeText(LocationMap.this, item.getTitle(), Toast.LENGTH_SHORT).show();
      } else {
        // Show dialog with options on tap
        AlertDialog.Builder builder = new AlertDialog.Builder(LocationMap.this);
        tapCode = item.getSnippet();
        tapName = item.getTitle();
        builder
            .setTitle(getString(R.string.station))
            .setMessage(tapName + " (" + tapCode + ")")
            .setPositiveButton(
                getString(R.string.query),
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    // USSD query
                    BusPlus bp = (BusPlus) getApplicationContext();
                    bp.callUSSDCode(tapCode);
                    dialog.dismiss();
                  }
                })
            .setNeutralButton(
                getString(R.string.favorites),
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    String suffix = "";
                    if (!lineSummary.equals(""))
                      suffix = " (" + lineSummary.replaceAll("\\s+/.*?/", "") + ")";

                    // Add favorite and toast a message
                    helper.insertFavorite(Integer.parseInt(tapCode), tapName + suffix);
                    BusPlus bp = (BusPlus) getApplicationContext();
                    bp.showToastMessage(getString(R.string.favorite_added_to_list));
                  }
                })
            .setNegativeButton(
                getString(R.string.shortcut),
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    String suffix = "";
                    if (!lineSummary.equals(""))
                      suffix = " (" + lineSummary.replaceAll("\\s+/.*?/", "") + ")";

                    // Add shortcut
                    BusPlus bp = (BusPlus) getApplicationContext();
                    bp.setupShortcut(tapCode, tapName + suffix);
                  }
                });
        AlertDialog alert = builder.create();
        alert.show();
      }
      return (true);
    }
 @Override
 protected boolean onTap(int index) {
   // TODO Auto-generated method stub
   OverlayItem item = overlayItems.get(index);
   AlertDialog.Builder builder = new AlertDialog.Builder(context);
   builder.setTitle(item.getTitle());
   builder.setMessage(item.getSnippet());
   Dialog dialog = builder.create();
   dialog.show();
   return true;
 }
 public void paintTasks() {
   allOverlays = mapView.getOverlays();
   allOverlays.remove(tasksPositionOverlay);
   tasksPositionOverlay = new TasksOverlay(doneMarker, this);
   tasksCursor = global_app.getDataStorage().getAllTasks();
   DecimalFormat km = new DecimalFormat();
   km.setMaximumFractionDigits(2);
   DecimalFormat m = new DecimalFormat();
   m.setMaximumFractionDigits(1);
   while (tasksCursor.moveToNext()) {
     double lat = tasksCursor.getDouble(tasksCursor.getColumnIndex(DataStorage.C_LAT));
     double lon = tasksCursor.getDouble(tasksCursor.getColumnIndex(DataStorage.C_LON));
     String taskTitle = (tasksCursor.getString(tasksCursor.getColumnIndex(DataStorage.C_NAME)));
     int taskState = (tasksCursor.getInt(tasksCursor.getColumnIndex(DataStorage.C_STATE)));
     int taskId = (tasksCursor.getInt(tasksCursor.getColumnIndex(DataStorage.C_ID)));
     GeoPoint taskLocation = new GeoPoint((int) (lat * 1E6), (int) (lon * 1E6));
     Location tmp = new Location(provider);
     tmp.setLatitude(lat);
     tmp.setLongitude(lon);
     double distance = lastLocation.distanceTo(tmp);
     String prettyDistance;
     if (distance > 1000) prettyDistance = km.format(distance / 1000) + "km";
     else prettyDistance = m.format(distance) + "m";
     OverlayItem taskOverlayItem =
         new OverlayItem(
             taskLocation,
             taskTitle + " (id: " + Integer.toString(taskId) + ")",
             "oddalone o: " + prettyDistance);
     Drawable marker;
     switch (taskState) {
       case 0:
         marker = cancelMarker;
         break;
       case 1:
         marker = pendingMarker;
         break;
       case 2:
         marker = currentMarker;
         break;
       default:
         marker = doneMarker;
         break;
     }
     int w = marker.getIntrinsicWidth();
     int h = marker.getIntrinsicHeight();
     marker.setBounds(-w / 2, -h, w / 2, 0);
     taskOverlayItem.setMarker(marker);
     tasksPositionOverlay.addOverlay(taskOverlayItem);
   }
   allOverlays.add(tasksPositionOverlay);
   mapView.invalidate();
   tasksCursor.close();
 }
  @Override
  protected boolean onBalloonTap(int index, OverlayItem item) {
    Toast.makeText(c, "Retrieving profile for " + item.getTitle(), Toast.LENGTH_LONG).show();
    Intent other = new Intent(c, OtherProfileActivity.class);
    UserProfile userProf = fetchProfile(item.getTitle());
    SnotgAndroidConstants.STATE_CHAT_OTHER_USERID =
        userProf.getUserId(); // State for chat recipient

    Bundle b = new Bundle();
    b.putSerializable("profile", userProf);
    other.putExtras(b);
    c.startActivity(other);

    return true;
  }
  public void noteClicked(OverlayItem item, int index) {
    suppressNextTap();

    mapView.getController().animateTo(item.getPoint());

    noteClicked(index);
  }
Exemple #19
0
    @Override
    protected boolean onTap(int i) {
      OverlayItem item = getItem(i);
      GeoPoint geo = item.getPoint();
      Point pt = map.getProjection().toPixels(geo, null);

      View view = panel.getView();

      ((TextView) view.findViewById(R.id.latitude))
          .setText(String.valueOf(geo.getLatitudeE6() / 1000000.0));
      ((TextView) view.findViewById(R.id.longitude))
          .setText(String.valueOf(geo.getLongitudeE6() / 1000000.0));
      ((TextView) view.findViewById(R.id.x)).setText(String.valueOf(pt.x));
      ((TextView) view.findViewById(R.id.y)).setText(String.valueOf(pt.y));

      panel.show(pt.y * 2 > map.getHeight());

      return (true);
    }
  @Override
  protected boolean onTap(int index) {

    if (myContext != null) {

      // obtain zipcode and locationid of tapped item
      OverlayItem item = overlayList.get(index);
      String zipcode = item.getTitle();
      String locationid = item.getSnippet();

      // start Demographic activity, passing in zipcode
      SearchMapActivity mapActivity = (SearchMapActivity) myContext;
      Intent intent = new Intent(mapActivity, DemographicActivity.class);
      intent.putExtra("zipcode", zipcode);
      intent.putExtra("locationid", locationid);
      mapActivity.startActivity(intent);
    }
    return true;
  }
 @Override
 protected boolean onTap(int index) {
   OverlayItem item = overlays.get(index);
   AlertDialog.Builder dialog = new AlertDialog.Builder(context);
   dialog.setTitle(item.getTitle());
   dialog.setMessage(item.getSnippet());
   if ((item instanceof StopOverlayItem) && (context instanceof MapChooserActivity)) {
     final Stop stop = ((StopOverlayItem) item).getStop();
     if (stop.getNumber() != null) {
       dialog.setPositiveButton(
           context.getString(R.string.open),
           new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int id) {
               dialog.dismiss();
               FetchRoutesTask task = new FetchRoutesTask(context, db);
               ((MapChooserActivity) context).setFetchRoutesTask(task);
               task.execute(stop.getNumber());
             }
           });
     }
     dialog.setNegativeButton(
         context.getString(R.string.cancel),
         new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int id) {
             dialog.cancel();
           }
         });
   } else {
     dialog.setNegativeButton(
         context.getString(R.string.ok),
         new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int id) {
             dialog.cancel();
           }
         });
   }
   dialog.show();
   return true;
 }
  @Override
  public void draw(android.graphics.Canvas canvas, MapView mapView, boolean shadow) {
    super.draw(canvas, mapView, shadow);

    // go through all OverlayItems and draw title for each of them
    for (OverlayItem item : mOverlays) {
      /* Converts latitude & longitude of this overlay item to coordinates on screen.
       * As we have called boundCenterBottom() in constructor, so these coordinates
       * will be of the bottom center position of the displayed marker.
       */
      GeoPoint point = item.getPoint();
      Point markerBottomCenterCoords = new Point();
      mapView.getProjection().toPixels(point, markerBottomCenterCoords);

      /* Find the width and height of the title*/
      TextPaint paintText = new TextPaint();
      Paint paintRect = new Paint();

      Rect rect = new Rect();
      paintText.setTextSize(FONT_SIZE);
      paintText.getTextBounds(item.getTitle(), 0, item.getTitle().length(), rect);

      rect.inset(-TITLE_MARGIN, -TITLE_MARGIN);
      rect.offsetTo(
          markerBottomCenterCoords.x - rect.width() / 2,
          markerBottomCenterCoords.y - markerHeight - rect.height());

      paintText.setTextAlign(Paint.Align.CENTER);
      paintText.setTextSize(FONT_SIZE);
      paintText.setARGB(255, 255, 255, 255);
      paintRect.setARGB(130, 0, 0, 0);

      canvas.drawRoundRect(new RectF(rect), 2, 2, paintRect);
      canvas.drawText(
          item.getTitle(), rect.left + rect.width() / 2, rect.bottom - TITLE_MARGIN, paintText);
    }
  }
 /**
  * Constructor for the fountain overlay
  *
  * @param f Fountain information associated with overlay
  * @param marker Drawable to be rendered
  */
 public FountainOverlayItem(Fountain f, Drawable marker) {
   // Overlay position is the fountain's coordinates
   super(f.getCoordinates(), "", "");
   super.setMarker(marker);
   this.fountain = f;
 }
Exemple #24
0
  @Override
  public void draw(android.graphics.Canvas canvas, MapView mapView, boolean shadow) {
    super.draw(canvas, mapView, shadow);

    Paint mPaint = new Paint();
    mPaint.setDither(true);
    mPaint.setColor(Color.RED);
    mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStrokeWidth(2);

    List<Clue> clues = huntedService.getDataProvider().getTrackLog();

    Clue prevClue = null;
    for (Clue clue : clues) {
      if (prevClue != null) {
        GeoPoint prevCluePoint = Map.getPointForClue(prevClue);
        GeoPoint currentCluePoint = Map.getPointForClue(clue);
        Point fromPoint = new Point();
        mapView.getProjection().toPixels(prevCluePoint, fromPoint);
        Point toPoint = new Point();
        mapView.getProjection().toPixels(currentCluePoint, toPoint);
        canvas.drawLine(fromPoint.x, fromPoint.y, toPoint.x, toPoint.y, mPaint);
      }

      prevClue = clue;
    }

    // go through all OverlayItems and draw title for each of them
    List<OverlayItem> overlaysCopy = new ArrayList<OverlayItem>(overlays);
    for (OverlayItem item : overlaysCopy) {
      /* Converts latitude & longitude of this overlay item to coordinates on screen.
       * As we have called boundCenterBottom() in constructor, so these coordinates
       * will be of the bottom center position of the displayed marker.
       */
      GeoPoint point = item.getPoint();
      Point markerBottomCenterCoords = new Point();
      mapView.getProjection().toPixels(point, markerBottomCenterCoords);

      /* Find the width and height of the title*/
      TextPaint paintText = new TextPaint();
      Paint paintRect = new Paint();

      Rect rect = new Rect();
      paintText.setTextSize(FONT_SIZE);
      paintText.getTextBounds(item.getTitle(), 0, item.getTitle().length(), rect);

      rect.inset(-TITLE_MARGIN, -TITLE_MARGIN);
      rect.offsetTo(
          markerBottomCenterCoords.x - rect.width() / 2,
          markerBottomCenterCoords.y - 15 - rect.height());

      paintText.setTextAlign(Paint.Align.CENTER);
      paintText.setTextSize(FONT_SIZE);
      paintText.setARGB(255, 255, 255, 255);
      paintRect.setARGB(130, 0, 0, 0);

      canvas.drawRoundRect(new RectF(rect), 2, 2, paintRect);
      canvas.drawText(
          item.getTitle(), rect.left + rect.width() / 2, rect.bottom - TITLE_MARGIN, paintText);
    }
  }
Exemple #25
0
 @Override
 protected boolean onTap(int i) {
   Toast.makeText(RestaurantMap.this, item.getSnippet(), Toast.LENGTH_SHORT).show();
   return (true);
 }