m-new"> 104
}
}
@Override
public int getItemCount() {
return beanLab.beans().size() + 1;
}
private void bindContentViewHolder(IViewHolder viewHolder, final int position) {
if (beanLab.beans().size() == 0 || position >= beanLab.beans().size()) {
return;
}
final ChatRecommendBean bean = beanLab.beans().get(position);
TopicDetailAdapter.ContentViewHolder contentViewHolder = (TopicDetailAdapter.ContentViewHolder) viewHolder;
ConstraintLayout.LayoutParams coverImageParams = (ConstraintLayout.LayoutParams) contentViewHolder.coverImage.getLayoutParams();
coverImageParams.width = itemWidth;
if (bean.coverImgW == 0 || bean.coverImgH == 0) {
coverImageParams.height = (int) (itemWidth * 16f / 9f);
} else {
if ((float) bean.coverImgH / bean.coverImgW > 16f / 9f) {
coverImageParams.height = (int) (itemWidth * 16f / 9f);
} else {
coverImageParams.height = (int) ((float) itemWidth * bean.coverImgH / bean.coverImgW);
}
}
contentViewHolder.coverImage.setLayoutParams(coverImageParams);
ImageDisplayUtils.dispalyImg(context, bean.coverImgUrl, contentViewHolder.coverImage);
contentViewHolder.videoIcon.setVisibility(bean.targetType == ChatRecommendBean.TARGET_TYPE_VIDEO ? View.VISIBLE : View.GONE);
contentViewHolder.isTop.setVisibility(bean.isTop == 1 ? View.VISIBLE : View.GONE);
contentViewHolder.title.setText(bean.title);
if (TextUtils.isEmpty(bean.headImgUrl)) {
Picasso.with(context)
.load(R.drawable.icon_face2_0)
.placeholder(R.drawable.icon_face2_0)
.error(R.drawable.icon_face2_0)
.transform(new CircleTransform())
.into(contentViewHolder.headImage);
} else {
Picasso.with(context)
.load("http://cdz.evcharge.cc/zhannew/uploadfile/" + bean.headImgUrl)
.placeholder(R.drawable.icon_face2_0)
.error(R.drawable.icon_face2_0)
.transform(new CircleTransform())
.into(contentViewHolder.headImage);
}
contentViewHolder.nickName.setText(bean.nickName);
contentViewHolder.likeInfo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (bean.likeFlg == 0) {
doLike(position);
}
}
});
if (bean.likeFlg == 1) {
contentViewHolder.likeIcon.setBackgroundResource(R.drawable.app_talk_main_list_zan_red_icon);
} else {
contentViewHolder.likeIcon.setBackgroundResource(R.drawable.app_talk_main_list_zan_icon);
}
int likeNum = bean.likeNums;
if (likeNum > 0) {
contentViewHolder.likeNum.setVisibility(View.VISIBLE);
contentViewHolder.likeNum.setText(likeNum < 999 ? likeNum + "" : "999+");
} else {
contentViewHolder.likeNum.setVisibility(View.GONE);
}
}
private void bindFooterViewHolder(IViewHolder viewHolder, int position) {
TopicDetailAdapter.FooterViewHolder footerViewHolder = (TopicDetailAdapter.FooterViewHolder) viewHolder;
StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams) footerViewHolder.footerContainer.getLayoutParams();
layoutParams.setFullSpan(true);
footerViewHolder.footerContainer.setVisibility(showFooter ? View.VISIBLE : View.GONE);
ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) footerViewHolder.footerView.getLayoutParams();
if (TopicDetailBeanLab.get(context).beans().size() == 0) {
footerViewHolder.footTextView.setText("还没有任何内容哦,快来抢沙发~");
params.height = DensityUtil.dip2px(context, (screenHeight - headerHeight - statusHeight) / 4);
params.bottomMargin = 0;
} else {
footerViewHolder.footTextView.setText("已经全部加载完毕");
params.height = DensityUtil.dip2px(context, 20);
params.bottomMargin = DensityUtil.dip2px(context, 10);
}
if (showFooter == false) {
params.height = 0;
params.bottomMargin = DensityUtil.dip2px(context, 10);
}
footerViewHolder.footTextView.setLayoutParams(params);
}
/**
* 点赞操作
*
* @param position
*/
private void doLike(final int position) {
final ChatRecommendBean bean = TopicDetailBeanLab.get(context).beans().get(position);
String url = MainApplication.urlNew + "/topic/like.do";
Map<String, String> map = new HashMap<>();
map.put("targetId", bean.targetId + "");
map.put("targetType", bean.targetType + "");
map.put("flag", "1");
map.put("authorId", bean.addUserId + "");
CommonParams.addCommonParams(map);
OkHttpUtils.get().url(url).params(map).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
@Override
public void onError(Call call, Exception e) {
ToastUtil.showToast(context, "点赞失败,请重试", Toast.LENGTH_SHORT);
}
@Override
public void onResponse(String res) {
String code = JsonUtils.getKeyResult(res, "code");
String desc = JsonUtils.getKeyResult(res, "desc");
if ("1000".equals(code)) {
bean.likeFlg = 1;
bean.likeNums += 1;
notifyItemChanged(position);
} else {
ToastUtil.showToast(context, desc, Toast.LENGTH_SHORT);
}
}
});
}
public void setContentData(ArrayList<ChatRecommendBean> beans) {
beanLab.clear();
beanLab.add(beans);
notifyDataSetChanged();
}
public void addContentData(ArrayList<ChatRecommendBean> beans) {
int startSize = beanLab.beans().size();
beanLab.add(beans);
notifyItemRangeChanged(startSize, beans.size());
}
public void setFooterData(Boolean showFooter) {
this.showFooter = showFooter;
notifyItemRangeChanged(getItemCount(), 1);
}
}
|
||
| 73 | 73 |
|
| 74 | 74 |
|
| 75 | 75 |
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| 79 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| 79 |
|
|
| 80 | 80 |
|
| 81 | 81 |
|
| 82 | 82 |
|
|
||
| 6 | 6 |
|
| 7 | 7 |
|
| 8 | 8 |
|
| 9 |
|
|
| 9 |
|
|
| 10 | 10 |
|
| 11 | 11 |
|
| 12 | 12 |
|
| 13 |
|
|
| 14 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 | 15 |
|
| 16 | 16 |
|
| 17 |
|
|
| 17 |
|
|
| 18 | 18 |
|
| 19 | 19 |
|
| 20 | 20 |
|
|
||
| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
|
| 23 |
|
|
| 24 |
|
|
|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 19 |
|
|
| 21 |
|
|
| 22 |
|
|
| 23 |
|
|
| 24 |
|
|
| 20 | 25 |
|
| 21 | 26 |
|
| 22 |
|
|
| 27 |
|
|
| 28 |
|
|
| 23 | 29 |
|
| 24 | 30 |
|
| 25 | 31 |
|
| 32 |
|
|
| 26 | 33 |
|
| 27 | 34 |
|
| 28 | 35 |
|
| 29 | 36 |
|
| 30 | 37 |
|
| 31 | 38 |
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
|
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
|
|
| 96 |
|
|
| 97 |
|
|
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| 116 |
|
|
| 117 |
|
|
| 118 |
|
|
| 119 |
|
|
| 120 |
|
|
| 121 |
|
|
| 122 |
|
|
| 123 |
|
|
| 124 |
|
|
| 125 |
|
|
| 126 |
|
|
| 127 |
|
|
| 128 |
|
|
| 129 |
|
|
| 130 |
|
|
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
| 136 |
|
|
| 137 |
|
|
| 138 |
|
|
| 139 |
|
|
| 140 |
|
|
| 141 |
|
|
| 142 |
|
|
| 143 |
|
|
| 144 |
|
|
| 145 |
|
|
| 146 |
|
|
| 147 |
|
|
| 148 |
|
|
| 149 |
|
|
| 150 |
|
|
| 151 |
|
|
| 152 |
|
|
| 153 |
|
|
| 154 |
|
|
| 155 |
|
|
| 156 |
|
|
| 157 |
|
|
| 158 |
|
|
| 159 |
|
|
| 160 |
|
|
| 161 |
|
|
| 162 |
|
|
| 163 |
|
|
| 164 |
|
|
| 165 |
|
|
| 166 |
|
|
| 167 |
|
|
| 168 |
|
|
| 169 |
|
|
| 170 |
|
|
| 171 |
|
|
| 172 |
|
|
| 173 |
|
|
| 174 |
|
|
| 175 |
|
|
| 176 |
|
|
| 177 |
|
|
| 178 |
|
|
| 32 | 179 |
|
| 33 | 180 |
|
| 34 | 181 |
|
| 182 |
|
|
| 183 |
|
|
| 184 |
|
|
| 185 |
|
|
| 186 |
|
|
| 187 |
|
|
| 188 |
|
|
| 189 |
|
|
| 190 |
|
|
| 191 |
|
|
| 192 |
|
|
| 193 |
|
|
| 194 |
|
|
| 195 |
|
|
| 196 |
|
|
| 197 |
|
|
| 198 |
|
|
| 199 |
|
|
| 200 |
|
|
| 201 |
|
|
| 202 |
|
|
| 203 |
|
|
| 204 |
|
|
| 205 |
|
|
| 206 |
|
|
| 207 |
|
|
| 208 |
|
|
| 209 |
|
|
| 210 |
|
|
| 211 |
|
|
| 212 |
|
|
| 213 |
|
|
| 214 |
|
|
| 215 |
|
|
| 216 |
|
|
| 217 |
|
|
| 218 |
|
|
| 219 |
|
|
| 220 |
|
|
| 221 |
|
|
| 222 |
|
|
| 223 |
|
|
| 224 |
|
|
| 225 |
|
|
| 226 |
|
|
| 227 |
|
|
| 228 |
|
|
| 229 |
|
|
| 230 |
|
|
| 231 |
|
|
| 232 |
|
|
| 233 |
|
|
| 234 |
|
|
| 235 |
|
|
| 236 |
|
|
| 237 |
|
|
| 35 | 238 |
|