예제 #1
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View row = convertView;
    CardViewHolder viewHolder;
    if (row == null) {
      LayoutInflater inflater =
          (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      row = inflater.inflate(R.layout.card_wishlist, parent, false);
      viewHolder = new CardViewHolder();
      viewHolder.name = (TextView) row.findViewById(R.id.info_text);
      viewHolder.image = (CircleImageView) row.findViewById(R.id.image);
      row.setTag(viewHolder);
    } else {
      viewHolder = (CardViewHolder) row.getTag();
    }
    final ChildCard card = getItem(position);
    viewHolder.name.setText(card.getName());
    // viewHolder.image.setImageResource(R.mipmap.ic_launcher);

    row.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(getContext(), HistoryActivity.class);
            intent.putExtra("child_id", card.getId());
            getContext().startActivity(intent);
          }
        });
    return row;
  }
예제 #2
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View row = convertView;
    CardViewHolder viewHolder;
    if (row == null) {
      LayoutInflater inflater =
          (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      row = inflater.inflate(R.layout.card_wishlist, parent, false);
      viewHolder = new CardViewHolder();
      viewHolder.line1 = (TextView) row.findViewById(R.id.info_text);
      viewHolder.image = (NetworkImageView) row.findViewById(R.id.image);
      row.setTag(viewHolder);
    } else {
      viewHolder = (CardViewHolder) row.getTag();
    }
    final Card card = getItem(position);
    viewHolder.line1.setText(card.getName());
    viewHolder.image.setImageUrl(
        card.getUrl_image(), RequestManager.getInstance().doRequest().getImageLoader());

    row.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(getContext(), ProductDetailActivity.class);
            intent.putExtra("product_id", card.getId());
            getContext().startActivity(intent);
          }
        });
    return row;
  }
예제 #3
0
  @Override
  public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
    super.onBindViewHolder(viewHolder, item);

    final CardViewHolder cardViewHolder = (CardViewHolder) viewHolder;
    final ImageCardView imageCardView = cardViewHolder.getImageCardView();

    AlbumSimple albumSimple = (AlbumSimple) item;

    // name
    imageCardView.setTitleText(albumSimple.name);

    // Load real album (not simple) from API
    SpotifyTvApplication app = SpotifyTvApplication.getInstance();
    app.getSpotifyService()
        .getAlbum(
            albumSimple.id,
            new Callback<Album>() {
              @Override
              public void success(final Album album, Response response) {
                // artists
                final StringBuilder artists = new StringBuilder();
                for (ArtistSimple artist : album.artists) {
                  if (artists.length() > 0) {
                    artists.append(", ");
                  }
                  artists.append(artist.name);
                }

                // image
                final String imageUrl = album.images.get(0).url;

                // run on UI thread
                imageCardView.post(
                    new Runnable() {
                      @Override
                      public void run() {
                        imageCardView.setContentText(artists);

                        cardViewHolder.updateCardViewImage(URI.create(imageUrl));
                      }
                    });
              }

              @Override
              public void failure(RetrofitError error) {}
            });
  }