LibraryHolder.java 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package eu.kanade.mangafeed.ui.library;
  2. import android.view.View;
  3. import android.widget.ImageView;
  4. import android.widget.TextView;
  5. import eu.kanade.mangafeed.R;
  6. import eu.kanade.mangafeed.data.cache.CoverCache;
  7. import eu.kanade.mangafeed.data.database.models.Manga;
  8. import uk.co.ribot.easyadapter.ItemViewHolder;
  9. import uk.co.ribot.easyadapter.PositionInfo;
  10. import uk.co.ribot.easyadapter.annotations.LayoutId;
  11. import uk.co.ribot.easyadapter.annotations.ViewId;
  12. @LayoutId(R.layout.item_catalogue)
  13. public class LibraryHolder extends ItemViewHolder<Manga> {
  14. @ViewId(R.id.thumbnail) ImageView thumbnail;
  15. @ViewId(R.id.title) TextView title;
  16. @ViewId(R.id.author) TextView author;
  17. @ViewId(R.id.unreadText) TextView unreadText;
  18. public LibraryHolder(View view) {
  19. super(view);
  20. }
  21. public void onSetValues(Manga manga, PositionInfo positionInfo) {
  22. title.setText(manga.title);
  23. author.setText(manga.author);
  24. if (manga.unread > 0) {
  25. unreadText.setVisibility(View.VISIBLE);
  26. unreadText.setText(Integer.toString(manga.unread));
  27. } else {
  28. unreadText.setVisibility(View.GONE);
  29. }
  30. if (manga.thumbnail_url != null) {
  31. CoverCache.loadLocalInto(getContext(), thumbnail, manga.thumbnail_url);
  32. } else {
  33. thumbnail.setImageResource(android.R.color.transparent);
  34. }
  35. }
  36. }