Search in sources :

Example 1 with TransportStopRoute

use of net.osmand.plus.transport.TransportStopRoute in project Osmand by osmandapp.

the class MapContextMenuFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    processScreenHeight(container);
    menu = getMapActivity().getContextMenu();
    markerPaddingPx = dpToPx(MARKER_PADDING_DP);
    markerPaddingXPx = dpToPx(MARKER_PADDING_X_DP);
    shadowHeight = dpToPx(SHADOW_HEIGHT_TOP_DP);
    topScreenPosY = addStatusBarHeightIfNeeded(-shadowHeight);
    bottomToolbarPosY = addStatusBarHeightIfNeeded(getResources().getDimensionPixelSize(R.dimen.dashboard_map_toolbar));
    minHalfY = viewHeight - (int) (viewHeight * menu.getHalfScreenMaxHeightKoef());
    zoomPaddingTop = dpToPx(ZOOM_PADDING_TOP_DP);
    view = inflater.inflate(R.layout.map_context_menu_fragment, container, false);
    if (!menu.isActive()) {
        return view;
    }
    AndroidUtils.addStatusBarPadding21v(getMapActivity(), view);
    nightMode = menu.isNightMode();
    mainView = view.findViewById(R.id.context_menu_main);
    toolbarContainer = view.findViewById(R.id.context_menu_toolbar_container);
    toolbarView = view.findViewById(R.id.context_menu_toolbar);
    toolbarBackButton = view.findViewById(R.id.context_menu_toolbar_back);
    toolbarTextView = (TextView) view.findViewById(R.id.context_menu_toolbar_text);
    updateVisibility(toolbarContainer, 0);
    toolbarBackButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            openMenuHeaderOnly();
        }
    });
    topButtonContainer = view.findViewById(R.id.context_menu_top_button_container);
    view.findViewById(R.id.context_menu_top_back).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            openMenuHeaderOnly();
        }
    });
    updateVisibility(topButtonContainer, 0);
    map = getMapActivity().getMapView();
    RotatedTileBox box = map.getCurrentRotatedTileBox().copy();
    customMapCenter = menu.getMapCenter() != null;
    if (!customMapCenter) {
        mapCenter = box.getCenterLatLon();
        menu.setMapCenter(mapCenter);
        double markerLat = menu.getLatLon().getLatitude();
        double markerLon = menu.getLatLon().getLongitude();
        origMarkerX = (int) box.getPixXFromLatLon(markerLat, markerLon);
        origMarkerY = (int) box.getPixYFromLatLon(markerLat, markerLon);
    } else {
        mapCenter = menu.getMapCenter();
        origMarkerX = box.getCenterPixelX();
        origMarkerY = box.getCenterPixelY();
    }
    mapZoom = menu.getMapZoom();
    if (mapZoom == 0) {
        mapZoom = map.getZoom();
    }
    // Left title button
    final View leftTitleButtonView = view.findViewById(R.id.title_button_view);
    leftTitleButtonView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            TitleButtonController leftTitleButtonController = menu.getLeftTitleButtonController();
            if (leftTitleButtonController != null) {
                leftTitleButtonController.buttonPressed();
            }
        }
    });
    // Right title button
    final View rightTitleButtonView = view.findViewById(R.id.title_button_right_view);
    rightTitleButtonView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            TitleButtonController rightTitleButtonController = menu.getRightTitleButtonController();
            if (rightTitleButtonController != null) {
                rightTitleButtonController.buttonPressed();
            }
        }
    });
    // Left download button
    final View leftDownloadButtonView = view.findViewById(R.id.download_button_left_view);
    leftDownloadButtonView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            TitleButtonController leftDownloadButtonController = menu.getLeftDownloadButtonController();
            if (leftDownloadButtonController != null) {
                leftDownloadButtonController.buttonPressed();
            }
        }
    });
    // Right download button
    final View rightDownloadButtonView = (View) view.findViewById(R.id.download_button_right_view);
    rightDownloadButtonView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            TitleButtonController rightDownloadButtonController = menu.getRightDownloadButtonController();
            if (rightDownloadButtonController != null) {
                rightDownloadButtonController.buttonPressed();
            }
        }
    });
    // Bottom title button
    final View bottomTitleButtonView = view.findViewById(R.id.title_button_bottom_view);
    bottomTitleButtonView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            TitleButtonController bottomTitleButtonController = menu.getBottomTitleButtonController();
            if (bottomTitleButtonController != null) {
                bottomTitleButtonController.buttonPressed();
            }
        }
    });
    // Progress bar
    final ImageView progressButton = (ImageView) view.findViewById(R.id.progressButton);
    progressButton.setImageDrawable(getIcon(R.drawable.ic_action_remove_dark, R.color.ctx_menu_buttons_icon_color));
    progressButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            TitleProgressController titleProgressController = menu.getTitleProgressController();
            if (titleProgressController != null) {
                titleProgressController.buttonPressed();
            }
        }
    });
    menu.updateData();
    updateButtonsAndProgress();
    if (menu.isLandscapeLayout()) {
        final TypedValue typedValueAttr = new TypedValue();
        getMapActivity().getTheme().resolveAttribute(R.attr.left_menu_view_bg, typedValueAttr, true);
        mainView.setBackgroundResource(typedValueAttr.resourceId);
        mainView.setLayoutParams(new FrameLayout.LayoutParams(menu.getLandscapeWidthPx(), ViewGroup.LayoutParams.MATCH_PARENT));
        View fabContainer = view.findViewById(R.id.context_menu_fab_container);
        fabContainer.setLayoutParams(new FrameLayout.LayoutParams(menu.getLandscapeWidthPx(), ViewGroup.LayoutParams.MATCH_PARENT));
    }
    runLayoutListener();
    final GestureDetector singleTapDetector = new GestureDetector(view.getContext(), new SingleTapConfirm());
    final GestureDetector swipeDetector = new GestureDetector(view.getContext(), new HorizontalSwipeConfirm(true));
    final View.OnTouchListener slideTouchListener = new View.OnTouchListener() {

        private float dy;

        private float dyMain;

        private float mDownY;

        private int minimumVelocity;

        private int maximumVelocity;

        private VelocityTracker velocityTracker;

        private OverScroller scroller;

        private boolean slidingUp;

        private boolean slidingDown;

        private boolean hasMoved;

        {
            scroller = new OverScroller(getContext());
            final ViewConfiguration configuration = ViewConfiguration.get(getContext());
            minimumVelocity = configuration.getScaledMinimumFlingVelocity();
            maximumVelocity = configuration.getScaledMaximumFlingVelocity();
        }

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (!hasMoved && event.getY() <= menuTopViewHeight) {
                if (singleTapDetector.onTouchEvent(event)) {
                    moving = false;
                    openMenuHalfScreen();
                    recycleVelocityTracker();
                    return true;
                }
            }
            if (menu.isLandscapeLayout()) {
                if (swipeDetector.onTouchEvent(event)) {
                    menu.close();
                    recycleVelocityTracker();
                    return true;
                }
            }
            switch(event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    hasMoved = false;
                    mDownY = event.getRawY();
                    dy = event.getY();
                    dyMain = getViewY();
                    initOrResetVelocityTracker();
                    velocityTracker.addMovement(event);
                    break;
                case MotionEvent.ACTION_MOVE:
                    if (Math.abs(event.getRawY() - mDownY) > mainView.getTouchSlop()) {
                        moving = true;
                    }
                    if (moving) {
                        hasMoved = true;
                        float y = event.getY();
                        float newY = getViewY() + (y - dy);
                        if (menu.isLandscapeLayout() && newY > topScreenPosY) {
                            newY = topScreenPosY;
                        }
                        setViewY((int) newY, false, false);
                        menuFullHeight = view.getHeight() - (int) newY + 10;
                        ViewGroup.LayoutParams lp = mainView.getLayoutParams();
                        lp.height = Math.max(menuFullHeight, menuTitleHeight);
                        mainView.setLayoutParams(lp);
                        mainView.requestLayout();
                        float newEventY = newY - (dyMain - dy);
                        MotionEvent ev = MotionEvent.obtain(event.getDownTime(), event.getEventTime(), event.getAction(), event.getX(), newEventY, event.getMetaState());
                        initVelocityTrackerIfNotExists();
                        velocityTracker.addMovement(ev);
                        updateToolbar();
                        updateTopButton();
                    }
                    break;
                case MotionEvent.ACTION_UP:
                    if (moving) {
                        moving = false;
                        hasMoved = false;
                        int currentY = getViewY();
                        final VelocityTracker velocityTracker = this.velocityTracker;
                        velocityTracker.computeCurrentVelocity(1000, maximumVelocity);
                        int initialVelocity = (int) velocityTracker.getYVelocity();
                        if ((Math.abs(initialVelocity) > minimumVelocity)) {
                            scroller.abortAnimation();
                            scroller.fling(0, currentY, 0, initialVelocity, 0, 0, Math.min(viewHeight - menuFullHeightMax, getFullScreenTopPosY()), screenHeight, 0, 0);
                            currentY = scroller.getFinalY();
                            scroller.abortAnimation();
                            slidingUp = initialVelocity < -2000;
                            slidingDown = initialVelocity > 2000;
                        } else {
                            slidingUp = false;
                            slidingDown = false;
                        }
                        changeMenuState(currentY, slidingUp, slidingDown);
                    }
                    recycleVelocityTracker();
                    break;
                case MotionEvent.ACTION_CANCEL:
                    moving = false;
                    hasMoved = false;
                    recycleVelocityTracker();
                    break;
            }
            return true;
        }

        private void initOrResetVelocityTracker() {
            if (velocityTracker == null) {
                velocityTracker = VelocityTracker.obtain();
            } else {
                velocityTracker.clear();
            }
        }

        private void initVelocityTrackerIfNotExists() {
            if (velocityTracker == null) {
                velocityTracker = VelocityTracker.obtain();
                velocityTracker.clear();
            }
        }

        private void recycleVelocityTracker() {
            if (velocityTracker != null) {
                velocityTracker.recycle();
                velocityTracker = null;
            }
        }
    };
    View topShadowAllView = view.findViewById(R.id.context_menu_top_shadow_all);
    AndroidUtils.setBackground(getMapActivity(), topShadowAllView, nightMode, R.drawable.bg_map_context_menu_light, R.drawable.bg_map_context_menu_dark);
    ((InterceptorLinearLayout) mainView).setListener(slideTouchListener);
    mainView.setOnTouchListener(slideTouchListener);
    buildHeader();
    ((TextView) view.findViewById(R.id.context_menu_line1)).setTextColor(ContextCompat.getColor(getContext(), nightMode ? R.color.ctx_menu_title_color_dark : R.color.ctx_menu_title_color_light));
    View menuLine2 = view.findViewById(R.id.context_menu_line2);
    if (menuLine2 != null) {
        ((TextView) menuLine2).setTextColor(ContextCompat.getColor(getContext(), R.color.ctx_menu_subtitle_color));
    }
    ((TextView) view.findViewById(R.id.distance)).setTextColor(ContextCompat.getColor(getContext(), nightMode ? R.color.ctx_menu_direction_color_dark : R.color.ctx_menu_direction_color_light));
    AndroidUtils.setTextSecondaryColor(getMapActivity(), (TextView) view.findViewById(R.id.title_button_right_text), nightMode);
    AndroidUtils.setTextSecondaryColor(getMapActivity(), (TextView) view.findViewById(R.id.progressTitle), nightMode);
    // Zoom buttons
    zoomButtonsView = view.findViewById(R.id.context_menu_zoom_buttons);
    zoomInButtonView = (ImageButton) view.findViewById(R.id.context_menu_zoom_in_button);
    zoomOutButtonView = (ImageButton) view.findViewById(R.id.context_menu_zoom_out_button);
    if (menu.zoomButtonsVisible()) {
        updateImageButton(zoomInButtonView, R.drawable.map_zoom_in, R.drawable.map_zoom_in_night, R.drawable.btn_circle_trans, R.drawable.btn_circle_night, nightMode);
        updateImageButton(zoomOutButtonView, R.drawable.map_zoom_out, R.drawable.map_zoom_out_night, R.drawable.btn_circle_trans, R.drawable.btn_circle_night, nightMode);
        zoomInButtonView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                menu.zoomInPressed();
            }
        });
        zoomOutButtonView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                menu.zoomOutPressed();
            }
        });
        zoomButtonsView.setVisibility(View.VISIBLE);
    } else {
        zoomButtonsView.setVisibility(View.GONE);
    }
    GridView localTransportStopRoutesGrid = (GridView) view.findViewById(R.id.transport_stop_routes_grid);
    GridView nearbyTransportStopRoutesGrid = (GridView) view.findViewById(R.id.transport_stop_nearby_routes_grid);
    TextView nearbRoutesWithinTv = (TextView) view.findViewById(R.id.nearby_routes_within_text_view);
    LinearLayout nearbyRoutesLayout = (LinearLayout) view.findViewById(R.id.nearby_routes);
    List<TransportStopRoute> localTransportStopRoutes = menu.getLocalTransportStopRoutes();
    List<TransportStopRoute> nearbyTransportStopRoutes = menu.getNearbyTransportStopRoutes();
    if (nightMode) {
        nearbRoutesWithinTv.setTextColor(ContextCompat.getColor(getContext(), R.color.ctx_menu_bottom_view_secondary_text_color_dark));
    } else {
        nearbRoutesWithinTv.setTextColor(ContextCompat.getColor(getContext(), R.color.ctx_menu_nearby_routes_text_color_dark));
    }
    if (localTransportStopRoutes != null && localTransportStopRoutes.size() > 0) {
        localTransportStopRoutesGrid.setAdapter(createTransportStopRouteAdapter(localTransportStopRoutes));
        localTransportStopRoutesGrid.setVisibility(View.VISIBLE);
    } else {
        localTransportStopRoutesGrid.setVisibility(View.GONE);
    }
    if (nearbyTransportStopRoutes != null && nearbyTransportStopRoutes.size() > 0) {
        String nearInDistance = getMyApplication().getString(R.string.transport_nearby_routes) + " " + OsmAndFormatter.getFormattedDistance(TransportStopController.SHOW_STOPS_RADIUS_METERS, getMyApplication()).toUpperCase() + ":";
        nearbRoutesWithinTv.setText(nearInDistance);
        nearbyTransportStopRoutesGrid.setAdapter(createTransportStopRouteAdapter(nearbyTransportStopRoutes));
        nearbyTransportStopRoutesGrid.setVisibility(View.VISIBLE);
    } else {
        nearbyRoutesLayout.setVisibility(View.GONE);
    }
    View buttonsBottomBorder = view.findViewById(R.id.buttons_bottom_border);
    View buttonsTopBorder = view.findViewById(R.id.buttons_top_border);
    buttonsBottomBorder.setBackgroundColor(ContextCompat.getColor(getContext(), nightMode ? R.color.ctx_menu_buttons_divider_dark : R.color.ctx_menu_buttons_divider_light));
    buttonsTopBorder.setBackgroundColor(ContextCompat.getColor(getContext(), nightMode ? R.color.ctx_menu_buttons_divider_dark : R.color.ctx_menu_buttons_divider_light));
    View buttons = view.findViewById(R.id.context_menu_buttons);
    buttons.setBackgroundColor(ContextCompat.getColor(getContext(), nightMode ? R.color.ctx_menu_buttons_bg_dark : R.color.ctx_menu_buttons_bg_light));
    if (!menu.buttonsVisible()) {
        buttonsTopBorder.setVisibility(View.GONE);
        buttons.setVisibility(View.GONE);
    }
    View bottomButtons = view.findViewById(R.id.context_menu_bottom_buttons);
    bottomButtons.setBackgroundColor(ContextCompat.getColor(getContext(), nightMode ? R.color.ctx_menu_buttons_bg_dark : R.color.ctx_menu_buttons_bg_light));
    if (!menu.navigateButtonVisible()) {
        bottomButtons.findViewById(R.id.context_menu_directions_button).setVisibility(View.GONE);
    }
    // Action buttons
    final ImageView imageFavorite = (ImageView) view.findViewById(R.id.context_menu_fav_image_view);
    imageFavorite.setImageDrawable(getIcon(menu.getFavActionIconId(), R.color.ctx_menu_buttons_icon_color));
    imageFavorite.setContentDescription(getString(menu.getFavActionStringId()));
    ((TextView) view.findViewById(R.id.context_menu_fav_text_view)).setText(menu.getFavActionStringId());
    View favView = view.findViewById(R.id.context_menu_fav_view);
    favView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            menu.buttonFavoritePressed();
        }
    });
    final ImageView imageWaypoint = (ImageView) view.findViewById(R.id.context_menu_route_image_view);
    imageWaypoint.setImageDrawable(getIcon(menu.getWaypointActionIconId(), R.color.ctx_menu_buttons_icon_color));
    imageWaypoint.setContentDescription(getString(menu.getWaypointActionStringId()));
    View waypointView = view.findViewById(R.id.context_menu_route_view);
    if (menu.isButtonWaypointEnabled()) {
        waypointView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                menu.buttonWaypointPressed();
            }
        });
    } else {
        deactivate(waypointView);
    }
    final ImageView imageShare = (ImageView) view.findViewById(R.id.context_menu_share_image_view);
    imageShare.setImageDrawable(getIcon(R.drawable.map_action_gshare_dark, R.color.ctx_menu_buttons_icon_color));
    View shareView = view.findViewById(R.id.context_menu_share_view);
    shareView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            menu.buttonSharePressed();
        }
    });
    final ImageView imageMore = (ImageView) view.findViewById(R.id.context_menu_more_image_view);
    imageMore.setImageDrawable(getIcon(R.drawable.map_overflow_menu_white, R.color.ctx_menu_buttons_icon_color));
    View moreView = view.findViewById(R.id.context_menu_more_view);
    moreView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            menu.buttonMorePressed();
        }
    });
    // Bottom buttons
    int bottomButtonsColor = nightMode ? R.color.ctx_menu_controller_button_text_color_dark_n : R.color.ctx_menu_controller_button_text_color_light_n;
    TextView detailsButton = (TextView) view.findViewById(R.id.context_menu_details_button);
    detailsButton.setTextColor(ContextCompat.getColor(getContext(), bottomButtonsColor));
    detailsButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            openMenuHalfScreen();
        }
    });
    TextView directionsButton = (TextView) view.findViewById(R.id.context_menu_directions_button);
    int iconResId = R.drawable.map_directions;
    if (menu.navigateInPedestrianMode()) {
        iconResId = R.drawable.map_action_pedestrian_dark;
    }
    Drawable drawable = getIcon(iconResId, bottomButtonsColor);
    directionsButton.setTextColor(ContextCompat.getColor(getContext(), bottomButtonsColor));
    directionsButton.setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null);
    directionsButton.setCompoundDrawablePadding(dpToPx(8));
    directionsButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            menu.navigateButtonPressed();
        }
    });
    buildBottomView();
    LockableScrollView bottomScrollView = (LockableScrollView) view.findViewById(R.id.context_menu_bottom_scroll);
    bottomScrollView.setScrollingEnabled(false);
    bottomScrollView.setBackgroundColor(getResources().getColor(nightMode ? R.color.ctx_menu_bottom_view_bg_dark : R.color.ctx_menu_bottom_view_bg_light));
    view.findViewById(R.id.context_menu_bottom_view).setBackgroundColor(getResources().getColor(nightMode ? R.color.ctx_menu_bottom_view_bg_dark : R.color.ctx_menu_bottom_view_bg_light));
    // getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(false);
    containerLayoutListener = new OnLayoutChangeListener() {

        @Override
        public void onLayoutChange(View view, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
            if (bottom != oldBottom) {
                processScreenHeight(view.getParent());
                runLayoutListener();
            }
        }
    };
    created = true;
    return view;
}
Also used : GestureDetector(android.view.GestureDetector) SingleTapConfirm(net.osmand.plus.views.controls.SingleTapConfirm) ViewConfiguration(android.view.ViewConfiguration) TransportStopRoute(net.osmand.plus.transport.TransportStopRoute) TextView(android.widget.TextView) ImageView(android.widget.ImageView) TypedValue(android.util.TypedValue) OverScroller(android.widget.OverScroller) RotatedTileBox(net.osmand.data.RotatedTileBox) VelocityTracker(android.view.VelocityTracker) OnLayoutChangeListener(android.view.View.OnLayoutChangeListener) ViewGroup(android.view.ViewGroup) Drawable(android.graphics.drawable.Drawable) GridView(android.widget.GridView) ImageView(android.widget.ImageView) View(android.view.View) LockableScrollView(net.osmand.plus.LockableScrollView) TextView(android.widget.TextView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) QuadPoint(net.osmand.data.QuadPoint) LockableScrollView(net.osmand.plus.LockableScrollView) MotionEvent(android.view.MotionEvent) TitleButtonController(net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController) FrameLayout(android.widget.FrameLayout) HorizontalSwipeConfirm(net.osmand.plus.views.controls.HorizontalSwipeConfirm) GridView(android.widget.GridView) TitleProgressController(net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController) LinearLayout(android.widget.LinearLayout)

Example 2 with TransportStopRoute

use of net.osmand.plus.transport.TransportStopRoute in project Osmand by osmandapp.

the class MenuBuilder method getCollapsableTransportStopRoutesView.

private CollapsableView getCollapsableTransportStopRoutesView(final Context context, boolean collapsed, boolean isNearbyRoutes) {
    LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, false);
    List<TransportStopRoute> localTransportStopRoutes = mapContextMenu.getLocalTransportStopRoutes();
    List<TransportStopRoute> nearbyTransportStopRoutes = mapContextMenu.getNearbyTransportStopRoutes();
    if (!isNearbyRoutes) {
        buildTransportRouteRows(view, localTransportStopRoutes);
    } else {
        buildTransportRouteRows(view, nearbyTransportStopRoutes);
    }
    if (isNearbyRoutes && nearbyTransportStopRoutes.isEmpty()) {
        return null;
    } else {
        return new CollapsableView(view, this, collapsed);
    }
}
Also used : TransportStopRoute(net.osmand.plus.transport.TransportStopRoute) LinearLayout(android.widget.LinearLayout)

Example 3 with TransportStopRoute

use of net.osmand.plus.transport.TransportStopRoute in project Osmand by osmandapp.

the class MenuBuilder method buildTransportRouteRows.

private void buildTransportRouteRows(LinearLayout view, List<TransportStopRoute> routes) {
    for (int i = 0; i < routes.size(); i++) {
        final TransportStopRoute r = routes.get(i);
        boolean showDivider = i < routes.size() - 1;
        buildTransportRouteRow(view, r, createTransportRoutesViewClickListener(r), showDivider);
    }
}
Also used : TransportStopRoute(net.osmand.plus.transport.TransportStopRoute)

Example 4 with TransportStopRoute

use of net.osmand.plus.transport.TransportStopRoute in project Osmand by osmandapp.

the class MenuController method getMenuController.

public static MenuController getMenuController(MapActivity mapActivity, LatLon latLon, PointDescription pointDescription, Object object, MenuType menuType) {
    MenuController menuController = null;
    if (object != null) {
        if (object instanceof Amenity) {
            menuController = new AmenityMenuController(mapActivity, pointDescription, (Amenity) object);
        } else if (object instanceof FavouritePoint) {
            menuController = new FavouritePointMenuController(mapActivity, pointDescription, (FavouritePoint) object);
        } else if (object instanceof SearchHistoryHelper.HistoryEntry) {
            menuController = new HistoryMenuController(mapActivity, pointDescription, (SearchHistoryHelper.HistoryEntry) object);
        } else if (object instanceof TargetPoint) {
            menuController = new TargetPointMenuController(mapActivity, pointDescription, (TargetPoint) object);
        } else if (object instanceof Recording) {
            menuController = new AudioVideoNoteMenuController(mapActivity, pointDescription, (Recording) object);
        } else if (object instanceof OsmPoint) {
            menuController = new EditPOIMenuController(mapActivity, pointDescription, (OsmPoint) object);
        } else if (object instanceof WptPt) {
            menuController = new WptPtMenuController(mapActivity, pointDescription, (WptPt) object);
        } else if (object instanceof DownloadMapObject) {
            menuController = new MapDataMenuController(mapActivity, pointDescription, (DownloadMapObject) object);
        } else if (object instanceof OpenStreetNote) {
            menuController = new OsmBugMenuController(mapActivity, pointDescription, (OpenStreetNote) object);
        } else if (object instanceof GpxDisplayItem) {
            menuController = new GpxItemMenuController(mapActivity, pointDescription, (GpxDisplayItem) object);
        } else if (object instanceof MapMarker) {
            menuController = new MapMarkerMenuController(mapActivity, pointDescription, (MapMarker) object);
        } else if (object instanceof TransportStopRoute) {
            menuController = new TransportRouteController(mapActivity, pointDescription, (TransportStopRoute) object);
        } else if (object instanceof TransportStop) {
            menuController = new TransportStopController(mapActivity, pointDescription, (TransportStop) object);
        } else if (object instanceof AMapPoint) {
            menuController = new AMapPointMenuController(mapActivity, pointDescription, (AMapPoint) object);
        } else if (object instanceof LatLon) {
            if (pointDescription.isParking()) {
                menuController = new ParkingPositionMenuController(mapActivity, pointDescription);
            } else if (pointDescription.isMyLocation()) {
                menuController = new MyLocationMenuController(mapActivity, pointDescription);
            }
        } else if (object instanceof RouteDataObject) {
            menuController = new ImpassibleRoadsMenuController(mapActivity, pointDescription, (RouteDataObject) object);
        } else if (object instanceof RenderedObject) {
            menuController = new RenderedObjectMenuController(mapActivity, pointDescription, (RenderedObject) object);
        } else if (object instanceof MapillaryImage) {
            menuController = new MapillaryMenuController(mapActivity, pointDescription, (MapillaryImage) object);
        }
    }
    if (menuController == null) {
        menuController = new PointDescriptionMenuController(mapActivity, pointDescription);
    }
    menuController.menuType = menuType;
    menuController.setLatLon(latLon);
    menuController.onCreated();
    return menuController;
}
Also used : TargetPointMenuController(net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController) WptPt(net.osmand.plus.GPXUtilities.WptPt) HistoryMenuController(net.osmand.plus.mapcontextmenu.controllers.HistoryMenuController) TransportStopController(net.osmand.plus.mapcontextmenu.controllers.TransportStopController) FavouritePoint(net.osmand.data.FavouritePoint) MapMarker(net.osmand.plus.MapMarkersHelper.MapMarker) MapillaryImage(net.osmand.plus.mapillary.MapillaryImage) ParkingPositionMenuController(net.osmand.plus.parkingpoint.ParkingPositionMenuController) GpxDisplayItem(net.osmand.plus.GpxSelectionHelper.GpxDisplayItem) GpxItemMenuController(net.osmand.plus.mapcontextmenu.controllers.GpxItemMenuController) MapDataMenuController(net.osmand.plus.mapcontextmenu.controllers.MapDataMenuController) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) RenderedObjectMenuController(net.osmand.plus.mapcontextmenu.controllers.RenderedObjectMenuController) ImpassibleRoadsMenuController(net.osmand.plus.mapcontextmenu.controllers.ImpassibleRoadsMenuController) EditPOIMenuController(net.osmand.plus.osmedit.EditPOIMenuController) TransportStopRoute(net.osmand.plus.transport.TransportStopRoute) MapMarkerMenuController(net.osmand.plus.mapcontextmenu.controllers.MapMarkerMenuController) PointDescriptionMenuController(net.osmand.plus.mapcontextmenu.controllers.PointDescriptionMenuController) AMapPointMenuController(net.osmand.plus.mapcontextmenu.controllers.AMapPointMenuController) TransportStop(net.osmand.data.TransportStop) Amenity(net.osmand.data.Amenity) FavouritePointMenuController(net.osmand.plus.mapcontextmenu.controllers.FavouritePointMenuController) AudioVideoNoteMenuController(net.osmand.plus.audionotes.AudioVideoNoteMenuController) OsmBugMenuController(net.osmand.plus.osmedit.OsmBugMenuController) OsmPoint(net.osmand.plus.osmedit.OsmPoint) TransportRouteController(net.osmand.plus.mapcontextmenu.controllers.TransportRouteController) AMapPoint(net.osmand.aidl.maplayer.point.AMapPoint) AmenityMenuController(net.osmand.plus.mapcontextmenu.controllers.AmenityMenuController) DownloadMapObject(net.osmand.plus.views.DownloadedRegionsLayer.DownloadMapObject) MyLocationMenuController(net.osmand.plus.mapcontextmenu.controllers.MyLocationMenuController) RenderedObjectMenuController(net.osmand.plus.mapcontextmenu.controllers.RenderedObjectMenuController) PointDescriptionMenuController(net.osmand.plus.mapcontextmenu.controllers.PointDescriptionMenuController) MapMarkerMenuController(net.osmand.plus.mapcontextmenu.controllers.MapMarkerMenuController) AMapPointMenuController(net.osmand.plus.mapcontextmenu.controllers.AMapPointMenuController) OsmBugMenuController(net.osmand.plus.osmedit.OsmBugMenuController) WptPtMenuController(net.osmand.plus.mapcontextmenu.controllers.WptPtMenuController) MapillaryMenuController(net.osmand.plus.mapillary.MapillaryMenuController) GpxItemMenuController(net.osmand.plus.mapcontextmenu.controllers.GpxItemMenuController) HistoryMenuController(net.osmand.plus.mapcontextmenu.controllers.HistoryMenuController) ParkingPositionMenuController(net.osmand.plus.parkingpoint.ParkingPositionMenuController) MapDataMenuController(net.osmand.plus.mapcontextmenu.controllers.MapDataMenuController) TargetPointMenuController(net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController) AudioVideoNoteMenuController(net.osmand.plus.audionotes.AudioVideoNoteMenuController) AmenityMenuController(net.osmand.plus.mapcontextmenu.controllers.AmenityMenuController) ImpassibleRoadsMenuController(net.osmand.plus.mapcontextmenu.controllers.ImpassibleRoadsMenuController) EditPOIMenuController(net.osmand.plus.osmedit.EditPOIMenuController) FavouritePointMenuController(net.osmand.plus.mapcontextmenu.controllers.FavouritePointMenuController) MyLocationMenuController(net.osmand.plus.mapcontextmenu.controllers.MyLocationMenuController) LatLon(net.osmand.data.LatLon) RenderedObject(net.osmand.NativeLibrary.RenderedObject) OpenStreetNote(net.osmand.plus.osmedit.OsmBugsLayer.OpenStreetNote) RouteDataObject(net.osmand.binary.RouteDataObject) Recording(net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording) WptPtMenuController(net.osmand.plus.mapcontextmenu.controllers.WptPtMenuController) MapillaryMenuController(net.osmand.plus.mapillary.MapillaryMenuController)

Example 5 with TransportStopRoute

use of net.osmand.plus.transport.TransportStopRoute in project Osmand by osmandapp.

the class TransportStopRouteAdapter method getView.

@NonNull
@Override
public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.transport_stop_route_item, parent, false);
    }
    TransportStopRoute transportStopRoute = getItem(position);
    if (transportStopRoute != null) {
        TextView transportStopRouteTextView = (TextView) convertView.findViewById(R.id.transport_stop_route_text);
        transportStopRouteTextView.setText(getAdjustedRouteRef(transportStopRoute.route.getRef()));
        GradientDrawable gradientDrawableBg = (GradientDrawable) transportStopRouteTextView.getBackground();
        gradientDrawableBg.setColor(transportStopRoute.getColor(app, nightMode));
    }
    convertView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (listener != null) {
                listener.onClick(position);
            }
        }
    });
    return convertView;
}
Also used : TransportStopRoute(net.osmand.plus.transport.TransportStopRoute) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) GradientDrawable(android.graphics.drawable.GradientDrawable) NonNull(android.support.annotation.NonNull)

Aggregations

TransportStopRoute (net.osmand.plus.transport.TransportStopRoute)10 TransportStop (net.osmand.data.TransportStop)3 View (android.view.View)2 LinearLayout (android.widget.LinearLayout)2 TextView (android.widget.TextView)2 ArrayList (java.util.ArrayList)2 QuadPoint (net.osmand.data.QuadPoint)2 QuadRect (net.osmand.data.QuadRect)2 TransportRoute (net.osmand.data.TransportRoute)2 TransportStopType (net.osmand.plus.transport.TransportStopType)2 Drawable (android.graphics.drawable.Drawable)1 GradientDrawable (android.graphics.drawable.GradientDrawable)1 NonNull (android.support.annotation.NonNull)1 TypedValue (android.util.TypedValue)1 GestureDetector (android.view.GestureDetector)1 MotionEvent (android.view.MotionEvent)1 VelocityTracker (android.view.VelocityTracker)1 OnLayoutChangeListener (android.view.View.OnLayoutChangeListener)1 ViewConfiguration (android.view.ViewConfiguration)1 ViewGroup (android.view.ViewGroup)1