Ejemplo n.º 1
0
  /**
   * Adds a button from the ObjectButton data to the root container
   *
   * @param button ObjectButton to add
   * @param root ViewGroup where it will be added
   */
  private void addButton2(ObjectButton button, ViewGroup root) {
    Button actionButton =
        (Button) LayoutInflater.from(this).inflate(R.layout.button_action_detail, root, false);
    String text = JunaioPlugin.getResourceString(getApplicationContext(), button.getButtonName());
    if (text != null) actionButton.setText(text);
    else {
      actionButton.setText(button.getButtonName());
    }

    actionButton.setOnClickListener(actionClickListener2);
    // add the value (probably an URL) to the tag so it can be extracted on
    // the listener
    actionButton.setTag(button.getButtonValue());
    root.addView(actionButton, 0);
  }
Ejemplo n.º 2
0
  /** Set POI action buttons */
  private void loadPOIActions() {
    ViewGroup root = (ViewGroup) findViewById(R.id.actionButtonContainer);

    // get the popup objet and add the buttons to the container
    ObjectPopup popup = mPOI.getObjectPopup();
    ObjectButtonVector buttons = popup.getButtons();
    for (int i = 0, j = (int) buttons.size(); i < j; i++) {
      ObjectButton button = buttons.get(i);
      addButton2(button, root);
    }

    // if the routing is enabled, check if we have a navigation intent
    // handler and add a button for navigation
    if (mPOI.isRoutingEnabled()) {
      Intent intent =
          new Intent(
              android.content.Intent.ACTION_VIEW,
              Uri.parse(
                  "google.navigation:q="
                      + mPOI.getLocation().getLatitude()
                      + ","
                      + mPOI.getLocation().getLongitude()));
      List<ResolveInfo> list =
          getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
      if (list.size() > 0) {
        ObjectButton button = new ObjectButton();
        button.setButtonName(getString(R.string.MSG_TITLE_DIRECTIONS));
        button.setButtonValue(
            "google.navigation:q="
                + mPOI.getLocation().getLatitude()
                + ","
                + mPOI.getLocation().getLongitude());
        addButton2(button, root);
      }
    }
  }