|
@ -64,6 +64,7 @@ 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;
|
67
|
68
|
|
68
|
69
|
public static ChatContentCommentListDialogFragment newInstance(ChatRecommendBean bean) {
|
69
|
70
|
Bundle args = new Bundle();
|
|
@ -159,9 +160,8 @@ public class ChatContentCommentListDialogFragment extends DialogFragment impleme
|
159
|
160
|
public void onClick(View view) {
|
160
|
161
|
switch (view.getId()) {
|
161
|
162
|
case R.id.bWriteComment: // 写评论
|
162
|
|
CommonDialogFragment commonDialogFragment = CommonDialogFragment.newInstance(bCommentContent.getText().toString(), CommonDialogFragment.DialogTypeComment);
|
|
163
|
CommonDialogFragment commonDialogFragment = CommonDialogFragment.newInstance(bCommentContent.getText().toString(), "优质评论会被优先展示", CommonDialogFragment.DialogTypeComment);
|
163
|
164
|
commonDialogFragment.show(getChildFragmentManager(), "CommonDialogFragment");
|
164
|
|
|
165
|
165
|
commonDialogFragment.setOnCommonDialogFragmentListener(new CommonDialogFragment.OnCommonDialogFragmentListener() {
|
166
|
166
|
@Override
|
167
|
167
|
public void updateComment(String comment) {
|
|
@ -223,6 +223,7 @@ public class ChatContentCommentListDialogFragment extends DialogFragment impleme
|
223
|
223
|
|
224
|
224
|
@Override
|
225
|
225
|
public void onResponse(String response) {
|
|
226
|
Log.d(TAG, "onResponse: " + response);
|
226
|
227
|
String code = JsonUtils.getKeyResult(response, "code");
|
227
|
228
|
String desc = JsonUtils.getKeyResult(response, "desc");
|
228
|
229
|
if ("1000".equals(code)) {
|
|
@ -233,6 +234,9 @@ public class ChatContentCommentListDialogFragment extends DialogFragment impleme
|
233
|
234
|
if (chatContentCommentListDialogFragmentListener != null) {
|
234
|
235
|
chatContentCommentListDialogFragmentListener.updateCommentNum(chatRecommendBean.commentNums);
|
235
|
236
|
}
|
|
237
|
} else if ("8010".equals(code)) {
|
|
238
|
startActivity(new Intent(getActivity().getApplicationContext(), LoginActivity.class));
|
|
239
|
ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
|
236
|
240
|
} else {
|
237
|
241
|
ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
|
238
|
242
|
}
|
|
@ -328,6 +332,7 @@ public class ChatContentCommentListDialogFragment extends DialogFragment impleme
|
328
|
332
|
private TextView replyLabel;
|
329
|
333
|
private ConstraintLayout replyAndDeleteView;
|
330
|
334
|
private TextView deleteComment;
|
|
335
|
private ConstraintLayout listItemView;
|
331
|
336
|
|
332
|
337
|
public CommentHolder(LayoutInflater layoutInflater, ViewGroup parent) {
|
333
|
338
|
super(layoutInflater.inflate(R.layout.list_item_comment, parent, false));
|
|
@ -348,13 +353,14 @@ public class ChatContentCommentListDialogFragment extends DialogFragment impleme
|
348
|
353
|
replyInfo = itemView.findViewById(R.id.replyInfo);
|
349
|
354
|
replyLabel = itemView.findViewById(R.id.replyLabel);
|
350
|
355
|
deleteComment = itemView.findViewById(R.id.deleteComment);
|
351
|
|
|
|
356
|
listItemView = itemView.findViewById(R.id.listItemView);
|
352
|
357
|
}
|
353
|
358
|
|
354
|
359
|
private void initListener() {
|
355
|
360
|
likeView.setOnClickListener(this);
|
356
|
361
|
replyInfo.setOnClickListener(this);
|
357
|
362
|
deleteComment.setOnClickListener(this);
|
|
363
|
listItemView.setOnClickListener(this);
|
358
|
364
|
}
|
359
|
365
|
|
360
|
366
|
@Override
|
|
@ -366,12 +372,10 @@ public class ChatContentCommentListDialogFragment extends DialogFragment impleme
|
366
|
372
|
case R.id.replyInfo: // 点击查看回复列表
|
367
|
373
|
break;
|
368
|
374
|
case R.id.deleteComment: // 删除评论操作
|
369
|
|
if (MainApplication.isLogin()) {
|
370
|
|
loginSign();
|
371
|
|
} else {
|
372
|
|
startActivity(new Intent(getActivity().getApplicationContext(), LoginActivity.class));
|
373
|
|
ToastUtil.showToast(getActivity().getApplicationContext(), "请先登录", Toast.LENGTH_SHORT);
|
374
|
|
}
|
|
375
|
deleteComment();
|
|
376
|
break;
|
|
377
|
case R.id.listItemView: // 回复
|
|
378
|
|
375
|
379
|
break;
|
376
|
380
|
}
|
377
|
381
|
}
|
|
@ -463,44 +467,19 @@ public class ChatContentCommentListDialogFragment extends DialogFragment impleme
|
463
|
467
|
});
|
464
|
468
|
}
|
465
|
469
|
|
466
|
|
// 服务器签名验证
|
467
|
|
private void loginSign() {
|
468
|
|
String url = MainApplication.urlNew + "/topic/sign.do";
|
469
|
|
final Map<String, String> map = new HashMap<>();
|
470
|
|
map.put("fileNames", "android");
|
471
|
|
map.put("targetType", ChatRecommendBean.TARGET_TYPE_IMAGE_TEXT + "");
|
472
|
|
CommonParams.addCommonParams(map);
|
473
|
|
|
474
|
|
OkHttpUtils.post().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
|
475
|
|
@Override
|
476
|
|
public void onError(Call call, Exception e) {
|
477
|
|
ToastUtil.showToast(getContext(), e.getMessage(), Toast.LENGTH_SHORT);
|
478
|
|
}
|
479
|
|
|
480
|
|
@Override
|
481
|
|
public void onResponse(String response) {
|
482
|
|
String code = JsonUtils.getKeyResult(response, "code");
|
483
|
|
String desc = JsonUtils.getKeyResult(response, "desc");
|
484
|
|
if ("1000".equals(code)) {
|
485
|
|
deleteComment();
|
486
|
|
} else if ("8010".equals(code)) {
|
487
|
|
startActivity(new Intent(getContext(), LoginActivity.class));
|
488
|
|
ToastUtil.showToast(getContext(), desc, Toast.LENGTH_LONG);
|
489
|
|
} else {
|
490
|
|
ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
|
491
|
|
}
|
492
|
|
}
|
493
|
|
});
|
494
|
|
}
|
495
|
|
|
496
|
470
|
private void deleteComment() {
|
|
471
|
if (!MainApplication.isLogin()) {
|
|
472
|
startActivity(new Intent(getActivity().getApplicationContext(), LoginActivity.class));
|
|
473
|
ToastUtil.showToast(getActivity().getApplicationContext(), "请先登录", Toast.LENGTH_SHORT);
|
|
474
|
return;
|
|
475
|
}
|
|
476
|
|
497
|
477
|
String url = MainApplication.urlNew + "/topic/del.do";
|
498
|
478
|
final Map<String, String> map = new HashMap<>();
|
499
|
479
|
map.put("targetId", bean.id + "");
|
500
|
480
|
map.put("targetType", "25");
|
501
|
481
|
map.put("userId", bean.userId + "");
|
502
|
482
|
CommonParams.addCommonParams(map);
|
503
|
|
|
504
|
483
|
OkHttpUtils.post().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
|
505
|
484
|
@Override
|
506
|
485
|
public void onError(Call call, Exception e) {
|
|
@ -521,6 +500,9 @@ public class ChatContentCommentListDialogFragment extends DialogFragment impleme
|
521
|
500
|
if (chatContentCommentListDialogFragmentListener != null) {
|
522
|
501
|
chatContentCommentListDialogFragmentListener.updateCommentNum(chatRecommendBean.commentNums);
|
523
|
502
|
}
|
|
503
|
} else if ("8010".equals(code)) {
|
|
504
|
startActivity(new Intent(getActivity().getApplicationContext(), LoginActivity.class));
|
|
505
|
ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
|
524
|
506
|
} else {
|
525
|
507
|
ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
|
526
|
508
|
}
|