Esempio n. 1
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 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());
          }
        }
        @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());
          }
        }