@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // FIXME Should have its own layout setContentView(R.layout.act_track_properties); int index = getIntent().getExtras().getInt("index"); Androzic application = (Androzic) getApplication(); route = application.getRoute(index); name = (TextView) findViewById(R.id.name_text); name.setText(route.name); /* description = (TextView) findViewById(R.id.description_text); description.setText(track.description); */ show = (CheckBox) findViewById(R.id.show_check); show.setChecked(route.show); color = (ColorButton) findViewById(R.id.color_button); color.setColor(route.lineColor, getResources().getColor(R.color.routeline)); ViewGroup width = (ViewGroup) findViewById(R.id.width_layout); width.setVisibility(View.GONE); Button save = (Button) findViewById(R.id.done_button); save.setOnClickListener(saveOnClickListener); Button cancel = (Button) findViewById(R.id.cancel_button); cancel.setOnClickListener( new OnClickListener() { public void onClick(View v) { finish(); } }); }
@Override protected void onDraw(final Canvas c, final MapView mapView, int centerX, int centerY) { if (!track.show) return; Androzic application = (Androzic) context.getApplication(); final int[] cxy = mapView.mapCenterXY; int w2 = mapView.getWidth() / 2; int h2 = mapView.getHeight() / 2; int left = cxy[0] - w2; int right = cxy[0] + w2; int top = cxy[1] - h2; int bottom = cxy[1] + h2; final Path path = new Path(); boolean first = true; boolean skipped = false; int lastX = 0, lastY = 0; List<TrackPoint> trackpoints = track.getPoints(); synchronized (trackpoints) { for (TrackPoint tp : trackpoints) { int[] xy = new int[2]; if (tp.dirty) { xy = application.getXYbyLatLon(tp.latitude, tp.longitude); tp.x = xy[0]; tp.y = xy[1]; tp.dirty = false; } else { xy[0] = tp.x; xy[1] = tp.y; } if (first) { path.setLastPoint(xy[0] - cxy[0], xy[1] - cxy[1]); lastX = xy[0]; lastY = xy[1]; first = false; continue; } if ((lastX == xy[0] && lastY == xy[1]) || lastX < left && cxy[0] < left || lastX > right && cxy[0] > right || lastY < top && cxy[1] < top || lastY > bottom && cxy[1] > bottom) { lastX = xy[0]; lastY = xy[1]; skipped = true; continue; } if (skipped) { path.moveTo(lastX - cxy[0], lastY - cxy[1]); skipped = false; } if (tp.continous) path.lineTo(xy[0] - cxy[0], xy[1] - cxy[1]); else path.moveTo(xy[0] - cxy[0], xy[1] - cxy[1]); lastX = xy[0]; lastY = xy[1]; } } c.drawPath(path, paint); }