use of com.rideread.rideread.data.result.Comment in project ride-read-android by Ride-Read.
the class MomentsAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder tHolder, int position) {
if (TYPE_ITEM == tHolder.getItemViewType()) {
Moment moment = mMomentList.get(position);
MomentUser user = moment.getUser();
boolean isAttent = 0 == user.getIsFollowed();
MomentViewHolder holder = (MomentViewHolder) tHolder;
holder.mClMomentLayout.setOnClickListener(v -> {
Bundle bundle = new Bundle();
bundle.putInt(MomentDetailActivity.SELECTED_MOMENT_MID, moment.getMid());
bundle.putInt(MomentDetailActivity.USER_TYPE, isAttent ? MomentDetailActivity.USER_TYPE_ATTENTED : MomentDetailActivity.USER_TYPE_NEARBY);
mActivity.gotoActivity(MomentDetailActivity.class, bundle);
});
ImgLoader.getInstance().displayImage(user.getFaceUrl(), holder.mImgAvatar);
holder.mTvName.setText(user.getUsername());
holder.mImgAvatar.setOnClickListener(v -> {
Bundle bundle = new Bundle();
bundle.putInt(UserMomentsActivity.SELECTED_UID, user.getUid());
bundle.putString(UserMomentsActivity.SELECTED_USERNAME, user.getUsername());
mActivity.gotoActivity(UserMomentsActivity.class, bundle);
});
String msg = moment.getMsg();
if (!TextUtils.isEmpty(msg)) {
holder.mTvMomentText.setText(msg);
holder.mTvMomentText.setVisibility(View.VISIBLE);
} else {
holder.mTvMomentText.setVisibility(View.GONE);
}
List<String> pictures = moment.getPictures();
if (!ListUtils.isEmpty(pictures)) {
holder.mNineGridImgView.setAdapter(adapter);
holder.mNineGridImgView.setImagesData(pictures);
holder.mNineGridImgView.setVisibility(View.VISIBLE);
} else {
holder.mNineGridImgView.setVisibility(View.GONE);
}
holder.mBtnAttention.setBackgroundResource(isAttent ? R.drawable.icon_attented : R.drawable.icon_attention);
holder.mBtnAttention.setOnClickListener(v -> {
if (isAttent) {
ApiUtils.unfollow(user.getUid(), new BaseCallback<BaseModel<DefJsonResult>>() {
@Override
protected void onSuccess(BaseModel<DefJsonResult> model) throws Exception {
holder.mBtnAttention.setBackgroundResource(R.drawable.icon_attention);
user.setIsFollowed(-1);
}
});
} else {
ApiUtils.follow(user.getUid(), new BaseCallback<BaseModel<DefJsonResult>>() {
@Override
protected void onSuccess(BaseModel<DefJsonResult> model) throws Exception {
holder.mBtnAttention.setBackgroundResource(R.drawable.icon_attented);
user.setIsFollowed(1);
}
});
}
});
List<ThumbsUpUser> thumbsUp = moment.getThumbsUp();
int likeCount = ListUtils.isEmpty(thumbsUp) ? 0 : thumbsUp.size();
holder.mBtnLike.setOnClickListener(v -> ApiUtils.updateThumbsUp(moment.getMid(), new BaseCallback<BaseModel<DefJsonResult>>() {
@Override
protected void onSuccess(BaseModel<DefJsonResult> model) throws Exception {
ToastUtils.show("成功点赞");
holder.mTvLikeCount.setText((likeCount + 1) + "");
}
}));
holder.mTvTime.setText(getFriendlyTimeSpanByNow(moment.getCreatedAt()));
holder.mTvLikeCount.setText(likeCount + "");
List<Comment> comments = moment.getComment();
int commentSize = ListUtils.isEmpty(comments) ? 0 : comments.size();
holder.mTvCommentCount.setText(commentSize + "");
//TODO
holder.mTvLocInfo.setText(moment.getMomentLocation() + " 距离我" + moment.getDistanceString());
holder.setIsRecyclable(false);
} else if (TYPE_HEADER == tHolder.getItemViewType()) {
} else {
//最后一个位置
}
}
use of com.rideread.rideread.data.result.Comment in project ride-read-android by Ride-Read.
the class UserMomentsAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder tHolder, int position) {
if (TYPE_ITEM == tHolder.getItemViewType()) {
Moment moment = mMomentList.get(position);
MomentViewHolder holder = (MomentViewHolder) tHolder;
holder.mClMomentLayout.setOnClickListener(v -> {
Bundle bundle = new Bundle();
bundle.putInt(MomentDetailActivity.SELECTED_MOMENT_MID, moment.getMid());
mActivity.gotoActivity(MomentDetailActivity.class, bundle);
});
String msg = moment.getMsg();
if (!TextUtils.isEmpty(msg)) {
holder.mTvMomentText.setText(msg);
holder.mTvMomentText.setVisibility(View.VISIBLE);
} else {
holder.mTvMomentText.setVisibility(View.GONE);
}
List<String> pictures = moment.getPictures();
if (!ListUtils.isEmpty(pictures)) {
holder.mNineGridImgView.setAdapter(adapter);
holder.mNineGridImgView.setImagesData(pictures);
holder.mNineGridImgView.setVisibility(View.VISIBLE);
} else {
holder.mNineGridImgView.setVisibility(View.GONE);
}
holder.mTvTime.setText(getFriendlyTimeSpanByNow(moment.getCreatedAt()));
List<ThumbsUpUser> thumbsUp = moment.getThumbsUp();
int likeCount = ListUtils.isEmpty(thumbsUp) ? 0 : thumbsUp.size();
holder.mTvLikeCount.setText(likeCount + "");
List<Comment> comments = moment.getComment();
int commentSize = ListUtils.isEmpty(comments) ? 0 : comments.size();
holder.mTvCommentCount.setText(commentSize + "");
//TODO
holder.mTvLocInfo.setText(moment.getMomentLocation() + " 距离我" + moment.getDistanceString());
holder.setIsRecyclable(false);
} else if (TYPE_HEADER == tHolder.getItemViewType()) {
} else {
//最后一个位置
}
}
use of com.rideread.rideread.data.result.Comment in project ride-read-android by Ride-Read.
the class CommentsAdapter method getItemView.
@Override
public View getItemView(int position, View convertView, ViewHolder viewHolder, ViewGroup viewGroup) {
SimpleDraweeView sdv_thumb_avatar = viewHolder.getView(R.id.sdv_thumb_avatar);
TextView tv_thumb_username = viewHolder.getView(R.id.tv_thumb_username);
TextView tv_thumb_time = viewHolder.getView(R.id.tv_thumb_time);
TextView tv_thumb_content = viewHolder.getView(R.id.tv_thumb_content);
Comment comment = getItem(position);
ImgLoader.getInstance().displayImage(comment.getFaceUrl(), sdv_thumb_avatar);
tv_thumb_username.setText(comment.getUsername());
tv_thumb_time.setText(TimeUtils.getFriendlyTimeSpanByNow(comment.getCreatedAt()));
tv_thumb_content.setText(comment.getMsg());
sdv_thumb_avatar.setOnClickListener(v -> {
Bundle bundle = new Bundle();
bundle.putInt(UserMomentsActivity.SELECTED_UID, comment.getUid());
bundle.putString(UserMomentsActivity.SELECTED_USERNAME, comment.getUsername());
((BaseActivity) mContext).gotoActivity(UserMomentsActivity.class, bundle);
});
return convertView;
}
Aggregations