コード例 #1
0
ファイル: cgeowaypoint.java プロジェクト: YraFyra/c-geo
    @Override
    public void run() {
      try {
        waypoint = app.loadWaypoint(id);

        loadWaypointHandler.sendMessage(new Message());
      } catch (Exception e) {
        Log.e(cgSettings.tag, "cgeowaypoint.loadWaypoint.run: " + e.toString());
      }
    }
コード例 #2
0
  private void radarTo() {
    if (waypoint == null || waypoint.latitude == null || waypoint.longitude == null) {
      warning.showToast(res.getString(R.string.err_location_unknown));
    }

    try {
      if (cgBase.isIntentAvailable(activity, "com.google.android.radar.SHOW_RADAR") == true) {
        Intent radarIntent = new Intent("com.google.android.radar.SHOW_RADAR");
        radarIntent.putExtra("latitude", new Float(waypoint.latitude));
        radarIntent.putExtra("longitude", new Float(waypoint.longitude));
        activity.startActivity(radarIntent);
      } else {
        AlertDialog.Builder dialog = new AlertDialog.Builder(activity);
        dialog.setTitle(res.getString(R.string.err_radar_title));
        dialog.setMessage(res.getString(R.string.err_radar_message));
        dialog.setCancelable(true);
        dialog.setPositiveButton(
            "yes",
            new DialogInterface.OnClickListener() {

              public void onClick(DialogInterface dialog, int id) {
                try {
                  activity.startActivity(
                      new Intent(
                          Intent.ACTION_VIEW,
                          Uri.parse("market://search?q=pname:com.eclipsim.gpsstatus2")));
                  dialog.cancel();
                } catch (Exception e) {
                  warning.showToast(res.getString(R.string.err_radar_market));
                  Log.e(cgSettings.tag, "cgeowaypoint.radarTo.onClick: " + e.toString());
                }
              }
            });
        dialog.setNegativeButton(
            "no",
            new DialogInterface.OnClickListener() {

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

        AlertDialog alert = dialog.create();
        alert.show();
      }
    } catch (Exception e) {
      warning.showToast(res.getString(R.string.err_radar_generic));
      Log.e(cgSettings.tag, "cgeowaypoint.radarTo: " + e.toString());
    }
  }
コード例 #3
0
ファイル: cgeowaypoint.java プロジェクト: YraFyra/c-geo
        @Override
        public void handleMessage(Message msg) {
          try {
            if (waypoint == null) {
              if (waitDialog != null) {
                waitDialog.dismiss();
                waitDialog = null;
              }

              warning.showToast(res.getString(R.string.err_waypoint_load_failed));

              finish();
              return;
            } else {
              final TextView identification = (TextView) findViewById(R.id.identification);
              final TextView coords = (TextView) findViewById(R.id.coordinates);
              final TextView note = (TextView) findViewById(R.id.note);
              final LinearLayout navigationPart = (LinearLayout) findViewById(R.id.navigation_part);

              if (waypoint.name != null && waypoint.name.length() > 0) {
                base.setTitle(activity, Html.fromHtml(waypoint.name.trim()).toString());
              } else {
                base.setTitle(activity, res.getString(R.string.waypoint_title));
              }

              if (waypoint.prefix.equalsIgnoreCase("OWN") == false) {
                identification.setText(waypoint.prefix.trim() + "/" + waypoint.lookup.trim());
              } else {
                identification.setText(res.getString(R.string.waypoint_custom));
              }

              if (waypoint.latitude != null && waypoint.longitude != null) {
                coords.setText(
                    Html.fromHtml(
                        base.formatCoordinate(waypoint.latitude, "lat", true)
                            + " | "
                            + base.formatCoordinate(waypoint.longitude, "lon", true)),
                    TextView.BufferType.SPANNABLE);
              } else {
                coords.setText(res.getString(R.string.waypoint_unknown_coordinates));
              }

              if (waypoint.note != null && waypoint.note.length() > 0) {
                note.setText(Html.fromHtml(waypoint.note.trim()), TextView.BufferType.SPANNABLE);
              }

              if (waypoint.latitude != null && waypoint.longitude != null) {
                Button buttonCompass = (Button) findViewById(R.id.compass);
                buttonCompass.setOnClickListener(
                    new navigateToListener(
                        waypoint.latitude, waypoint.longitude, waypoint.name, ""));

                Button buttonRadar = (Button) findViewById(R.id.radar);
                if (base.isIntentAvailable(activity, "com.google.android.radar.SHOW_RADAR")
                    == true) {
                  buttonRadar.setEnabled(true);
                  buttonRadar.setOnClickListener(
                      new radarToListener(waypoint.latitude, waypoint.longitude));
                } else {
                  buttonRadar.setEnabled(false);
                }

                Button buttonMap = (Button) findViewById(R.id.map);
                buttonMap.setOnClickListener(
                    new mapToListener(waypoint.latitude, waypoint.longitude));

                Button buttonMapExt = (Button) findViewById(R.id.map_ext);
                buttonMapExt.setOnClickListener(new mapExtToListener(waypoint));

                Button buttonTurn = (Button) findViewById(R.id.turn);
                buttonTurn.setOnClickListener(
                    new turnToListener(waypoint.latitude, waypoint.longitude));

                navigationPart.setVisibility(View.VISIBLE);
              }

              Button buttonEdit = (Button) findViewById(R.id.edit);
              buttonEdit.setOnClickListener(new editWaypointListener(waypoint.id));

              Button buttonDelete = (Button) findViewById(R.id.delete);
              if (waypoint.type != null && waypoint.type.equalsIgnoreCase("own") == true) {
                buttonDelete.setOnClickListener(new deleteWaypointListener(waypoint.id));
                buttonDelete.setVisibility(View.VISIBLE);
              }

              if (waitDialog != null) {
                waitDialog.dismiss();
                waitDialog = null;
              }
            }
          } catch (Exception e) {
            if (waitDialog != null) {
              waitDialog.dismiss();
              waitDialog = null;
            }
            Log.e(cgSettings.tag, "cgeowaypoint.loadWaypointHandler: " + e.toString());
          }
        }
コード例 #4
0
        @Override
        public void handleMessage(Message msg) {
          try {
            if (waypoint == null) {
              if (waitDialog != null) {
                waitDialog.dismiss();
                waitDialog = null;
              }

              warning.showToast(res.getString(R.string.err_waypoint_load_failed));

              finish();
              return;
            } else {
              final TextView identification = (TextView) findViewById(R.id.identification);
              final TextView coords = (TextView) findViewById(R.id.coordinates);
              final TextView note = (TextView) findViewById(R.id.note);
              final ImageView compass = (ImageView) findViewById(R.id.compass);
              final View separator = (View) findViewById(R.id.separator);

              if (waypoint.name != null && waypoint.name.length() > 0) {
                base.setTitle(activity, Html.fromHtml(waypoint.name.trim()).toString());
              } else {
                base.setTitle(activity, res.getString(R.string.waypoint_title));
              }

              if (waypoint.prefix.equalsIgnoreCase("OWN") == false) {
                identification.setText(waypoint.prefix.trim() + "/" + waypoint.lookup.trim());
              } else {
                identification.setText(res.getString(R.string.waypoint_custom));
              }

              if (waypoint.latitude != null && waypoint.longitude != null) {
                coords.setText(
                    Html.fromHtml(
                        base.formatCoordinate(waypoint.latitude, "lat", true)
                            + " | "
                            + base.formatCoordinate(waypoint.longitude, "lon", true)),
                    TextView.BufferType.SPANNABLE);
                compass.setVisibility(View.VISIBLE);
                separator.setVisibility(View.VISIBLE);
              } else {
                coords.setText(res.getString(R.string.waypoint_unknown_coordinates));
                compass.setVisibility(View.GONE);
                separator.setVisibility(View.GONE);
              }

              if (waypoint.note != null && waypoint.note.length() > 0) {
                note.setText(Html.fromHtml(waypoint.note.trim()), TextView.BufferType.SPANNABLE);
              }

              Button buttonEdit = (Button) findViewById(R.id.edit);
              buttonEdit.setOnClickListener(new editWaypointListener(waypoint.id));

              Button buttonDelete = (Button) findViewById(R.id.delete);
              if (waypoint.type != null && waypoint.type.equalsIgnoreCase("own") == true) {
                buttonDelete.setOnClickListener(new deleteWaypointListener(waypoint.id));
                buttonDelete.setVisibility(View.VISIBLE);
              }

              if (waitDialog != null) {
                waitDialog.dismiss();
                waitDialog = null;
              }
            }
          } catch (Exception e) {
            if (waitDialog != null) {
              waitDialog.dismiss();
              waitDialog = null;
            }
            Log.e(cgSettings.tag, "cgeowaypoint.loadWaypointHandler: " + e.toString());
          }
        }