Skip to content

Instantly share code, notes, and snippets.

@catalinghita8
Created August 1, 2017 15:58
Show Gist options
  • Save catalinghita8/eb038622cde1de03787fef35aa2d86b7 to your computer and use it in GitHub Desktop.
Save catalinghita8/eb038622cde1de03787fef35aa2d86b7 to your computer and use it in GitHub Desktop.
public class CatalogAdapter extends ArrayAdapter<BookObject> {
public CatalogAdapter(Activity context, List<BookObject> books) {
super(context, 0, books); // 2nd par is 0 because we inflate manually
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// Check if the existing view is being reused, otherwise inflate the view
View listItemView = convertView;
if (listItemView == null) {
listItemView = LayoutInflater.from(getContext()).inflate(
R.layout.catalog_grid_list, parent, false);
}
BookObject currentBook = getItem(position);
TextView TitleTextView = (TextView) listItemView.findViewById(R.id.catalog_Title_text_view);
TitleTextView.setText(currentBook.getTitle());
TextView SubtitleTextView = (TextView) listItemView.findViewById(R.id.catalog_Subtitle_text_view);
SubtitleTextView.setText(currentBook.getSubtitle());
String title = currentBook.getAuthors();
TextView AuthorsTextView = (TextView) listItemView.findViewById(R.id.catalog_Authors_text_view);
AuthorsTextView.setText(title);
ImageView ThumbnailImageView = (ImageView) listItemView.findViewById(R.id.catalog_book_image_id);
Picasso.with(CatalogActivity.mCatalogActivity).load(currentBook.getImageURL()).into(ThumbnailImageView);
return listItemView;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment