浏览代码

modift like

1145873331@qq.com 6 年之前
父节点
当前提交
c0604e5315
共有 1 个文件被更改,包括 32 次插入4 次删除
  1. 32 4
      app/src/main/java/com/electric/chargingpile/fragment/SvVideoShowView.java

+ 32 - 4
app/src/main/java/com/electric/chargingpile/fragment/SvVideoShowView.java

@ -14,6 +14,7 @@ import android.widget.LinearLayout;
14 14
import android.widget.TextView;
15 15
import android.widget.Toast;
16 16
17
import com.blankj.utilcode.util.ToastUtils;
17 18
import com.bumptech.glide.Glide;
18 19
import com.bumptech.glide.request.RequestOptions;
19 20
import com.electric.chargingpile.R;
@ -167,13 +168,13 @@ public class SvVideoShowView implements View.OnClickListener {
167 168
168 169
    }
169 170
170
    private void likeRequest(int targetType, int targetId, final int likeFlag, int authorId) {
171
    private void likeRequest(final int likeFlag) {
171 172
        String url = MainApplication.urlNew + "/article/like";
172 173
        Map<String, String> map = new HashMap<>();
173
        map.put("targetType", targetType + "");
174
        map.put("targetId", targetId + "");
174
        map.put("targetType", talkRecommendBean.targetType + "");
175
        map.put("targetId", talkRecommendBean.targetId + "");
175 176
        map.put("flag", likeFlag + "");
176
        map.put("authorId", authorId + "");
177
        map.put("authorId", talkRecommendBean.addUserId + "");
177 178
        map.put("totalLikeCnt", "1");
178 179
        if (MainApplication.isLogin()) {
179 180
            map.put("user_id", MainApplication.userId);
@ -195,10 +196,21 @@ public class SvVideoShowView implements View.OnClickListener {
195 196
                    @Override
196 197
                    public void onResponse(String response) {
197 198
                        String rtnCode = JsonUtils.getKeyResult(response, "code");
199
200
201
202
//                        sv_show_like_ll =view.findViewById(R.id.sv_show_like_ll);
203
                        sv_show_like_img =view.findViewById(R.id.sv_show_like_img);
204
                        ToastUtils.showLong("like没有提供图片");
205
//                        sv_show_like_tv =view.findViewById(R.id.sv_show_like_tv);
198 206
                        if ("1000".equals(rtnCode)) {
199 207
                            if (likeFlag == 1) {
208
                                talkRecommendBean.likeNums+=1;
209
                                sv_show_like_tv.setText(""+talkRecommendBean.likeNums);
200 210
                                //点赞
201 211
                            } else {
212
                                talkRecommendBean.likeNums-=1;
213
                                sv_show_like_tv.setText(""+talkRecommendBean.likeNums);
202 214
                                //取消赞
203 215
                            }
204 216
                        }
@ -225,6 +237,8 @@ public class SvVideoShowView implements View.OnClickListener {
225 237
        sv_show_tvcon_more.setOnClickListener(this);
226 238
        sv_show_comment_count_ll.setOnClickListener(this);
227 239
        sv_show_comment_ll.setOnClickListener(this);
240
        sv_show_forward.setOnClickListener(this);
241
        sv_show_like_ll.setOnClickListener(this);
228 242
    }
229 243
230 244
    private void initPlayer(View view) {
@ -325,11 +339,25 @@ public class SvVideoShowView implements View.OnClickListener {
325 339
                videoCommentDialog.getData();
326 340
                videoCommentDialog.show();
327 341
                break;
342
            case R.id.sv_show_forward:
343
                ToastUtils.showLong("我是转发!");
344
                break;
345
            case R.id.sv_show_like_ll:
346
                int likeFlg = talkRecommendBean.likeFlg;
347
                int newLike = 0;
348
                if (likeFlg == 0) {
349
                    newLike = 1;
350
                } else {
351
                    newLike = 0;
352
                }
353
                likeRequest(newLike);
354
                break;
328 355
            default:
329 356
                break;
330 357
        }
331 358
    }
332 359
360
333 361
    public void onDestroy() {
334 362
        if (upVideoView2 != null) {
335 363
            upVideoView2.stopPlayback();