use of net.osmand.core.samples.android.sample1.view.DirectionDrawable in project Osmand by osmandapp.
the class QuickSearchListAdapter method updateLocationView.
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h, ImageView arrow, int arrowResId, TextView txt, LatLon toLoc, int screenOrientation, SampleApplication app, Context ctx, boolean paint) {
float[] mes = new float[2];
if (fromLoc != null && toLoc != null) {
Location.distanceBetween(toLoc.getLatitude(), toLoc.getLongitude(), fromLoc.getLatitude(), fromLoc.getLongitude(), mes);
}
if (arrow != null) {
boolean newImage = false;
if (arrowResId == 0) {
arrowResId = R.drawable.ic_direction_arrow;
}
DirectionDrawable dd;
if (!(arrow.getDrawable() instanceof DirectionDrawable)) {
newImage = true;
dd = new DirectionDrawable(ctx, arrow.getWidth(), arrow.getHeight());
} else {
dd = (DirectionDrawable) arrow.getDrawable();
}
dd.setImage(arrowResId, useCenter ? R.color.color_distance : R.color.color_myloc_distance);
if (fromLoc == null || h == null || toLoc == null) {
dd.setAngle(0);
} else {
dd.setAngle(mes[1] - h + 180 + screenOrientation);
}
if (newImage) {
arrow.setImageDrawable(dd);
}
arrow.invalidate();
}
if (txt != null) {
if (fromLoc != null && toLoc != null) {
if (paint) {
txt.setTextColor(app.getResources().getColor(useCenter ? R.color.color_distance : R.color.color_myloc_distance));
}
txt.setText(SampleFormatter.getFormattedDistance(mes[0], app));
} else {
txt.setText("");
}
}
}
Aggregations