huyuguo vor 5 Jahren
Ursprung
Commit
148e65f9d2

+ 1 - 0
app/build.gradle

@ -286,4 +286,5 @@ dependencies {
286 286
287 287
    compile 'com.shuyu:GSYVideoPlayer:5.0.2'
288 288
    compile 'com.github.chrisbanes:PhotoView:2.0.0'
289
    compile 'com.wang.avi:library:2.1.3'
289 290
}

+ 5 - 49
app/src/main/java/com/electric/chargingpile/activity/ChatContentListActivity.java

@ -135,17 +135,6 @@ public class ChatContentListActivity extends AppCompatActivity {
135 135
        GSYVideoManager.releaseAllVideos();
136 136
    }
137 137
138
    @Override
139
    public void onBackPressed() {
140
        final ChatContentFragment chatContentFragment = (ChatContentFragment) chatContentAdapter.map.get(chatContentPosition + "");
141
        if (chatContentFragment.allCommentsContainer.getVisibility() == View.GONE) {
142
            finish();
143
        } else {
144
            chatContentFragment.allCommentsContainer.setVisibility(View.GONE);
145
        }
146
147
    }
148
149 138
    private void initView() {
150 139
        isFirstPlay = true;
151 140
        screenWidth = ScreenUtils.getScreenWidth(ChatContentListActivity.this);
@ -287,15 +276,11 @@ public class ChatContentListActivity extends AppCompatActivity {
287 276
        private ConstraintLayout userInfo;
288 277
        private ConstraintLayout statusBar;
289 278
        private TextView commentNumber;
290
        private ConstraintLayout allComments;
291
        public ConstraintLayout allCommentsContainer;
292 279
        private ViewPager photoPager;
293 280
        private ConstraintLayout bottomView;
294 281
        private TextView navTitle;
295 282
        private List<ChatPhotoFragment> chatPhotoFragments;
296 283
        private ChatPhotoFragmentPagerAdapter chatPhotoFragmentPagerAdapter;
297
        private TextView bCommentContent;
298
        private TextView bPublish;
299 284
300 285
        public static ChatContentFragment newInstance(int index, String from) {
301 286
            ChatContentFragment fragment = new ChatContentFragment();
@ -410,10 +395,6 @@ public class ChatContentListActivity extends AppCompatActivity {
410 395
            rootView.findViewById(R.id.bottomView).setOnClickListener(this);
411 396
            rootView.findViewById(R.id.writeComment).setOnClickListener(this);
412 397
            rootView.findViewById(R.id.comment).setOnClickListener(this);
413
            allCommentsContainer.setOnClickListener(this);
414
            allComments.setOnClickListener(this);
415
            rootView.findViewById(R.id.allCommentsClose).setOnClickListener(this);
416
            rootView.findViewById(R.id.bWriteComment).setOnClickListener(this);
417 398
        }
418 399
419 400
        @Override
@ -461,30 +442,8 @@ public class ChatContentListActivity extends AppCompatActivity {
461 442
                    dialogFragment.show(getChildFragmentManager(), "评论列表");
462 443
                    break;
463 444
                case R.id.allCommentsClose: // 关闭评论
464
                case R.id.allCommentsContainer:
465
                    setViewPagerScroll(true);
466
                    allCommentsContainer.setVisibility(View.GONE);
467
                    break;
468
                case R.id.bWriteComment: // 写评论
469
                    CommonDialogFragment commonDialogFragment = CommonDialogFragment.newInstance(bCommentContent.getText().toString());
470
                    commonDialogFragment.show(getChildFragmentManager(), "CommonDialogFragment");
471
472
                    commonDialogFragment.setOnCommonDialogFragmentListener(new CommonDialogFragment.OnCommonDialogFragmentListener() {
473
                        @Override
474
                        public void updateComment(String comment) {
475
                            bCommentContent.setText(comment);
476
                            if (comment.length() > 0) {
477
                                bPublish.setTextColor(Color.parseColor("#00EDB2"));
478
                            } else {
479
                                bPublish.setTextColor(Color.parseColor("#7e7e7e"));
480
                            }
481
                        }
482
483
                        @Override
484
                        public void publish() {
485
                            Log.d(TAG, "publish: xxxxxxxxxxxxxx");
486
                        }
487
                    });
445
//                    setViewPagerScroll(true);
446
//                    allCommentsContainer.setVisibility(View.GONE);
488 447
                    break;
489 448
            }
490 449
        }
@ -518,10 +477,7 @@ public class ChatContentListActivity extends AppCompatActivity {
518 477
            userInfo = rootView.findViewById(R.id.userInfo);
519 478
            commentNumber = rootView.findViewById(R.id.commentNumber);
520 479
521
            allCommentsContainer = rootView.findViewById(R.id.allCommentsContainer);
522
            allComments = rootView.findViewById(R.id.allComments);
523
            bCommentContent = rootView.findViewById(R.id.bCommentContent);
524
            bPublish = rootView.findViewById(R.id.bPublish);
480
525 481
526 482
            ConstraintLayout.LayoutParams statusBarParams = (ConstraintLayout.LayoutParams) statusBar.getLayoutParams();
527 483
            statusBarParams.height = statusBarHeight;
@ -564,7 +520,7 @@ public class ChatContentListActivity extends AppCompatActivity {
564 520
                        .into(headImage);
565 521
            }
566 522
567
            nickName.setText(bean.nickName);
523
            nickName.setText(bean.nickName + " " + bean.carSeriesName);
568 524
            addDate.setText(bean.addDate);
569 525
570 526
@ -579,7 +535,7 @@ public class ChatContentListActivity extends AppCompatActivity {
579 535
            if (bean.commentNums == 0) {
580 536
                commentNumber.setText("");
581 537
            } else {
582
                commentNumber.setText(bean.commentNums + "");
538
                commentNumber.setText(bean.commentNums < 10000 ? bean.commentNums + "" : String.format("%.1fW",bean.commentNums/10000f));
583 539
            }
584 540
        }
585 541

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

+ 2 - 0
app/src/main/java/com/electric/chargingpile/data/ChatRecommendBean.java

@ -23,6 +23,7 @@ public class ChatRecommendBean implements Serializable {
23 23
    public List<String> imgUrls;
24 24
    public String headImgUrl;
25 25
    public String nickName;
26
    public String carSeriesName;
26 27
    public String topicName;
27 28
    public String content;
28 29
    public String shareUrl;
@ -52,6 +53,7 @@ public class ChatRecommendBean implements Serializable {
52 53
                ", imgUrls=" + imgUrls +
53 54
                ", headImgUrl='" + headImgUrl + '\'' +
54 55
                ", nickName='" + nickName + '\'' +
56
                ", carSeriesName='" + carSeriesName + '\'' +
55 57
                ", topicName='" + topicName + '\'' +
56 58
                ", content='" + content + '\'' +
57 59
                ", shareUrl='" + shareUrl + '\'' +

+ 165 - 4
app/src/main/java/com/electric/chargingpile/fragment/ChatContentCommentListDialogFragment.java

@ -1,23 +1,58 @@
1 1
package com.electric.chargingpile.fragment;
2 2
3 3
import android.app.Dialog;
4
import android.graphics.Color;
4 5
import android.os.Bundle;
5 6
import android.support.annotation.NonNull;
6 7
import android.support.annotation.Nullable;
8
import android.support.constraint.ConstraintLayout;
7 9
import android.support.v4.app.DialogFragment;
10
import android.support.v7.widget.LinearLayoutManager;
11
import android.support.v7.widget.RecyclerView;
12
import android.support.v7.widget.SimpleItemAnimator;
13
import android.util.Log;
8 14
import android.view.Gravity;
9 15
import android.view.LayoutInflater;
10 16
import android.view.View;
11 17
import android.view.ViewGroup;
12 18
import android.view.Window;
13 19
import android.view.WindowManager;
20
import android.widget.TextView;
21
import android.widget.Toast;
14 22
23
import com.andview.refreshview.XRefreshView;
15 24
import com.electric.chargingpile.R;
25
import com.electric.chargingpile.activity.UserPageActivity;
26
import com.electric.chargingpile.application.MainApplication;
16 27
import com.electric.chargingpile.data.ChatRecommendBean;
28
import com.electric.chargingpile.data.UserHomePageBean;
29
import com.electric.chargingpile.util.CommonParams;
30
import com.electric.chargingpile.util.JsonUtils;
31
import com.electric.chargingpile.util.ToastUtil;
32
import com.electric.chargingpile.view.CircleProgressBar;
33
import com.wang.avi.AVLoadingIndicatorView;
34
import com.zhy.http.okhttp.OkHttpUtils;
35
import com.zhy.http.okhttp.callback.StringCallback;
17 36
18
public class ChatContentCommentListDialogFragment extends DialogFragment {
37
import java.util.HashMap;
38
import java.util.Map;
39
40
import okhttp3.Call;
41
42
public class ChatContentCommentListDialogFragment extends DialogFragment implements View.OnClickListener {
43
    private static final String TAG = "ChatContentCommentListDialogFragment";
19 44
    private static final String ARG_BEAN = "bean";
20 45
    private ChatRecommendBean bean;
46
    private ConstraintLayout allComments;
47
    private TextView bCommentContent;
48
    private TextView bPublish;
49
    private Dialog dialog;
50
    private TextView allCommentTitle;
51
52
    private int page = 1;
53
    private AVLoadingIndicatorView loadingIndicator;
54
    private XRefreshView xRefreshView;
55
    private RecyclerView recyclerView;
21 56
22 57
    public static ChatContentCommentListDialogFragment newInstance(ChatRecommendBean bean) {
23 58
        Bundle args = new Bundle();
@ -30,7 +65,7 @@ public class ChatContentCommentListDialogFragment extends DialogFragment {
30 65
    @NonNull
31 66
    @Override
32 67
    public Dialog onCreateDialog(Bundle savedInstanceState) {
33
        Dialog dialog = new Dialog(getActivity(), R.style.CommentDialog);
68
        dialog = new Dialog(getActivity(), R.style.CommentDialog);
34 69
        // 外部点击设置为可取消
35 70
        dialog.setCancelable(true);
36 71
        dialog.setCanceledOnTouchOutside(true);
@ -46,12 +81,138 @@ public class ChatContentCommentListDialogFragment extends DialogFragment {
46 81
        layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
47 82
        window.setAttributes(layoutParams);
48 83
49
        initDialog(dialog);
84
        initDialog();
85
        initListener();
50 86
        return dialog;
51 87
    }
52 88
53 89
54
    private void initDialog(Dialog dialog) {
90
    private void initDialog() {
55 91
        bean = (ChatRecommendBean) getArguments().getSerializable(ARG_BEAN);
92
93
        allComments = dialog.findViewById(R.id.allComments);
94
        bCommentContent = dialog.findViewById(R.id.bCommentContent);
95
        bPublish = dialog.findViewById(R.id.bPublish);
96
        allCommentTitle = dialog.findViewById(R.id.allCommentTitle);
97
        loadingIndicator = dialog.findViewById(R.id.loadingIndicator);
98
        loadingIndicator.show();
99
        xRefreshView = dialog.findViewById(R.id.xRefreshView);
100
        recyclerView = dialog.findViewById(R.id.recyclerView);
101
        recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
102
        ((SimpleItemAnimator)recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
103
104
        allCommentTitle.setText("全部评论 " + bean.commentNums );
105
        requestData();
56 106
    }
107
108
    private void initListener() {
109
        allComments.setOnClickListener(this);
110
        dialog.findViewById(R.id.allCommentsClose).setOnClickListener(this);
111
        dialog.findViewById(R.id.bWriteComment).setOnClickListener(this);
112
    }
113
114
    @Override
115
    public void onClick(View view) {
116
        switch (view.getId()) {
117
            case R.id.bWriteComment: // 写评论
118
                CommonDialogFragment commonDialogFragment = CommonDialogFragment.newInstance(bCommentContent.getText().toString());
119
                commonDialogFragment.show(getChildFragmentManager(), "CommonDialogFragment");
120
121
                commonDialogFragment.setOnCommonDialogFragmentListener(new CommonDialogFragment.OnCommonDialogFragmentListener() {
122
                    @Override
123
                    public void updateComment(String comment) {
124
                        bCommentContent.setText(comment);
125
                        if (comment.length() > 0) {
126
                            bPublish.setTextColor(Color.parseColor("#00EDB2"));
127
                        } else {
128
                            bPublish.setTextColor(Color.parseColor("#7e7e7e"));
129
                        }
130
                    }
131
132
                    @Override
133
                    public void publish() {
134
                    }
135
                });
136
                break;
137
            case R.id.allCommentsClose:
138
                dialog.dismiss();
139
                break;
140
        }
141
    }
142
143
    private void requestData() {
144
        String url = MainApplication.urlNew + "/topic/comments/list.do";
145
        Map<String, String> map = new HashMap<>();
146
        map.put("page", page + "");
147
        map.put("limit", "20");
148
        map.put("targetId", bean.targetId + "");
149
        map.put("targetType", bean.targetType + "");
150
        if (page== 1) {
151
            map.put("commentsId", "0");
152
        } else {
153
            // TODO
154
        }
155
156
        CommonParams.addCommonParams(map);
157
158
        Log.d(TAG, "requestData: " + url);
159
        Log.d(TAG, "requestData: " + map);
160
        OkHttpUtils.get().url(url).params(map).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
161
            @Override
162
            public void onError(Call call, Exception e) {
163
                if (page == 1) {
164
                    xRefreshView.stopRefresh();
165
                } else {
166
                    page--;
167
                    xRefreshView.stopLoadMore();
168
                }
169
                ToastUtil.showToast(getContext(), "加载失败,请重试", Toast.LENGTH_SHORT);
170
            }
171
172
            @Override
173
            public void onResponse(String s) {
174
                String code = JsonUtils.getKeyResult(s, "code");
175
                Log.d(TAG, "onResponse: " + s);
176
                if ("1000".equals(code)) {
177
                    String data = JsonUtils.getKeyResult(s, "data");
178
//                    UserHomePageBean userHomePageBean = (UserHomePageBean) JsonUtils.parseToObjectBean(data, UserHomePageBean.class);
179
                    if (page == 1) {
180
                        xRefreshView.setLoadComplete(false);
181
//                        userVo = userHomePageBean.userVo;
182
//                        updateTopView();
183
//                        if (userHomePageBean.list.size() == 0) {
184
//                            zeroTopicNum.setVisibility(View.VISIBLE);
185
//                            xRefreshView.setLoadComplete(true);
186
//                        } else {
187
//                            zeroTopicNum.setVisibility(View.GONE);
188
//                            userPageAdapter.setContentData(userHomePageBean.list);
189
//                        }
190
//                        userPageAdapter.setFooterData(false);
191
                        xRefreshView.stopRefresh();
192
                    } else {
193
//                        if (userHomePageBean.list.size() == 0) {
194
//                            xRefreshView.setLoadComplete(true);
195
////                            userPageAdapter.setFooterData(true);
196
//                        } else {
197
//                            userPageAdapter.addContentData(userHomePageBean.list);
198
//                            userPageAdapter.setFooterData(false);
199
//                        }
200
                        xRefreshView.stopLoadMore();
201
                    }
202
                } else {
203
                    String desc = JsonUtils.getKeyResult(s, "desc");
204
                    ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
205
                    if (page == 1) {
206
                        xRefreshView.stopRefresh();
207
                    } else {
208
                        page--;
209
                        xRefreshView.stopLoadMore();
210
                    }
211
                }
212
213
            }
214
        });
215
    }
216
217
//    private class CommentAdapter extends RecyclerView.Adapter
57 218
}

+ 67 - 14
app/src/main/res/layout/fragment_chat_content_comment_list.xml

@ -1,6 +1,5 @@
1 1
<?xml version="1.0" encoding="utf-8"?>
2 2
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    android:id="@+id/allCommentsContainer"
4 3
    xmlns:app="http://schemas.android.com/apk/res-auto"
5 4
    xmlns:tools="http://schemas.android.com/tools"
6 5
    android:layout_width="match_parent"
@ -16,38 +15,92 @@
16 15
        app:layout_constraintLeft_toLeftOf="parent"
17 16
        app:layout_constraintRight_toRightOf="parent">
18 17
19
18
        <!-- 标题栏-->
20 19
        <android.support.constraint.ConstraintLayout
20
            android:id="@+id/titleView"
21 21
            android:layout_width="match_parent"
22 22
            android:layout_height="40dp"
23 23
            app:layout_constraintTop_toTopOf="parent">
24
24 25
            <TextView
25 26
                android:id="@+id/allCommentTitle"
26
                tools:text="全部评论 12"
27
                app:layout_constraintTop_toTopOf="parent"
28
                app:layout_constraintBottom_toBottomOf="parent"
27
                android:layout_width="match_parent"
28
                android:layout_height="wrap_content"
29 29
                android:gravity="center_horizontal"
30
                android:textSize="14sp"
31 30
                android:textColor="#c2c2c2"
32
                android:layout_width="match_parent"
33
                android:layout_height="wrap_content" />
31
                android:textSize="14sp"
32
                app:layout_constraintBottom_toBottomOf="parent"
33
                app:layout_constraintTop_toTopOf="parent"
34
                tools:text="全部评论 12" />
35
34 36
            <ImageView
35 37
                android:id="@+id/allCommentsClose"
36
                android:src="@drawable/icon_close"
37
                android:scaleType="center"
38
                app:layout_constraintRight_toRightOf="parent"
39 38
                android:layout_width="45dp"
40
                android:layout_height="match_parent" />
39
                android:layout_height="match_parent"
40
                android:scaleType="center"
41
                android:src="@drawable/icon_close"
42
                app:layout_constraintRight_toRightOf="parent" />
41 43
42 44
            <View
43
                android:background="#505050"
44 45
                android:layout_width="match_parent"
45 46
                android:layout_height="1dp"
47
                android:background="#505050"
46 48
                app:layout_constraintBottom_toBottomOf="parent" />
47 49
        </android.support.constraint.ConstraintLayout>
48 50
51
        <!-- 内容部分 -->
52
        <android.support.constraint.ConstraintLayout
53
            android:layout_width="match_parent"
54
            android:layout_height="wrap_content"
55
            android:minHeight="386dp"
56
            app:layout_constraintBottom_toTopOf="@+id/bottomView"
57
            app:layout_constraintTop_toBottomOf="@+id/titleView">
58
59
            <com.andview.refreshview.XRefreshView
60
                android:id="@+id/xRefreshView"
61
                android:layout_width="match_parent"
62
                android:layout_height="match_parent">
63
64
                <android.support.v7.widget.RecyclerView
65
                    android:id="@+id/recyclerView"
66
                    android:layout_width="match_parent"
67
                    android:layout_height="match_parent">
68
69
                </android.support.v7.widget.RecyclerView>
70
            </com.andview.refreshview.XRefreshView>
71
72
            <android.support.constraint.ConstraintLayout
73
                android:id="@+id/loadingView"
74
                android:layout_width="match_parent"
75
                android:layout_height="match_parent">
76
77
                <com.wang.avi.AVLoadingIndicatorView
78
                    android:id="@+id/loadingIndicator"
79
                    android:layout_width="wrap_content"
80
                    android:layout_height="wrap_content"
81
                    android:layout_marginTop="80dp"
82
                    app:indicatorName="BallClipRotatePulseIndicator"
83
                    app:layout_constraintLeft_toLeftOf="parent"
84
                    app:layout_constraintRight_toRightOf="parent"
85
                    app:layout_constraintTop_toTopOf="parent" />
86
87
                <TextView
88
                    android:id="@+id/textView37"
89
                    android:layout_width="wrap_content"
90
                    android:layout_height="wrap_content"
91
                    android:layout_marginTop="20dp"
92
                    android:text="小主正在为您努力加载,请耐心等待~"
93
                    android:textColor="#ffffff"
94
                    android:textSize="14sp"
95
                    app:layout_constraintEnd_toEndOf="parent"
96
                    app:layout_constraintStart_toStartOf="parent"
97
                    app:layout_constraintTop_toBottomOf="@+id/loadingIndicator" />
98
            </android.support.constraint.ConstraintLayout>
99
        </android.support.constraint.ConstraintLayout>
100
49 101
        <!-- 底部评论输入及发布 -->
50 102
        <android.support.constraint.ConstraintLayout
103
            android:id="@+id/bottomView"
51 104
            android:layout_width="match_parent"
52 105
            android:layout_height="54dp"
53 106
            android:background="#535353"
@ -83,9 +136,9 @@
83 136
                    android:layout_height="wrap_content"
84 137
                    android:ellipsize="end"
85 138
                    android:gravity="center_vertical"
86
                    android:paddingLeft="5dp"
87 139
                    android:hint="写评论"
88 140
                    android:maxLines="1"
141
                    android:paddingLeft="5dp"
89 142
                    android:textColor="#ffffff"
90 143
                    android:textColorHint="#c2c2c2"
91 144
                    android:textSize="14sp"

+ 0 - 9
app/src/main/res/layout/fragment_chat_content_pictures.xml

@ -362,13 +362,4 @@
362 362
        </android.support.constraint.ConstraintLayout>
363 363
364 364
    </android.support.constraint.ConstraintLayout>
365
366
    <include
367
        layout="@layout/fragment_chat_content_comment_list"
368
        android:visibility="gone" />
369
    <FrameLayout
370
        android:id="@+id/fragment_container"
371
        android:layout_width="match_parent"
372
        android:layout_height="match_parent">
373
    </FrameLayout>
374 365
</android.support.constraint.ConstraintLayout>

+ 0 - 8
app/src/main/res/layout/fragment_chat_content_video.xml

@ -379,12 +379,4 @@
379 379
380 380
    </android.support.constraint.ConstraintLayout>
381 381
382
    <include
383
        layout="@layout/fragment_chat_content_comment_list"
384
        android:visibility="gone" />
385
    <FrameLayout
386
        android:id="@+id/fragment_container"
387
        android:layout_width="match_parent"
388
        android:layout_height="match_parent">
389
    </FrameLayout>
390 382
</android.support.constraint.ConstraintLayout>

+ 1 - 0
app/src/main/res/values/styles.xml

@ -17,6 +17,7 @@
17 17
        <item name="android:layout_width">match_parent</item>
18 18
        <item name="android:layout_height">wrap_content</item>
19 19
        <item name="android:windowIsFloating">true</item>
20
        <item name="android:windowSoftInputMode">stateAlwaysHidden</item><!--显示软件盘-->
20 21
    </style>
21 22

22 23
    <style name="actionBarTheme" parent="ThemeOverlay.AppCompat.Dark.ActionBar">