EventViewHolder extends DataViewHolder<EventItem> { @Override public void populate(final EventItem eventItem) { Event event = eventItem.getItem(); Association assoc = map.get(event.getAssociation()); title.setText(event.getTitle()); association.setText(assoc.getName()); start.setText(event.getLocalStart().format(HOUR_FORMATTER)); cardView.setOnClickListener(v -> { Intent intent = EventDetailsActivity.start(v.getContext(), event, assoc); v.getContext().startActivity(intent); }); float size = ViewUtils.convertDpToPixel(4, cardView.getContext()); boolean isLast = eventItem.isLastOfSection(); ShapeAppearanceModel.Builder builder = new ShapeAppearanceModel.Builder() .setAllCorners(new RoundedCornerTreatment()) .setTopLeftCornerSize(0) .setTopRightCornerSize(0) .setBottomLeftCornerSize(isLast ? size : 0) .setBottomRightCornerSize(isLast ? size : 0); cardView.setShapeAppearanceModel(builder.build()); int bottomMarginInPx = isLast ? itemView.getContext().getResources().getDimensionPixelSize(R.dimen.card_margin_half) : 0; ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) cardView.getLayoutParams(); params.bottomMargin = bottomMarginInPx; cardView.setLayoutParams(params); divider.setVisibility(eventItem.isLastOfSection() ? View.GONE : View.VISIBLE); } EventViewHolder(View v, AssociationMap map); @Override void populate(final EventItem eventItem);  }
@Test(expected = IllegalStateException.class) public void populateHeader() { View view = inflate(R.layout.item_event_item); EventViewHolder viewHolder = new EventViewHolder(view, new MemoryAssociationMap()); EventItem item = new EventItem(generate(LocalDate.class)); viewHolder.populate(item); }