@Test public void testGetCardView(){ ViewGroup parent=mock(ViewGroup.class); ImageView imageView=mock(ImageView.class); TextView titleTextView=mock(TextView.class); TextView descriptionTextView=mock(TextView.class); CardModel cardModel=initializeCardModel(); View convertView=initializeView(imageView, titleTextView, descriptionTextView); SimpleCardStackAdapter simpleCardStackAdapter=initializeSimpleCardStackAdapter(); simpleCardStackAdapter.getCardView(1, cardModel, convertView, parent); verify(imageView).setImageDrawable(cardModel.getCardImageDrawable()); verify(titleTextView).setText(cardModel.getTitle()); verify(descriptionTextView).setText(cardModel.getDescription()); }
@Override public View getCardView(int position, CardModel model, View convertView, ViewGroup parent) { if(convertView == null) { LayoutInflater inflater = LayoutInflater.from(getContext()); convertView = inflater.inflate(R.layout.std_card_inner, parent, false); assert convertView != null; } ((ImageView) convertView.findViewById(R.id.image)).setImageDrawable(model.getCardImageDrawable()); ((TextView) convertView.findViewById(R.id.title)).setText(model.getTitle()); ((TextView) convertView.findViewById(R.id.description)).setText(model.getDescription()); return convertView; }
SimpleCardStackAdapter extends CardStackAdapter { @Override public View getCardView(int position, CardModel model, View convertView, ViewGroup parent) { if(convertView == null) { LayoutInflater inflater = LayoutInflater.from(getContext()); convertView = inflater.inflate(R.layout.std_card_inner, parent, false); assert convertView != null; } ((ImageView) convertView.findViewById(R.id.image)).setImageDrawable(model.getCardImageDrawable()); ((TextView) convertView.findViewById(R.id.title)).setText(model.getTitle()); ((TextView) convertView.findViewById(R.id.description)).setText(model.getDescription()); return convertView; } }
SimpleCardStackAdapter extends CardStackAdapter { @Override public View getCardView(int position, CardModel model, View convertView, ViewGroup parent) { if(convertView == null) { LayoutInflater inflater = LayoutInflater.from(getContext()); convertView = inflater.inflate(R.layout.std_card_inner, parent, false); assert convertView != null; } ((ImageView) convertView.findViewById(R.id.image)).setImageDrawable(model.getCardImageDrawable()); ((TextView) convertView.findViewById(R.id.title)).setText(model.getTitle()); ((TextView) convertView.findViewById(R.id.description)).setText(model.getDescription()); return convertView; } SimpleCardStackAdapter(Context context); }
SimpleCardStackAdapter extends CardStackAdapter { @Override public View getCardView(int position, CardModel model, View convertView, ViewGroup parent) { if(convertView == null) { LayoutInflater inflater = LayoutInflater.from(getContext()); convertView = inflater.inflate(R.layout.std_card_inner, parent, false); assert convertView != null; } ((ImageView) convertView.findViewById(R.id.image)).setImageDrawable(model.getCardImageDrawable()); ((TextView) convertView.findViewById(R.id.title)).setText(model.getTitle()); ((TextView) convertView.findViewById(R.id.description)).setText(model.getDescription()); return convertView; } SimpleCardStackAdapter(Context context); @Override View getCardView(int position, CardModel model, View convertView, ViewGroup parent); }
SimpleCardStackAdapter extends CardStackAdapter { @Override public View getCardView(int position, CardModel model, View convertView, ViewGroup parent) { if(convertView == null) { LayoutInflater inflater = LayoutInflater.from(getContext()); convertView = inflater.inflate(R.layout.std_card_inner, parent, false); assert convertView != null; } ((ImageView) convertView.findViewById(R.id.image)).setImageDrawable(model.getCardImageDrawable()); ((TextView) convertView.findViewById(R.id.title)).setText(model.getTitle()); ((TextView) convertView.findViewById(R.id.description)).setText(model.getDescription()); return convertView; } SimpleCardStackAdapter(Context context); @Override View getCardView(int position, CardModel model, View convertView, ViewGroup parent);  }