Bladeren bron

分享功能开发完成

huyuguo 5 jaren geleden
bovenliggende
commit
78e1a07b30

+ 161 - 3
app/src/main/java/com/electric/chargingpile/activity/ChatContentListActivity.java

@ -22,11 +22,15 @@ import android.view.MotionEvent;
22 22
import android.view.View;
23 23
import android.view.ViewGroup;
24 24
import android.view.ViewTreeObserver;
25
import android.view.animation.Animation;
26
import android.view.animation.AnimationUtils;
25 27
import android.widget.ImageView;
26 28
import android.widget.ProgressBar;
29
import android.widget.RelativeLayout;
27 30
import android.widget.TextView;
28 31
import android.widget.Toast;
29 32
33
import com.blankj.utilcode.util.LogUtils;
30 34
import com.blankj.utilcode.util.NetworkUtils;
31 35
import com.electric.chargingpile.R;
32 36
import com.electric.chargingpile.adapter.ChatPhotoFragmentPagerAdapter;
@ -50,6 +54,7 @@ import com.electric.chargingpile.util.ToastUtil;
50 54
import com.electric.chargingpile.util.Util;
51 55
import com.electric.chargingpile.video.VideoPlayer;
52 56
import com.electric.chargingpile.view.AlertDialog;
57
import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet;
53 58
import com.shuyu.gsyvideoplayer.GSYVideoADManager;
54 59
import com.shuyu.gsyvideoplayer.GSYVideoManager;
55 60
import com.shuyu.gsyvideoplayer.listener.GSYVideoProgressListener;
@ -64,6 +69,12 @@ import java.util.HashMap;
64 69
import java.util.List;
65 70
import java.util.Map;
66 71
72
import cn.sharesdk.framework.Platform;
73
import cn.sharesdk.framework.PlatformActionListener;
74
import cn.sharesdk.framework.ShareSDK;
75
import cn.sharesdk.tencent.qq.QQ;
76
import cn.sharesdk.wechat.friends.Wechat;
77
import cn.sharesdk.wechat.moments.WechatMoments;
67 78
import okhttp3.Call;
68 79
69 80
public class ChatContentListActivity extends AppCompatActivity {
@ -281,6 +292,15 @@ public class ChatContentListActivity extends AppCompatActivity {
281 292
        private TextView navTitle;
282 293
        private List<ChatPhotoFragment> chatPhotoFragments;
283 294
        private ChatPhotoFragmentPagerAdapter chatPhotoFragmentPagerAdapter;
295
        private ConstraintLayout transmit;
296
297
        private String shareUrl;
298
        private String shareStatus = "";
299
        private String sharePoint = "";
300
        private String sharePlatform = "";
301
        private RelativeLayout rl_point;
302
        private TextView tv_point;
303
        private Animation animation;
284 304
285 305
        public static ChatContentFragment newInstance(int index, String from) {
286 306
            ChatContentFragment fragment = new ChatContentFragment();
@ -395,6 +415,7 @@ public class ChatContentListActivity extends AppCompatActivity {
395 415
            rootView.findViewById(R.id.bottomView).setOnClickListener(this);
396 416
            rootView.findViewById(R.id.writeComment).setOnClickListener(this);
397 417
            rootView.findViewById(R.id.comment).setOnClickListener(this);
418
            transmit.setOnClickListener(this);
398 419
        }
399 420
400 421
        @Override
@ -445,7 +466,7 @@ public class ChatContentListActivity extends AppCompatActivity {
445 466
                            if (bean.commentNums == 0) {
446 467
                                commentNumber.setText("");
447 468
                            } else {
448
                                commentNumber.setText(bean.commentNums < 10000 ? bean.commentNums + "" : String.format("%.1fW",bean.commentNums/10000f));
469
                                commentNumber.setText(bean.commentNums < 10000 ? bean.commentNums + "" : String.format("%.1fW", bean.commentNums / 10000f));
449 470
                            }
450 471
                        }
451 472
                    });
@ -455,6 +476,140 @@ public class ChatContentListActivity extends AppCompatActivity {
455 476
//                    setViewPagerScroll(true);
456 477
//                    allCommentsContainer.setVisibility(View.GONE);
457 478
                    break;
479
                case R.id.transmit:  // 转发
480
                    transmit();
481
                    break;
482
            }
483
        }
484
485
        private void transmit() {
486
            showSimpleBottomSheetGrid();
487
        }
488
489
        private void showSimpleBottomSheetGrid() {
490
            final int TAG_SHARE_WECHAT_FRIEND = 0;
491
            final int TAG_SHARE_WECHAT_MOMENT = 1;
492
            final int TAG_SHARE_QQ = 2;
493
            QMUIBottomSheet.BottomGridSheetBuilder builder = new QMUIBottomSheet.BottomGridSheetBuilder(getContext());
494
            QMUIBottomSheet build = builder.addItem(R.drawable.icon_share_wechat, "微信", TAG_SHARE_WECHAT_FRIEND, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
495
                    .addItem(R.drawable.icon_share_wechatquan, "朋友圈", TAG_SHARE_WECHAT_MOMENT, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
496
                    .addItem(R.drawable.icon_share_qq, "QQ", TAG_SHARE_QQ, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
497
                    .setOnSheetItemClickListener(new QMUIBottomSheet.BottomGridSheetBuilder.OnSheetItemClickListener() {
498
                        @Override
499
                        public void onClick(QMUIBottomSheet dialog, View itemView) {
500
                            dialog.dismiss();
501
                            int tag = (int) itemView.getTag();
502
                            switch (tag) {
503
                                case TAG_SHARE_WECHAT_FRIEND:
504
                                    share(Wechat.NAME);
505
                                    break;
506
                                case TAG_SHARE_WECHAT_MOMENT:
507
                                    share(WechatMoments.NAME);
508
                                    break;
509
                                case TAG_SHARE_QQ:
510
                                    share(QQ.NAME);
511
                                    break;
512
                            }
513
                        }
514
                    }).build();
515
            build.show();
516
        }
517
518
        private void share(final String name) {
519
520
521
            Platform.ShareParams paramsToShare = new Platform.ShareParams();
522
            if (TextUtils.isEmpty(bean.title)) {
523
                paramsToShare.setTitle("推荐");
524
            } else {
525
                paramsToShare.setTitle(bean.title);
526
            }
527
            paramsToShare.setText("在充电桩聊聊你的生活");
528
529
            paramsToShare.setTitleUrl(bean.shareUrl);
530
            paramsToShare.setUrl(bean.shareUrl);
531
            paramsToShare.setImageUrl(bean.coverImgUrl);
532
            paramsToShare.setShareType(Platform.SHARE_WEBPAGE);
533
            Platform platform = ShareSDK.getPlatform(name);
534
            platform.setPlatformActionListener(new PlatformActionListener() {
535
                @Override
536
                public void onComplete(Platform platform, int i, HashMap<String, Object> hashMap) {
537
                    if (platform.getName().equalsIgnoreCase(QQ.NAME)) {
538
                        if (MainApplication.isLogin()) {
539
                            shareStatus = "yes";
540
                            sharePlatform = "qq";
541
                            getShareIntegral();
542
                        }
543
                    } else {
544
                        getShareIntegral();
545
                    }
546
547
                    ToastUtil.showToast(getContext(), "分享成功", Toast.LENGTH_SHORT);
548
                }
549
550
                @Override
551
                public void onError(Platform platform, int i, Throwable throwable) {
552
                    LogUtils.e(throwable.getMessage());
553
                }
554
555
                @Override
556
                public void onCancel(Platform platform, int i) {
557
                }
558
            });
559
            platform.share(paramsToShare);
560
        }
561
562
        private void getShareIntegral() {
563
            String url = MainApplication.url + "/zhannew/basic/web/index.php/member/insert-task?userid=" + MainApplication.userId;
564
            OkHttpUtils.get().url(url).build().execute(new StringCallback() {
565
                @Override
566
                public void onError(Call call, Exception e) {
567
568
                }
569
570
                @Override
571
                public void onResponse(String response) {
572
                    LogUtils.e(response);
573
                    String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
574
                    if ("01".equals(rtnCode)) {
575
                        String plusScore = JsonUtils.getKeyResult(response, "plusScore");
576
                        if (!plusScore.equals("")) {
577
                            if (sharePlatform.equals("qq")) {
578
                                sharePoint = plusScore;
579
                            } else {
580
                                tv_point.setText(plusScore);
581
                                rl_point.setVisibility(View.VISIBLE);
582
                                rl_point.startAnimation(animation);
583
                                new Handler().postDelayed(new Runnable() {
584
                                    public void run() {
585
                                        rl_point.setVisibility(View.GONE);
586
                                    }
587
                                }, 1500);
588
                            }
589
                        }
590
591
                    } else {
592
593
                    }
594
                }
595
            });
596
        }
597
598
        @Override
599
        public void onResume() {
600
            super.onResume();
601
            if (shareStatus.equals("yes") && !sharePoint.equals("") && sharePlatform.equals("qq")) {
602
                tv_point.setText(sharePoint);
603
                rl_point.setVisibility(View.VISIBLE);
604
                rl_point.startAnimation(animation);
605
                new Handler().postDelayed(new Runnable() {
606
                    public void run() {
607
                        rl_point.setVisibility(View.GONE);
608
                    }
609
                }, 1500);
610
                shareStatus = "";
611
                sharePoint = "";
612
                sharePlatform = "";
458 613
            }
459 614
        }
460 615
@ -486,8 +641,11 @@ public class ChatContentListActivity extends AppCompatActivity {
486 641
            topicTitle = rootView.findViewById(R.id.topicTitle);
487 642
            userInfo = rootView.findViewById(R.id.userInfo);
488 643
            commentNumber = rootView.findViewById(R.id.commentNumber);
644
            transmit = rootView.findViewById(R.id.transmit);
489 645
490
646
            rl_point = rootView.findViewById(R.id.rl_point);
647
            tv_point = rootView.findViewById(R.id.tv_point);
648
            animation = AnimationUtils.loadAnimation(getContext(), R.anim.nn);
491 649
492 650
            ConstraintLayout.LayoutParams statusBarParams = (ConstraintLayout.LayoutParams) statusBar.getLayoutParams();
493 651
            statusBarParams.height = statusBarHeight;
@ -545,7 +703,7 @@ public class ChatContentListActivity extends AppCompatActivity {
545 703
            if (bean.commentNums == 0) {
546 704
                commentNumber.setText("");
547 705
            } else {
548
                commentNumber.setText(bean.commentNums < 10000 ? bean.commentNums + "" : String.format("%.1fW",bean.commentNums/10000f));
706
                commentNumber.setText(bean.commentNums < 10000 ? bean.commentNums + "" : String.format("%.1fW", bean.commentNums / 10000f));
549 707
            }
550 708
        }
551 709

+ 161 - 2
app/src/main/java/com/electric/chargingpile/activity/TopicDetailActivity.java

@ -2,6 +2,7 @@ package com.electric.chargingpile.activity;
2 2
3 3
import android.content.Intent;
4 4
import android.os.Bundle;
5
import android.os.Handler;
5 6
import android.support.annotation.Nullable;
6 7
import android.support.constraint.ConstraintLayout;
7 8
import android.support.v7.app.AppCompatActivity;
@ -10,11 +11,15 @@ import android.support.v7.widget.StaggeredGridLayoutManager;
10 11
import android.text.TextUtils;
11 12
import android.util.Log;
12 13
import android.view.View;
14
import android.view.animation.Animation;
15
import android.view.animation.AnimationUtils;
13 16
import android.widget.ImageView;
17
import android.widget.RelativeLayout;
14 18
import android.widget.TextView;
15 19
import android.widget.Toast;
16 20
17 21
import com.andview.refreshview.XRefreshView;
22
import com.blankj.utilcode.util.LogUtils;
18 23
import com.electric.chargingpile.R;
19 24
import com.electric.chargingpile.adapter.TopicDetailAdapter;
20 25
import com.electric.chargingpile.application.MainApplication;
@ -29,12 +34,19 @@ import com.electric.chargingpile.util.JsonUtils;
29 34
import com.electric.chargingpile.util.LoadingDialog;
30 35
import com.electric.chargingpile.util.NetUtil;
31 36
import com.electric.chargingpile.util.ToastUtil;
37
import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet;
32 38
import com.zhy.http.okhttp.OkHttpUtils;
33 39
import com.zhy.http.okhttp.callback.StringCallback;
34 40
35 41
import java.util.HashMap;
36 42
import java.util.Map;
37 43
44
import cn.sharesdk.framework.Platform;
45
import cn.sharesdk.framework.PlatformActionListener;
46
import cn.sharesdk.framework.ShareSDK;
47
import cn.sharesdk.tencent.qq.QQ;
48
import cn.sharesdk.wechat.friends.Wechat;
49
import cn.sharesdk.wechat.moments.WechatMoments;
38 50
import okhttp3.Call;
39 51
40 52
/**
@ -59,6 +71,14 @@ public class TopicDetailActivity extends AppCompatActivity implements View.OnCli
59 71
    private ConstraintLayout topicOfflineView;
60 72
    private TopicHomePageBean homePageBean;
61 73
74
    private String shareUrl;
75
    private String shareStatus = "";
76
    private String sharePoint = "";
77
    private String sharePlatform = "";
78
    private RelativeLayout rl_point;
79
    private TextView tv_point;
80
    private Animation animation;
81
62 82
    @Override
63 83
    protected void onCreate(@Nullable Bundle savedInstanceState) {
64 84
        super.onCreate(savedInstanceState);
@ -84,6 +104,10 @@ public class TopicDetailActivity extends AppCompatActivity implements View.OnCli
84 104
        noNetView = findViewById(R.id.noNetView);
85 105
        topicOfflineView = findViewById(R.id.topicOfflineView);
86 106
107
        rl_point = findViewById(R.id.rl_point);
108
        tv_point = findViewById(R.id.tv_point);
109
        animation = AnimationUtils.loadAnimation(TopicDetailActivity.this, R.anim.nn);
110
87 111
        xRefreshView = findViewById(R.id.xRefreshView);
88 112
        xRefreshView.setPullLoadEnable(true); // 允许加载更多
89 113
        xRefreshView.setPinnedTime(0);
@ -139,7 +163,7 @@ public class TopicDetailActivity extends AppCompatActivity implements View.OnCli
139 163
        topicDetailAdapter.setOnRecyclerItemClickListener(new RecyclerItemTypeClickListener() {
140 164
            @Override
141 165
            public void onItemClickListener(int position, int index) {
142
                Intent intent =  new Intent(TopicDetailActivity.this, ChatContentListActivity.class);
166
                Intent intent = new Intent(TopicDetailActivity.this, ChatContentListActivity.class);
143 167
                intent.putExtra("from", ChatContentListActivity.FROM_TOPIC_DETAIL);
144 168
                intent.putExtra("index", position - 1);
145 169
                startActivityForResult(intent, ChatContentListActivity.REQUEST_CODE_TOPIC_DETAIL);
@ -209,7 +233,11 @@ public class TopicDetailActivity extends AppCompatActivity implements View.OnCli
209 233
    }
210 234
211 235
    private void shareInfo() {
212
        // TODO by hyg share information
236
        if (TextUtils.isEmpty(shareUrl)) {
237
            ToastUtil.showToast(TopicDetailActivity.this, "分享链接不存在", Toast.LENGTH_SHORT);
238
        } else {
239
            showSimpleBottomSheetGrid();
240
        }
213 241
    }
214 242
215 243
    // 服务器签名验证
@ -252,6 +280,7 @@ public class TopicDetailActivity extends AppCompatActivity implements View.OnCli
252 280
    }
253 281
254 282
    private void requestData(String init) {
283
255 284
        String url = MainApplication.urlNew + "/topic/homepage.do";
256 285
        Map<String, String> map = new HashMap<>();
257 286
        map.put("topicId", topicId + "");
@ -281,6 +310,7 @@ public class TopicDetailActivity extends AppCompatActivity implements View.OnCli
281 310
                String desc = JsonUtils.getKeyResult(res, "desc");
282 311
                if ("1000".equals(code)) {
283 312
                    String data = JsonUtils.getKeyResult(res, "data");
313
                    shareUrl = JsonUtils.getKeyResult(data, "shareUrl");
284 314
                    if ("{}".equals(data)) {
285 315
                        topicOfflineView.setVisibility(View.VISIBLE);
286 316
                        return;
@ -318,4 +348,133 @@ public class TopicDetailActivity extends AppCompatActivity implements View.OnCli
318 348
            }
319 349
        });
320 350
    }
351
352
    private void showSimpleBottomSheetGrid() {
353
        final int TAG_SHARE_WECHAT_FRIEND = 0;
354
        final int TAG_SHARE_WECHAT_MOMENT = 1;
355
        final int TAG_SHARE_QQ = 2;
356
        QMUIBottomSheet.BottomGridSheetBuilder builder = new QMUIBottomSheet.BottomGridSheetBuilder(TopicDetailActivity.this);
357
        QMUIBottomSheet build = builder.addItem(R.drawable.icon_share_wechat, "微信", TAG_SHARE_WECHAT_FRIEND, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
358
                .addItem(R.drawable.icon_share_wechatquan, "朋友圈", TAG_SHARE_WECHAT_MOMENT, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
359
                .addItem(R.drawable.icon_share_qq, "QQ", TAG_SHARE_QQ, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
360
                .setOnSheetItemClickListener(new QMUIBottomSheet.BottomGridSheetBuilder.OnSheetItemClickListener() {
361
                    @Override
362
                    public void onClick(QMUIBottomSheet dialog, View itemView) {
363
                        dialog.dismiss();
364
                        int tag = (int) itemView.getTag();
365
                        switch (tag) {
366
                            case TAG_SHARE_WECHAT_FRIEND:
367
                                share(Wechat.NAME);
368
                                break;
369
                            case TAG_SHARE_WECHAT_MOMENT:
370
                                share(WechatMoments.NAME);
371
                                break;
372
                            case TAG_SHARE_QQ:
373
                                share(QQ.NAME);
374
                                break;
375
                        }
376
                    }
377
                }).build();
378
        build.show();
379
    }
380
381
    private void share(final String name) {
382
        Platform.ShareParams paramsToShare = new Platform.ShareParams();
383
        if(TextUtils.isEmpty(homePageBean.topicVo.name)) {
384
            paramsToShare.setTitle("推荐");
385
        } else {
386
            paramsToShare.setTitle(homePageBean.topicVo.name);
387
        }
388
        if (TextUtils.isEmpty(homePageBean.topicVo.desc)) {
389
            paramsToShare.setText("在充电桩聊聊你的生活");
390
        } else {
391
            paramsToShare.setText(homePageBean.topicVo.desc);
392
        }
393
394
        paramsToShare.setTitleUrl(shareUrl);
395
        paramsToShare.setUrl(shareUrl);
396
        paramsToShare.setImageUrl(homePageBean.topicVo.coverImgUrl);
397
        paramsToShare.setShareType(Platform.SHARE_WEBPAGE);
398
        Platform platform = ShareSDK.getPlatform(name);
399
        platform.setPlatformActionListener(new PlatformActionListener() {
400
            @Override
401
            public void onComplete(Platform platform, int i, HashMap<String, Object> hashMap) {
402
                if (platform.getName().equalsIgnoreCase(QQ.NAME)) {
403
                    if (MainApplication.isLogin()) {
404
                        shareStatus = "yes";
405
                        sharePlatform = "qq";
406
                        getShareIntegral();
407
                    }
408
                } else {
409
                    getShareIntegral();
410
                }
411
412
                ToastUtil.showToast(getApplicationContext(), "分享成功", Toast.LENGTH_SHORT);
413
            }
414
415
            @Override
416
            public void onError(Platform platform, int i, Throwable throwable) {
417
                LogUtils.e(throwable.getMessage());
418
            }
419
420
            @Override
421
            public void onCancel(Platform platform, int i) {
422
            }
423
        });
424
        platform.share(paramsToShare);
425
    }
426
427
    private void getShareIntegral() {
428
        String url = MainApplication.url + "/zhannew/basic/web/index.php/member/insert-task?userid=" + MainApplication.userId;
429
        OkHttpUtils.get().url(url).build().execute(new StringCallback() {
430
            @Override
431
            public void onError(Call call, Exception e) {
432
433
            }
434
435
            @Override
436
            public void onResponse(String response) {
437
                LogUtils.e(response);
438
                String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
439
                if ("01".equals(rtnCode)) {
440
                    String plusScore = JsonUtils.getKeyResult(response, "plusScore");
441
                    if (!plusScore.equals("")) {
442
                        if (sharePlatform.equals("qq")) {
443
                            sharePoint = plusScore;
444
                        } else {
445
                            tv_point.setText(plusScore);
446
                            rl_point.setVisibility(View.VISIBLE);
447
                            rl_point.startAnimation(animation);
448
                            new Handler().postDelayed(new Runnable() {
449
                                public void run() {
450
                                    rl_point.setVisibility(View.GONE);
451
                                }
452
                            }, 1500);
453
                        }
454
                    }
455
456
                } else {
457
458
                }
459
            }
460
        });
461
    }
462
463
    @Override
464
    protected void onResume() {
465
        super.onResume();
466
        if (shareStatus.equals("yes") && !sharePoint.equals("") && sharePlatform.equals("qq")) {
467
            tv_point.setText(sharePoint);
468
            rl_point.setVisibility(View.VISIBLE);
469
            rl_point.startAnimation(animation);
470
            new Handler().postDelayed(new Runnable() {
471
                public void run() {
472
                    rl_point.setVisibility(View.GONE);
473
                }
474
            }, 1500);
475
            shareStatus = "";
476
            sharePoint = "";
477
            sharePlatform = "";
478
        }
479
    }
321 480
}

+ 154 - 1
app/src/main/java/com/electric/chargingpile/activity/UserPageActivity.java

@ -3,6 +3,7 @@ package com.electric.chargingpile.activity;
3 3
import android.content.Intent;
4 4
import android.graphics.Bitmap;
5 5
import android.graphics.drawable.Drawable;
6
import android.os.Handler;
6 7
import android.support.constraint.ConstraintLayout;
7 8
import android.support.v7.app.AppCompatActivity;
8 9
import android.os.Bundle;
@ -10,12 +11,15 @@ import android.support.v7.widget.RecyclerView;
10 11
import android.support.v7.widget.StaggeredGridLayoutManager;
11 12
import android.text.TextUtils;
12 13
import android.view.View;
14
import android.view.animation.Animation;
15
import android.view.animation.AnimationUtils;
13 16
import android.widget.ImageView;
14 17
import android.widget.RelativeLayout;
15 18
import android.widget.TextView;
16 19
import android.widget.Toast;
17 20
18 21
import com.andview.refreshview.XRefreshView;
22
import com.blankj.utilcode.util.LogUtils;
19 23
import com.electric.chargingpile.R;
20 24
import com.electric.chargingpile.adapter.TopicDetailAdapter;
21 25
import com.electric.chargingpile.adapter.UserPageAdapter;
@ -29,6 +33,7 @@ import com.electric.chargingpile.util.JsonUtils;
29 33
import com.electric.chargingpile.util.LoadingDialog;
30 34
import com.electric.chargingpile.util.NetUtil;
31 35
import com.electric.chargingpile.util.ToastUtil;
36
import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet;
32 37
import com.squareup.picasso.Picasso;
33 38
import com.squareup.picasso.Target;
34 39
import com.umeng.analytics.MobclickAgent;
@ -38,6 +43,12 @@ import com.zhy.http.okhttp.callback.StringCallback;
38 43
import java.util.HashMap;
39 44
import java.util.Map;
40 45
46
import cn.sharesdk.framework.Platform;
47
import cn.sharesdk.framework.PlatformActionListener;
48
import cn.sharesdk.framework.ShareSDK;
49
import cn.sharesdk.tencent.qq.QQ;
50
import cn.sharesdk.wechat.friends.Wechat;
51
import cn.sharesdk.wechat.moments.WechatMoments;
41 52
import okhttp3.Call;
42 53
43 54
public class UserPageActivity extends AppCompatActivity implements View.OnClickListener {
@ -63,6 +74,13 @@ public class UserPageActivity extends AppCompatActivity implements View.OnClickL
63 74
    private ConstraintLayout zeroTopicNum;
64 75
    private TextView topicNum;
65 76
77
    private String shareStatus = "";
78
    private String sharePoint = "";
79
    private String sharePlatform = "";
80
    private RelativeLayout rl_point;
81
    private TextView tv_point;
82
    private Animation animation;
83
66 84
67 85
    @Override
68 86
    protected void onCreate(Bundle savedInstanceState) {
@ -98,6 +116,9 @@ public class UserPageActivity extends AppCompatActivity implements View.OnClickL
98 116
        noNetTry = findViewById(R.id.noNetTry);
99 117
        zeroTopicNum = findViewById(R.id.zeroTopicNum);
100 118
119
        rl_point = findViewById(R.id.rl_point);
120
        tv_point = findViewById(R.id.tv_point);
121
        animation = AnimationUtils.loadAnimation(UserPageActivity.this, R.anim.nn);
101 122
102 123
        if (NetUtil.CheckNetwork(this)) {
103 124
            noNetView.setVisibility(View.GONE);
@ -191,7 +212,10 @@ public class UserPageActivity extends AppCompatActivity implements View.OnClickL
191 212
                    page = 1;
192 213
                    loadingDialog.show();
193 214
                    requestData();
215
                    return;
194 216
                }
217
218
                showSimpleBottomSheetGrid();
195 219
                break;
196 220
            case R.id.noNetTry:
197 221
                if (NetUtil.CheckNetwork(UserPageActivity.this)) {
@ -242,7 +266,7 @@ public class UserPageActivity extends AppCompatActivity implements View.OnClickL
242 266
                String code = JsonUtils.getKeyResult(s, "code");
243 267
                if ("1000".equals(code)) {
244 268
                    String data = JsonUtils.getKeyResult(s, "data");
245
                    UserHomePageBean userHomePageBean = (UserHomePageBean) JsonUtils.parseToObjectBean(data, UserHomePageBean.class);
269
                    userHomePageBean = (UserHomePageBean) JsonUtils.parseToObjectBean(data, UserHomePageBean.class);
246 270
                    if (page == 1) {
247 271
                        xRefreshView.setLoadComplete(false);
248 272
                        userVo = userHomePageBean.userVo;
@ -311,4 +335,133 @@ public class UserPageActivity extends AppCompatActivity implements View.OnClickL
311 335
312 336
        topicNum.setText(userVo.topicNums);
313 337
    }
338
339
    private void showSimpleBottomSheetGrid() {
340
        final int TAG_SHARE_WECHAT_FRIEND = 0;
341
        final int TAG_SHARE_WECHAT_MOMENT = 1;
342
        final int TAG_SHARE_QQ = 2;
343
        QMUIBottomSheet.BottomGridSheetBuilder builder = new QMUIBottomSheet.BottomGridSheetBuilder(UserPageActivity.this);
344
        QMUIBottomSheet build = builder.addItem(R.drawable.icon_share_wechat, "微信", TAG_SHARE_WECHAT_FRIEND, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
345
                .addItem(R.drawable.icon_share_wechatquan, "朋友圈", TAG_SHARE_WECHAT_MOMENT, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
346
                .addItem(R.drawable.icon_share_qq, "QQ", TAG_SHARE_QQ, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE)
347
                .setOnSheetItemClickListener(new QMUIBottomSheet.BottomGridSheetBuilder.OnSheetItemClickListener() {
348
                    @Override
349
                    public void onClick(QMUIBottomSheet dialog, View itemView) {
350
                        dialog.dismiss();
351
                        int tag = (int) itemView.getTag();
352
                        switch (tag) {
353
                            case TAG_SHARE_WECHAT_FRIEND:
354
                                share(Wechat.NAME);
355
                                break;
356
                            case TAG_SHARE_WECHAT_MOMENT:
357
                                share(WechatMoments.NAME);
358
                                break;
359
                            case TAG_SHARE_QQ:
360
                                share(QQ.NAME);
361
                                break;
362
                        }
363
                    }
364
                }).build();
365
        build.show();
366
    }
367
368
    private void share(final String name) {
369
        Platform.ShareParams paramsToShare = new Platform.ShareParams();
370
        if (TextUtils.isEmpty(userHomePageBean.userVo.nickName)) {
371
            paramsToShare.setTitle("推荐");
372
        } else {
373
            paramsToShare.setTitle(userHomePageBean.userVo.nickName + "的个人主页");
374
        }
375
        if (TextUtils.isEmpty(userHomePageBean.userVo.nickName)) {
376
            paramsToShare.setText("在充电桩聊聊你的生活");
377
        } else {
378
            paramsToShare.setText("快来看看" + userHomePageBean.userVo.nickName + "都在分享什么吧");
379
        }
380
381
        paramsToShare.setTitleUrl(userHomePageBean.shareUrl);
382
        paramsToShare.setUrl(userHomePageBean.shareUrl);
383
        paramsToShare.setImageUrl("http://cdz.evcharge.cc/zhannew/uploadfile/" + userHomePageBean.userVo.headImgUrl);
384
        paramsToShare.setShareType(Platform.SHARE_WEBPAGE);
385
        Platform platform = ShareSDK.getPlatform(name);
386
        platform.setPlatformActionListener(new PlatformActionListener() {
387
            @Override
388
            public void onComplete(Platform platform, int i, HashMap<String, Object> hashMap) {
389
                if (platform.getName().equalsIgnoreCase(QQ.NAME)) {
390
                    if (MainApplication.isLogin()) {
391
                        shareStatus = "yes";
392
                        sharePlatform = "qq";
393
                        getShareIntegral();
394
                    }
395
                } else {
396
                    getShareIntegral();
397
                }
398
399
                ToastUtil.showToast(getApplicationContext(), "分享成功", Toast.LENGTH_SHORT);
400
            }
401
402
            @Override
403
            public void onError(Platform platform, int i, Throwable throwable) {
404
                LogUtils.e(throwable.getMessage());
405
            }
406
407
            @Override
408
            public void onCancel(Platform platform, int i) {
409
            }
410
        });
411
        platform.share(paramsToShare);
412
    }
413
414
    private void getShareIntegral() {
415
        String url = MainApplication.url + "/zhannew/basic/web/index.php/member/insert-task?userid=" + MainApplication.userId;
416
        OkHttpUtils.get().url(url).build().execute(new StringCallback() {
417
            @Override
418
            public void onError(Call call, Exception e) {
419
420
            }
421
422
            @Override
423
            public void onResponse(String response) {
424
                LogUtils.e(response);
425
                String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
426
                if ("01".equals(rtnCode)) {
427
                    String plusScore = JsonUtils.getKeyResult(response, "plusScore");
428
                    if (!plusScore.equals("")) {
429
                        if (sharePlatform.equals("qq")) {
430
                            sharePoint = plusScore;
431
                        } else {
432
                            tv_point.setText(plusScore);
433
                            rl_point.setVisibility(View.VISIBLE);
434
                            rl_point.startAnimation(animation);
435
                            new Handler().postDelayed(new Runnable() {
436
                                public void run() {
437
                                    rl_point.setVisibility(View.GONE);
438
                                }
439
                            }, 1500);
440
                        }
441
                    }
442
443
                } else {
444
445
                }
446
            }
447
        });
448
    }
449
450
    @Override
451
    protected void onResume() {
452
        super.onResume();
453
        if (shareStatus.equals("yes") && !sharePoint.equals("") && sharePlatform.equals("qq")) {
454
            tv_point.setText(sharePoint);
455
            rl_point.setVisibility(View.VISIBLE);
456
            rl_point.startAnimation(animation);
457
            new Handler().postDelayed(new Runnable() {
458
                public void run() {
459
                    rl_point.setVisibility(View.GONE);
460
                }
461
            }, 1500);
462
            shareStatus = "";
463
            sharePoint = "";
464
            sharePlatform = "";
465
        }
466
    }
314 467
}

+ 1 - 1
app/src/main/java/com/electric/chargingpile/data/CommentBean.java

@ -22,7 +22,7 @@ public class CommentBean implements Serializable {
22 22
    public int likeFlg;
23 23
    public int isDel;
24 24
    public String addDate;
25
    public long replyNums;
25
    public int replyNums;
26 26
27 27
28 28
}

+ 10 - 3
app/src/main/java/com/electric/chargingpile/fragment/ChatContentCommentListDialogFragment.java

@ -226,7 +226,6 @@ public class ChatContentCommentListDialogFragment extends DialogFragment impleme
226 226
227 227
            @Override
228 228
            public void onResponse(String response) {
229
                Log.d(TAG, "onResponse: " + response);
230 229
                String code = JsonUtils.getKeyResult(response, "code");
231 230
                String desc = JsonUtils.getKeyResult(response, "desc");
232 231
                if ("1000".equals(code)) {
@ -377,7 +376,15 @@ public class ChatContentCommentListDialogFragment extends DialogFragment impleme
377 376
                    doLike();
378 377
                    break;
379 378
                case R.id.replyInfo: //  点击查看回复列表
380
                    
379
                    ChatContentReplyListDialogFragment dialogFragment = ChatContentReplyListDialogFragment.newInstance(chatRecommendBean, bean);
380
                    dialogFragment.show(getChildFragmentManager(), "回复列表");
381
                    dialogFragment.setOnCommonDialogFragmentListener(new ChatContentReplyListDialogFragment.OnChatContentReplyListDialogFragmentListener() {
382
                        @Override
383
                        public void updateCommentNum(int num) {
384
                            bean.replyNums = num;
385
                            commentAdapter.notifyItemChanged(position);
386
                        }
387
                    });
381 388
                    break;
382 389
                case R.id.deleteComment: // 删除评论操作
383 390
                    deleteComment();
@ -550,7 +557,7 @@ public class ChatContentCommentListDialogFragment extends DialogFragment impleme
550 557
            final Map<String, String> map = new HashMap<>();
551 558
            map.put("targetId", chatRecommendBean.targetId + "");
552 559
            map.put("targetType", chatRecommendBean.targetType + "");
553
            map.put("userId", MainApplication.userId );
560
            map.put("userId", MainApplication.userId);
554 561
            map.put("toUserId", chatRecommendBean.addUserId + "");
555 562
            map.put("level", "2");
556 563
            map.put("content", replyContent);

+ 595 - 0
app/src/main/java/com/electric/chargingpile/fragment/ChatContentReplyListDialogFragment.java

@ -0,0 +1,595 @@
1
package com.electric.chargingpile.fragment;
2
3
import android.app.Dialog;
4
import android.content.Intent;
5
import android.graphics.Color;
6
import android.os.Bundle;
7
import android.support.annotation.NonNull;
8
import android.support.constraint.ConstraintLayout;
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.text.TextUtils;
14
import android.util.Log;
15
import android.view.Gravity;
16
import android.view.LayoutInflater;
17
import android.view.View;
18
import android.view.ViewGroup;
19
import android.view.Window;
20
import android.view.WindowManager;
21
import android.widget.ImageView;
22
import android.widget.TextView;
23
import android.widget.Toast;
24
25
import com.andview.refreshview.XRefreshView;
26
import com.electric.chargingpile.R;
27
import com.electric.chargingpile.activity.LoginActivity;
28
import com.electric.chargingpile.application.MainApplication;
29
import com.electric.chargingpile.data.ChatRecommendBean;
30
import com.electric.chargingpile.data.CommentBean;
31
import com.electric.chargingpile.util.CircleTransform;
32
import com.electric.chargingpile.util.CommonParams;
33
import com.electric.chargingpile.util.JsonUtils;
34
import com.electric.chargingpile.util.ToastUtil;
35
import com.squareup.picasso.Picasso;
36
import com.wang.avi.AVLoadingIndicatorView;
37
import com.zhy.http.okhttp.OkHttpUtils;
38
import com.zhy.http.okhttp.callback.StringCallback;
39
40
import org.w3c.dom.Text;
41
42
import java.util.ArrayList;
43
import java.util.HashMap;
44
import java.util.List;
45
import java.util.Map;
46
47
import okhttp3.Call;
48
49
public class ChatContentReplyListDialogFragment extends DialogFragment implements View.OnClickListener {
50
    private static final String TAG = "ChatContentReplyListDialogFragment";
51
    private static final String ARG_BEAN = "bean";
52
    private static final String ARG_COMMENT_BEAN = "comment_bean";
53
    private OnChatContentReplyListDialogFragmentListener chatContentReplyListDialogFragmentListener;
54
    private ChatRecommendBean chatRecommendBean;
55
    private ConstraintLayout allComments;
56
    private TextView bCommentContent;
57
    private TextView bPublish;
58
    private Dialog dialog;
59
    private TextView allCommentTitle;
60
61
    private int page = 0;
62
    private AVLoadingIndicatorView loadingIndicator;
63
    private XRefreshView xRefreshView;
64
    private RecyclerView recyclerView;
65
    private ConstraintLayout loadingView;
66
    private CommentAdapter commentAdapter;
67
    private ConstraintLayout noDataView;
68
    private CommentBean commentBean;
69
    private ImageView commentHeadImage;
70
    private TextView commentNickName;
71
    private TextView commentAddDate;
72
    private TextView commentContent;
73
74
    public static ChatContentReplyListDialogFragment newInstance(ChatRecommendBean bean, CommentBean commentBean) {
75
        Bundle args = new Bundle();
76
        args.putSerializable(ARG_BEAN, bean);
77
        args.putSerializable(ARG_COMMENT_BEAN, commentBean);
78
        ChatContentReplyListDialogFragment dialogFragment = new ChatContentReplyListDialogFragment();
79
        dialogFragment.setArguments(args);
80
        return dialogFragment;
81
    }
82
83
    @NonNull
84
    @Override
85
    public Dialog onCreateDialog(Bundle savedInstanceState) {
86
        dialog = new Dialog(getActivity(), R.style.CommentDialog);
87
        // 外部点击设置为可取消
88
89
        dialog.setCancelable(true);
90
        dialog.setCanceledOnTouchOutside(true);
91
92
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
93
        dialog.setContentView(R.layout.fragment_chat_content_reply_list);
94
95
        Window window = dialog.getWindow();
96
        WindowManager.LayoutParams layoutParams = window.getAttributes();
97
        // 布局属性位于整个窗口底部
98
        layoutParams.gravity = Gravity.BOTTOM;
99
        // 布局属性宽度填充整个窗口,默认是有margin的
100
        layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
101
        window.setAttributes(layoutParams);
102
103
        initDialog();
104
        initListener();
105
        return dialog;
106
    }
107
108
109
    private void initDialog() {
110
        chatRecommendBean = (ChatRecommendBean) getArguments().getSerializable(ARG_BEAN);
111
        commentBean = (CommentBean)getArguments().getSerializable(ARG_COMMENT_BEAN);
112
113
        allComments = dialog.findViewById(R.id.allComments);
114
        bCommentContent = dialog.findViewById(R.id.bCommentContent);
115
        bPublish = dialog.findViewById(R.id.bPublish);
116
        allCommentTitle = dialog.findViewById(R.id.allCommentTitle);
117
        loadingView = dialog.findViewById(R.id.loadingView);
118
        loadingIndicator = dialog.findViewById(R.id.loadingIndicator);
119
        noDataView = dialog.findViewById(R.id.noDataView);
120
121
        commentHeadImage = dialog.findViewById(R.id.commentHeadImage);
122
        commentNickName = dialog.findViewById(R.id.commentNickName);
123
        commentAddDate = dialog.findViewById(R.id.commentAddDate);
124
        commentContent = dialog.findViewById(R.id.commentContent);
125
126
        showLoading();
127
        xRefreshView = dialog.findViewById(R.id.xRefreshView);
128
        xRefreshView.setPullRefreshEnable(false);
129
        xRefreshView.setPullLoadEnable(true);
130
        xRefreshView.setPinnedTime(0);
131
        recyclerView = dialog.findViewById(R.id.recyclerView);
132
        recyclerView.setHasFixedSize(true);
133
        recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
134
        ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
135
136
        commentAdapter = new CommentAdapter();
137
        recyclerView.setAdapter(commentAdapter);
138
139
        xRefreshView.setXRefreshViewListener(new XRefreshView.SimpleXRefreshListener() {
140
            @Override
141
            public void onRefresh(boolean isPullDown) {
142
            }
143
144
            @Override
145
            public void onLoadMore(boolean isSilence) {
146
                requestData();
147
            }
148
        });
149
150
        allCommentTitle.setText("全部回复 " + commentBean.replyNums);
151
152
        if (TextUtils.isEmpty(commentBean.headImgFromUser)) {
153
            Picasso.with(getContext())
154
                    .load(R.drawable.icon_face2_0)
155
                    .placeholder(R.drawable.icon_face2_0)
156
                    .error(R.drawable.icon_face2_0)
157
                    .transform(new CircleTransform())
158
                    .into(commentHeadImage);
159
        } else {
160
            Picasso.with(getContext())
161
                    .load("http://cdz.evcharge.cc/zhannew/uploadfile/" + commentBean.headImgFromUser)
162
                    .placeholder(R.drawable.icon_face2_0)
163
                    .error(R.drawable.icon_face2_0)
164
                    .transform(new CircleTransform())
165
                    .into(commentHeadImage);
166
        }
167
168
        commentNickName.setText(commentBean.nickNameFromUser);
169
        commentAddDate.setText(commentBean.addDate);
170
        commentContent.setText(commentBean.content);
171
        requestData();
172
    }
173
174
    private void showLoading() {
175
        loadingIndicator.show();
176
        loadingView.setVisibility(View.VISIBLE);
177
    }
178
179
    private void hideLoading() {
180
        loadingIndicator.hide();
181
        loadingView.setVisibility(View.GONE);
182
    }
183
184
    private void initListener() {
185
        allComments.setOnClickListener(this);
186
        dialog.findViewById(R.id.allCommentsClose).setOnClickListener(this);
187
        dialog.findViewById(R.id.bWriteComment).setOnClickListener(this);
188
        bPublish.setOnClickListener(this);
189
    }
190
191
    @Override
192
    public void onClick(View view) {
193
        switch (view.getId()) {
194
            case R.id.bWriteComment: // 写评论
195
                CommonDialogFragment commonDialogFragment = CommonDialogFragment.newInstance(bCommentContent.getText().toString(), "@" + commentBean.nickNameFromUser, CommonDialogFragment.DialogTypeComment);
196
                commonDialogFragment.show(getChildFragmentManager(), "CommonDialogFragment");
197
                commonDialogFragment.setOnCommonDialogFragmentListener(new CommonDialogFragment.OnCommonDialogFragmentListener() {
198
                    @Override
199
                    public void updateComment(String comment) {
200
                        bCommentContent.setText(comment);
201
                        if (comment.length() > 0) {
202
                            bPublish.setTextColor(Color.parseColor("#00EDB2"));
203
                        } else {
204
                            bPublish.setTextColor(Color.parseColor("#7e7e7e"));
205
                        }
206
                    }
207
208
                    @Override
209
                    public void publish() {
210
                        if (bCommentContent.getText().toString().length() > 0) {
211
                            publishReply();
212
                        }
213
                    }
214
215
                    @Override
216
                    public void updateReply(String reply) {
217
                    }
218
219
                    @Override
220
                    public void reply() {
221
222
                    }
223
                });
224
                break;
225
            case R.id.bPublish:
226
                if (bCommentContent.getText().toString().length() > 0) {
227
                    publishReply();
228
                }
229
                break;
230
            case R.id.allCommentsClose:
231
                dialog.dismiss();
232
                break;
233
        }
234
    }
235
236
    private void publishReply() {
237
        if (!MainApplication.isLogin()) {
238
            startActivity(new Intent(getActivity().getApplicationContext(), LoginActivity.class));
239
            ToastUtil.showToast(getActivity().getApplicationContext(), "请先登录", Toast.LENGTH_SHORT);
240
            return;
241
        }
242
243
        String url = MainApplication.urlNew + "/topic/comments/publish.do";
244
        final Map<String, String> map = new HashMap<>();
245
        map.put("targetId", chatRecommendBean.targetId + "");
246
        map.put("targetType", chatRecommendBean.targetType + "");
247
        map.put("userId", MainApplication.userId );
248
        map.put("toUserId", chatRecommendBean.addUserId + "");
249
        map.put("level", "2");
250
        map.put("content", bCommentContent.getText().toString());
251
        map.put("parentId", commentBean.id + "");
252
253
        CommonParams.addCommonParams(map);
254
255
        OkHttpUtils.post().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
256
            @Override
257
            public void onError(Call call, Exception e) {
258
                ToastUtil.showToast(getContext(), e.getMessage(), Toast.LENGTH_SHORT);
259
            }
260
261
            @Override
262
            public void onResponse(String response) {
263
                Log.d(TAG, "onResponse: " + response);
264
                String code = JsonUtils.getKeyResult(response, "code");
265
                String desc = JsonUtils.getKeyResult(response, "desc");
266
                if ("1000".equals(code)) {
267
                    commentAdapter.clearData();
268
                    requestData();
269
                    commentBean.replyNums ++;
270
                    allCommentTitle.setText("全部回复 " + commentBean.replyNums);
271
                    if (chatContentReplyListDialogFragmentListener != null) {
272
                        chatContentReplyListDialogFragmentListener.updateCommentNum(commentBean.replyNums);
273
                    }
274
275
                    bCommentContent.setText("");
276
                    bPublish.setTextColor(Color.parseColor("#7e7e7e"));
277
278
                } else if ("8010".equals(code)) {
279
                    startActivity(new Intent(getActivity().getApplicationContext(), LoginActivity.class));
280
                    ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
281
                } else {
282
                    ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
283
                }
284
            }
285
        });
286
    }
287
288
289
    private void requestData() {
290
        List<CommentBean> beans = commentAdapter.getCurrentData();
291
        String url = MainApplication.urlNew + "/topic/comments/detail.do";
292
        Map<String, String> map = new HashMap<>();
293
        map.put("limit", "20");
294
        map.put("targetId", chatRecommendBean.targetId + "");
295
        map.put("targetType", chatRecommendBean.targetType + "");
296
        map.put("parentId", commentBean.id + "");
297
        if (beans.size() == 0) {
298
            page = 1;
299
        } else {
300
            page = beans.size() / 10 + beans.size() % 10 == 0 ? 0 : 1;
301
        }
302
        map.put("page", page + "");
303
304
        if (page == 1) {
305
            map.put("commentsId", "0");
306
        } else {
307
            CommentBean bean = beans.get(beans.size() - 1);
308
            map.put("commentsId", bean.commentsId + "");
309
        }
310
311
        CommonParams.addCommonParams(map);
312
313
        OkHttpUtils.get().url(url).params(map).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
314
            @Override
315
            public void onError(Call call, Exception e) {
316
                hideLoading();
317
                if (page == 1) {
318
                    xRefreshView.stopRefresh();
319
                } else {
320
                    page--;
321
                    xRefreshView.stopLoadMore();
322
                }
323
                ToastUtil.showToast(getContext(), "加载失败,请重试", Toast.LENGTH_SHORT);
324
            }
325
326
            @Override
327
            public void onResponse(String s) {
328
                Log.d(TAG, "onResponse: " + s);
329
330
                hideLoading();
331
                String code = JsonUtils.getKeyResult(s, "code");
332
                if ("1000".equals(code)) {
333
                    String data = JsonUtils.getKeyResult(s, "data");
334
                    List<CommentBean> allBeans = (List<CommentBean>) JsonUtils.parseToObjectList(data, CommentBean.class);
335
                    List<CommentBean> beans = new ArrayList<>();
336
                    if (allBeans.size() > 1) {
337
                        for (int i = 1; i < allBeans.size(); i++) {
338
                            beans.add(allBeans.get(i));
339
                        }
340
                    }
341
                    if (page == 1) {
342
                        if (beans.size() == 0) {
343
                            noDataView.setVisibility(View.VISIBLE);
344
                        } else {
345
                            noDataView.setVisibility(View.GONE);
346
                            commentAdapter.setData(beans);
347
                        }
348
                    } else {
349
                        if (beans.size() > 0) {
350
                            commentAdapter.addData(beans);
351
                        }
352
                    }
353
354
                    if (beans.size() < 20) {
355
                        xRefreshView.setLoadComplete(true);
356
                    }
357
                    xRefreshView.stopLoadMore();
358
359
                } else {
360
                    String desc = JsonUtils.getKeyResult(s, "desc");
361
                    ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
362
                    xRefreshView.stopLoadMore();
363
                }
364
365
            }
366
        });
367
    }
368
369
    private class CommentHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
370
        private CommentBean bean;
371
        private String replyContent = "";
372
        private int position;
373
        private TextView content;
374
        private ImageView headImage;
375
        private TextView nickName;
376
        private TextView addDate;
377
        private ImageView likeIcon;
378
        private TextView likeLabel;
379
        private ConstraintLayout likeView;
380
        private TextView deleteComment;
381
382
        public CommentHolder(LayoutInflater layoutInflater, ViewGroup parent) {
383
            super(layoutInflater.inflate(R.layout.list_item_reply, parent, false));
384
385
            initView();
386
            initListener();
387
        }
388
389
        private void initView() {
390
            content = itemView.findViewById(R.id.content);
391
            headImage = itemView.findViewById(R.id.headImage);
392
            nickName = itemView.findViewById(R.id.nickName);
393
            addDate = itemView.findViewById(R.id.addDate);
394
            likeIcon = itemView.findViewById(R.id.likeIcon);
395
            likeLabel = itemView.findViewById(R.id.likeLabel);
396
            likeView = itemView.findViewById(R.id.likeView);
397
            deleteComment = itemView.findViewById(R.id.deleteComment);
398
        }
399
400
        private void initListener() {
401
            likeView.setOnClickListener(this);
402
            deleteComment.setOnClickListener(this);
403
        }
404
405
        @Override
406
        public void onClick(View view) {
407
            switch (view.getId()) {
408
                case R.id.likeView:
409
                    doLike();
410
                    break;
411
                case R.id.deleteComment: // 删除评论操作
412
                    deleteComment();
413
                    break;
414
            }
415
        }
416
417
        private void bindView(CommentBean bean, int position) {
418
            this.bean = bean;
419
            this.position = position;
420
            content.setText(bean.content);
421
            nickName.setText(bean.nickNameFromUser);
422
            addDate.setText(bean.addDate);
423
            if (bean.likeFlg == 1) {
424
                likeIcon.setImageResource(R.drawable.like_red_icon);
425
            } else {
426
                likeIcon.setImageResource(R.drawable.like_small_icon);
427
            }
428
            if (bean.likeNums > 0) {
429
                likeLabel.setText(bean.likeNums > 999 ? "999+" : bean.likeNums + "");
430
            } else {
431
                likeLabel.setText("");
432
            }
433
434
            if (TextUtils.isEmpty(bean.headImgFromUser)) {
435
                Picasso.with(getContext())
436
                        .load(R.drawable.icon_face2_0)
437
                        .placeholder(R.drawable.icon_face2_0)
438
                        .error(R.drawable.icon_face2_0)
439
                        .transform(new CircleTransform())
440
                        .into(headImage);
441
            } else {
442
                Picasso.with(getContext())
443
                        .load("http://cdz.evcharge.cc/zhannew/uploadfile/" + bean.headImgFromUser)
444
                        .placeholder(R.drawable.icon_face2_0)
445
                        .error(R.drawable.icon_face2_0)
446
                        .transform(new CircleTransform())
447
                        .into(headImage);
448
            }
449
450
            if (MainApplication.userId.equals(bean.userId + "")) {
451
                deleteComment.setVisibility(View.VISIBLE);
452
            } else {
453
                deleteComment.setVisibility(View.GONE);
454
            }
455
        }
456
457
        /**
458
         * 点赞操作
459
         */
460
        private void doLike() {
461
            String url = MainApplication.urlNew + "/topic/like.do";
462
            Map<String, String> map = new HashMap<>();
463
            map.put("targetId", bean.id + "");
464
            map.put("targetType", "26");
465
            map.put("flag", "1");
466
            map.put("authorId", bean.userId + "");
467
            CommonParams.addCommonParams(map);
468
469
            OkHttpUtils.get().url(url).params(map).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
470
                @Override
471
                public void onError(Call call, Exception e) {
472
                    ToastUtil.showToast(getContext(), "点赞失败,请重试", Toast.LENGTH_SHORT);
473
                }
474
475
                @Override
476
                public void onResponse(String res) {
477
                    String code = JsonUtils.getKeyResult(res, "code");
478
                    String desc = JsonUtils.getKeyResult(res, "desc");
479
                    if ("1000".equals(code)) {
480
                        bean.likeFlg = 1;
481
                        bean.likeNums += 1;
482
                        commentAdapter.notifyItemChanged(position);
483
                    } else {
484
                        ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
485
                    }
486
                }
487
            });
488
        }
489
490
        private void deleteComment() {
491
            if (!MainApplication.isLogin()) {
492
                startActivity(new Intent(getActivity().getApplicationContext(), LoginActivity.class));
493
                ToastUtil.showToast(getActivity().getApplicationContext(), "请先登录", Toast.LENGTH_SHORT);
494
                return;
495
            }
496
497
            String url = MainApplication.urlNew + "/topic/del.do";
498
            final Map<String, String> map = new HashMap<>();
499
            map.put("targetId", bean.id + "");
500
            map.put("targetType", "25");
501
            map.put("userId", bean.userId + "");
502
            CommonParams.addCommonParams(map);
503
            OkHttpUtils.post().params(map).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() {
504
                @Override
505
                public void onError(Call call, Exception e) {
506
                    ToastUtil.showToast(getContext(), e.getMessage(), Toast.LENGTH_SHORT);
507
                }
508
509
                @Override
510
                public void onResponse(String response) {
511
                    String code = JsonUtils.getKeyResult(response, "code");
512
                    String desc = JsonUtils.getKeyResult(response, "desc");
513
                    if ("1000".equals(code)) {
514
                        commentAdapter.removeData(position);
515
                        commentAdapter.notifyItemRemoved(position);
516
                        if (commentBean.replyNums > 0) {
517
                            commentBean.replyNums--;
518
                        }
519
                        allCommentTitle.setText("全部回复 " + commentBean.replyNums);
520
                        if (chatContentReplyListDialogFragmentListener != null) {
521
                            chatContentReplyListDialogFragmentListener.updateCommentNum(commentBean.replyNums);
522
                        }
523
                    } else if ("8010".equals(code)) {
524
                        startActivity(new Intent(getActivity().getApplicationContext(), LoginActivity.class));
525
                        ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
526
                    } else {
527
                        ToastUtil.showToast(getContext(), desc, Toast.LENGTH_SHORT);
528
                    }
529
                }
530
            });
531
        }
532
    }
533
534
    private class CommentAdapter extends RecyclerView.Adapter<CommentHolder> {
535
        private static final String TAG = "CommentAdapter";
536
        private List<CommentBean> beans;
537
538
        public CommentAdapter() {
539
            this.beans = new ArrayList<>();
540
        }
541
542
        @Override
543
        public CommentHolder onCreateViewHolder(ViewGroup parent, int i) {
544
            LayoutInflater layoutInflater = LayoutInflater.from(getActivity());
545
            return new CommentHolder(layoutInflater, parent);
546
        }
547
548
        @Override
549
        public void onBindViewHolder(CommentHolder commentHolder, int i) {
550
            CommentBean bean = beans.get(i);
551
            commentHolder.bindView(bean, i);
552
        }
553
554
        @Override
555
        public int getItemCount() {
556
            return beans.size();
557
        }
558
559
        public void setData(List<CommentBean> beans) {
560
            this.beans.clear();
561
            this.beans.addAll(beans);
562
            notifyDataSetChanged();
563
        }
564
565
        public void addData(List<CommentBean> beans) {
566
            int size = this.beans.size();
567
            this.beans.addAll(beans);
568
            notifyItemRangeChanged(size, beans.size());
569
        }
570
571
        public void clearData() {
572
            beans.clear();
573
        }
574
575
        public void removeData(int position) {
576
            if (position < beans.size()) {
577
                beans.remove(position);
578
            }
579
580
        }
581
582
        public List<CommentBean> getCurrentData() {
583
            return beans;
584
        }
585
586
    }
587
588
    public interface OnChatContentReplyListDialogFragmentListener {
589
        void updateCommentNum(int num);
590
    }
591
592
    public void setOnCommonDialogFragmentListener(OnChatContentReplyListDialogFragmentListener listener) {
593
        this.chatContentReplyListDialogFragmentListener = listener;
594
    }
595
}

+ 60 - 2
app/src/main/res/layout/activity_topic_detail.xml

@ -41,11 +41,12 @@
41 41
            android:textSize="15sp"
42 42
            app:layout_constraintBottom_toBottomOf="parent"
43 43
            app:layout_constraintEnd_toEndOf="parent"
44
            app:layout_constraintTop_toTopOf="parent" />
44
            app:layout_constraintTop_toTopOf="parent"
45
            tools:background="#ff0000" />
45 46
46 47
        <TextView
47 48
            android:id="@+id/titleTextView"
48
            android:layout_width="wrap_content"
49
            android:layout_width="0dp"
49 50
            android:layout_height="0dp"
50 51
            android:layout_marginStart="8dp"
51 52
            android:layout_marginEnd="8dp"
@ -57,6 +58,7 @@
57 58
            app:layout_constraintEnd_toStartOf="@+id/shareTextView"
58 59
            app:layout_constraintStart_toEndOf="@+id/backImageView"
59 60
            app:layout_constraintTop_toTopOf="parent"
61
            tools:background="#00ff00"
60 62
            tools:text="TextView" />
61 63
    </android.support.constraint.ConstraintLayout>
62 64
@ -116,4 +118,60 @@
116 118
        app:layout_constraintRight_toRightOf="parent"
117 119
        app:layout_constraintTop_toBottomOf="@+id/navBar" />
118 120
121
    <RelativeLayout
122
        android:id="@+id/rl_point"
123
        android:layout_width="80dp"
124
        android:layout_height="80dp"
125
        android:layout_marginTop="100dp"
126
        android:background="@drawable/icon_point_bg"
127
        android:visibility="gone"
128
        app:layout_constraintLeft_toLeftOf="parent"
129
        app:layout_constraintRight_toRightOf="parent"
130
        app:layout_constraintTop_toTopOf="parent">
131
132
        <LinearLayout
133
            android:layout_width="wrap_content"
134
            android:layout_height="wrap_content"
135
            android:layout_centerInParent="true"
136
            android:orientation="vertical">
137
138
            <LinearLayout
139
                android:layout_width="wrap_content"
140
                android:layout_height="wrap_content"
141
                android:layout_gravity="center_horizontal">
142
143
                <TextView
144
                    android:layout_width="wrap_content"
145
                    android:layout_height="wrap_content"
146
                    android:text="+"
147
                    android:textColor="@color/white"
148
                    android:textSize="16sp" />
149
150
                <TextView
151
                    android:id="@+id/tv_point"
152
                    android:layout_width="wrap_content"
153
                    android:layout_height="wrap_content"
154
                    android:layout_marginLeft="2dp"
155
                    android:text="20"
156
                    android:textColor="@color/white"
157
                    android:textSize="19sp" />
158
159
160
            </LinearLayout>
161
162
            <TextView
163
                android:layout_width="wrap_content"
164
                android:layout_height="wrap_content"
165
                android:layout_gravity="center_horizontal"
166
                android:layout_marginTop="2dp"
167
                android:text="充电币"
168
                android:textColor="@color/white"
169
                android:textSize="13sp" />
170
171
172
        </LinearLayout>
173
174
175
    </RelativeLayout>
176
119 177
</android.support.constraint.ConstraintLayout>

+ 55 - 0
app/src/main/res/layout/activity_user_page.xml

@ -235,5 +235,60 @@
235 235
            app:layout_constraintVertical_bias="0.35000002" />
236 236
237 237
    </android.support.constraint.ConstraintLayout>
238
    <RelativeLayout
239
        android:id="@+id/rl_point"
240
        android:layout_width="80dp"
241
        android:layout_height="80dp"
242
        android:layout_marginTop="100dp"
243
        android:background="@drawable/icon_point_bg"
244
        android:visibility="gone"
245
        app:layout_constraintLeft_toLeftOf="parent"
246
        app:layout_constraintRight_toRightOf="parent"
247
        app:layout_constraintTop_toTopOf="parent">
248
249
        <LinearLayout
250
            android:layout_width="wrap_content"
251
            android:layout_height="wrap_content"
252
            android:layout_centerInParent="true"
253
            android:orientation="vertical">
254
255
            <LinearLayout
256
                android:layout_width="wrap_content"
257
                android:layout_height="wrap_content"
258
                android:layout_gravity="center_horizontal">
259
260
                <TextView
261
                    android:layout_width="wrap_content"
262
                    android:layout_height="wrap_content"
263
                    android:text="+"
264
                    android:textColor="@color/white"
265
                    android:textSize="16sp" />
266
267
                <TextView
268
                    android:id="@+id/tv_point"
269
                    android:layout_width="wrap_content"
270
                    android:layout_height="wrap_content"
271
                    android:layout_marginLeft="2dp"
272
                    android:text="20"
273
                    android:textColor="@color/white"
274
                    android:textSize="19sp" />
275
276
277
            </LinearLayout>
278
279
            <TextView
280
                android:layout_width="wrap_content"
281
                android:layout_height="wrap_content"
282
                android:layout_gravity="center_horizontal"
283
                android:layout_marginTop="2dp"
284
                android:text="充电币"
285
                android:textColor="@color/white"
286
                android:textSize="13sp" />
287
288
289
        </LinearLayout>
290
291
292
    </RelativeLayout>
238 293
239 294
</android.support.constraint.ConstraintLayout>

+ 56 - 1
app/src/main/res/layout/fragment_chat_content_pictures.xml

@ -46,6 +46,7 @@
46 46
            app:layout_constraintLeft_toLeftOf="parent" />
47 47
48 48
        <ImageView
49
            android:visibility="gone"
49 50
            android:id="@+id/moreIcon"
50 51
            android:layout_width="wrap_content"
51 52
            android:layout_height="match_parent"
@ -360,6 +361,60 @@
360 361
            </android.support.constraint.ConstraintLayout>
361 362
362 363
        </android.support.constraint.ConstraintLayout>
363
364 364
    </android.support.constraint.ConstraintLayout>
365
    <RelativeLayout
366
        android:id="@+id/rl_point"
367
        android:layout_width="80dp"
368
        android:layout_height="80dp"
369
        android:layout_marginTop="100dp"
370
        android:background="@drawable/icon_point_bg"
371
        android:visibility="gone"
372
        app:layout_constraintLeft_toLeftOf="parent"
373
        app:layout_constraintRight_toRightOf="parent"
374
        app:layout_constraintTop_toTopOf="parent">
375
376
        <LinearLayout
377
            android:layout_width="wrap_content"
378
            android:layout_height="wrap_content"
379
            android:layout_centerInParent="true"
380
            android:orientation="vertical">
381
382
            <LinearLayout
383
                android:layout_width="wrap_content"
384
                android:layout_height="wrap_content"
385
                android:layout_gravity="center_horizontal">
386
387
                <TextView
388
                    android:layout_width="wrap_content"
389
                    android:layout_height="wrap_content"
390
                    android:text="+"
391
                    android:textColor="@color/white"
392
                    android:textSize="16sp" />
393
394
                <TextView
395
                    android:id="@+id/tv_point"
396
                    android:layout_width="wrap_content"
397
                    android:layout_height="wrap_content"
398
                    android:layout_marginLeft="2dp"
399
                    android:text="20"
400
                    android:textColor="@color/white"
401
                    android:textSize="19sp" />
402
403
404
            </LinearLayout>
405
406
            <TextView
407
                android:layout_width="wrap_content"
408
                android:layout_height="wrap_content"
409
                android:layout_gravity="center_horizontal"
410
                android:layout_marginTop="2dp"
411
                android:text="充电币"
412
                android:textColor="@color/white"
413
                android:textSize="13sp" />
414
415
416
        </LinearLayout>
417
418
419
    </RelativeLayout>
365 420
</android.support.constraint.ConstraintLayout>

+ 307 - 0
app/src/main/res/layout/fragment_chat_content_reply_list.xml

@ -0,0 +1,307 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    xmlns:app="http://schemas.android.com/apk/res-auto"
4
    xmlns:tools="http://schemas.android.com/tools"
5
    android:layout_width="match_parent"
6
    android:layout_height="match_parent"
7
    tools:background="#68b8be">
8
9
    <android.support.constraint.ConstraintLayout
10
        android:id="@+id/allComments"
11
        android:layout_width="match_parent"
12
        android:layout_height="480dp"
13
        android:background="#424242"
14
        app:layout_constraintBottom_toBottomOf="parent"
15
        app:layout_constraintLeft_toLeftOf="parent"
16
        app:layout_constraintRight_toRightOf="parent">
17
18
        <!-- 标题栏-->
19
        <android.support.constraint.ConstraintLayout
20
            android:id="@+id/titleView"
21
            android:layout_width="match_parent"
22
            android:layout_height="40dp"
23
            app:layout_constraintTop_toTopOf="parent">
24
25
            <TextView
26
                android:id="@+id/allCommentTitle"
27
                android:layout_width="match_parent"
28
                android:layout_height="wrap_content"
29
                android:gravity="center_horizontal"
30
                android:textColor="#c2c2c2"
31
                android:textSize="14sp"
32
                app:layout_constraintBottom_toBottomOf="parent"
33
                app:layout_constraintTop_toTopOf="parent"
34
                tools:text="全部回复 12" />
35
36
            <ImageView
37
                android:id="@+id/allCommentsClose"
38
                android:layout_width="45dp"
39
                android:layout_height="match_parent"
40
                android:scaleType="center"
41
                android:src="@drawable/icon_close"
42
                app:layout_constraintRight_toRightOf="parent" />
43
44
            <View
45
                android:layout_width="match_parent"
46
                android:layout_height="1dp"
47
                android:background="#505050"
48
                app:layout_constraintBottom_toBottomOf="parent" />
49
        </android.support.constraint.ConstraintLayout>
50
        <android.support.constraint.ConstraintLayout
51
            android:id="@+id/commentView"
52
            android:layout_width="match_parent"
53
            app:layout_constraintLeft_toLeftOf="parent"
54
            app:layout_constraintRight_toRightOf="parent"
55
            app:layout_constraintTop_toBottomOf="@+id/titleView"
56
            android:layout_height="wrap_content">
57
            <!-- 用户信息及点赞 -->
58
            <android.support.constraint.ConstraintLayout
59
                android:id="@+id/commentTopView"
60
                android:layout_width="match_parent"
61
                android:layout_height="64dp"
62
                android:paddingTop="10dp"
63
                app:layout_constraintTop_toTopOf="parent">
64
65
                <ImageView
66
                    android:id="@+id/commentHeadImage"
67
                    android:layout_width="20dp"
68
                    android:layout_height="20dp"
69
                    android:layout_marginLeft="15dp"
70
                    app:layout_constraintBottom_toBottomOf="parent"
71
                    app:layout_constraintLeft_toLeftOf="parent"
72
                    app:layout_constraintTop_toTopOf="parent"
73
                    tools:srcCompat="@tools:sample/avatars[8]" />
74
75
                <TextView
76
                    android:id="@+id/commentNickName"
77
                    android:layout_width="wrap_content"
78
                    android:layout_height="wrap_content"
79
                    android:layout_marginLeft="5dp"
80
                    android:paddingTop="10dp"
81
                    android:textColor="#ffffff"
82
                    android:textSize="12sp"
83
                    app:layout_constraintLeft_toRightOf="@+id/commentHeadImage"
84
                    app:layout_constraintTop_toTopOf="parent"
85
                    tools:text="小电" />
86
87
                <TextView
88
                    android:id="@+id/commentAddDate"
89
                    android:layout_width="wrap_content"
90
                    android:layout_height="wrap_content"
91
                    android:layout_marginLeft="5dp"
92
                    android:layout_marginBottom="10dp"
93
                    android:textColor="#888888"
94
                    android:textSize="12sp"
95
                    app:layout_constraintBottom_toBottomOf="parent"
96
                    app:layout_constraintLeft_toRightOf="@+id/commentHeadImage"
97
                    tools:text="刚刚" />
98
            </android.support.constraint.ConstraintLayout>
99
100
            <TextView
101
                android:id="@+id/commentContent"
102
                android:layout_width="match_parent"
103
                android:layout_height="wrap_content"
104
                android:layout_marginLeft="39dp"
105
                android:layout_marginRight="37dp"
106
                android:textColor="#ffffff"
107
                android:textSize="14sp"
108
                app:layout_constraintTop_toBottomOf="@+id/commentTopView"
109
                tools:text="充电桩挺多的,但是油车也多,充电的车也多。园区进门就收费,还好去了两次都充上了。"></TextView>
110
111
            <View
112
                android:layout_width="match_parent"
113
                android:layout_height="1dp"
114
                android:layout_marginTop="20dp"
115
                android:background="#505050"
116
                app:layout_constraintBottom_toBottomOf="parent"
117
                app:layout_constraintTop_toBottomOf="@+id/commentContent" />
118
119
        </android.support.constraint.ConstraintLayout>
120
121
        <com.andview.refreshview.XRefreshView
122
            android:id="@+id/xRefreshView"
123
            android:layout_width="0dp"
124
            android:layout_height="0dp"
125
            app:layout_constraintBottom_toTopOf="@+id/bottomView"
126
            app:layout_constraintLeft_toLeftOf="parent"
127
            app:layout_constraintRight_toRightOf="parent"
128
            app:layout_constraintTop_toBottomOf="@+id/commentView">
129
130
            <android.support.v7.widget.RecyclerView
131
                android:id="@+id/recyclerView"
132
                android:layout_width="match_parent"
133
                android:layout_height="match_parent">
134
135
            </android.support.v7.widget.RecyclerView>
136
        </com.andview.refreshview.XRefreshView>
137
138
139
        <!-- 加载部分部分 -->
140
        <android.support.constraint.ConstraintLayout
141
            android:id="@+id/loadingView"
142
            android:layout_width="0dp"
143
            android:layout_height="0dp"
144
            android:visibility="gone"
145
            app:layout_constraintBottom_toTopOf="@+id/bottomView"
146
            app:layout_constraintEnd_toEndOf="parent"
147
            app:layout_constraintStart_toStartOf="parent"
148
            app:layout_constraintTop_toBottomOf="@+id/titleView">
149
150
            <com.wang.avi.AVLoadingIndicatorView
151
                android:id="@+id/loadingIndicator"
152
                android:layout_width="wrap_content"
153
                android:layout_height="wrap_content"
154
                android:layout_marginTop="80dp"
155
                app:indicatorName="BallClipRotatePulseIndicator"
156
                app:layout_constraintLeft_toLeftOf="parent"
157
                app:layout_constraintRight_toRightOf="parent"
158
                app:layout_constraintTop_toTopOf="parent" />
159
160
            <TextView
161
                android:id="@+id/textView37"
162
                android:layout_width="wrap_content"
163
                android:layout_height="wrap_content"
164
                android:layout_marginTop="20dp"
165
                android:text="小主正在为您努力加载,请耐心等待~"
166
                android:textColor="#ffffff"
167
                android:textSize="14sp"
168
                app:layout_constraintEnd_toEndOf="parent"
169
                app:layout_constraintStart_toStartOf="parent"
170
                app:layout_constraintTop_toBottomOf="@+id/loadingIndicator" />
171
        </android.support.constraint.ConstraintLayout>
172
173
        <!-- 没有数据 -->
174
        <android.support.constraint.ConstraintLayout
175
            android:id="@+id/noDataView"
176
            android:layout_width="0dp"
177
            android:layout_height="0dp"
178
            android:visibility="gone"
179
            app:layout_constraintBottom_toTopOf="@+id/bottomView"
180
            app:layout_constraintEnd_toEndOf="parent"
181
            app:layout_constraintStart_toStartOf="parent"
182
            app:layout_constraintTop_toBottomOf="@+id/titleView">
183
184
            <TextView
185
                android:layout_width="wrap_content"
186
                android:layout_height="wrap_content"
187
                android:layout_marginTop="20dp"
188
                android:text="还没有评论哦,快去抢沙发~"
189
                android:textColor="#ffffff"
190
                android:textSize="14sp"
191
                app:layout_constraintBottom_toBottomOf="parent"
192
                app:layout_constraintEnd_toEndOf="parent"
193
                app:layout_constraintStart_toStartOf="parent"
194
                app:layout_constraintTop_toTopOf="parent" />
195
        </android.support.constraint.ConstraintLayout>
196
197
        <!-- 检查网络 -->
198
        <android.support.constraint.ConstraintLayout
199
            android:id="@+id/noNetView"
200
            android:layout_width="0dp"
201
            android:layout_height="wrap_content"
202
            android:visibility="gone"
203
            app:layout_constraintBottom_toTopOf="@+id/bottomView"
204
            app:layout_constraintEnd_toEndOf="parent"
205
            app:layout_constraintStart_toStartOf="parent"
206
            app:layout_constraintTop_toBottomOf="@+id/titleView">
207
208
            <TextView
209
                android:id="@+id/noNetTitle"
210
                android:layout_width="wrap_content"
211
                android:layout_height="wrap_content"
212
                android:layout_marginTop="20dp"
213
                android:text="网络跑调啦,请检查网络~"
214
                android:textColor="#ffffff"
215
                android:textSize="14sp"
216
                app:layout_constraintEnd_toEndOf="parent"
217
                app:layout_constraintStart_toStartOf="parent"
218
                app:layout_constraintTop_toTopOf="parent" />
219
220
            <TextView
221
                android:id="@+id/noNetTry"
222
                android:layout_width="wrap_content"
223
                android:layout_height="wrap_content"
224
                android:layout_marginTop="20dp"
225
                android:width="123dp"
226
                android:height="40dp"
227
                android:background="@drawable/btn_comment_shape"
228
                android:gravity="center"
229
                android:text="点击重试"
230
                android:textColor="#ffffff"
231
                android:textSize="14sp"
232
                app:layout_constraintBottom_toBottomOf="parent"
233
                app:layout_constraintEnd_toEndOf="parent"
234
                app:layout_constraintStart_toStartOf="parent"
235
                app:layout_constraintTop_toBottomOf="@+id/noNetTitle" />
236
237
        </android.support.constraint.ConstraintLayout>
238
239
        <!-- 底部评论输入及发布 -->
240
        <android.support.constraint.ConstraintLayout
241
            android:id="@+id/bottomView"
242
            android:layout_width="match_parent"
243
            android:layout_height="54dp"
244
            android:background="#535353"
245
            app:layout_constraintBottom_toBottomOf="parent"
246
            app:layout_constraintEnd_toEndOf="parent"
247
            app:layout_constraintStart_toStartOf="parent">
248
249
            <android.support.constraint.ConstraintLayout
250
                android:id="@+id/bWriteComment"
251
                android:layout_width="0dp"
252
                android:layout_height="30dp"
253
                android:layout_marginLeft="15dp"
254
                android:background="@drawable/bg_comment_shape"
255
                app:layout_constraintBottom_toBottomOf="parent"
256
                app:layout_constraintLeft_toLeftOf="parent"
257
                app:layout_constraintRight_toLeftOf="@+id/bPublish"
258
                app:layout_constraintTop_toTopOf="parent">
259
260
                <ImageView
261
                    android:id="@+id/bCommentIcon"
262
                    android:layout_width="wrap_content"
263
                    android:layout_height="wrap_content"
264
                    android:layout_marginStart="15dp"
265
                    android:paddingRight="5dp"
266
                    app:layout_constraintBottom_toBottomOf="parent"
267
                    app:layout_constraintStart_toStartOf="parent"
268
                    app:layout_constraintTop_toTopOf="parent"
269
                    app:srcCompat="@drawable/write_comment_icon" />
270
271
                <TextView
272
                    android:id="@+id/bCommentContent"
273
                    android:layout_width="0dp"
274
                    android:layout_height="wrap_content"
275
                    android:ellipsize="end"
276
                    android:gravity="center_vertical"
277
                    android:maxLines="1"
278
                    android:hint="写评论"
279
                    android:paddingLeft="5dp"
280
                    android:textColor="#ffffff"
281
                    android:textColorHint="#c2c2c2"
282
                    android:textSize="14sp"
283
                    app:layout_constraintBottom_toBottomOf="parent"
284
                    app:layout_constraintLeft_toRightOf="@+id/bCommentIcon"
285
                    app:layout_constraintRight_toRightOf="parent"
286
                    app:layout_constraintTop_toTopOf="parent" />
287
            </android.support.constraint.ConstraintLayout>
288
289
            <TextView
290
                android:id="@+id/bPublish"
291
                android:layout_width="wrap_content"
292
                android:layout_height="0dp"
293
                android:gravity="center_vertical"
294
                android:paddingLeft="13dp"
295
                android:paddingRight="15dp"
296
                android:text="发布"
297
                android:textColor="#7e7e7e"
298
                android:textSize="14sp"
299
                app:layout_constraintBottom_toBottomOf="parent"
300
                app:layout_constraintRight_toRightOf="parent"
301
                app:layout_constraintTop_toTopOf="parent"
302
                tools:layout_editor_absoluteX="348dp"
303
                tools:layout_editor_absoluteY="19dp" />
304
        </android.support.constraint.ConstraintLayout>
305
    </android.support.constraint.ConstraintLayout>
306
307
</android.support.constraint.ConstraintLayout>

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

@ -75,6 +75,7 @@
75 75
            app:layout_constraintLeft_toLeftOf="parent" />
76 76
77 77
        <ImageView
78
            android:visibility="gone"
78 79
            android:id="@+id/moreIcon"
79 80
            android:layout_width="wrap_content"
80 81
            android:layout_height="match_parent"
@ -379,4 +380,60 @@
379 380
380 381
    </android.support.constraint.ConstraintLayout>
381 382
383
    <RelativeLayout
384
        android:id="@+id/rl_point"
385
        android:layout_width="80dp"
386
        android:layout_height="80dp"
387
        android:layout_marginTop="100dp"
388
        android:background="@drawable/icon_point_bg"
389
        android:visibility="gone"
390
        app:layout_constraintLeft_toLeftOf="parent"
391
        app:layout_constraintRight_toRightOf="parent"
392
        app:layout_constraintTop_toTopOf="parent">
393
394
        <LinearLayout
395
            android:layout_width="wrap_content"
396
            android:layout_height="wrap_content"
397
            android:layout_centerInParent="true"
398
            android:orientation="vertical">
399
400
            <LinearLayout
401
                android:layout_width="wrap_content"
402
                android:layout_height="wrap_content"
403
                android:layout_gravity="center_horizontal">
404
405
                <TextView
406
                    android:layout_width="wrap_content"
407
                    android:layout_height="wrap_content"
408
                    android:text="+"
409
                    android:textColor="@color/white"
410
                    android:textSize="16sp" />
411
412
                <TextView
413
                    android:id="@+id/tv_point"
414
                    android:layout_width="wrap_content"
415
                    android:layout_height="wrap_content"
416
                    android:layout_marginLeft="2dp"
417
                    android:text="20"
418
                    android:textColor="@color/white"
419
                    android:textSize="19sp" />
420
421
422
            </LinearLayout>
423
424
            <TextView
425
                android:layout_width="wrap_content"
426
                android:layout_height="wrap_content"
427
                android:layout_gravity="center_horizontal"
428
                android:layout_marginTop="2dp"
429
                android:text="充电币"
430
                android:textColor="@color/white"
431
                android:textSize="13sp" />
432
433
434
        </LinearLayout>
435
436
437
    </RelativeLayout>
438
382 439
</android.support.constraint.ConstraintLayout>

+ 119 - 0
app/src/main/res/layout/list_item_reply.xml

@ -0,0 +1,119 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    xmlns:app="http://schemas.android.com/apk/res-auto"
4
    xmlns:tools="http://schemas.android.com/tools"
5
    android:id="@+id/listItemView"
6
    android:layout_width="match_parent"
7
    android:layout_height="wrap_content"
8
    tools:background="#424242">
9
10
    <!-- 用户信息及点赞 -->
11
    <android.support.constraint.ConstraintLayout
12
        android:id="@+id/topView"
13
        android:layout_width="match_parent"
14
        android:layout_height="64dp"
15
        android:paddingTop="10dp"
16
        app:layout_constraintTop_toTopOf="parent">
17
18
        <ImageView
19
            android:id="@+id/headImage"
20
            android:layout_width="20dp"
21
            android:layout_height="20dp"
22
            android:layout_marginLeft="15dp"
23
            app:layout_constraintBottom_toBottomOf="parent"
24
            app:layout_constraintLeft_toLeftOf="parent"
25
            app:layout_constraintTop_toTopOf="parent"
26
            tools:srcCompat="@tools:sample/avatars[8]" />
27
28
        <TextView
29
            android:id="@+id/nickName"
30
            android:layout_width="wrap_content"
31
            android:layout_height="wrap_content"
32
            android:layout_marginLeft="5dp"
33
            android:paddingTop="10dp"
34
            android:textColor="#ffffff"
35
            android:textSize="12sp"
36
            app:layout_constraintLeft_toRightOf="@+id/headImage"
37
            app:layout_constraintTop_toTopOf="parent"
38
            tools:text="小电" />
39
40
        <TextView
41
            android:id="@+id/addDate"
42
            android:layout_width="wrap_content"
43
            android:layout_height="wrap_content"
44
            android:layout_marginLeft="5dp"
45
            android:layout_marginBottom="10dp"
46
            android:textColor="#888888"
47
            android:textSize="12sp"
48
            app:layout_constraintBottom_toBottomOf="parent"
49
            app:layout_constraintLeft_toRightOf="@+id/headImage"
50
            tools:text="刚刚" />
51
52
        <android.support.constraint.ConstraintLayout
53
            android:id="@+id/likeView"
54
            android:layout_width="wrap_content"
55
            android:layout_height="match_parent"
56
            android:paddingLeft="17dp"
57
            android:paddingRight="17dp"
58
            app:layout_constraintRight_toRightOf="parent"
59
            tools:background="#ff0000">
60
61
            <ImageView
62
                android:id="@+id/likeIcon"
63
                android:layout_width="18dp"
64
                android:layout_height="18dp"
65
                android:src="@drawable/like_small_icon"
66
                app:layout_constraintBottom_toBottomOf="parent"
67
                app:layout_constraintLeft_toLeftOf="parent"
68
                app:layout_constraintTop_toTopOf="parent" />
69
70
            <TextView
71
                android:id="@+id/likeLabel"
72
                android:layout_width="wrap_content"
73
                android:layout_height="wrap_content"
74
                android:paddingLeft="4dp"
75
                android:textColor="#888888"
76
                android:textSize="12sp"
77
                app:layout_constraintBottom_toBottomOf="parent"
78
                app:layout_constraintLeft_toRightOf="@+id/likeIcon"
79
                app:layout_constraintRight_toRightOf="parent"
80
                app:layout_constraintTop_toTopOf="parent"
81
                tools:text="123" />
82
83
        </android.support.constraint.ConstraintLayout>
84
    </android.support.constraint.ConstraintLayout>
85
86
    <TextView
87
        android:id="@+id/content"
88
        android:layout_width="match_parent"
89
        android:layout_height="wrap_content"
90
        android:layout_marginLeft="39dp"
91
        android:layout_marginRight="37dp"
92
        android:textColor="#ffffff"
93
        android:textSize="14sp"
94
        app:layout_constraintTop_toBottomOf="@+id/topView"
95
        tools:text="充电桩挺多的,但是油车也多,充电的车也多。园区进门就收费,还好去了两次都充上了。"></TextView>
96
97
    <TextView
98
        android:id="@+id/deleteComment"
99
        android:layout_width="wrap_content"
100
        android:layout_height="42dp"
101
        android:gravity="center"
102
        android:paddingLeft="29dp"
103
        android:paddingRight="10dp"
104
        android:text="删除"
105
        android:textColor="#c2c2c2"
106
        android:textSize="12sp"
107
        app:layout_constraintLeft_toLeftOf="parent"
108
        app:layout_constraintTop_toBottomOf="@+id/content"
109
        tools:background="#790f59" />
110
111
    <View
112
        android:layout_width="match_parent"
113
        android:layout_height="1dp"
114
        android:layout_marginLeft="16dp"
115
        android:layout_marginTop="10dp"
116
        android:background="#505050"
117
        app:layout_constraintBottom_toBottomOf="parent"
118
        app:layout_constraintTop_toBottomOf="@+id/deleteComment" />
119
</android.support.constraint.ConstraintLayout>