@Test public void givenTwoLineText_whenSetVariant_thenVariantChanged() { listItemView.setVariant(ListItemView.VARIANT_TWO_LINE_TEXT); assertThat(listItemView) .hasVariant(ListItemView.VARIANT_TWO_LINE_TEXT) .hasSecondaryTextView() .doesNotHaveTertiaryTextView() .doesNotHaveIconView() .doesNotHaveAvatarView(); }
public void setVariant(@ListItemVariant int variant) { this.variant = variant; @LayoutRes int layout = getLayoutFromVariant(variant); removeAllViews(); LayoutInflater inflater = LayoutInflater.from(getContext()); inflater.inflate(layout, this); findChildViews(); setTexts(); setDrawables(); }
ListItemView extends FrameLayout { public void setVariant(@ListItemVariant int variant) { this.variant = variant; @LayoutRes int layout = getLayoutFromVariant(variant); removeAllViews(); LayoutInflater inflater = LayoutInflater.from(getContext()); inflater.inflate(layout, this); findChildViews(); setTexts(); setDrawables(); } }
ListItemView extends FrameLayout { public void setVariant(@ListItemVariant int variant) { this.variant = variant; @LayoutRes int layout = getLayoutFromVariant(variant); removeAllViews(); LayoutInflater inflater = LayoutInflater.from(getContext()); inflater.inflate(layout, this); findChildViews(); setTexts(); setDrawables(); } ListItemView(Context context);  ListItemView(Context context, AttributeSet attrs);  ListItemView(Context context, AttributeSet attrs, int defStyleAttr); @TargetApi(21)  ListItemView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes); }
ListItemView extends FrameLayout { public void setVariant(@ListItemVariant int variant) { this.variant = variant; @LayoutRes int layout = getLayoutFromVariant(variant); removeAllViews(); LayoutInflater inflater = LayoutInflater.from(getContext()); inflater.inflate(layout, this); findChildViews(); setTexts(); setDrawables(); } ListItemView(Context context);  ListItemView(Context context, AttributeSet attrs);  ListItemView(Context context, AttributeSet attrs, int defStyleAttr); @TargetApi(21)  ListItemView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes); @ListItemVariant int getVariant(); void setVariant(@ListItemVariant int variant); CharSequence getPrimaryText(); void setPrimaryText(@StringRes int textRes); void setPrimaryText(CharSequence text); @Nullable CharSequence getSecondaryText(); void setSecondaryText(@StringRes int textRes); void setSecondaryText(CharSequence text); @Nullable CharSequence getTertiaryText(); void setTertiaryText(@StringRes int textRes); void setTertiaryText(CharSequence text); @Nullable Drawable getIcon(); void setIcon(@DrawableRes int iconRes); void setIcon(Drawable icon); @Nullable Drawable getAvatar(); void setAvatar(@DrawableRes int avatarRes); void setAvatar(Drawable avatar); }
ListItemView extends FrameLayout { public void setVariant(@ListItemVariant int variant) { this.variant = variant; @LayoutRes int layout = getLayoutFromVariant(variant); removeAllViews(); LayoutInflater inflater = LayoutInflater.from(getContext()); inflater.inflate(layout, this); findChildViews(); setTexts(); setDrawables(); } ListItemView(Context context);  ListItemView(Context context, AttributeSet attrs);  ListItemView(Context context, AttributeSet attrs, int defStyleAttr); @TargetApi(21)  ListItemView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes); @ListItemVariant int getVariant(); void setVariant(@ListItemVariant int variant); CharSequence getPrimaryText(); void setPrimaryText(@StringRes int textRes); void setPrimaryText(CharSequence text); @Nullable CharSequence getSecondaryText(); void setSecondaryText(@StringRes int textRes); void setSecondaryText(CharSequence text); @Nullable CharSequence getTertiaryText(); void setTertiaryText(@StringRes int textRes); void setTertiaryText(CharSequence text); @Nullable Drawable getIcon(); void setIcon(@DrawableRes int iconRes); void setIcon(Drawable icon); @Nullable Drawable getAvatar(); void setAvatar(@DrawableRes int avatarRes); void setAvatar(Drawable avatar); static final int VARIANT_ONE_LINE_TEXT; static final int VARIANT_ONE_LINE_TEXT_ICON; static final int VARIANT_ONE_LINE_TEXT_AVATAR; static final int VARIANT_ONE_LINE_TEXT_ICON_AVATAR; static final int VARIANT_TWO_LINE_TEXT; static final int VARIANT_TWO_LINE_TEXT_ICON; static final int VARIANT_TWO_LINE_TEXT_AVATAR; static final int VARIANT_TWO_LINE_TEXT_ICON_AVATAR; static final int VARIANT_THREE_LINE_TEXT; static final int VARIANT_THREE_LINE_TEXT_ICON; static final int VARIANT_THREE_LINE_TEXT_AVATAR; static final int VARIANT_THREE_LINE_TEXT_ICON_AVATAR; }