@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof AtyViewHolder) { // ViewCompat.setTransitionName( ((AtyViewHolder) holder).activityItem.user_name,"1"); // ((AtyViewHolder) holder).activityItem.user_name.setText(atyItem.getUserName()); // ((AtyViewHolder) holder).activityItem.user_photo.setImageResource(atyItem.getUserIcon()); ((AtyViewHolder) holder).aty_name.setText(atyItem.getAtyName()); ((AtyViewHolder) holder).aty_content.setText(atyItem.getAtyContent()); ((AtyViewHolder) holder).total_comment.setText(atyItem.getAtyComment()); ((AtyViewHolder) holder).totle_plus.setText(atyItem.getAtyPlus()); ((AtyViewHolder) holder) .publish_time.setText(atyItem.getAtyStartTime() + "-\n" + atyItem.getAtyEndTime()); ((AtyViewHolder) holder).activity_tag.setText(atyItem.getAtyType()); ((AtyViewHolder) holder).imageViewContainer.removeAllViews(); ((AtyViewHolder) holder).atyPlace.setText(atyItem.getAtyPlace()); ((AtyViewHolder) holder).total_member.setText(atyItem.getAtyMembers()); if (atyItem.getAtyPlused().equals("false")) { ((AtyViewHolder) holder) .plus_fab.setBackgroundTintList( ColorStateList.valueOf(activity.getResources().getColor(R.color.fab_gray))); ((AtyViewHolder) holder) .plus_fab.setImageDrawable( activity.getResources().getDrawable(R.drawable.ic_action_plus_one)); } else if (atyItem.getAtyPlused().equals("true")) { ((AtyViewHolder) holder) .plus_fab.setBackgroundTintList( ColorStateList.valueOf(activity.getResources().getColor(R.color.primary))); ((AtyViewHolder) holder) .plus_fab.setImageDrawable( activity.getResources().getDrawable(R.drawable.ic_action_plus_one_white)); } if (atyItem.getAtyJoined().equals("true")) { ((AtyViewHolder) holder).mjoinBtn.setText("已加入"); ((AtyViewHolder) holder) .mjoinBtn.setTextColor(activity.getResources().getColor(R.color.primary)); } else if (atyItem.getAtyJoined().equals("false")) { ((AtyViewHolder) holder).mjoinBtn.setText("加入"); ((AtyViewHolder) holder) .mjoinBtn.setTextColor(activity.getResources().getColor(R.color.black)); } for (int i = 0; i < atyItem.getAtyAlbum().size(); i++) { ImageView imageView = (ImageView) activity.getLayoutInflater().inflate(R.layout.image, null); WindowManager windowManager = activity.getWindowManager(); DisplayMetrics dm = new DisplayMetrics(); Display display = windowManager.getDefaultDisplay(); int width = display.getWidth() - 7; int height = display.getHeight(); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(width, height * 2 / 5); Glide.with(activity).load(atyItem.getAtyAlbum().get(i)).into(imageView); imageView.setLayoutParams(layoutParams); imageView.setTag(i); imageView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // Uri uri = atyItem.getAtyAlbum().get((Integer)v.getTag()); MyDialog dialog = new MyDialog(); dialog.setUri(atyItem.getAtyAlbum().get((Integer) v.getTag())); dialog.show(activity.getSupportFragmentManager(), "showPicture"); } }); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); ((AtyViewHolder) holder).imageViewContainer.addView(imageView); } setAnimation(((AtyViewHolder) holder).cardView, position); } else if (holder instanceof CommentViewHolder) { CommentData item = commentDatas.get(position - 1); // ((CommentViewHolder) holder).user_name.setText(item.getUserName()); ((CommentViewHolder) holder).time.setText(item.getTime()); // ((CommentViewHolder) holder).user_photo.setImageResource(item.getUserIcon()); ((CommentViewHolder) holder).user_comment.setText(item.getComment()); } }
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof AtyViewHolder) { ((AtyViewHolder) holder).atysItem.tvName.setText(aty.getUsername()); // mViewHolder.atysItem.tvJoined.setText(atysList.getJoincount()); // fill html data ((AtyViewHolder) holder).atysItem.tvTime.setText(dateFormat(aty.getPubtime())); ((AtyViewHolder) holder).atysItem.tvTitle.setText(aty.getTitle()); ((AtyViewHolder) holder).atysItem.tvAddress.setText(aty.getPlace()); // ((AtyViewHolder) holder).atysItem.tvBeginTime.setText(aty.getTime()); ((AtyViewHolder) holder).atysItem.tvJoined.setText(aty.getJoincount()); String picture1 = aty.getPicturefir(); String picture2 = aty.getPicturesec(); String faceUrl = aty.getUserface(); if (faceUrl != null && faceUrl.length() > 0) { Bitmap faceImage = AppCache.getImage(faceUrl); if (faceImage != null) { ((AtyViewHolder) holder).atysItem.ivFace.setImageBitmap(faceImage); } } else { ((AtyViewHolder) holder).atysItem.ivFace.setImageBitmap(null); } WindowManager windowManager = activity.getWindowManager(); Display display = windowManager.getDefaultDisplay(); int width = display.getWidth() - 7; int height = display.getHeight(); layoutParams = new LinearLayout.LayoutParams(width, height * 2 / 5); Bitmap pic1Image = AppCache.getImage(picture1); if (pic1Image != null) { ((AtyViewHolder) holder).atysItem.imageContains.removeAllViews(); ImageView imageView = new ImageView(activity); imageView.setLayoutParams(layoutParams); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setImageBitmap(pic1Image); if (pic1Image != null) { ((AtyViewHolder) holder).atysItem.imageContains.addView(imageView); } } Bitmap pic2Image = AppCache.getImage(picture2); if (pic2Image != null) { ImageView imageView = new ImageView(activity); imageView.setLayoutParams(layoutParams); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setImageBitmap(pic2Image); if (pic1Image != null) { ((AtyViewHolder) holder).atysItem.imageContains.addView(imageView); } } } else if (holder instanceof CommentViewHolder) { Log.d("position", String.valueOf(position)); Comment comment = comments.get(position - 1); ((CommentViewHolder) holder).tvName.setText(comment.getUsername()); ((CommentViewHolder) holder).tvContent.setText(comment.getContent()); ((CommentViewHolder) holder).tvPubtime.setText(comment.getPubtime()); String faceUrl = comment.getUserface(); if (faceUrl != null && faceUrl.length() > 0) { Bitmap faceImage = AppCache.getImage(faceUrl); if (faceImage != null) { ((CommentViewHolder) holder).ivFace.setImageBitmap(faceImage); } } else { ((CommentViewHolder) holder).ivFace.setImageBitmap(null); } } }