Search in sources :

Example 56 with MapActivity

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();
    }
}
Also used : MapActivity(net.osmand.plus.activities.MapActivity)

Example 57 with MapActivity

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);
        }
    }
}
Also used : MapActivity(net.osmand.plus.activities.MapActivity)

Example 58 with MapActivity

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();
    }
}
Also used : MapMarkersLayer(net.osmand.plus.views.MapMarkersLayer) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) RecyclerView(android.support.v7.widget.RecyclerView) MapActivity(net.osmand.plus.activities.MapActivity)

Example 59 with MapActivity

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);
    }
}
Also used : WptPt(net.osmand.plus.GPXUtilities.WptPt) TextView(android.widget.TextView) ApplicationMode(net.osmand.plus.ApplicationMode) TrkSegment(net.osmand.plus.GPXUtilities.TrkSegment) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) MapActivity(net.osmand.plus.activities.MapActivity)

Example 60 with MapActivity

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();
    }
}
Also used : MapMarkersLayer(net.osmand.plus.views.MapMarkersLayer) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) RecyclerView(android.support.v7.widget.RecyclerView) MapActivity(net.osmand.plus.activities.MapActivity)

Aggregations

MapActivity (net.osmand.plus.activities.MapActivity)85 View (android.view.View)39 ImageView (android.widget.ImageView)28 TextView (android.widget.TextView)28 RecyclerView (android.support.v7.widget.RecyclerView)15 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)14 AlertDialog (android.support.v7.app.AlertDialog)12 Nullable (android.support.annotation.Nullable)11 DialogInterface (android.content.DialogInterface)10 AdapterView (android.widget.AdapterView)9 LatLon (net.osmand.data.LatLon)9 OsmandApplication (net.osmand.plus.OsmandApplication)9 Bundle (android.os.Bundle)7 Button (android.widget.Button)7 EditText (android.widget.EditText)7 ImageButton (android.widget.ImageButton)7 FavouritePoint (net.osmand.data.FavouritePoint)7 Fragment (android.support.v4.app.Fragment)6 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)6 ViewTreeObserver (android.view.ViewTreeObserver)6