RouteDescriptionItem extends BaseView { public void setRoute(final Route route) { if (route == null) { throw new IllegalArgumentException(getContext().getString(R.string.msdkui_exception_route_null)); } mRoute = route; final ImageView icon = (ImageView) mSections.get(Section.TYPE_ICON); final Integer id = RouteUtil.getIcon(mRoute); if (id == 0) { icon.setVisibility(GONE); } else { icon.setImageResource(id); icon.setColorFilter(ThemeUtil.getColor(getContext(), R.attr.colorForeground), PorterDuff.Mode.SRC_ATOP); } final Spannable totalTime = RouteUtil.getTimeToArrive(getContext(), mRoute, isTrafficEnabled()); ((TextView) mSections.get(Section.TIME)).setText(totalTime); ((TextView) mSections.get(Section.TIME)).setContentDescription( getContext().getString(R.string.msdkui_duration) + " " + totalTime); if (isTrafficEnabled() && !isBikeOrPedestrian()) { ((TextView) mSections.get(Section.TRAFFIC_WARNING)).setVisibility(View.VISIBLE); final Spannable delayText = RouteUtil.getTrafficDelayed(getContext(), mRoute); ((TextView) mSections.get(Section.TRAFFIC_WARNING)).setText(delayText); ((TextView) mSections.get(Section.TRAFFIC_WARNING)).setContentDescription(delayText.toString().replace( getContext().getString(R.string.msdkui_incl), getContext().getString(R.string.msdkui_including))); } else { ((TextView) mSections.get(Section.TRAFFIC_WARNING)).setVisibility(GONE); } ((TextView) mSections.get(Section.DETAILS)).setText( RouteUtil.getDetails(getContext(), mRoute, mUnitSystem)); ((SectionBar) mSections.get(Section.SECTION_BAR)) .bind(RouteUtil.getSectionBar(getContext(), mRoute), mSectionBarScaling); final String arrivalTime = RouteUtil.getArrivalTime(getContext(), mRoute, isTrafficEnabled()); ((TextView) mSections.get(Section.ARRIVAL_TIME)).setText(arrivalTime); ((TextView) mSections.get(Section.ARRIVAL_TIME)).setContentDescription( getContext().getString(R.string.msdkui_arrive_at) + arrivalTime); setVisibility(VISIBLE); } RouteDescriptionItem(final Context context);  RouteDescriptionItem(final Context context, final AttributeSet attrs);  RouteDescriptionItem(final Context context, final AttributeSet attrs, final int defStyleAttr); @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)  RouteDescriptionItem(final Context context, final AttributeSet attrs, final int defStyleAttr,
            final int defStyleRes); void setSectionVisible(final Section section, final boolean visible); boolean isSectionVisible(final Section section); EnumSet<Section> getVisibleSections(); void setVisibleSections(final EnumSet<Section> sectionEnumSet); boolean isTrafficEnabled(); void setTrafficEnabled(final boolean isTraffic); Route getRoute(); void setRoute(final Route route); float getSectionBarScaling(); void setSectionBarScaling(final float sectionBarScaling); boolean isBikeOrPedestrian();  }
@Test(expected = IllegalArgumentException.class) public void testSetNullRouteException() { mRouteDescriptionItem.setRoute(null); }