huyuguo преди 5 години
родител
ревизия
5336ca560f

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

+ 22 - 40
app/src/main/java/com/electric/chargingpile/fragment/ChatContentCommentListDialogFragment.java

@ -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
                    }

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

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

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

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