Search in sources :

Example 6 with SampleApplication

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("");
        }
    }
}
Also used : DirectionDrawable(net.osmand.core.samples.android.sample1.view.DirectionDrawable)

Example 7 with SampleApplication

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";
        }
    }
}
Also used : SampleApplication(net.osmand.core.samples.android.sample1.SampleApplication) LatLonPoint(com.jwetherell.openmap.common.LatLonPoint) UTMPoint(com.jwetherell.openmap.common.UTMPoint) LatLonPoint(com.jwetherell.openmap.common.LatLonPoint) UTMPoint(com.jwetherell.openmap.common.UTMPoint)

Example 8 with SampleApplication

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());
}
Also used : SampleApplication(net.osmand.core.samples.android.sample1.SampleApplication) IconsCache(net.osmand.core.samples.android.sample1.IconsCache)

Aggregations

SampleApplication (net.osmand.core.samples.android.sample1.SampleApplication)6 LatLonPoint (com.jwetherell.openmap.common.LatLonPoint)2 UTMPoint (com.jwetherell.openmap.common.UTMPoint)2 IconsCache (net.osmand.core.samples.android.sample1.IconsCache)2 Amenity (net.osmand.data.Amenity)2 DisplayMetrics (android.util.DisplayMetrics)1 GestureDetector (android.view.GestureDetector)1 View (android.view.View)1 ImageButton (android.widget.ImageButton)1 TextView (android.widget.TextView)1 AtlasMapRendererView (net.osmand.core.android.AtlasMapRendererView)1 IMapStylesCollection (net.osmand.core.jni.IMapStylesCollection)1 MapObjectsSymbolsProvider (net.osmand.core.jni.MapObjectsSymbolsProvider)1 MapPresentationEnvironment (net.osmand.core.jni.MapPresentationEnvironment)1 MapPrimitivesProvider (net.osmand.core.jni.MapPrimitivesProvider)1 MapPrimitiviser (net.osmand.core.jni.MapPrimitiviser)1 MapRasterLayerProvider_Software (net.osmand.core.jni.MapRasterLayerProvider_Software)1 MapStylesCollection (net.osmand.core.jni.MapStylesCollection)1 ObfMapObjectsProvider (net.osmand.core.jni.ObfMapObjectsProvider)1 ObfsCollection (net.osmand.core.jni.ObfsCollection)1