Search in sources :

Example 46 with MapActivity

use of net.osmand.plus.activities.MapActivity in project Osmand by osmandapp.

the class MeasurementToolFragment method enterMeasurementMode.

private void enterMeasurementMode() {
    MapActivity mapActivity = getMapActivity();
    MeasurementToolLayer measurementLayer = getMeasurementLayer();
    if (mapActivity != null && measurementLayer != null) {
        measurementLayer.setInMeasurementMode(true);
        mapActivity.refreshMap();
        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;
        }
        updateText();
    }
}
Also used : 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 47 with MapActivity

use of net.osmand.plus.activities.MapActivity in project Osmand by osmandapp.

the class MeasurementToolFragment method showPointsList.

private void showPointsList() {
    pointsListOpened = true;
    upDownBtn.setImageDrawable(downIcon);
    MapActivity mapActivity = getMapActivity();
    if (mapActivity != null) {
        if (portrait && pointsListContainer != null) {
            pointsListContainer.setVisibility(View.VISIBLE);
        } else {
            showPointsListFragment();
        }
        OsmandMapTileView tileView = mapActivity.getMapView();
        previousMapPosition = tileView.getMapPosition();
        if (portrait) {
            tileView.setMapPosition(MIDDLE_TOP_CONSTANT);
        } else {
            tileView.setMapPosition(LANDSCAPE_MIDDLE_RIGHT_CONSTANT);
        }
        mapActivity.refreshMap();
    }
}
Also used : OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) MapActivity(net.osmand.plus.activities.MapActivity)

Example 48 with MapActivity

use of net.osmand.plus.activities.MapActivity in project Osmand by osmandapp.

the class MeasurementToolFragment method setPreviousMapPosition.

private void setPreviousMapPosition() {
    MapActivity mapActivity = getMapActivity();
    if (mapActivity != null) {
        mapActivity.getMapView().setMapPosition(previousMapPosition);
        mapActivity.refreshMap();
    }
}
Also used : MapActivity(net.osmand.plus.activities.MapActivity)

Example 49 with MapActivity

use of net.osmand.plus.activities.MapActivity in project Osmand by osmandapp.

the class MeasurementToolFragment method createOptionsFragmentListener.

private OptionsFragmentListener createOptionsFragmentListener() {
    return new OptionsFragmentListener() {

        final MapActivity mapActivity = getMapActivity();

        final MeasurementToolLayer measurementLayer = getMeasurementLayer();

        @Override
        public void snapToRoadOnCLick() {
            if (!editingCtx.isInSnapToRoadMode()) {
                showSnapToRoadMenu(true);
            } else {
                disableSnapToRoadMode();
            }
        }

        @Override
        public void addToGpxOnClick() {
            if (mapActivity != null && measurementLayer != null) {
                if (editingCtx.getPointsCount() > 0) {
                    addToGpx(mapActivity);
                } else {
                    Toast.makeText(mapActivity, getString(R.string.none_point_error), Toast.LENGTH_SHORT).show();
                }
            }
        }

        @Override
        public void saveAsNewTrackOnClick() {
            if (mapActivity != null && measurementLayer != null) {
                if (editingCtx.getPointsCount() > 0) {
                    openSaveAsNewTrackMenu(mapActivity);
                } else {
                    Toast.makeText(mapActivity, getString(R.string.none_point_error), Toast.LENGTH_SHORT).show();
                }
            }
        }

        @Override
        public void addToTheTrackOnClick() {
            if (mapActivity != null && measurementLayer != null) {
                if (editingCtx.getPointsCount() > 0) {
                    showAddToTrackDialog(mapActivity);
                } else {
                    Toast.makeText(mapActivity, getString(R.string.none_point_error), Toast.LENGTH_SHORT).show();
                }
            }
        }

        @Override
        public void clearAllOnClick() {
            editingCtx.getCommandManager().execute(new ClearPointsCommand(measurementLayer));
            editingCtx.cancelSnapToRoad();
            if (pointsListOpened) {
                hidePointsList();
            }
            disable(redoBtn, upDownBtn);
            updateText();
            saved = false;
        }
    };
}
Also used : ClearPointsCommand(net.osmand.plus.measurementtool.command.ClearPointsCommand) OptionsFragmentListener(net.osmand.plus.measurementtool.OptionsBottomSheetDialogFragment.OptionsFragmentListener) MapActivity(net.osmand.plus.activities.MapActivity)

Example 50 with MapActivity

use of net.osmand.plus.activities.MapActivity in project Osmand by osmandapp.

the class MeasurementToolFragment method switchMovePointMode.

private void switchMovePointMode(boolean enable) {
    if (enable) {
        toolBarController.setBackBtnIconIds(R.drawable.ic_action_mode_back, R.drawable.ic_action_mode_back);
    } else {
        toolBarController.setBackBtnIconIds(R.drawable.ic_action_remove_dark, R.drawable.ic_action_remove_dark);
    }
    MapActivity mapActivity = getMapActivity();
    if (mapActivity != null) {
        mapActivity.showTopToolbar(toolBarController);
    }
    markGeneralComponents(enable ? View.GONE : View.VISIBLE);
    mark(enable ? View.VISIBLE : View.GONE, R.id.move_point_text, R.id.move_point_controls);
    mainIcon.setImageDrawable(getActiveIcon(enable ? R.drawable.ic_action_move_point : R.drawable.ic_action_ruler));
}
Also used : 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