huyuguo 5 年 前
コミット
5336ca560f

+ 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";

+ 22 - 40
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;
67
68
68
    public static ChatContentCommentListDialogFragment newInstance(ChatRecommendBean bean) {
69
    public static ChatContentCommentListDialogFragment newInstance(ChatRecommendBean bean) {
69
        Bundle args = new Bundle();
70
        Bundle args = new Bundle();
159
    public void onClick(View view) {
160
    public void onClick(View view) {
160
        switch (view.getId()) {
161
        switch (view.getId()) {
161
            case R.id.bWriteComment: // 写评论
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
                commonDialogFragment.show(getChildFragmentManager(), "CommonDialogFragment");
164
                commonDialogFragment.show(getChildFragmentManager(), "CommonDialogFragment");
164
165
                commonDialogFragment.setOnCommonDialogFragmentListener(new CommonDialogFragment.OnCommonDialogFragmentListener() {
165
                commonDialogFragment.setOnCommonDialogFragmentListener(new CommonDialogFragment.OnCommonDialogFragmentListener() {
166
                    @Override
166
                    @Override
167
                    public void updateComment(String comment) {
167
                    public void updateComment(String comment) {
223
223
224
            @Override
224
            @Override
225
            public void onResponse(String response) {
225
            public void onResponse(String response) {
226
                Log.d(TAG, "onResponse: " + response);
226
                String code = JsonUtils.getKeyResult(response, "code");
227
                String code = JsonUtils.getKeyResult(response, "code");
227
                String desc = JsonUtils.getKeyResult(response, "desc");
228
                String desc = JsonUtils.getKeyResult(response, "desc");
228
                if ("1000".equals(code)) {
229
                if ("1000".equals(code)) {
233
                    if (chatContentCommentListDialogFragmentListener != null) {
234
                    if (chatContentCommentListDialogFragmentListener != null) {
234
                        chatContentCommentListDialogFragmentListener.updateCommentNum(chatRecommendBean.commentNums);
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
                } else {
240
                } else {
237
                    ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
241
                    ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
238
                }
242
                }
328
        private TextView replyLabel;
332
        private TextView replyLabel;
329
        private ConstraintLayout replyAndDeleteView;
333
        private ConstraintLayout replyAndDeleteView;
330
        private TextView deleteComment;
334
        private TextView deleteComment;
335
        private ConstraintLayout listItemView;
331
336
332
        public CommentHolder(LayoutInflater layoutInflater, ViewGroup parent) {
337
        public CommentHolder(LayoutInflater layoutInflater, ViewGroup parent) {
333
            super(layoutInflater.inflate(R.layout.list_item_comment, parent, false));
338
            super(layoutInflater.inflate(R.layout.list_item_comment, parent, false));
348
            replyInfo = itemView.findViewById(R.id.replyInfo);
353
            replyInfo = itemView.findViewById(R.id.replyInfo);
349
            replyLabel = itemView.findViewById(R.id.replyLabel);
354
            replyLabel = itemView.findViewById(R.id.replyLabel);
350
            deleteComment = itemView.findViewById(R.id.deleteComment);
355
            deleteComment = itemView.findViewById(R.id.deleteComment);
351
356
            listItemView = itemView.findViewById(R.id.listItemView);
352
        }
357
        }
353
358
354
        private void initListener() {
359
        private void initListener() {
355
            likeView.setOnClickListener(this);
360
            likeView.setOnClickListener(this);
356
            replyInfo.setOnClickListener(this);
361
            replyInfo.setOnClickListener(this);
357
            deleteComment.setOnClickListener(this);
362
            deleteComment.setOnClickListener(this);
363
            listItemView.setOnClickListener(this);
358
        }
364
        }
359
365
360
        @Override
366
        @Override
366
                case R.id.replyInfo: //  点击查看回复列表
372
                case R.id.replyInfo: //  点击查看回复列表
367
                    break;
373
                    break;
368
                case R.id.deleteComment: // 删除评论操作
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
                    break;
379
                    break;
376
            }
380
            }
377
        }
381
        }
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
        private void deleteComment() {
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
            String url = MainApplication.urlNew + "/topic/del.do";
477
            String url = MainApplication.urlNew + "/topic/del.do";
498
            final Map<String, String> map = new HashMap<>();
478
            final Map<String, String> map = new HashMap<>();
499
            map.put("targetId", bean.id + "");
479
            map.put("targetId", bean.id + "");
500
            map.put("targetType", "25");
480
            map.put("targetType", "25");
501
            map.put("userId", bean.userId + "");
481
            map.put("userId", bean.userId + "");
502
            CommonParams.addCommonParams(map);
482
            CommonParams.addCommonParams(map);
503
504
            OkHttpUtils.post().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
483
            OkHttpUtils.post().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
505
                @Override
484
                @Override
506
                public void onError(Call call, Exception e) {
485
                public void onError(Call call, Exception e) {
521
                        if (chatContentCommentListDialogFragmentListener != null) {
500
                        if (chatContentCommentListDialogFragmentListener != null) {
522
                            chatContentCommentListDialogFragmentListener.updateCommentNum(chatRecommendBean.commentNums);
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
                    } else {
506
                    } else {
525
                        ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
507
                        ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
526
                    }
508
                    }

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

7
import android.support.v4.app.DialogFragment;
7
import android.support.v4.app.DialogFragment;
8
import android.text.Editable;
8
import android.text.Editable;
9
import android.text.TextWatcher;
9
import android.text.TextWatcher;
10
import android.util.Log;
11
import android.view.Gravity;
10
import android.view.Gravity;
12
import android.view.View;
11
import android.view.View;
13
import android.view.Window;
12
import android.view.Window;
27
26
28
    private static final String TAG = "CommonDialogFragment";
27
    private static final String TAG = "CommonDialogFragment";
29
    private static final String ARG_COMMENT = "comment";
28
    private static final String ARG_COMMENT = "comment";
29
    private static final String ARG_HINT = "hint";
30
    private static final String ARG_TYPE = "type";
30
    private static final String ARG_TYPE = "type";
31
    private Dialog dialogFragment;
31
    private Dialog dialogFragment;
32
    private String type;
32
    private String type;
37
    private ConstraintLayout countInfo;
37
    private ConstraintLayout countInfo;
38
    private TextView count;
38
    private TextView count;
39
39
40
    public static CommonDialogFragment newInstance(String comment, String type) {
40
    public static CommonDialogFragment newInstance(String comment,String hint, String type) {
41
        CommonDialogFragment dialogFragment = new CommonDialogFragment();
41
        CommonDialogFragment dialogFragment = new CommonDialogFragment();
42
        Bundle args = new Bundle();
42
        Bundle args = new Bundle();
43
        args.putString(ARG_COMMENT, comment);
43
        args.putString(ARG_COMMENT, comment);
44
        args.putString(ARG_HINT, hint);
44
        args.putString(ARG_TYPE, type);
45
        args.putString(ARG_TYPE, type);
45
        dialogFragment.setArguments(args);
46
        dialogFragment.setArguments(args);
46
        return dialogFragment;
47
        return dialogFragment;
49
    @Override
50
    @Override
50
    public Dialog onCreateDialog(Bundle savedInstanceState) {
51
    public Dialog onCreateDialog(Bundle savedInstanceState) {
51
        final String comment = getArguments().getString(ARG_COMMENT);
52
        final String comment = getArguments().getString(ARG_COMMENT);
53
        final String hint = getArguments().getString(ARG_HINT);
54
        type = getArguments().getString(ARG_TYPE);
55
52
        dialogFragment = new Dialog(getActivity(), R.style.BottomDialog);
56
        dialogFragment = new Dialog(getActivity(), R.style.BottomDialog);
53
        // 外部点击设置为可取消
57
        // 外部点击设置为可取消
54
        dialogFragment.setCancelable(true);
58
        dialogFragment.setCancelable(true);
73
77
74
        editText.setText(comment);
78
        editText.setText(comment);
75
        editText.setSelection(comment.length());
79
        editText.setSelection(comment.length());
76
80
        editText.setHint(hint);
77
        updateView(comment);
81
        updateView(comment);
78
82
79
        send.setOnClickListener(new View.OnClickListener() {
83
        send.setOnClickListener(new View.OnClickListener() {

+ 2 - 1
app/src/main/res/layout/list_item_comment.xml

2
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
2
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    xmlns:app="http://schemas.android.com/apk/res-auto"
3
    xmlns:app="http://schemas.android.com/apk/res-auto"
4
    xmlns:tools="http://schemas.android.com/tools"
4
    xmlns:tools="http://schemas.android.com/tools"
5
    android:id="@+id/listItemView"
5
    android:layout_width="match_parent"
6
    android:layout_width="match_parent"
6
    android:layout_height="wrap_content"
7
    android:layout_height="wrap_content"
7
    tools:background="#424242">
8
    tools:background="#424242">
98
        android:layout_width="wrap_content"
99
        android:layout_width="wrap_content"
99
        android:layout_height="42dp"
100
        android:layout_height="42dp"
100
        android:paddingLeft="29dp"
101
        android:paddingLeft="29dp"
101
        app:layout_constraintLeft_toLeftOf="parent"
102
        app:layout_constraintBottom_toBottomOf="parent"
102
        app:layout_constraintBottom_toBottomOf="parent"
103
        app:layout_constraintLeft_toLeftOf="parent"
103
        app:layout_constraintTop_toBottomOf="@+id/content"
104
        app:layout_constraintTop_toBottomOf="@+id/content"
104
        tools:background="#06648f">
105
        tools:background="#06648f">
105
106