use of net.osmand.core.samples.android.sample1.SampleApplication 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("");
}
}
}
use of net.osmand.core.samples.android.sample1.SampleApplication in project Osmand by osmandapp.
the class PointDescription method getLocationNamePlain.
public static String getLocationNamePlain(Context ctx, double lat, double lon) {
SampleApplication app = SampleApplication.getApp(ctx);
int f = app.getCoordinatesFormat();
if (f == PointDescription.UTM_FORMAT) {
UTMPoint pnt = new UTMPoint(new LatLonPoint(lat, lon));
return pnt.zone_number + "" + pnt.zone_letter + " " + ((long) pnt.easting) + " " + ((long) pnt.northing);
} else {
try {
return LocationConvert.convert(lat, f) + ", " + LocationConvert.convert(lon, f);
} catch (RuntimeException e) {
e.printStackTrace();
return "0, 0";
}
}
}
use of net.osmand.core.samples.android.sample1.SampleApplication in project Osmand by osmandapp.
the class DirectionDrawable method setImage.
public void setImage(int resourceId, int clrId) {
IconsCache iconsCache = ((SampleApplication) ctx.getApplicationContext()).getIconsCache();
arrowImage = iconsCache.getIcon(resourceId, clrId);
this.resourceId = resourceId;
onBoundsChange(getBounds());
}
Aggregations