Просмотр исходного кода

add topic details http request

1145873331@qq.com лет назад: 6
Родитель
Сommit
05b76f50ac

+ 0 - 4
app/src/main/java/com/electric/chargingpile/activity/TalkActivity.java

@ -88,10 +88,6 @@ public class TalkActivity extends AppCompatActivity implements View.OnClickListe
88 88
        isRefresh = true;
89 89
        MobclickAgent.onEvent(getApplicationContext(),"0071");
90 90
        setBackground(0);
91
92
93
        VideoCommentDialog videoPubilshDialog = new VideoCommentDialog(this);
94
        videoPubilshDialog.show();
95 91
    }
96 92
97 93
    private void initViews(){

+ 24 - 9
app/src/main/java/com/electric/chargingpile/activity/VideoDetaislActivity.java

@ -24,9 +24,17 @@ public class VideoDetaislActivity extends Activity implements View.OnClickListen
24 24
    private SvVideoPagerAdapter viewPagerAdapter;
25 25
    private SvVideoShowView videoShowView;
26 26
27
    private boolean isFirst = true, isChange = false;
28
27 29
    private MyHandler mHandler = new MyHandler(this);
28 30
29 31
32
33
    int position = 0;
34
    List<TalkRecommendBean> talkRecommendBeans;
35
36
37
30 38
    static class MyHandler extends Handler {
31 39
        private WeakReference<VideoDetaislActivity> mWeakReference;
32 40
@ -58,11 +66,20 @@ public class VideoDetaislActivity extends Activity implements View.OnClickListen
58 66
59 67
            @Override
60 68
            public void onPageSelected(int position) {
61
69
                if (!isChange) {
70
                    isChange = true;
71
                }
62 72
            }
63 73
64 74
            @Override
65 75
            public void onPageScrollStateChanged(int state) {
76
                if (state == ViewPager.SCROLL_STATE_IDLE && isChange) {
77
                    isChange = false;
78
                    if (videoShowView != null) {
79
                        videoShowView.onDestroy();
80
                    }
81
                    initPlayByPostion(talkRecommendBeans, pager_video.getCurrentItem(), false);
82
                }
66 83
67 84
            }
68 85
        });
@ -78,16 +95,11 @@ public class VideoDetaislActivity extends Activity implements View.OnClickListen
78 95
            case R.id.vd_title_dot:
79 96
                break;
80 97
            case R.id.vd_title_back:
81
                VideoPubilshDialog videoPubilshDialog = new VideoPubilshDialog(this);
82
                videoPubilshDialog.show();
98
                finish();
83 99
                break;
84 100
        }
85 101
    }
86 102
87
88
    int position = 0;
89
    List<TalkRecommendBean> talkRecommendBeans;
90
91 103
    private void addIntentInfo() {
92 104
        position = getIntent().getIntExtra("pos", 0);
93 105
        talkRecommendBeans = (List<TalkRecommendBean>) getIntent().getSerializableExtra("list");
@ -96,7 +108,10 @@ public class VideoDetaislActivity extends Activity implements View.OnClickListen
96 108
        viewPagerAdapter.setInitViewListener(new SvVideoPagerAdapter.InitViewListener() {
97 109
            @Override
98 110
            public void initFirstViewAfter() {
99
                initPlayByPostion(talkRecommendBeans, position, true);
111
                if (isFirst) {
112
                    isFirst = false;
113
                    initPlayByPostion(talkRecommendBeans, position, true);
114
                }
100 115
            }
101 116
        });
102 117
    }
@ -113,7 +128,7 @@ public class VideoDetaislActivity extends Activity implements View.OnClickListen
113 128
                            videoShowView.setInfo(videoInfos.get(position));
114 129
                        }
115 130
                    }
116
                    videoShowView.updateView();
131
                    videoShowView.updateView(position, videoInfos.get(position));
117 132
                    videoShowView.initAndPlay();
118 133
                }
119 134
            }, 100);

+ 21 - 11
app/src/main/java/com/electric/chargingpile/adapter/VideoCommentAdapter.java

@ -12,6 +12,7 @@ import android.widget.TextView;
12 12
import com.bumptech.glide.Glide;
13 13
import com.bumptech.glide.request.RequestOptions;
14 14
import com.electric.chargingpile.R;
15
import com.electric.chargingpile.application.MainApplication;
15 16
import com.electric.chargingpile.base.RecyclerViewHolder;
16 17
import com.electric.chargingpile.data.FindData;
17 18
import com.electric.chargingpile.data.VideoCommentBean;
@ -40,7 +41,7 @@ public class VideoCommentAdapter extends RecyclerView.Adapter<VideoCommentAdapte
40 41
    @Override
41 42
    public void onBindViewHolder(@NonNull VideoCommentViewHolder viewHolder, int position) {
42 43
        VideoCommentBean videoCommentBean = dataList.get(position);
43
        int likeFlg = videoCommentBean.getLikeFlg();
44
        int likeFlg = videoCommentBean.likeFlg;
44 45
        if (likeFlg == 0) {
45 46
            //not zan
46 47
//            viewHolder.mItemUserLikeImg = (ImageView) itemView.findViewById(R.id.item_user_like_img);
@ -48,22 +49,31 @@ public class VideoCommentAdapter extends RecyclerView.Adapter<VideoCommentAdapte
48 49
            // zan
49 50
        }
50 51
51
        viewHolder.mItemUserLikeCount.setText(videoCommentBean.getLikeNums() + "");
52
        viewHolder.mItemUserLikeCount.setText(videoCommentBean.likeNums + "");
52 53
53 54
54
        Glide.with(context).load(videoCommentBean.getHeadImgFromUser())
55
        Glide.with(context).load(videoCommentBean.headImgFromUser)
55 56
                .transition(withCrossFade()).into(viewHolder.mItemUserAvatar);
56 57
57
        viewHolder.mItemUserName.setText(videoCommentBean.getNickNameFromUser());
58
        viewHolder.mItemUserName.setText(videoCommentBean.nickNameFromUser);
58 59
59
        viewHolder.mItemUserTime.setText(videoCommentBean.getAddDate());
60
        viewHolder.mItemUserCon.setText(videoCommentBean.getContent());
60
        viewHolder.mItemUserTime.setText(videoCommentBean.addDate + "");
61
        viewHolder.mItemUserCon.setText(videoCommentBean.content);
61 62
62 63
//        viewHolder.mItemUserOperation = (LinearLayout) itemView.findViewById(R.id.item_user_operation);
63
//        viewHolder.mItemUserReportLl = (LinearLayout) itemView.findViewById(R.id.item_user_report_ll);
64
        viewHolder.mItemUserReportCount.setText(videoCommentBean.getReplyNums() + "");
65
//        viewHolder.mItemUserDelete = (TextView) itemView.findViewById(R.id.item_user_delete);
66
64
        if (videoCommentBean.replyNums > 0) {
65
            viewHolder.mItemUserReportLl.setVisibility(View.VISIBLE);
66
            viewHolder.mItemUserReportCount.setText(videoCommentBean.replyNums + "");
67
        } else {
68
            viewHolder.mItemUserReportLl.setVisibility(View.GONE);
69
        }
70
        if (MainApplication.isLogin()) {
71
            if (videoCommentBean.userId.equals(MainApplication.userId)) {
72
                viewHolder.mItemUserDelete.setVisibility(View.VISIBLE);
73
            } else {
74
                viewHolder.mItemUserDelete.setVisibility(View.VISIBLE);
75
            }
76
        }
67 77
68 78
    }
69 79
@ -76,7 +86,7 @@ public class VideoCommentAdapter extends RecyclerView.Adapter<VideoCommentAdapte
76 86
77 87
    }
78 88
79
    public void addData(ArrayList<VideoCommentBean> qadata) {
89
    public void addData(List<VideoCommentBean> qadata) {
80 90
        if (qadata != null) {
81 91
            dataList.addAll(qadata);
82 92
        }

+ 9 - 22
app/src/main/java/com/electric/chargingpile/data/TalkRecommendBean.java

@ -3,7 +3,7 @@ package com.electric.chargingpile.data;
3 3
import java.io.Serializable;
4 4
5 5
public class TalkRecommendBean implements Serializable {
6
//     "targetId": 4,
6
    //     "targetId": 4,
7 7
//             "targetType": 23,
8 8
//             "title": "这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件这是一个视频文件",
9 9
//             "topicId": 1,
@ -22,35 +22,22 @@ public class TalkRecommendBean implements Serializable {
22 22
    public int targetType;
23 23
    public String title;
24 24
    public String name;
25
    public long addTime;
25 26
    public int topicId;
26 27
    public int joinNums;
27 28
    public String coverImgUrl;
28 29
    public String headImgUrl;
29 30
    public String nickName;
31
    public String topicName;
32
    public String content;
33
    public String shareUrl;
30 34
    public int likeNums;
35
    public int source;
36
    public String videoUrl;
31 37
    public int commentNums;
32 38
    public int isTop;
33 39
    public int likeFlg;
34
    public int source;
40
    public boolean isLoaded = false;
41
35 42
36
    @Override
37
    public String toString() {
38
        return "TalkRecommendBean{" +
39
                "targetId=" + targetId +
40
                ", addUserId=" + addUserId +
41
                ", targetType=" + targetType +
42
                ", title='" + title + '\'' +
43
                ", name='" + name + '\'' +
44
                ", topicId=" + topicId +
45
                ", joinNums=" + joinNums +
46
                ", coverImgUrl='" + coverImgUrl + '\'' +
47
                ", headImgUrl='" + headImgUrl + '\'' +
48
                ", nickName='" + nickName + '\'' +
49
                ", likeNums=" + likeNums +
50
                ", commentNums=" + commentNums +
51
                ", isTop=" + isTop +
52
                ", likeFlg=" + likeFlg +
53
                ", source=" + source +
54
                '}';
55
    }
56 43
}

+ 20 - 171
app/src/main/java/com/electric/chargingpile/data/VideoCommentBean.java

@ -5,176 +5,25 @@ package com.electric.chargingpile.data;
5 5
 */
6 6
7 7
public class VideoCommentBean {
8
    private String targetId = "";
9
    private int targetType;
10
    private int level;
11
    private String userId = "";
12
    private String nickNameFromUser = "";
13
    private String headImgFromUser = "";
14
    private String toUserId = "";
15
    private String nickNameToUser = "";
16
    private String headImgToUser = "";
17
    private String content = "";
18
    private int likeNums;
19
    private int likeFlg;
20
    private String addDate;
21
    private String commentsId;
22
    private String commentsId2;
8
    public long targetId ;
9
    public int targetType;
10
    public int level;
11
    public String userId ;
12
    public String nickNameFromUser ;
13
    public String headImgFromUser ;
14
    public String toUserId ;
15
    public String nickNameToUser ;
16
    public String headImgToUser ;
17
    public String content ;
18
    public int likeNums;
19
    public int likeFlg;
20
    public long addDate;
21
    public String commentsId;
22
    public String commentsId2;
23
24
    public String userId2;
25
    public String nickName2;
26
    public String content2;
27
    public int replyNums;
23 28
24
    private String userId2;
25
    private String nickName2;
26
    private String content2;
27
    private String replyNums;
28
29
    public String getTargetId() {
30
        return targetId;
31
    }
32
33
    public void setTargetId(String targetId) {
34
        this.targetId = targetId;
35
    }
36
37
    public int getTargetType() {
38
        return targetType;
39
    }
40
41
    public void setTargetType(int targetType) {
42
        this.targetType = targetType;
43
    }
44
45
    public int getLevel() {
46
        return level;
47
    }
48
49
    public void setLevel(int level) {
50
        this.level = level;
51
    }
52
53
    public String getUserId() {
54
        return userId;
55
    }
56
57
    public void setUserId(String userId) {
58
        this.userId = userId;
59
    }
60
61
    public String getNickNameFromUser() {
62
        return nickNameFromUser;
63
    }
64
65
    public void setNickNameFromUser(String nickNameFromUser) {
66
        this.nickNameFromUser = nickNameFromUser;
67
    }
68
69
    public String getHeadImgFromUser() {
70
        return headImgFromUser;
71
    }
72
73
    public void setHeadImgFromUser(String headImgFromUser) {
74
        this.headImgFromUser = headImgFromUser;
75
    }
76
77
    public String getToUserId() {
78
        return toUserId;
79
    }
80
81
    public void setToUserId(String toUserId) {
82
        this.toUserId = toUserId;
83
    }
84
85
    public String getNickNameToUser() {
86
        return nickNameToUser;
87
    }
88
89
    public void setNickNameToUser(String nickNameToUser) {
90
        this.nickNameToUser = nickNameToUser;
91
    }
92
93
    public String getHeadImgToUser() {
94
        return headImgToUser;
95
    }
96
97
    public void setHeadImgToUser(String headImgToUser) {
98
        this.headImgToUser = headImgToUser;
99
    }
100
101
    public String getContent() {
102
        return content;
103
    }
104
105
    public void setContent(String content) {
106
        this.content = content;
107
    }
108
109
    public int getLikeNums() {
110
        return likeNums;
111
    }
112
113
    public void setLikeNums(int likeNums) {
114
        this.likeNums = likeNums;
115
    }
116
117
    public int getLikeFlg() {
118
        return likeFlg;
119
    }
120
121
    public void setLikeFlg(int likeFlg) {
122
        this.likeFlg = likeFlg;
123
    }
124
125
    public String getAddDate() {
126
        return addDate;
127
    }
128
129
    public void setAddDate(String addDate) {
130
        this.addDate = addDate;
131
    }
132
133
    public String getCommentsId() {
134
        return commentsId;
135
    }
136
137
    public void setCommentsId(String commentsId) {
138
        this.commentsId = commentsId;
139
    }
140
141
    public String getCommentsId2() {
142
        return commentsId2;
143
    }
144
145
    public void setCommentsId2(String commentsId2) {
146
        this.commentsId2 = commentsId2;
147
    }
148
149
    public String getUserId2() {
150
        return userId2;
151
    }
152
153
    public void setUserId2(String userId2) {
154
        this.userId2 = userId2;
155
    }
156
157
    public String getNickName2() {
158
        return nickName2;
159
    }
160
161
    public void setNickName2(String nickName2) {
162
        this.nickName2 = nickName2;
163
    }
164
165
    public String getContent2() {
166
        return content2;
167
    }
168
169
    public void setContent2(String content2) {
170
        this.content2 = content2;
171
    }
172
173
    public String getReplyNums() {
174
        return replyNums;
175
    }
176
177
    public void setReplyNums(String replyNums) {
178
        this.replyNums = replyNums;
179
    }
180 29
}

+ 0 - 37
app/src/main/java/com/electric/chargingpile/data/VideoDetailsBean.java

@ -1,37 +0,0 @@
1
package com.electric.chargingpile.data;
2
3
/**
4
 * Created by Demon on 16/11/22.
5
 */
6
7
public class VideoDetailsBean {
8
    private String targetId ="";
9
    private int targetType;
10
    private String videoUrl ="";
11
    private String coverImgUrl ="";
12
    private String authorName ="";
13
    private String authorHeadImg ="";
14
    private String authorId ="";
15
    private String title ="";
16
    private String publishDate_s ="";
17
    private String h5Url ="";
18
    private int likeNums;
19
20
    private int likeFlg;
21
    private int feedFlg;
22
    private int commentsNums;
23
    private int visitTimes;
24
25
    private int picsVos;
26
27
28
29
30
    public class Video{
31
32
    }
33
34
    public class Pic{
35
36
    }
37
}

+ 96 - 11
app/src/main/java/com/electric/chargingpile/fragment/SvVideoShowView.java

@ -1,6 +1,8 @@
1 1
package com.electric.chargingpile.fragment;
2 2
3 3
import android.app.Activity;
4
import android.text.TextUtils;
5
import android.util.Log;
4 6
import android.view.LayoutInflater;
5 7
import android.view.View;
6 8
import android.view.ViewGroup;
@ -12,23 +14,28 @@ import android.widget.Toast;
12 14
import com.electric.chargingpile.R;
13 15
import com.electric.chargingpile.application.MainApplication;
14 16
import com.electric.chargingpile.data.TalkRecommendBean;
15
import com.electric.chargingpile.data.VideoDetailsBean;
17
import com.electric.chargingpile.util.CircleTransform;
16 18
import com.electric.chargingpile.util.JsonUtils;
17 19
import com.electric.chargingpile.util.ToastUtil;
20
import com.electric.chargingpile.view.VideoCommentDialog;
21
import com.electric.chargingpile.view.VideoPubilshDialog;
22
import com.squareup.picasso.Picasso;
18 23
import com.zhy.http.okhttp.OkHttpUtils;
19 24
import com.zhy.http.okhttp.callback.StringCallback;
20 25
21 26
import java.util.HashMap;
27
import java.util.List;
22 28
import java.util.Map;
23 29
24 30
import okhttp3.Call;
25 31
26
public class SvVideoShowView {
32
public class SvVideoShowView implements View.OnClickListener {
27 33
28 34
    private Activity activity;
29 35
    private OnDeleteVideoListener listener;
30 36
    private View view;
31 37
    private ViewGroup viewGroup;
38
    private TalkRecommendBean talkRecommendBean;
32 39
33 40
34 41
    private LinearLayout sv_show_forward, sv_show_comment_count_ll, sv_show_like_ll,
@ -50,24 +57,30 @@ public class SvVideoShowView {
50 57
    }
51 58
52 59
    public void setInfo(TalkRecommendBean talkRecommendBean) {
60
        this.talkRecommendBean = talkRecommendBean;
53 61
        int targetType = talkRecommendBean.targetType;
54
        if (targetType == 1) {
62
        if (targetType == 23) {
55 63
            view = LayoutInflater.from(activity).inflate(R.layout.view_show_view, null);
56 64
            initPlayer(view);
57
        } else {
65
        } else if(targetType==24) {
58 66
            view = LayoutInflater.from(activity).inflate(R.layout.view_show_zoom, null);
59 67
            initZoomPhoto(view);
60 68
        }
61 69
        initBottom(view);
62 70
        viewGroup.addView(view);
63
        requestHeaderData(targetType, talkRecommendBean.targetId);
71
        if (talkRecommendBean.isLoaded) {
72
            setData();
73
        } else {
74
            requestHeaderData(targetType, talkRecommendBean.targetId);
75
        }
64 76
    }
65 77
66 78
    private void requestHeaderData(int targetType, long targetId) {
67
        String url = MainApplication.urlNew + "/article/detail";
79
        String url = MainApplication.urlNew + "/topic/detail.do";
68 80
        Map<String, String> map = new HashMap<>();
69 81
        map.put("targetType", targetType + "");
70 82
        map.put("targetId", targetId + "");
83
        map.put("limit", "1");
71 84
        if (MainApplication.isLogin()) {
72 85
            map.put("user_id", MainApplication.userId);
73 86
        }
@ -87,18 +100,64 @@ public class SvVideoShowView {
87 100
88 101
                    @Override
89 102
                    public void onResponse(String response) {
103
104
                        Log.e("SvVideoShowView", talkRecommendBean.toString());
105
106
                        Log.e("SvVideoShowView",response);
107
                        Log.e("SvVideoShowView","-----------------------------");
90 108
                        String rtnCode = JsonUtils.getKeyResult(response, "code");
91 109
                        if ("1000".equals(rtnCode)) {
92 110
                            String rtnMsg = JsonUtils.getKeyResult(response, "data");
93
                            VideoDetailsBean qadata = (VideoDetailsBean) JsonUtils
94
                                    .parseToObjectList(rtnMsg, VideoDetailsBean.class);
95
                            setData(qadata);
111
                            List<TalkRecommendBean> qadata = JsonUtils
112
                                    .parseToObjectList(rtnMsg, TalkRecommendBean.class);
113
                            if (qadata != null && qadata.size() > 0) {
114
                                talkRecommendBean = qadata.get(0);
115
                            }
116
                            talkRecommendBean.isLoaded=true;
117
                            setData();
96 118
                        }
97 119
                    }
98 120
                });
99 121
    }
100 122
101
    private void setData(VideoDetailsBean qadata) {
123
    private void setData() {
124
        sv_show_comment_count_tv.setText(talkRecommendBean.commentNums + "");
125
        sv_show_like_tv.setText(talkRecommendBean.likeNums + "");
126
        sv_show_tvcon.setText(talkRecommendBean.content);
127
        sv_show_user_name.setText(talkRecommendBean.nickName);
128
        sv_show_user_time.setText("" + talkRecommendBean.addTime);
129
        sv_show_topic_con.setText(talkRecommendBean.topicName);
130
131
        if (TextUtils.isEmpty(talkRecommendBean.headImgUrl)) {
132
            Picasso.with(activity)
133
                    .load(R.drawable.icon_face2_0)
134
                    .placeholder(R.drawable.icon_face2_0)
135
                    .error(R.drawable.icon_face2_0)
136
                    .transform(new CircleTransform())
137
                    .into(sv_show_user_avatar);
138
        } else {
139
            Picasso.with(activity)
140
                    .load(talkRecommendBean.headImgUrl)
141
                    .placeholder(R.drawable.icon_face2_0)
142
                    .error(R.drawable.icon_face2_0)
143
                    .transform(new CircleTransform())
144
                    .into(sv_show_user_avatar);
145
        }
146
147
        if (talkRecommendBean.likeFlg == 1) {
148
//            sv_show_like_img  like
149
        } else {
150
            // sv_show_like_img  not like
151
        }
152
153
        if (sv_show_tvcon.getLineCount() >= 3) {
154
            sv_show_tvcon_more.setVisibility(View.VISIBLE);
155
        } else {
156
            sv_show_tvcon_more.setVisibility(View.GONE);
157
        }
158
//        private ImageView , ;
159
160
//        private View ;
102 161
103 162
    }
104 163
@ -158,6 +217,8 @@ public class SvVideoShowView {
158 217
        sv_show_user_name = view.findViewById(R.id.sv_show_user_name);
159 218
        sv_show_user_time = view.findViewById(R.id.sv_show_user_time);
160 219
        sv_show_topic_con = view.findViewById(R.id.sv_show_topic_con);
220
        sv_show_tvcon_more.setOnClickListener(this);
221
        sv_show_comment_count_ll.setOnClickListener(this);
161 222
    }
162 223
163 224
    private void initPlayer(View view) {
@ -173,12 +234,36 @@ public class SvVideoShowView {
173 234
        return view;
174 235
    }
175 236
176
    public void updateView() {
237
    public void updateView(int position, TalkRecommendBean talkRecommendBean) {
238
        int targetType = talkRecommendBean.targetType;
239
        long targetId = talkRecommendBean.targetId;
240
177 241
    }
178 242
179 243
    public void initAndPlay() {
180 244
    }
181 245
246
    @Override
247
    public void onClick(View view) {
248
        switch (view.getId()) {
249
            case R.id.sv_show_tvcon_more:
250
                new VideoPubilshDialog(activity, talkRecommendBean).show();
251
                break;
252
            case R.id.sv_show_comment_count_ll:
253
                VideoCommentDialog videoCommentDialog = new VideoCommentDialog(activity, talkRecommendBean);
254
                videoCommentDialog.getData();
255
                videoCommentDialog.show();
256
                break;
257
            default:
258
                break;
259
        }
260
    }
261
262
    public void onDestroy() {
263
264
//释放播放资源
265
    }
266
182 267
183 268
    public interface OnDeleteVideoListener {
184 269
        void onDelete();

+ 2 - 1
app/src/main/java/com/electric/chargingpile/fragment/TalkRecommendFragment.java

@ -237,7 +237,8 @@ public class TalkRecommendFragment extends Fragment implements View.OnClickListe
237 237
                String rtnCode = JsonUtils.getKeyResult(response, "code");
238 238
                if ("1000".equals(rtnCode)) {
239 239
                    String rtnMsg = JsonUtils.getKeyResult(response, "data");
240
                    ArrayList<TalkRecommendBean> qadata = (ArrayList<TalkRecommendBean>) JsonUtils.parseToObjectList(rtnMsg, TalkRecommendBean.class);
240
                    ArrayList<TalkRecommendBean> qadata = (ArrayList<TalkRecommendBean>)
241
                            JsonUtils.parseToObjectList(rtnMsg, TalkRecommendBean.class);
241 242
                    layoutAdapter.setHeaderData(qadata);
242 243
                    requestData();
243 244
                }

+ 43 - 7
app/src/main/java/com/electric/chargingpile/view/VideoCommentDialog.java

@ -2,10 +2,14 @@ package com.electric.chargingpile.view;
2 2
3 3
import android.app.Dialog;
4 4
import android.content.Context;
5
import android.graphics.Color;
5 6
import android.os.Bundle;
6 7
import android.support.v7.widget.RecyclerView;
8
import android.text.Editable;
7 9
import android.text.TextUtils;
10
import android.text.TextWatcher;
8 11
import android.view.Gravity;
12
import android.view.KeyEvent;
9 13
import android.view.LayoutInflater;
10 14
import android.view.View;
11 15
import android.view.Window;
@ -29,6 +33,7 @@ import com.zhy.http.okhttp.callback.StringCallback;
29 33
30 34
import java.util.ArrayList;
31 35
import java.util.HashMap;
36
import java.util.List;
32 37
import java.util.Map;
33 38
34 39
import okhttp3.Call;
@ -41,13 +46,15 @@ public class VideoCommentDialog extends Dialog implements View.OnClickListener {
41 46
    private RecyclerView showCommentLv;
42 47
    private EditText showCommentEd;
43 48
    private TextView showCommentPublish;
49
    private TalkRecommendBean talkRecommendBean;
44 50
45 51
    private VideoCommentAdapter videoCommentAdapter;
46 52
47 53
48
    public VideoCommentDialog(Context context) {
54
    public VideoCommentDialog(Context context, TalkRecommendBean talkRecommendBean) {
49 55
        super(context, R.style.bottomDialogStyle);
50 56
        this.context = context;
57
        this.talkRecommendBean = talkRecommendBean;
51 58
    }
52 59
53 60
@ -68,9 +75,13 @@ public class VideoCommentDialog extends Dialog implements View.OnClickListener {
68 75
69 76
    }
70 77
71
    public void setComment(int targetType, int targetId, final int commentId) {
78
    public void getData() {
79
        setComment(talkRecommendBean.targetType, talkRecommendBean.targetId, 0);
80
    }
81
82
    public void setComment(int targetType, long targetId, final int commentId) {
72 83
73
        String url = MainApplication.urlNew + "/article/like";
84
        String url = MainApplication.urlNew + "/topic/comments/list.do";
74 85
        Map<String, String> map = new HashMap<>();
75 86
        map.put("targetType", targetType + "");
76 87
        map.put("targetId", targetId + "");
@ -122,7 +133,26 @@ public class VideoCommentDialog extends Dialog implements View.OnClickListener {
122 133
        showCommentLv = (RecyclerView) convertView.findViewById(R.id.show_comment_lv);
123 134
        showCommentEd = (EditText) convertView.findViewById(R.id.show_comment_ed);
124 135
        showCommentPublish = (TextView) convertView.findViewById(R.id.show_comment_publish);
136
        showCommentPublish.addTextChangedListener(new TextWatcher() {
137
            @Override
138
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
139
140
            }
141
142
            @Override
143
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
144
                if (i2 > 0) {
145
                    showCommentPublish.setTextColor(Color.parseColor("#00edb2"));
146
                } else {
147
                    showCommentPublish.setTextColor(Color.parseColor("#7E7E7E"));
148
                }
149
            }
150
151
            @Override
152
            public void afterTextChanged(Editable editable) {
125 153
154
            }
155
        });
126 156
        videoCommentAdapter = new VideoCommentAdapter(context);
127 157
        showCommentLv.setAdapter(videoCommentAdapter);
128 158
@ -142,16 +172,17 @@ public class VideoCommentDialog extends Dialog implements View.OnClickListener {
142 172
                    Toast.makeText(context, "请输入评论内容!", Toast.LENGTH_SHORT).show();
143 173
                    return;
144 174
                }
145
//                publishComment(commentCon);
175
                publishComment(commentCon, talkRecommendBean.targetId, talkRecommendBean.targetType,
176
                        "0", "0", 1, "0");
146 177
                break;
147 178
            default:
148 179
                break;
149 180
        }
150 181
    }
151 182
152
    private void publishComment(String commentCon, int targetId, int targetType, String toUserId,
183
    private void publishComment(String commentCon, long targetId, int targetType, String toUserId,
153 184
                                String parentId, int level, String toCommentIds) {
154
        String url = MainApplication.urlNew + "/comments/publish";
185
        String url = MainApplication.urlNew + "/topic/comments/publish.do";
155 186
        Map<String, String> map = new HashMap<>();
156 187
        map.put("targetType", targetType + "");
157 188
        map.put("targetId", targetId + "");
@ -183,8 +214,13 @@ public class VideoCommentDialog extends Dialog implements View.OnClickListener {
183 214
                        String rtnCode = JsonUtils.getKeyResult(response, "code");
184 215
                        if ("1000".equals(rtnCode)) {
185 216
                            String rtnMsg = JsonUtils.getKeyResult(response, "data");
186
                            ArrayList<VideoCommentBean> qadata = (ArrayList<VideoCommentBean>) JsonUtils.parseToObjectList(rtnMsg, VideoCommentBean.class);
217
                            List<VideoCommentBean> qadata = JsonUtils.parseToObjectList(rtnMsg, VideoCommentBean.class);
218
187 219
                            if (videoCommentAdapter != null) {
220
                                if (qadata.size() > 0) {
221
                                    showCommentTitle.setText("全部评论 " + qadata.size());
222
                                }
223
188 224
                                videoCommentAdapter.addData(qadata);
189 225
                            }
190 226
                        }

+ 41 - 2
app/src/main/java/com/electric/chargingpile/view/VideoPubilshDialog.java

@ -3,6 +3,7 @@ package com.electric.chargingpile.view;
3 3
import android.app.Dialog;
4 4
import android.content.Context;
5 5
import android.os.Bundle;
6
import android.text.TextUtils;
6 7
import android.view.Gravity;
7 8
import android.view.LayoutInflater;
8 9
import android.view.View;
@ -13,12 +14,17 @@ import android.widget.LinearLayout;
13 14
import android.widget.TextView;
14 15
15 16
import com.electric.chargingpile.R;
17
import com.electric.chargingpile.data.TalkRecommendBean;
18
import com.electric.chargingpile.util.CircleTransform;
19
import com.squareup.picasso.Picasso;
16 20
17 21
public class VideoPubilshDialog extends Dialog implements View.OnClickListener {
18 22
    private Context context;
23
    private TalkRecommendBean talkRecommendBean;
19 24
20
    public VideoPubilshDialog(Context context) {
25
    public VideoPubilshDialog(Context context, TalkRecommendBean talkRecommendBean) {
21 26
        super(context, R.style.bottomDialogStyle);
27
        this.talkRecommendBean = talkRecommendBean;
22 28
        this.context = context;
23 29
    }
24 30
@ -27,7 +33,7 @@ public class VideoPubilshDialog extends Dialog implements View.OnClickListener {
27 33
    private TextView videoPublishTopicCon;
28 34
    private LinearLayout videoPublishUserLl;
29 35
    private ImageView videoPublishUserAvatar;
30
    private TextView videoPublishUserName;
36
    private TextView videoPublishUserName,videoPublishCon;
31 37
32 38
    @Override
33 39
    protected void onCreate(Bundle savedInstanceState) {
@ -37,12 +43,37 @@ public class VideoPubilshDialog extends Dialog implements View.OnClickListener {
37 43
        videoPublishClose = inflate.findViewById(R.id.video_publish_close);
38 44
        videoPublishTopic = inflate.findViewById(R.id.video_publish_topic);
39 45
        videoPublishTopicCon = inflate.findViewById(R.id.video_publish_topic_con);
46
        videoPublishCon = inflate.findViewById(R.id.video_publish_con);
40 47
        videoPublishUserLl = inflate.findViewById(R.id.video_publish_user_ll);
41 48
        videoPublishUserAvatar = inflate.findViewById(R.id.video_publish_user_avatar);
42 49
        videoPublishUserName = inflate.findViewById(R.id.video_publish_user_name);
43 50
44 51
        videoPublishClose.setOnClickListener(this);
45 52
53
54
        videoPublishTopicCon.setText(talkRecommendBean.title);
55
        videoPublishCon.setText(talkRecommendBean.title);
56
57
        if (TextUtils.isEmpty(talkRecommendBean.headImgUrl)) {
58
            Picasso.with(context)
59
                    .load(R.drawable.icon_face2_0)
60
                    .placeholder(R.drawable.icon_face2_0)
61
                    .error(R.drawable.icon_face2_0)
62
                    .transform(new CircleTransform())
63
                    .into(videoPublishUserAvatar);
64
        } else {
65
            Picasso.with(context)
66
                    .load(talkRecommendBean.headImgUrl)
67
                    .placeholder(R.drawable.icon_face2_0)
68
                    .error(R.drawable.icon_face2_0)
69
                    .transform(new CircleTransform())
70
                    .into(videoPublishUserAvatar);
71
        }
72
73
        videoPublishUserName.setText(talkRecommendBean.nickName);
74
//        sv_show_user_time.setText("" + talkRecommendBean.addTime);
75
76
46 77
        setContentView(inflate);
47 78
48 79
@ -63,4 +94,12 @@ public class VideoPubilshDialog extends Dialog implements View.OnClickListener {
63 94
                break;
64 95
        }
65 96
    }
97
98
    @Override
99
    public void show() {
100
        if(talkRecommendBean==null){
101
            return;
102
        }
103
        super.show();
104
    }
66 105
}

+ 1 - 1
app/src/main/res/layout/activity_videodetails.xml

@ -2,7 +2,7 @@
2 2
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 3
    android:layout_width="match_parent"
4 4
    android:layout_height="match_parent"
5
    android:background="#424242">
5
    android:background="#9FF33C">
6 6
7 7
8 8
    <com.electric.chargingpile.view.sview.VerticalViewPager

+ 3 - 3
app/src/main/res/layout/sv_video_publish_info.xml

@ -12,7 +12,7 @@
12 12
        android:layout_alignParentEnd="true"
13 13
        android:layout_marginTop="14dp"
14 14
        android:layout_marginEnd="14dp"
15
        android:background="#fff" />
15
        android:background="@drawable/icon_dialog_close" />
16 16
17 17
18 18
    <LinearLayout
@ -56,8 +56,7 @@
56 56
        <ImageView
57 57
            android:id="@+id/video_publish_user_avatar"
58 58
            android:layout_width="20dp"
59
            android:layout_height="20dp"
60
            android:background="#3df" />
59
            android:layout_height="20dp"  />
61 60
62 61
        <TextView
63 62
            android:id="@+id/video_publish_user_name"
@ -70,6 +69,7 @@
70 69
    </LinearLayout>
71 70
72 71
    <TextView
72
        android:id="@+id/video_publish_con"
73 73
        android:layout_width="match_parent"
74 74
        android:layout_height="wrap_content"
75 75
        android:layout_below="@+id/video_publish_user_ll"

+ 6 - 12
app/src/main/res/layout/view_show_bottom.xml

@ -49,7 +49,6 @@
49 49
                android:id="@+id/sv_show_comment_count_tv"
50 50
                android:layout_width="wrap_content"
51 51
                android:layout_height="wrap_content"
52
                android:text="1230w"
53 52
                android:textSize="12sp" />
54 53
55 54
        </LinearLayout>
@ -74,7 +73,6 @@
74 73
                android:id="@+id/sv_show_like_tv"
75 74
                android:layout_width="wrap_content"
76 75
                android:layout_height="wrap_content"
77
                android:text="12我30w"
78 76
                android:textSize="12sp" />
79 77
80 78
        </LinearLayout>
@ -121,8 +119,7 @@
121 119
        android:layout_marginBottom="23dp"
122 120
        android:ellipsize="end"
123 121
        android:maxLines="3"
124
        android:text="3-超出三行的,点击文字,上滑弹窗,显示出所有文字内容,根据内容自适应高度,最高为一半屏幕高度,字数超高,以滚动条滑动显示。3-超出三行的,点击文字,上滑弹窗,显示出所有文字内容,根据内容自适应高度,最高为一半屏幕高度,字数超高,以滚动条滑动显示。"
125
        android:textSize="14sp" />
122
         android:textSize="14sp" />
126 123
127 124
    <View
128 125
        android:id="@+id/sv_show_tvcon_more"
@ -131,7 +128,8 @@
131 128
        android:layout_above="@+id/sv_show_bottom"
132 129
        android:layout_alignParentEnd="true"
133 130
        android:layout_marginBottom="28dp"
134
        android:background="@color/__picker_black_40" />
131
        android:rotation="90"
132
        android:background="@drawable/ssdk_country_back_arrow" />
135 133
136 134
    <RelativeLayout
137 135
        android:id="@+id/sv_show_user_info"
@ -139,15 +137,13 @@
139 137
        android:layout_height="34dp"
140 138
        android:layout_above="@+id/sv_show_tvcon"
141 139
        android:layout_marginLeft="15dp"
142
        android:layout_marginBottom="5dp"
143
        android:background="#2ff">
140
        android:layout_marginBottom="5dp">
144 141
145 142
        <ImageView
146 143
            android:id="@+id/sv_show_user_avatar"
147 144
            android:layout_width="20dp"
148 145
            android:layout_height="20dp"
149
            android:layout_centerVertical="true"
150
            android:background="#fff" />
146
            android:layout_centerVertical="true" />
151 147
152 148
        <TextView
153 149
            android:id="@+id/sv_show_user_name"
@ -170,7 +166,6 @@
170 166
            android:textSize="12sp" />
171 167
    </RelativeLayout>
172 168
173
174 169
    <LinearLayout
175 170
        android:id="@+id/sv_show_topic"
176 171
        android:layout_width="wrap_content"
@ -196,8 +191,7 @@
196 191
            android:layout_marginRight="12dp"
197 192
            android:ellipsize="end"
198 193
            android:maxLines="1"
199
            android:text="显示出所有文字内容显示出所有文字内容显示出所有文字内容显示出所有文字内容显示出所有文字内容显示出所有文字内容显示出所有文字内容"
200
            android:textColor="#fff"
194
             android:textColor="#fff"
201 195
            android:textSize="11sp" />
202 196
    </LinearLayout>
203 197

+ 4 - 2
app/src/main/res/layout/view_show_comment.xml

@ -10,7 +10,7 @@
10 10
        android:layout_height="wrap_content"
11 11
        android:layout_centerHorizontal="true"
12 12
        android:layout_marginTop="10dp"
13
        android:text="12sp12sp12sp"
13
        android:text="全部评论"
14 14
        android:textColor="#c2c2c2"
15 15
        android:textSize="14sp" />
16 16
@ -22,7 +22,7 @@
22 22
        android:layout_alignParentEnd="true"
23 23
        android:layout_marginTop="9dp"
24 24
        android:layout_marginEnd="14dp"
25
        android:background="#fff" />
25
        android:background="@drawable/icon_dialog_close"  />
26 26
27 27
    <View
28 28
        android:layout_width="match_parent"
@ -55,8 +55,10 @@
55 55
            android:background="@drawable/bg_comment_report"
56 56
            android:hint="写评论"
57 57
            android:minHeight="30dp"
58
            android:maxLength="200"
58 59
            android:paddingStart="14dp"
59 60
            android:paddingEnd="14dp"
61
            android:textColor="#fff"
60 62
            android:textColorHint="#7e7e7e" />
61 63
62 64
        <TextView