Make transport rects colored in bottom view

This commit is contained in:
PavelRatushny 2017-12-20 17:44:42 +02:00
parent 24a75dc2bd
commit 5b136fdcdf
3 changed files with 40 additions and 36 deletions

View file

@ -7,6 +7,7 @@ import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.support.annotation.NonNull;
@ -726,7 +727,10 @@ public class MenuBuilder {
routeDesc.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark));
int drawableResId = r.type == null ? R.drawable.ic_action_polygom_dark : r.type.getResourceId();
((ImageView) view.findViewById(R.id.route_type_icon)).setImageDrawable(getRowIcon(drawableResId));
((TextView) view.findViewById(R.id.route_ref)).setText(r.route.getRef());
TextView refTextView = (TextView) view.findViewById(R.id.route_ref);
refTextView.setText(r.route.getRef());
GradientDrawable refBg = (GradientDrawable) refTextView.getBackground();
refBg.setColor(ContextCompat.getColor(parent.getContext(), r.getColor(!light)));
view.setOnClickListener(listener);
int typeResId;
switch (r.type) {

View file

@ -42,7 +42,7 @@ public class TransportStopRouteAdapter extends ArrayAdapter<TransportStopRoute>
TextView transportStopRouteTextView = (TextView) convertView.findViewById(R.id.transport_stop_route_text);
transportStopRouteTextView.setText(transportStopRoute.route.getRef());
GradientDrawable gradientDrawableBg = (GradientDrawable) transportStopRouteTextView.getBackground();
gradientDrawableBg.setColor(ContextCompat.getColor(getContext(), getColor(transportStopRoute)));
gradientDrawableBg.setColor(ContextCompat.getColor(getContext(), transportStopRoute.getColor(nightMode)));
}
convertView.setOnClickListener(new View.OnClickListener() {
@ -57,40 +57,6 @@ public class TransportStopRouteAdapter extends ArrayAdapter<TransportStopRoute>
return convertView;
}
private int getColor(TransportStopRoute route) {
int color;
switch (route.type) {
case BUS:
color = R.color.route_bus_color;
break;
case SHARE_TAXI:
color = R.color.route_share_taxi_color;
break;
case TROLLEYBUS:
color = R.color.route_trolleybus_color;
break;
case TRAM:
color = R.color.route_tram_color;
break;
case TRAIN:
color = nightMode ? R.color.route_train_color_dark : R.color.route_train_color_light;
break;
case LIGHT_RAIL:
color = R.color.route_lightrail_color;
break;
case FUNICULAR:
color = R.color.route_funicular_color;
break;
case FERRY:
color = nightMode ? R.color.route_ferry_color_dark : R.color.route_ferry_color_light;
break;
default:
color = R.color.nav_track;
break;
}
return color;
}
public interface OnClickListener {
void onClick(int position);
}

View file

@ -264,5 +264,39 @@ public class TransportStopController extends MenuController {
}
return cp.getZoom();
}
public int getColor(boolean nightMode) {
int color;
switch (type) {
case BUS:
color = R.color.route_bus_color;
break;
case SHARE_TAXI:
color = R.color.route_share_taxi_color;
break;
case TROLLEYBUS:
color = R.color.route_trolleybus_color;
break;
case TRAM:
color = R.color.route_tram_color;
break;
case TRAIN:
color = nightMode ? R.color.route_train_color_dark : R.color.route_train_color_light;
break;
case LIGHT_RAIL:
color = R.color.route_lightrail_color;
break;
case FUNICULAR:
color = R.color.route_funicular_color;
break;
case FERRY:
color = nightMode ? R.color.route_ferry_color_dark : R.color.route_ferry_color_light;
break;
default:
color = R.color.nav_track;
break;
}
return color;
}
}
}