use of net.osmand.plus.OsmAndLocationProvider in project Osmand by osmandapp.
the class MapViewTrackingUtilities method backToLocationImpl.
public void backToLocationImpl(int zoom) {
if (mapView != null) {
OsmAndLocationProvider locationProvider = app.getLocationProvider();
if (!isMapLinkedToLocation()) {
setMapLinkedToLocation(true);
net.osmand.Location lastKnownLocation = locationProvider.getLastKnownLocation();
if (lastKnownLocation != null) {
AnimateDraggingMapThread thread = mapView.getAnimatedDraggingThread();
int fZoom = mapView.getZoom() < zoom ? zoom : mapView.getZoom();
movingToMyLocation = true;
thread.startMoving(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude(), fZoom, false, new Runnable() {
@Override
public void run() {
movingToMyLocation = false;
}
});
}
mapView.refreshMap();
}
if (locationProvider.getLastKnownLocation() == null) {
app.showToastMessage(R.string.unknown_location);
}
}
}
use of net.osmand.plus.OsmAndLocationProvider in project Osmand by osmandapp.
the class MapInfoWidgetsFactory method createGPSInfoControl.
public TextInfoWidget createGPSInfoControl(final MapActivity map) {
final OsmandApplication app = map.getMyApplication();
final OsmAndLocationProvider loc = app.getLocationProvider();
final TextInfoWidget gpsInfoControl = new TextInfoWidget(map) {
private int u = -1;
private int f = -1;
@Override
public boolean updateInfo(DrawSettings d) {
GPSInfo gpsInfo = loc.getGPSInfo();
if (gpsInfo.usedSatellites != u || gpsInfo.foundSatellites != f) {
u = gpsInfo.usedSatellites;
f = gpsInfo.foundSatellites;
setText(gpsInfo.usedSatellites + "/" + gpsInfo.foundSatellites, "");
return true;
}
return false;
}
};
gpsInfoControl.setIcons(R.drawable.widget_gps_info_day, R.drawable.widget_gps_info_night);
gpsInfoControl.setText(null, null);
gpsInfoControl.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
new StartGPSStatus(map).run();
}
});
return gpsInfoControl;
}
use of net.osmand.plus.OsmAndLocationProvider in project Osmand by osmandapp.
the class DashSimulateFragment method initView.
@Override
public View initView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_common_fragment, container, false);
TextView header = (TextView) view.findViewById(R.id.fav_text);
header.setText(TITLE_ID);
((Button) view.findViewById(R.id.show_all)).setVisibility(View.GONE);
LinearLayout tracks = (LinearLayout) view.findViewById(R.id.items);
View item = inflater.inflate(R.layout.dash_simulate_item, null, false);
tracks.addView(item);
final OsmAndLocationProvider loc = getMyApplication().getLocationProvider();
OnClickListener listener = new View.OnClickListener() {
@Override
public void onClick(View v) {
loc.getLocationSimulation().startStopRouteAnimation(getActivity());
dashboard.hideDashboard();
}
};
item.setOnClickListener(listener);
ImageButton actionButton = (ImageButton) item.findViewById(R.id.stop);
actionButton.setOnClickListener(listener);
actionButton.setContentDescription(getString(R.string.animate_route));
((TextView) item.findViewById(R.id.name)).setText(R.string.animate_route);
item.findViewById(R.id.divider).setVisibility(View.VISIBLE);
return view;
}
use of net.osmand.plus.OsmAndLocationProvider in project Osmand by osmandapp.
the class DashSimulateFragment method onOpenDash.
@Override
public void onOpenDash() {
OsmAndLocationProvider loc = getMyApplication().getLocationProvider();
boolean routeAnimating = loc.getLocationSimulation().isRouteAnimating();
((TextView) getView().findViewById(R.id.name)).setText(routeAnimating ? R.string.animate_route_off : R.string.animate_route);
ImageButton actionButton = (ImageButton) getView().findViewById(R.id.stop);
actionButton.setImageDrawable(!routeAnimating ? getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_play_dark) : getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_rec_stop));
actionButton.setContentDescription(getString(routeAnimating ? R.string.animate_route_off : R.string.animate_route));
}
use of net.osmand.plus.OsmAndLocationProvider in project Osmand by osmandapp.
the class RouteInfoWidgetsFactory method createMaxSpeedControl.
public TextInfoWidget createMaxSpeedControl(final MapActivity map) {
final RoutingHelper rh = map.getMyApplication().getRoutingHelper();
final OsmAndLocationProvider locationProvider = map.getMyApplication().getLocationProvider();
final MapViewTrackingUtilities trackingUtilities = map.getMapViewTrackingUtilities();
final TextInfoWidget speedControl = new TextInfoWidget(map) {
private float cachedSpeed = 0;
@Override
public boolean updateInfo(DrawSettings drawSettings) {
float mx = 0;
if ((rh == null || !rh.isFollowingMode() || rh.isDeviatedFromRoute() || rh.getCurrentGPXRoute() != null) && trackingUtilities.isMapLinkedToLocation()) {
RouteDataObject ro = locationProvider.getLastKnownRouteSegment();
if (ro != null) {
mx = ro.getMaximumSpeed(ro.bearingVsRouteDirection(locationProvider.getLastKnownLocation()));
}
} else if (rh != null) {
mx = rh.getCurrentMaxSpeed();
} else {
mx = 0f;
}
if (cachedSpeed != mx) {
cachedSpeed = mx;
if (cachedSpeed == 0) {
setText(null, null);
} else if (cachedSpeed == RouteDataObject.NONE_MAX_SPEED) {
setText(map.getString(R.string.max_speed_none), "");
} else {
String ds = OsmAndFormatter.getFormattedSpeed(cachedSpeed, map.getMyApplication());
int ls = ds.lastIndexOf(' ');
if (ls == -1) {
setText(ds, null);
} else {
setText(ds.substring(0, ls), ds.substring(ls + 1));
}
}
return true;
}
return false;
}
};
speedControl.setIcons(R.drawable.widget_max_speed_day, R.drawable.widget_max_speed_night);
speedControl.setText(null, null);
return speedControl;
}
Aggregations