Преглед на файлове

评论列表开发完成

huyuguo преди 5 години
родител
ревизия
35d08171e8

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

@ -73,10 +73,10 @@ public class MainApplication extends MultiDexApplication {
73 73
    public static String firstPoint = "";
74 74
    public static Boolean firstSsyd;
75 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 80
    public static String pic_url = "http:/s/cdz.evcharge.cc/zhannew/uploadfile/";
81 81
    //	public static String url = "https://cdz.d1ev.com";
82 82
    public static String build_flag = "0";

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

@ -64,7 +64,6 @@ public class ChatContentCommentListDialogFragment extends DialogFragment impleme
64 64
    private ConstraintLayout loadingView;
65 65
    private CommentAdapter commentAdapter;
66 66
    private ConstraintLayout noDataView;
67
    public String type;
68 67
69 68
    public static ChatContentCommentListDialogFragment newInstance(ChatRecommendBean bean) {
70 69
        Bundle args = new Bundle();
@ -181,7 +180,11 @@ public class ChatContentCommentListDialogFragment extends DialogFragment impleme
181 180
                    }
182 181
183 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,6 +237,9 @@ public class ChatContentCommentListDialogFragment extends DialogFragment impleme
234 237
                    if (chatContentCommentListDialogFragmentListener != null) {
235 238
                        chatContentCommentListDialogFragmentListener.updateCommentNum(chatRecommendBean.commentNums);
236 239
                    }
240
241
                    bCommentContent.setText("");
242
                    bPublish.setTextColor(Color.parseColor("#7e7e7e"));
237 243
                } else if ("8010".equals(code)) {
238 244
                    startActivity(new Intent(getActivity().getApplicationContext(), LoginActivity.class));
239 245
                    ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
@ -320,6 +326,7 @@ public class ChatContentCommentListDialogFragment extends DialogFragment impleme
320 326
321 327
    private class CommentHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
322 328
        private CommentBean bean;
329
        private String replyContent = "";
323 330
        private int position;
324 331
        private TextView content;
325 332
        private ImageView headImage;
@ -370,12 +377,33 @@ public class ChatContentCommentListDialogFragment extends DialogFragment impleme
370 377
                    doLike();
371 378
                    break;
372 379
                case R.id.replyInfo: //  点击查看回复列表
380
                    
373 381
                    break;
374 382
                case R.id.deleteComment: // 删除评论操作
375 383
                    deleteComment();
376 384
                    break;
377 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 407
                    break;
380 408
            }
381 409
        }
@ -399,6 +427,7 @@ public class ChatContentCommentListDialogFragment extends DialogFragment impleme
399 427
400 428
            if (bean.replyNums > 0) {
401 429
                replyInfo.setVisibility(View.VISIBLE);
430
                replyLabel.setText(bean.replyNums + "回复");
402 431
                if (MainApplication.userId.equals(bean.userId + "")) {
403 432
                    replyAndDeleteView.setVisibility(View.VISIBLE);
404 433
                } else {
@ -407,7 +436,7 @@ public class ChatContentCommentListDialogFragment extends DialogFragment impleme
407 436
                }
408 437
            } else {
409 438
                replyInfo.setVisibility(View.GONE);
410
                replyLabel.setText(bean.replyNums + "");
439
                replyLabel.setText(bean.replyNums + "回复");
411 440
                if (MainApplication.userId.equals(bean.userId + "")) {
412 441
                    replyAndDeleteView.setVisibility(View.VISIBLE);
413 442
                    deleteComment.setVisibility(View.VISIBLE);
@ -510,6 +539,50 @@ public class ChatContentCommentListDialogFragment extends DialogFragment impleme
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 588
    private class CommentAdapter extends RecyclerView.Adapter<CommentHolder> {

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

@ -84,8 +84,13 @@ public class CommonDialogFragment extends DialogFragment {
84 84
            @Override
85 85
            public void onClick(View view) {
86 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 92
                    dismiss();
88
                    commonDialogFragmentListener.publish();
93
89 94
                }
90 95
            }
91 96
        });
@ -105,7 +110,12 @@ public class CommonDialogFragment extends DialogFragment {
105 110
                }
106 111
                updateView(comment);
107 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,7 +173,9 @@ public class CommonDialogFragment extends DialogFragment {
163 173
    public interface OnCommonDialogFragmentListener {
164 174
        void updateComment(String comment);
165 175
        void publish();
166
        void reply(String content);
176
177
        void updateReply(String reply);
178
        void reply();
167 179
    }
168 180
169 181
    public void setOnCommonDialogFragmentListener(OnCommonDialogFragmentListener listener) {