Explorar el Código

评论列表开发完成

huyuguo %!s(int64=5) %!d(string=hace) años
padre
commit
35d08171e8

+ 4 - 4
app/src/main/java/com/electric/chargingpile/application/MainApplication.java

73
    public static String firstPoint = "";
73
    public static String firstPoint = "";
74
    public static Boolean firstSsyd;
74
    public static Boolean firstSsyd;
75
    public static String password = "";
75
    public static String password = "";
76
    public static String url = "http://59.110.68.162";// 充电桩测试环境
77
//    public static String url = "http://cdz.evcharge.cc";// 充电桩正式环境
78
    public static String urlNew = "http://123.56.67.7:83/api/0200";// 一电测试环境
79
//    public static String urlNew = "https://api.touchev.com:83/api/0200";// 一电正式环境
76
//    public static String url = "http://59.110.68.162";// 充电桩测试环境
77
    public static String url = "http://cdz.evcharge.cc";// 充电桩正式环境
78
//    public static String urlNew = "http://123.56.67.7:83/api/0200";// 一电测试环境
79
    public static String urlNew = "https://api.touchev.com:83/api/0200";// 一电正式环境
80
    public static String pic_url = "http:/s/cdz.evcharge.cc/zhannew/uploadfile/";
80
    public static String pic_url = "http:/s/cdz.evcharge.cc/zhannew/uploadfile/";
81
    //	public static String url = "https://cdz.d1ev.com";
81
    //	public static String url = "https://cdz.d1ev.com";
82
    public static String build_flag = "0";
82
    public static String build_flag = "0";

+ 76 - 3
app/src/main/java/com/electric/chargingpile/fragment/ChatContentCommentListDialogFragment.java

64
    private ConstraintLayout loadingView;
64
    private ConstraintLayout loadingView;
65
    private CommentAdapter commentAdapter;
65
    private CommentAdapter commentAdapter;
66
    private ConstraintLayout noDataView;
66
    private ConstraintLayout noDataView;
67
    public String type;
68
67
69
    public static ChatContentCommentListDialogFragment newInstance(ChatRecommendBean bean) {
68
    public static ChatContentCommentListDialogFragment newInstance(ChatRecommendBean bean) {
70
        Bundle args = new Bundle();
69
        Bundle args = new Bundle();
181
                    }
180
                    }
182
181
183
                    @Override
182
                    @Override
184
                    public void reply(String content) {
183
                    public void updateReply(String reply) {
184
                    }
185
186
                    @Override
187
                    public void reply() {
185
188
186
                    }
189
                    }
187
                });
190
                });
234
                    if (chatContentCommentListDialogFragmentListener != null) {
237
                    if (chatContentCommentListDialogFragmentListener != null) {
235
                        chatContentCommentListDialogFragmentListener.updateCommentNum(chatRecommendBean.commentNums);
238
                        chatContentCommentListDialogFragmentListener.updateCommentNum(chatRecommendBean.commentNums);
236
                    }
239
                    }
240
241
                    bCommentContent.setText("");
242
                    bPublish.setTextColor(Color.parseColor("#7e7e7e"));
237
                } else if ("8010".equals(code)) {
243
                } else if ("8010".equals(code)) {
238
                    startActivity(new Intent(getActivity().getApplicationContext(), LoginActivity.class));
244
                    startActivity(new Intent(getActivity().getApplicationContext(), LoginActivity.class));
239
                    ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
245
                    ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
320
326
321
    private class CommentHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
327
    private class CommentHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
322
        private CommentBean bean;
328
        private CommentBean bean;
329
        private String replyContent = "";
323
        private int position;
330
        private int position;
324
        private TextView content;
331
        private TextView content;
325
        private ImageView headImage;
332
        private ImageView headImage;
370
                    doLike();
377
                    doLike();
371
                    break;
378
                    break;
372
                case R.id.replyInfo: //  点击查看回复列表
379
                case R.id.replyInfo: //  点击查看回复列表
380
                    
373
                    break;
381
                    break;
374
                case R.id.deleteComment: // 删除评论操作
382
                case R.id.deleteComment: // 删除评论操作
375
                    deleteComment();
383
                    deleteComment();
376
                    break;
384
                    break;
377
                case R.id.listItemView: // 回复
385
                case R.id.listItemView: // 回复
386
                    CommonDialogFragment commonDialogFragment = CommonDialogFragment.newInstance(replyContent, "@" + bean.nickNameFromUser, CommonDialogFragment.DialogTypeReply);
387
                    commonDialogFragment.show(getChildFragmentManager(), "CommonDialogFragment");
388
                    commonDialogFragment.setOnCommonDialogFragmentListener(new CommonDialogFragment.OnCommonDialogFragmentListener() {
389
                        @Override
390
                        public void updateComment(String comment) {
391
                        }
378
392
393
                        @Override
394
                        public void publish() {
395
                        }
396
397
                        @Override
398
                        public void updateReply(String reply) {
399
                            replyContent = reply;
400
                        }
401
402
                        @Override
403
                        public void reply() {
404
                            publishReply();
405
                        }
406
                    });
379
                    break;
407
                    break;
380
            }
408
            }
381
        }
409
        }
399
427
400
            if (bean.replyNums > 0) {
428
            if (bean.replyNums > 0) {
401
                replyInfo.setVisibility(View.VISIBLE);
429
                replyInfo.setVisibility(View.VISIBLE);
430
                replyLabel.setText(bean.replyNums + "回复");
402
                if (MainApplication.userId.equals(bean.userId + "")) {
431
                if (MainApplication.userId.equals(bean.userId + "")) {
403
                    replyAndDeleteView.setVisibility(View.VISIBLE);
432
                    replyAndDeleteView.setVisibility(View.VISIBLE);
404
                } else {
433
                } else {
407
                }
436
                }
408
            } else {
437
            } else {
409
                replyInfo.setVisibility(View.GONE);
438
                replyInfo.setVisibility(View.GONE);
410
                replyLabel.setText(bean.replyNums + "");
439
                replyLabel.setText(bean.replyNums + "回复");
411
                if (MainApplication.userId.equals(bean.userId + "")) {
440
                if (MainApplication.userId.equals(bean.userId + "")) {
412
                    replyAndDeleteView.setVisibility(View.VISIBLE);
441
                    replyAndDeleteView.setVisibility(View.VISIBLE);
413
                    deleteComment.setVisibility(View.VISIBLE);
442
                    deleteComment.setVisibility(View.VISIBLE);
510
            });
539
            });
511
        }
540
        }
512
541
542
        private void publishReply() {
543
            if (!MainApplication.isLogin()) {
544
                startActivity(new Intent(getActivity().getApplicationContext(), LoginActivity.class));
545
                ToastUtil.showToast(getActivity().getApplicationContext(), "请先登录", Toast.LENGTH_SHORT);
546
                return;
547
            }
548
549
            String url = MainApplication.urlNew + "/topic/comments/publish.do";
550
            final Map<String, String> map = new HashMap<>();
551
            map.put("targetId", chatRecommendBean.targetId + "");
552
            map.put("targetType", chatRecommendBean.targetType + "");
553
            map.put("userId", MainApplication.userId );
554
            map.put("toUserId", chatRecommendBean.addUserId + "");
555
            map.put("level", "2");
556
            map.put("content", replyContent);
557
            map.put("parentId", bean.id + "");
558
559
            CommonParams.addCommonParams(map);
560
561
            OkHttpUtils.post().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
562
                @Override
563
                public void onError(Call call, Exception e) {
564
                    ToastUtil.showToast(getContext(), e.getMessage(), Toast.LENGTH_SHORT);
565
                }
566
567
                @Override
568
                public void onResponse(String response) {
569
                    Log.d(TAG, "onResponse: " + response);
570
                    String code = JsonUtils.getKeyResult(response, "code");
571
                    String desc = JsonUtils.getKeyResult(response, "desc");
572
                    if ("1000".equals(code)) {
573
                        replyContent = "";
574
                        bean.replyNums++;
575
                        commentAdapter.notifyItemChanged(position);
576
                    } else if ("8010".equals(code)) {
577
                        startActivity(new Intent(getActivity().getApplicationContext(), LoginActivity.class));
578
                        ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
579
                    } else {
580
                        ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
581
                    }
582
                }
583
            });
584
        }
585
513
    }
586
    }
514
587
515
    private class CommentAdapter extends RecyclerView.Adapter<CommentHolder> {
588
    private class CommentAdapter extends RecyclerView.Adapter<CommentHolder> {

+ 15 - 3
app/src/main/java/com/electric/chargingpile/fragment/CommonDialogFragment.java

84
            @Override
84
            @Override
85
            public void onClick(View view) {
85
            public void onClick(View view) {
86
                if (commonDialogFragmentListener != null && editText.getText().toString().trim().length() > 0) {
86
                if (commonDialogFragmentListener != null && editText.getText().toString().trim().length() > 0) {
87
                    if (DialogTypeComment.equals(type)) {
88
                        commonDialogFragmentListener.publish();
89
                    } else {
90
                        commonDialogFragmentListener.reply();
91
                    }
87
                    dismiss();
92
                    dismiss();
88
                    commonDialogFragmentListener.publish();
93
89
                }
94
                }
90
            }
95
            }
91
        });
96
        });
105
                }
110
                }
106
                updateView(comment);
111
                updateView(comment);
107
                if (commonDialogFragmentListener != null) {
112
                if (commonDialogFragmentListener != null) {
108
                    commonDialogFragmentListener.updateComment(comment);
113
                    if (DialogTypeComment.equals(type)) {
114
                        commonDialogFragmentListener.updateComment(comment);
115
                    } else {
116
                        commonDialogFragmentListener.updateReply(comment);
117
                    }
118
109
                }
119
                }
110
            }
120
            }
111
121
163
    public interface OnCommonDialogFragmentListener {
173
    public interface OnCommonDialogFragmentListener {
164
        void updateComment(String comment);
174
        void updateComment(String comment);
165
        void publish();
175
        void publish();
166
        void reply(String content);
176
177
        void updateReply(String reply);
178
        void reply();
167
    }
179
    }
168
180
169
    public void setOnCommonDialogFragmentListener(OnCommonDialogFragmentListener listener) {
181
    public void setOnCommonDialogFragmentListener(OnCommonDialogFragmentListener listener) {