Search in sources :

Example 1 with TrackColoringCard

use of net.osmand.plus.track.cards.TrackColoringCard in project Osmand by osmandapp.

the class TrackAppearanceFragment method onCardPressed.

@Override
public void onCardPressed(@NonNull BaseCard card) {
    MapActivity mapActivity = getMapActivity();
    if (mapActivity != null) {
        if (card instanceof SplitIntervalCard) {
            SplitIntervalBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), trackDrawInfo, this);
        } else if (card instanceof TrackColoringCard) {
            TrackColoringCard trackColoringCard = ((TrackColoringCard) card);
            ColoringType currentColoringType = trackColoringCard.getSelectedColoringType();
            String routeInfoAttribute = trackColoringCard.getRouteInfoAttribute();
            trackDrawInfo.setColoringType(currentColoringType);
            trackDrawInfo.setRouteInfoAttribute(routeInfoAttribute);
            refreshMap();
            if (coloringTypeCard != null) {
                coloringTypeCard.setColoringType(currentColoringType);
            }
            if (colorsCard != null) {
                AndroidUiHelper.updateVisibility(colorsCard.getView(), currentColoringType.isTrackSolid());
            }
            updatePromoCardVisibility();
        } else if (card instanceof ColorsCard) {
            int color = ((ColorsCard) card).getSelectedColor();
            trackDrawInfo.setColor(color);
            updateColorItems();
        } else if (card instanceof TrackWidthCard) {
            updateAppearanceIcon();
        } else if (card instanceof DirectionArrowsCard) {
            updateAppearanceIcon();
        }
    }
}
Also used : DirectionArrowsCard(net.osmand.plus.track.cards.DirectionArrowsCard) TrackWidthCard(net.osmand.plus.track.cards.TrackWidthCard) SplitIntervalCard(net.osmand.plus.track.cards.SplitIntervalCard) ColorsCard(net.osmand.plus.track.cards.ColorsCard) ColoringType(net.osmand.plus.routing.ColoringType) TrackColoringCard(net.osmand.plus.track.cards.TrackColoringCard) MapActivity(net.osmand.plus.activities.MapActivity)

Example 2 with TrackColoringCard

use of net.osmand.plus.track.cards.TrackColoringCard in project Osmand by osmandapp.

the class TrackAppearanceFragment method setupCards.

private void setupCards() {
    MapActivity mapActivity = getMapActivity();
    if (mapActivity != null) {
        ViewGroup container = getCardsContainer();
        container.removeAllViews();
        cards.clear();
        if (!selectedGpxFile.isShowCurrentTrack() && !Algorithms.isEmpty(getDisplaySegmentGroups())) {
            splitIntervalCard = new SplitIntervalCard(mapActivity, trackDrawInfo);
            addCard(container, splitIntervalCard);
        }
        addCard(container, new DirectionArrowsCard(mapActivity, trackDrawInfo));
        addCard(container, new ShowStartFinishCard(mapActivity, trackDrawInfo));
        trackColoringCard = new TrackColoringCard(mapActivity, selectedGpxFile, trackDrawInfo);
        addCard(container, trackColoringCard);
        setupColorsCard(container);
        GPXTrackAnalysis analysis = selectedGpxFile.getTrackAnalysis(app);
        ColoringType coloringType = trackDrawInfo.getColoringType();
        coloringTypeCard = new ColoringTypeCard(mapActivity, analysis, coloringType);
        addCard(container, coloringTypeCard);
        promoCard = new PromoBannerCard(mapActivity, true);
        addCard(container, promoCard);
        trackWidthCard = new TrackWidthCard(mapActivity, trackDrawInfo, new OnNeedScrollListener() {

            @Override
            public void onVerticalScrollNeeded(int y) {
                View view = trackWidthCard.getView();
                if (view != null) {
                    int resultYPosition = view.getTop() + y;
                    int dialogHeight = getInnerScrollableHeight();
                    ScrollView scrollView = (ScrollView) getBottomScrollView();
                    if (resultYPosition > (scrollView.getScrollY() + dialogHeight)) {
                        scrollView.smoothScrollTo(0, resultYPosition - dialogHeight);
                    }
                }
            }
        });
        addCard(container, trackWidthCard);
        addCard(container, new ActionsCard(mapActivity));
        updatePromoCardVisibility();
    }
}
Also used : ShowStartFinishCard(net.osmand.plus.track.cards.ShowStartFinishCard) TrackWidthCard(net.osmand.plus.track.cards.TrackWidthCard) ViewGroup(android.view.ViewGroup) GPXTrackAnalysis(net.osmand.GPXUtilities.GPXTrackAnalysis) ImageView(android.widget.ImageView) View(android.view.View) ScrollView(android.widget.ScrollView) DirectionArrowsCard(net.osmand.plus.track.cards.DirectionArrowsCard) SplitIntervalCard(net.osmand.plus.track.cards.SplitIntervalCard) ScrollView(android.widget.ScrollView) ColoringType(net.osmand.plus.routing.ColoringType) PromoBannerCard(net.osmand.plus.chooseplan.PromoBannerCard) ColoringTypeCard(net.osmand.plus.track.cards.ColoringTypeCard) TrackColoringCard(net.osmand.plus.track.cards.TrackColoringCard) ActionsCard(net.osmand.plus.track.cards.ActionsCard) MapActivity(net.osmand.plus.activities.MapActivity)

Aggregations

MapActivity (net.osmand.plus.activities.MapActivity)2 ColoringType (net.osmand.plus.routing.ColoringType)2 DirectionArrowsCard (net.osmand.plus.track.cards.DirectionArrowsCard)2 SplitIntervalCard (net.osmand.plus.track.cards.SplitIntervalCard)2 TrackColoringCard (net.osmand.plus.track.cards.TrackColoringCard)2 TrackWidthCard (net.osmand.plus.track.cards.TrackWidthCard)2 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 ImageView (android.widget.ImageView)1 ScrollView (android.widget.ScrollView)1 GPXTrackAnalysis (net.osmand.GPXUtilities.GPXTrackAnalysis)1 PromoBannerCard (net.osmand.plus.chooseplan.PromoBannerCard)1 ActionsCard (net.osmand.plus.track.cards.ActionsCard)1 ColoringTypeCard (net.osmand.plus.track.cards.ColoringTypeCard)1 ColorsCard (net.osmand.plus.track.cards.ColorsCard)1 ShowStartFinishCard (net.osmand.plus.track.cards.ShowStartFinishCard)1