예제 #1
0
  private boolean calc(final boolean signalError) {
    if (currentFormat == coordInputFormatEnum.Plain) {
      try {
        gp = new Geopoint(eLat.getText().toString(), eLon.getText().toString());
      } catch (Geopoint.ParseException e) {
        if (signalError) {
          context.showToast(context.getResources().getString(R.string.err_parse_lat_lon));
        }
        return false;
      }
      return true;
    }

    String latDir = bLat.getText().toString();
    String lonDir = bLon.getText().toString();
    String latDeg = eLatDeg.getText().toString();
    String lonDeg = eLonDeg.getText().toString();
    String latDegFrac = eLatMin.getText().toString();
    String lonDegFrac = eLonMin.getText().toString();
    String latMin = eLatMin.getText().toString();
    String lonMin = eLonMin.getText().toString();
    String latMinFrac = eLatSec.getText().toString();
    String lonMinFrac = eLonSec.getText().toString();
    String latSec = eLatSec.getText().toString();
    String lonSec = eLonSec.getText().toString();
    String latSecFrac = eLatSub.getText().toString();
    String lonSecFrac = eLonSub.getText().toString();

    switch (currentFormat) {
      case Deg:
        gp = new Geopoint(latDir, latDeg, latDegFrac, lonDir, lonDeg, lonDegFrac);
        break;
      case Min:
        gp = new Geopoint(latDir, latDeg, latMin, latMinFrac, lonDir, lonDeg, lonMin, lonMinFrac);
        break;
      case Sec:
        gp =
            new Geopoint(
                latDir,
                latDeg,
                latMin,
                latSec,
                latSecFrac,
                lonDir,
                lonDeg,
                lonMin,
                lonSec,
                lonSecFrac);
        break;
      case Plain:
        // This case has been handled above
      default:
        throw new IllegalArgumentException();
    }

    return true;
  }
  /** Opens a dialog to do actions on an user name */
  protected static void showUserActionsDialog(final CharSequence name, final View view) {
    final AbstractActivity context = (AbstractActivity) view.getContext();
    final Resources res = context.getResources();
    final CharSequence[] items = {
      res.getString(R.string.user_menu_view_hidden),
      res.getString(R.string.user_menu_view_found),
      res.getString(R.string.user_menu_open_browser),
      res.getString(R.string.user_menu_send_message)
    };

    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(res.getString(R.string.user_menu_title) + " " + name);
    builder.setItems(
        items,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int item) {
            switch (item) {
              case 0:
                cgeocaches.startActivityOwner(context, name.toString());
                return;
              case 1:
                cgeocaches.startActivityUserName(context, name.toString());
                return;
              case 2:
                context.startActivity(
                    new Intent(
                        Intent.ACTION_VIEW,
                        Uri.parse(
                            "http://www.geocaching.com/profile/?u="
                                + Network.encode(name.toString()))));
                return;
              case 3:
                context.startActivity(
                    new Intent(
                        Intent.ACTION_VIEW,
                        Uri.parse(
                            "http://www.geocaching.com/email/?u="
                                + Network.encode(name.toString()))));
                return;
              default:
                break;
            }
          }
        });
    final AlertDialog alert = builder.create();
    alert.show();
  }