use of net.osmand.plus.activities.MapActivity in project Osmand by osmandapp.
the class PlanRouteFragment method dismiss.
private void dismiss() {
MapActivity activity = getMapActivity();
if (activity != null) {
planRouteContext.setFragmentVisible(false);
activity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
}
}
use of net.osmand.plus.activities.MapActivity in project Osmand by osmandapp.
the class PlanRouteFragment method showMarkersRouteOnMap.
private void showMarkersRouteOnMap(boolean adjustMap) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.getMapLayers().getMapMarkersLayer().setRoute(planRouteContext.getSnapTrkSegment());
mapActivity.refreshMap();
if (adjustMap) {
showRouteOnMap(planRouteContext.getSnapTrkSegment().points);
}
}
}
use of net.osmand.plus.activities.MapActivity in project Osmand by osmandapp.
the class PlanRouteFragment method enterPlanRouteMode.
private void enterPlanRouteMode() {
final MapActivity mapActivity = getMapActivity();
MapMarkersLayer markersLayer = getMapMarkersLayer();
if (mapActivity != null && markersLayer != null) {
markersLayer.setInPlanRouteMode(true);
mapActivity.disableDrawer();
mark(portrait ? View.INVISIBLE : View.GONE, R.id.map_left_widgets_panel, R.id.map_right_widgets_panel, R.id.map_center_info);
mark(View.GONE, R.id.map_route_info_button, R.id.map_menu_button, R.id.map_compass_button, R.id.map_layers_button, R.id.map_search_button, R.id.map_quick_actions_button);
View collapseButton = mapActivity.findViewById(R.id.map_collapse_button);
if (collapseButton != null && collapseButton.getVisibility() == View.VISIBLE) {
wasCollapseButtonVisible = true;
collapseButton.setVisibility(View.INVISIBLE);
} else {
wasCollapseButtonVisible = false;
}
if (planRouteContext.getSnappedMode() == null) {
planRouteContext.setSnappedMode(ApplicationMode.DEFAULT);
}
setupAppModesBtn();
OsmandMapTileView tileView = mapActivity.getMapView();
previousMapPosition = tileView.getMapPosition();
tileView.setMapPosition(portrait ? MIDDLE_TOP_CONSTANT : LANDSCAPE_MIDDLE_RIGHT_CONSTANT);
selectedCount = mapActivity.getMyApplication().getMapMarkersHelper().getSelectedMarkersCount();
planRouteContext.recreateSnapTrkSegment(planRouteContext.isAdjustMapOnStart());
planRouteContext.setAdjustMapOnStart(true);
mapActivity.refreshMap();
updateSelectButton();
}
}
use of net.osmand.plus.activities.MapActivity in project Osmand by osmandapp.
the class PlanRouteFragment method updateText.
private void updateText() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
TextView distanceTv = (TextView) mainView.findViewById(R.id.markers_distance_text_view);
TextView timeTv = (TextView) mainView.findViewById(R.id.markers_time_text_view);
TextView countTv = (TextView) mainView.findViewById(R.id.markers_count_text_view);
ApplicationMode appMode = planRouteContext.getSnappedMode();
TrkSegment snapTrkSegment = planRouteContext.getSnapTrkSegment();
boolean defaultMode = appMode == ApplicationMode.DEFAULT;
float dist = 0;
for (int i = 1; i < snapTrkSegment.points.size(); i++) {
WptPt pt1 = snapTrkSegment.points.get(i - 1);
WptPt pt2 = snapTrkSegment.points.get(i);
dist += MapUtils.getDistance(pt1.lat, pt1.lon, pt2.lat, pt2.lon);
}
distanceTv.setText(OsmAndFormatter.getFormattedDistance(dist, mapActivity.getMyApplication()) + (defaultMode ? "" : ","));
if (defaultMode) {
timeTv.setText("");
} else {
int seconds = (int) (dist / appMode.getDefaultSpeed());
timeTv.setText("~ " + OsmAndFormatter.getFormattedDuration(seconds, mapActivity.getMyApplication()));
}
countTv.setText(mapActivity.getString(R.string.shared_string_markers) + ": " + selectedCount);
}
}
use of net.osmand.plus.activities.MapActivity in project Osmand by osmandapp.
the class PlanRouteFragment method exitPlanRouteMode.
private void exitPlanRouteMode() {
MapActivity mapActivity = getMapActivity();
MapMarkersLayer markersLayer = getMapMarkersLayer();
if (mapActivity != null && markersLayer != null) {
markersLayer.setInPlanRouteMode(false);
mapActivity.enableDrawer();
if (toolbarController != null) {
mapActivity.hideTopToolbar(toolbarController);
}
mark(View.VISIBLE, R.id.map_left_widgets_panel, R.id.map_right_widgets_panel, R.id.map_center_info, R.id.map_route_info_button, R.id.map_menu_button, R.id.map_compass_button, R.id.map_layers_button, R.id.map_search_button, R.id.map_quick_actions_button);
View collapseButton = mapActivity.findViewById(R.id.map_collapse_button);
if (collapseButton != null && wasCollapseButtonVisible) {
collapseButton.setVisibility(View.VISIBLE);
}
mapActivity.findViewById(R.id.snap_to_road_image_button).setVisibility(View.GONE);
mainView.findViewById(R.id.snap_to_road_progress_bar).setVisibility(View.GONE);
mapActivity.findViewById(R.id.bottom_controls_container).setVisibility(View.VISIBLE);
mapActivity.getMapView().setMapPosition(previousMapPosition);
if (cancelSnapToRoad) {
planRouteContext.cancelSnapToRoad();
}
markersLayer.setRoute(null);
mapActivity.refreshMap();
}
}
Aggregations