Dmitry Donskoy 2019-04-16 16:07:06 +03:00 committed by Aleksandr Zatsepin
parent c8ab7fb203
commit 216a9961e6
2 changed files with 17 additions and 36 deletions

View file

@ -1532,6 +1532,22 @@ public class PlacePageView extends NestedScrollView
}
}
@NonNull
private static PlacePageButtons.Item toPlacePageButton(@NonNull RoadWarningMarkType type)
{
switch (type)
{
case DIRTY:
return PlacePageButtons.Item.ROUTE_AVOID_UNPAVED;
case FERRY:
return PlacePageButtons.Item.ROUTE_AVOID_FERRY;
case TOLL:
return PlacePageButtons.Item.ROUTE_AVOID_TOLL;
default:
throw new AssertionError("Unsupported road warning type: " + type);
}
}
private void setButtons(@NonNull MapObject mapObject, boolean showBackButton, boolean showRoutingButton)
{
List<PlacePageButtons.PlacePageButton> buttons = new ArrayList<>();
@ -1539,7 +1555,7 @@ public class PlacePageView extends NestedScrollView
if (mapObject.getRoadWarningMarkType() != RoadWarningMarkType.UNKNOWN)
{
RoadWarningMarkType markType = mapObject.getRoadWarningMarkType();
PlacePageButtons.Item roadType = RoadWarningTypeToRoadTypeMap.get(markType);
PlacePageButtons.Item roadType = toPlacePageButton(markType);
buttons.add(roadType);
mButtons.setItems(buttons);
return;

View file

@ -1,35 +0,0 @@
package com.mapswithme.maps.widget.placepage;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.mapswithme.maps.bookmarks.data.RoadWarningMarkType;
import com.mapswithme.maps.widget.placepage.PlacePageButtons;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public class RoadWarningTypeToRoadTypeMap
{
private final static Map<RoadWarningMarkType, PlacePageButtons.Item> sMap = Collections.unmodifiableMap(createEntries());
@Nullable
public static PlacePageButtons.Item get(@NonNull RoadWarningMarkType key)
{
return sMap.get(key);
}
@NonNull
private static Map<RoadWarningMarkType, PlacePageButtons.Item> createEntries()
{
return new HashMap<RoadWarningMarkType, PlacePageButtons.Item>(){
private static final long serialVersionUID = -5608368159273229727L;
{
put(RoadWarningMarkType.DIRTY, PlacePageButtons.Item.ROUTE_AVOID_UNPAVED);
put(RoadWarningMarkType.FERRY, PlacePageButtons.Item.ROUTE_AVOID_FERRY);
put(RoadWarningMarkType.TOLL, PlacePageButtons.Item.ROUTE_AVOID_TOLL);
}
};
}
}