Merge master

This commit is contained in:
PavelRatushny 2017-12-26 10:34:04 +02:00
parent 432eb3276f
commit a14b55d054
3 changed files with 85 additions and 8 deletions

View file

@ -710,8 +710,81 @@ public class MenuBuilder {
); );
} }
private void buildTransportRouteRow(ViewGroup parent, TransportStopRoute r, OnClickListener listener) { private View buildTransportRowItem(View view, TransportStopRoute route, OnClickListener listener) {
if (!isFirstRow()) { LinearLayout baseView = new LinearLayout(view.getContext());
baseView.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams llBaseViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
baseView.setLayoutParams(llBaseViewParams);
baseView.setPadding(dpToPx(16), 0, dpToPx(16), dpToPx(12));
baseView.setBackgroundResource(AndroidUtils.resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground));
TextViewEx transportRect = new TextViewEx(view.getContext());
LinearLayout.LayoutParams trParams = new LinearLayout.LayoutParams(dpToPx(32), dpToPx(18));
trParams.setMargins(0, dpToPx(16), 0, 0);
transportRect.setLayoutParams(trParams);
transportRect.setGravity(Gravity.CENTER);
transportRect.setAllCaps(true);
transportRect.setTypeface(FontCache.getRobotoMedium(view.getContext()));
transportRect.setTextColor(Color.WHITE);
transportRect.setTextSize(10);
GradientDrawable shape = new GradientDrawable();
shape.setShape(GradientDrawable.RECTANGLE);
shape.setCornerRadius(dpToPx(3));
shape.setColor(route.getColor(mapActivity.getMyApplication(), !light));
transportRect.setBackgroundDrawable(shape);
transportRect.setText(route.route.getRef());
baseView.addView(transportRect);
LinearLayout infoView = new LinearLayout(view.getContext());
infoView.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams infoViewLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
infoViewLayoutParams.setMargins(dpToPx(16), dpToPx(12), dpToPx(16), 0);
infoView.setLayoutParams(infoViewLayoutParams);
baseView.addView(infoView);
TextView titleView = new TextView(view.getContext());
LinearLayout.LayoutParams titleParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
titleView.setLayoutParams(titleParams);
titleView.setTextSize(16);
titleView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark));
titleView.setText(route.getDescription(getMapActivity().getMyApplication(), true));
infoView.addView(titleView);
LinearLayout typeView = new LinearLayout(view.getContext());
typeView.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams typeViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
typeViewParams.setMargins(0, dpToPx(8), 0, 0);
typeView.setGravity(Gravity.CENTER);
typeView.setLayoutParams(typeViewParams);
infoView.addView(typeView);
ImageView typeImageView = new ImageView(view.getContext());
LinearLayout.LayoutParams typeImageParams = new LinearLayout.LayoutParams(dpToPx(16), dpToPx(16));
typeImageParams.setMargins(dpToPx(4), 0, dpToPx(4), 0);
typeImageView.setLayoutParams(typeImageParams);
int drawableResId = route.type == null ? R.drawable.ic_action_polygom_dark : route.type.getResourceId();
typeImageView.setImageDrawable(getRowIcon(drawableResId));
typeView.addView(typeImageView);
TextView typeTextView = new TextView(view.getContext());
LinearLayout.LayoutParams typeTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
typeTextView.setLayoutParams(typeTextParams);
typeTextView.setText(route.getTypeStrRes());
typeView.addView(typeTextView);
baseView.setOnClickListener(listener);
((ViewGroup) view).addView(baseView);
return baseView;
}
private void buildTransportRouteRow(ViewGroup parent, TransportStopRoute r, OnClickListener listener, boolean showDivider) {
buildTransportRowItem(parent, r, listener);
if (showDivider) {
buildRowDivider(parent); buildRowDivider(parent);
} }
} }

View file

@ -18,6 +18,7 @@ import net.osmand.plus.mapcontextmenu.OpeningHoursInfo;
import net.osmand.plus.mapcontextmenu.builders.FavouritePointMenuBuilder; import net.osmand.plus.mapcontextmenu.builders.FavouritePointMenuBuilder;
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor; import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor;
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragment; import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragment;
import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import java.util.ArrayList; import java.util.ArrayList;
@ -27,7 +28,7 @@ public class FavouritePointMenuController extends MenuController {
private FavouritePoint fav; private FavouritePoint fav;
private MapMarker mapMarker; private MapMarker mapMarker;
private List<TransportStopController.TransportStopRoute> routes = new ArrayList<>(); private List<TransportStopRoute> routes = new ArrayList<>();
private OpeningHoursInfo openingHoursInfo; private OpeningHoursInfo openingHoursInfo;
public FavouritePointMenuController(MapActivity mapActivity, PointDescription pointDescription, final FavouritePoint fav) { public FavouritePointMenuController(MapActivity mapActivity, PointDescription pointDescription, final FavouritePoint fav) {
@ -71,7 +72,7 @@ public class FavouritePointMenuController extends MenuController {
} }
@Override @Override
public List<TransportStopController.TransportStopRoute> getTransportStopRoutes() { public List<TransportStopRoute> getTransportStopRoutes() {
return routes; return routes;
} }

View file

@ -36,18 +36,21 @@ public class TransportStopController extends MenuController {
PointDescription pointDescription, TransportStop transportStop) { PointDescription pointDescription, TransportStop transportStop) {
super(new MenuBuilder(mapActivity), pointDescription, mapActivity); super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
this.transportStop = transportStop; this.transportStop = transportStop;
routes = processTransportStop(); processRoutes();
builder.setRoutes(routes);
} }
@Override @Override
protected void setObject(Object object) { protected void setObject(Object object) {
if (object instanceof TransportStop) { if (object instanceof TransportStop) {
this.transportStop = (TransportStop) object; this.transportStop = (TransportStop) object;
processRoutes();
}
}
private void processRoutes() {
routes = processTransportStop(); routes = processTransportStop();
builder.setRoutes(routes); builder.setRoutes(routes);
} }
}
@Override @Override
protected Object getObject() { protected Object getObject() {