ソースを参照

图片资源添加

huyuguo 5 年 前
コミット
35c232cb5c
共有35 個のファイルを変更した196 個の追加11 個の削除を含む
  1. 63 10
      app/src/main/java/com/electric/chargingpile/activity/ChatContentListActivity.java
  2. BIN
      app/src/main/res/drawable-xhdpi/comment_icon.png
  3. BIN
      app/src/main/res/drawable-xhdpi/comment_small_icon.png
  4. BIN
      app/src/main/res/drawable-xhdpi/delete_icon.png
  5. BIN
      app/src/main/res/drawable-xhdpi/fold_icon.png
  6. BIN
      app/src/main/res/drawable-xhdpi/like_icon.png
  7. BIN
      app/src/main/res/drawable-xhdpi/like_red_icon.png
  8. BIN
      app/src/main/res/drawable-xhdpi/like_small_icon.png
  9. BIN
      app/src/main/res/drawable-xhdpi/topic_icon.png
  10. BIN
      app/src/main/res/drawable-xhdpi/transmit_icon.png
  11. BIN
      app/src/main/res/drawable-xhdpi/unfold_icon.png
  12. BIN
      app/src/main/res/drawable-xhdpi/write_comment_icon.png
  13. BIN
      app/src/main/res/drawable-xxhdpi/comment_icon.png
  14. BIN
      app/src/main/res/drawable-xxhdpi/comment_small_icon.png
  15. BIN
      app/src/main/res/drawable-xxhdpi/delete_icon.png
  16. BIN
      app/src/main/res/drawable-xxhdpi/fold_icon.png
  17. BIN
      app/src/main/res/drawable-xxhdpi/like_icon.png
  18. BIN
      app/src/main/res/drawable-xxhdpi/like_red_icon.png
  19. BIN
      app/src/main/res/drawable-xxhdpi/like_small_icon.png
  20. BIN
      app/src/main/res/drawable-xxhdpi/topic_icon.png
  21. BIN
      app/src/main/res/drawable-xxhdpi/transmit_icon.png
  22. BIN
      app/src/main/res/drawable-xxhdpi/unfold_icon.png
  23. BIN
      app/src/main/res/drawable-xxhdpi/write_comment_icon.png
  24. BIN
      app/src/main/res/drawable-xxxhdpi/comment_icon.png
  25. BIN
      app/src/main/res/drawable-xxxhdpi/comment_small_icon.png
  26. BIN
      app/src/main/res/drawable-xxxhdpi/delete_icon.png
  27. BIN
      app/src/main/res/drawable-xxxhdpi/fold_icon.png
  28. BIN
      app/src/main/res/drawable-xxxhdpi/like_icon.png
  29. BIN
      app/src/main/res/drawable-xxxhdpi/like_red_icon.png
  30. BIN
      app/src/main/res/drawable-xxxhdpi/like_small_icon.png
  31. BIN
      app/src/main/res/drawable-xxxhdpi/topic_icon.png
  32. BIN
      app/src/main/res/drawable-xxxhdpi/transmit_icon.png
  33. BIN
      app/src/main/res/drawable-xxxhdpi/unfold_icon.png
  34. BIN
      app/src/main/res/drawable-xxxhdpi/write_comment_icon.png
  35. 133 1
      app/src/main/res/layout/fragment_chat_content_video.xml

+ 63 - 10
app/src/main/java/com/electric/chargingpile/activity/ChatContentListActivity.java

27
import com.electric.chargingpile.data.ChatRecommendBean;
27
import com.electric.chargingpile.data.ChatRecommendBean;
28
import com.electric.chargingpile.manager.PreferenceManager;
28
import com.electric.chargingpile.manager.PreferenceManager;
29
import com.electric.chargingpile.manager.ProfileManager;
29
import com.electric.chargingpile.manager.ProfileManager;
30
import com.electric.chargingpile.util.CommonParams;
30
import com.electric.chargingpile.util.DensityUtil;
31
import com.electric.chargingpile.util.DensityUtil;
31
import com.electric.chargingpile.util.ImageDisplayUtils;
32
import com.electric.chargingpile.util.ImageDisplayUtils;
33
import com.electric.chargingpile.util.JsonUtils;
32
import com.electric.chargingpile.util.ScreenUtils;
34
import com.electric.chargingpile.util.ScreenUtils;
33
import com.electric.chargingpile.util.ToastUtil;
35
import com.electric.chargingpile.util.ToastUtil;
34
import com.electric.chargingpile.util.Util;
36
import com.electric.chargingpile.util.Util;
39
import com.shuyu.gsyvideoplayer.listener.GSYVideoProgressListener;
41
import com.shuyu.gsyvideoplayer.listener.GSYVideoProgressListener;
40
import com.shuyu.gsyvideoplayer.listener.VideoAllCallBack;
42
import com.shuyu.gsyvideoplayer.listener.VideoAllCallBack;
41
import com.shuyu.gsyvideoplayer.video.base.GSYVideoView;
43
import com.shuyu.gsyvideoplayer.video.base.GSYVideoView;
44
import com.zhy.http.okhttp.OkHttpUtils;
45
import com.zhy.http.okhttp.callback.StringCallback;
42
46
43
import java.util.HashMap;
47
import java.util.HashMap;
44
import java.util.Map;
48
import java.util.Map;
45
49
46
import fr.castorflex.android.verticalviewpager.VerticalViewPager;
50
import fr.castorflex.android.verticalviewpager.VerticalViewPager;
51
import okhttp3.Call;
47
52
48
public class ChatContentListActivity extends AppCompatActivity {
53
public class ChatContentListActivity extends AppCompatActivity {
49
    private static final String TAG = "ChatContentListActivity";
54
    private static final String TAG = "ChatContentListActivity";
203
        private ImageView videoIcon;
208
        private ImageView videoIcon;
204
        private ChatRecommendBean bean;
209
        private ChatRecommendBean bean;
205
        private ImageView playIcon;
210
        private ImageView playIcon;
211
        private TextView likeLabel;
212
        private ImageView likeIcon;
206
213
207
        public static ChatContentFragment newInstance(int index, String from) {
214
        public static ChatContentFragment newInstance(int index, String from) {
208
            ChatContentFragment fragment = new ChatContentFragment();
215
            ChatContentFragment fragment = new ChatContentFragment();
239
            return rootView;
246
            return rootView;
240
        }
247
        }
241
248
242
        private void initVideoView(View rootView, ChatRecommendBean bean) {
249
        private void initVideoView(View rootView, final ChatRecommendBean bean) {
243
            videoPlayer = rootView.findViewById(R.id.videoPlayer);
250
            videoPlayer = rootView.findViewById(R.id.videoPlayer);
244
            videoPlayer.setUp(bean.videoUrl, true, "");
251
            videoPlayer.setUp(bean.videoUrl, true, "");
245
            videoIcon = rootView.findViewById(R.id.videoIcon);
252
            videoIcon = rootView.findViewById(R.id.videoIcon);
246
            playIcon = rootView.findViewById(R.id.playIcon);
253
            playIcon = rootView.findViewById(R.id.playIcon);
254
            likeLabel = rootView.findViewById(R.id.likeLabel);
255
            likeIcon = rootView.findViewById(R.id.likeIcon);
247
            ConstraintLayout navBar = rootView.findViewById(R.id.navBar);
256
            ConstraintLayout navBar = rootView.findViewById(R.id.navBar);
248
257
249
            if (bean.coverImgH != 0 && bean.coverImgW != 0 && bean.coverImgW > bean.coverImgH) {
258
            if (bean.coverImgH != 0 && bean.coverImgW != 0 && bean.coverImgW > bean.coverImgH) {
274
                }
283
                }
275
            });
284
            });
276
285
286
            likeLabel.setText(bean.likeNums > 999 ? "999+" : bean.likeNums + "");
287
288
            if (bean.likeFlg == 1) {
289
                likeIcon.setImageResource(R.drawable.like_red_icon);
290
            } else {
291
                likeIcon.setImageResource(R.drawable.like_icon);
292
            }
293
277
            videoPlayer.setVideoAllCallBack(new VideoAllCallBack() {
294
            videoPlayer.setVideoAllCallBack(new VideoAllCallBack() {
278
                @Override
295
                @Override
279
                public void onAutoComplete(String s, Object... objects) {
296
                public void onAutoComplete(String s, Object... objects) {
386
                    if (ProfileManager.getInstance().getMakeSureNetworkForView(getContext())) {
403
                    if (ProfileManager.getInstance().getMakeSureNetworkForView(getContext())) {
387
                        playOrPause();
404
                        playOrPause();
388
                    } else {
405
                    } else {
406
                        new AlertDialog(getContext()).builder()
407
                                .setMsg("目前正在移动网络下,是否播放")
408
                                .setPositiveButton("继续播放", new View.OnClickListener() {
409
                                    @Override
410
                                    public void onClick(View view) {
411
                                        ProfileManager.getInstance().setMakeSureNetworkForView(getContext());
412
                                        playOrPause();
413
                                    }
414
                                }).setNegativeButton("暂停播放", null).show();
415
                    }
416
                }
417
            });
389
418
419
            rootView.findViewById(R.id.like).setOnClickListener(new View.OnClickListener() {
420
                @Override
421
                public void onClick(View view) {
422
                    doLike(bean);
423
                }
424
            });
425
        }
426
427
        private void doLike(final ChatRecommendBean bean) {
428
            String url = MainApplication.urlNew + "/topic/like.do";
429
            Map<String, String> map = new HashMap<>();
430
            map.put("targetId", bean.targetId + "");
431
            map.put("targetType", bean.targetType + "");
432
            map.put("flag", "1");
433
            map.put("authorId", bean.addUserId + "");
434
            CommonParams.addCommonParams(map);
435
436
            OkHttpUtils.get().url(url).params(map).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
437
                @Override
438
                public void onError(Call call, Exception e) {
439
                    ToastUtil.showToast(getContext(), "点赞失败,请重试", Toast.LENGTH_SHORT);
440
                }
441
442
                @Override
443
                public void onResponse(String res) {
444
                    String code = JsonUtils.getKeyResult(res, "code");
445
                    String desc = JsonUtils.getKeyResult(res, "desc");
446
                    if ("1000".equals(code)) {
447
                        bean.likeFlg = 1;
448
                        bean.likeNums += 1;
449
450
                    } else {
451
                        ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
390
                    }
452
                    }
391
                    new AlertDialog(getContext()).builder()
392
                            .setMsg("目前正在移动网络下,是否播放")
393
                            .setPositiveButton("继续播放", new View.OnClickListener() {
394
                                @Override
395
                                public void onClick(View view) {
396
                                    ProfileManager.getInstance().setMakeSureNetworkForView(getContext());
397
                                    playOrPause();
398
                                }
399
                            }).setNegativeButton("暂停播放", null).show();
400
                }
453
                }
401
            });
454
            });
402
        }
455
        }

BIN
app/src/main/res/drawable-xhdpi/comment_icon.png


BIN
app/src/main/res/drawable-xhdpi/comment_small_icon.png


BIN
app/src/main/res/drawable-xhdpi/delete_icon.png


BIN
app/src/main/res/drawable-xhdpi/fold_icon.png


BIN
app/src/main/res/drawable-xhdpi/like_icon.png


BIN
app/src/main/res/drawable-xhdpi/like_red_icon.png


BIN
app/src/main/res/drawable-xhdpi/like_small_icon.png


BIN
app/src/main/res/drawable-xhdpi/topic_icon.png


BIN
app/src/main/res/drawable-xhdpi/transmit_icon.png


BIN
app/src/main/res/drawable-xhdpi/unfold_icon.png


BIN
app/src/main/res/drawable-xhdpi/write_comment_icon.png


BIN
app/src/main/res/drawable-xxhdpi/comment_icon.png


BIN
app/src/main/res/drawable-xxhdpi/comment_small_icon.png


BIN
app/src/main/res/drawable-xxhdpi/delete_icon.png


BIN
app/src/main/res/drawable-xxhdpi/fold_icon.png


BIN
app/src/main/res/drawable-xxhdpi/like_icon.png


BIN
app/src/main/res/drawable-xxhdpi/like_red_icon.png


BIN
app/src/main/res/drawable-xxhdpi/like_small_icon.png


BIN
app/src/main/res/drawable-xxhdpi/topic_icon.png


BIN
app/src/main/res/drawable-xxhdpi/transmit_icon.png


BIN
app/src/main/res/drawable-xxhdpi/unfold_icon.png


BIN
app/src/main/res/drawable-xxhdpi/write_comment_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/comment_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/comment_small_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/delete_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/fold_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/like_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/like_red_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/like_small_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/topic_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/transmit_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/unfold_icon.png


BIN
app/src/main/res/drawable-xxxhdpi/write_comment_icon.png


+ 133 - 1
app/src/main/res/layout/fragment_chat_content_video.xml

16
        app:layout_constraintTop_toTopOf="parent"></com.electric.chargingpile.video.VideoPlayer>
16
        app:layout_constraintTop_toTopOf="parent"></com.electric.chargingpile.video.VideoPlayer>
17
17
18
    <ImageView
18
    <ImageView
19
        android:background="#424242"
20
        android:layout_width="match_parent"
19
        android:layout_width="match_parent"
21
        android:layout_height="1.5dp"
20
        android:layout_height="1.5dp"
21
        android:background="#424242"
22
        app:layout_constraintBottom_toBottomOf="@+id/videoPlayer" />
22
        app:layout_constraintBottom_toBottomOf="@+id/videoPlayer" />
23
23
24
    <ImageView
24
    <ImageView
71
71
72
    </android.support.constraint.ConstraintLayout>
72
    </android.support.constraint.ConstraintLayout>
73
73
74
    <android.support.constraint.ConstraintLayout
75
        android:id="@+id/bottomView"
76
        android:layout_width="match_parent"
77
        android:layout_height="wrap_content"
78
        android:layout_marginBottom="-40dp"
79
        app:layout_constraintBottom_toBottomOf="parent">
80
81
        <android.support.constraint.ConstraintLayout
82
            android:layout_width="match_parent"
83
            android:layout_height="50dp"
84
            app:layout_constraintBottom_toBottomOf="parent"
85
            tools:background="#00aee6">
86
87
            <!-- 写评论-->
88
            <android.support.constraint.ConstraintLayout
89
                android:id="@+id/writeComment"
90
                android:layout_width="wrap_content"
91
                android:layout_height="match_parent"
92
                android:paddingLeft="15dp"
93
                android:paddingRight="15dp"
94
                app:layout_constraintLeft_toLeftOf="parent">
95
96
                <ImageView
97
                    android:id="@+id/WriteCommentIcon"
98
                    android:layout_width="wrap_content"
99
                    android:layout_height="wrap_content"
100
                    app:layout_constraintBottom_toBottomOf="parent"
101
                    app:layout_constraintLeft_toLeftOf="parent"
102
                    app:layout_constraintTop_toTopOf="parent"
103
                    app:srcCompat="@drawable/write_comment_icon" />
104
105
                <TextView
106
                    android:layout_width="wrap_content"
107
                    android:layout_height="match_parent"
108
                    android:gravity="center"
109
                    android:paddingLeft="3dp"
110
                    android:text="写评论"
111
                    android:textColor="#c2c2c2"
112
                    android:textSize="12sp"
113
                    app:layout_constraintLeft_toRightOf="@+id/WriteCommentIcon" />
114
            </android.support.constraint.ConstraintLayout>
115
116
            <!-- 转发 -->
117
            <android.support.constraint.ConstraintLayout
118
                android:id="@+id/transmit"
119
                android:layout_width="wrap_content"
120
                android:layout_height="match_parent"
121
                android:paddingLeft="15dp"
122
                android:paddingRight="15dp"
123
                app:layout_constraintRight_toRightOf="parent">
124
125
                <ImageView
126
                    android:layout_width="wrap_content"
127
                    android:layout_height="wrap_content"
128
                    android:paddingRight="3dp"
129
                    app:layout_constraintBottom_toBottomOf="parent"
130
                    app:layout_constraintRight_toLeftOf="@+id/transmitLabel"
131
                    app:layout_constraintTop_toTopOf="parent"
132
                    app:srcCompat="@drawable/transmit_icon" />
133
134
                <TextView
135
                    android:id="@+id/transmitLabel"
136
                    android:layout_width="wrap_content"
137
                    android:layout_height="match_parent"
138
                    android:gravity="center"
139
                    android:paddingLeft="3dp"
140
                    android:text="转发"
141
                    android:textColor="#888888"
142
                    android:textSize="12sp"
143
                    app:layout_constraintRight_toRightOf="parent" />
144
            </android.support.constraint.ConstraintLayout>
145
146
            <!-- 评论列表 -->
147
            <android.support.constraint.ConstraintLayout
148
                android:id="@+id/comment"
149
                android:layout_width="wrap_content"
150
                android:layout_height="match_parent"
151
                android:paddingLeft="15dp"
152
                android:paddingRight="15dp"
153
                app:layout_constraintRight_toLeftOf="@+id/transmit">
154
155
                <ImageView
156
                    android:layout_width="wrap_content"
157
                    android:layout_height="wrap_content"
158
                    android:src="@drawable/comment_icon"
159
                    app:layout_constraintBottom_toBottomOf="parent"
160
                    app:layout_constraintRight_toLeftOf="@+id/commentLabel"
161
                    app:layout_constraintTop_toTopOf="parent" />
162
163
                <TextView
164
                    android:id="@+id/commentLabel"
165
                    android:layout_width="wrap_content"
166
                    android:layout_height="match_parent"
167
                    android:gravity="center"
168
                    android:paddingLeft="3dp"
169
                    android:textColor="#888888"
170
                    android:textSize="12sp"
171
                    app:layout_constraintRight_toRightOf="parent"
172
                    tools:text="123" />
173
174
            </android.support.constraint.ConstraintLayout>
175
            <!-- 点赞 -->
176
            <android.support.constraint.ConstraintLayout
177
                android:id="@+id/like"
178
                android:layout_width="wrap_content"
179
                android:layout_height="match_parent"
180
                app:layout_constraintRight_toLeftOf="@+id/comment">
181
182
                <ImageView
183
                    android:id="@+id/likeIcon"
184
                    android:layout_width="wrap_content"
185
                    android:layout_height="wrap_content"
186
                    android:src="@drawable/like_icon"
187
                    app:layout_constraintBottom_toBottomOf="parent"
188
                    app:layout_constraintRight_toLeftOf="@+id/likeLabel"
189
                    app:layout_constraintTop_toTopOf="parent" />
190
191
                <TextView
192
                    android:id="@+id/likeLabel"
193
                    android:layout_width="wrap_content"
194
                    android:layout_height="match_parent"
195
                    android:gravity="center"
196
                    android:paddingLeft="3dp"
197
                    android:textColor="#888888"
198
                    android:textSize="12sp"
199
                    app:layout_constraintRight_toRightOf="parent"
200
                    tools:text="999+" />
201
            </android.support.constraint.ConstraintLayout>
202
203
        </android.support.constraint.ConstraintLayout>
204
    </android.support.constraint.ConstraintLayout>
205
74
</android.support.constraint.ConstraintLayout>
206
</android.support.constraint.ConstraintLayout>