@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof StudentViewHolder) { Student singleStudent = (Student) studentList.get(position); ((StudentViewHolder) holder).tvName.setText(singleStudent.getName()); ((StudentViewHolder) holder).tvEmailId.setText(singleStudent.getEmailId()); ((StudentViewHolder) holder).student = singleStudent; } else { ((ProgressViewHolder) holder).progressBar.setIndeterminate(true); } }
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { MyQuestionsFetched questions = mList.get(position); // Log.d("MyQuestionsAdapter","data size"+mList.size()); if (holder instanceof ViewHoldera) { ViewHoldera viewHolder = (ViewHoldera) holder; if (Build.VERSION.SDK_INT >= 21) { viewHolder.cv.setForeground( ContextCompat.getDrawable(viewHolder.cv.getContext(), R.drawable.ripple)); } else { // no ripple } viewHolder.name.setText(questions.getUser().getFullName()); viewHolder.date.setText(questions.getAskedOn()); if (language.equals("Hindi") && questions.getLanguageContents().size() > 0) { viewHolder.question.setText( questions.getLanguageContents().get(0).getContent(), TextView.BufferType.SPANNABLE); } else { viewHolder.question.setText(questions.getTitle(), TextView.BufferType.SPANNABLE); } Utility.fixTextView(viewHolder.question); // Log.d("FeedAdapter","Name is "+questions.getUser().getFullName()); if (questions.getUser().getFullName().equals(name) && !TextUtils.isEmpty(url)) { glide .with(viewHolder.user_image.getContext()) .load(Uri.parse(url)) .placeholder(R.drawable.person_image_empty) .error(R.drawable.person_image_empty) .transform(new CircleCropTransformation(viewHolder.user_image.getContext())) .into(viewHolder.user_image); } else { Drawable drawable = ContextCompat.getDrawable( viewHolder.user_image.getContext(), R.drawable.person_image_empty); viewHolder.user_image.setImageDrawable(drawable); } } else { ((ProgressViewHolder) holder).progressBar.setIndeterminate(true); } }
@Override public void onBindViewHolder(final RecyclerView.ViewHolder holder, int i) { if (holder instanceof PhotoViewHolder) { final PhotoViewHolder photoViewHolder = (PhotoViewHolder) holder; PhotoInfo pi = mPhotoList.get(i); photoViewHolder.vDate.setText(getDate(pi.date)); photoViewHolder.vDescription.setText(pi.description); if (mFragmentType == AbelanaClient.PhotoListType.PHOTO_LIST_STREAM || mFragmentType == AbelanaClient.PhotoListType.PHOTO_LIST_LIKES) { if (pi.vote == 1) { photoViewHolder.vVoteThumbsUp.setSelected(true); photoViewHolder.vVoteThumbsDown.setSelected(false); } if (pi.vote == -1) { photoViewHolder.vVoteThumbsDown.setSelected(true); photoViewHolder.vVoteThumbsUp.setSelected(false); } if (pi.vote == 0) { photoViewHolder.vVoteThumbsUp.setSelected(false); photoViewHolder.vVoteThumbsDown.setSelected(false); } photoViewHolder.vEdit.setVisibility(View.GONE); photoViewHolder.vDelete.setVisibility(View.GONE); photoViewHolder.vVoteThumbsUp.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { setPosition(photoViewHolder.getPosition()); mListener.onPhotoCardClick(v, getPosition()); } }); photoViewHolder.vVoteThumbsDown.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { setPosition(photoViewHolder.getPosition()); mListener.onPhotoCardClick(v, getPosition()); } }); } if (mFragmentType == AbelanaClient.PhotoListType.PHOTO_LIST_MINE) { photoViewHolder.vVoteThumbsUp.setVisibility(View.GONE); photoViewHolder.vVoteThumbsDown.setVisibility(View.GONE); photoViewHolder.vEdit.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { setPosition(photoViewHolder.getPosition()); mListener.onPhotoCardClick(v, getPosition()); } }); photoViewHolder.vDelete.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { setPosition(photoViewHolder.getPosition()); mListener.onPhotoCardClick(v, getPosition()); } }); } photoViewHolder.vSetWallpaper.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { setPosition(photoViewHolder.getPosition()); mListener.onPhotoCardClick(v, getPosition()); } }); photoViewHolder.itemView.setOnLongClickListener( new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { setPosition(photoViewHolder.getPosition()); return false; } }); Glide.with(mFragment).load(pi.url).crossFade().into(photoViewHolder.vPhoto); } else { ((ProgressViewHolder) holder).progressBar.setIndeterminate(true); } }