Ejemplo n.º 1
0
 @Override
 public void onBindViewHolder(BaseViewHolder holder, int position) {
   LineItem lineItem = (LineItem) getItem(position);
   GridSLM.LayoutParams lp = GridSLM.LayoutParams.from(holder.itemView.getLayoutParams());
   if (lineItem.isHeader) {
     lp.headerDisplay =
         LayoutManager.LayoutParams.HEADER_STICKY | LayoutManager.LayoutParams.HEADER_INLINE;
     lp.headerEndMarginIsAuto = true;
     lp.headerStartMarginIsAuto = true;
     ((HeaderViewHolder) holder).header.setText(lineItem.data.toString());
   } else {
     FestPhotoCardViewHolder jHolder = (FestPhotoCardViewHolder) holder;
     ListCard card = (ListCard) lineItem.data;
     Context context = jHolder.itemView.getContext();
     jHolder.title.setText(card.getVotingTitle());
     if (!TextUtils.isEmpty(card.getWin())) {
       jHolder.win.setVisibility(View.VISIBLE);
       int color;
       if ("1".equals(card.getWin())) {
         color = R.color.gold;
       } else if ("2".equals(card.getWin())) {
         color = R.color.silver;
       } else {
         color = R.color.bronze;
       }
       jHolder.win.setColorFilter(context.getResources().getColor(color));
     } else {
       jHolder.win.setVisibility(View.GONE);
     }
     Glide.with(context).load(Utils.getCardImageUrl(context, card)).into(jHolder.photo);
   }
   lp.setSlm(LinearSLM.ID);
   lp.setFirstPosition(lineItem.sectionFirstPosition);
   holder.itemView.setLayoutParams(lp);
 }