BottomCommentFunctionBar.java 27.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964
package com.wd.common.widget;

import android.app.Dialog;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.wd.foundation.wdkit.utils.DialogUtils;
import com.wd.common.interact.collect.CollectTools;
import com.wd.common.interact.collect.callback.CollectCallback;
import com.wd.common.interact.interacts.callback.IInteractDataListener;
import com.wd.common.interact.interacts.fetcher.InteractFetcher;
import com.wd.common.interact.like.LikeTools;
import com.wd.common.interact.like.QueryLikeStatusTools;
import com.wd.common.interact.like.callback.LikeCallback;
import com.wd.common.interact.like.callback.QueryLikeStatusCallback;
import com.wd.common.listener.AddFavoriteLabelCallback;
import com.wd.foundation.wdkit.utils.PDUtils;
import com.wd.common.utils.ProcessUtils;
import com.wd.common.utils.ToolsUtil;
import com.wd.fastcoding.base.R;
import com.wd.foundation.bean.comment.DisplayWorkInfoBean;
import com.wd.foundation.bean.comment.TransparentBean;
import com.wd.foundation.bean.custom.collect.AddDelCollectBean;
import com.wd.foundation.bean.response.InteractResponseDataBean;
import com.wd.foundation.wdkit.system.FastClickUtil;
import com.wd.foundation.wdkit.utils.NumberStrUtils;
import com.wd.foundation.wdkit.utils.SpUtils;
import com.wd.foundation.wdkit.utils.ToastNightUtil;
import com.wd.foundation.wdkit.utils.ViewUtils;
import com.wd.foundation.wdkit.view.AnimationView;
import com.wd.foundation.wdkit.view.customtextview.StrokeWidthTextView;
import com.wd.foundation.wdkitcore.thread.ThreadPoolUtils;
import com.wd.foundation.wdkitcore.tools.ArrayUtils;
import com.wd.foundation.wdkitcore.tools.ResUtils;
import com.wd.foundation.wdkitcore.tools.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author LiuKun
 * @date:2023/5/9
 * @desc:底部评论tab
 */
public class BottomCommentFunctionBar extends FrameLayout {

    /**
     * 头部分割线
     */
    private View topLine;
    /**
     * 返回按钮
     */
    private ImageView backIv;

    /**
     * 输入框
     */
    private View inputView;
    /**
     * 评论图标
     */
    private ImageView commentIv;
    /**
     * 评论数
     */
    private StrokeWidthTextView commentNumTv;
    private LinearLayout commentNumLayout;
    /**
     * 点赞数
     */
    private StrokeWidthTextView likeNumTv;
    private LinearLayout likeNumLayout;
    /**
     * 点赞按钮
     */
    private AnimationView likeIv;
    /**
     * 收藏按钮
     */
    private AnimationView collectIv;
    /**
     * 收藏按钮父布局
     */
    private FrameLayout flCollectIv;
    /**
     * 分享按钮
     */
    private ImageView shareView;

    /**
     * 黑色还是白色
     */
    private boolean isBlack;

    private CommentFunctionListener commentFunctionListener;
    /**
     * 添加标签回调
     */
    private AddFavoriteLabelCallback addFavoriteLabelCallback;

    /**
     * 当前内容id、内容类型
     */
    private String contentId;
    private String contentType;
    private String contentRelId = "0";
    private String relType = "0";
    private String likeStatus = "0";
    private String collectStatus = "0";
    //  commentDisplay:评论展示 1:显示 2 隐藏
    private int commentDisplay=0;
    private int likesStyle = 0;
    private int rmhPlatform = 0;
    private String isDetail = "1";
    private String title = "";
    private String channelId = "";

    /**
     * 是否显示功能菜单 1显示 2隐藏
     */
    private int menuShow = 1;

    /**
     * 工作线程
     */
    private WorkThreadHandler mHandler;
    /**
     * 加载框
     */
    private Dialog mLoadingDialog;

    /**
     * 按照产品要求正确的应该取互动接口查询到的评论数
     */
    private long interactCommentNum;

    long likeCount = 0;

    public BottomCommentFunctionBar(@NonNull Context context) {
        super(context);
        init(context, null);
    }

    public BottomCommentFunctionBar(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context, attrs);
    }

    public BottomCommentFunctionBar(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context, attrs);
    }

    /**
     * 初始化
     */
    private void init(Context context, AttributeSet attrs) {
        if (attrs != null) {
            TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.BottomCommentFunctionBar);
            isBlack = a.getBoolean(R.styleable.BottomCommentFunctionBar_black_bar, false);
            a.recycle();
        }
        View rootView = LayoutInflater.from(context).inflate(R.layout.layout_comment_input_bottom, null);
        initView(rootView);
        addListener();
        this.addView(rootView);
        initHandler(context);
    }

    /**
     * 初始化线程
     */
    private void initHandler(Context context) {
        mLoadingDialog = DialogUtils.createRequestDialog(context, true);
        HandlerThread handlerThread = new HandlerThread("realLocService");
        handlerThread.start();
        mHandler = new WorkThreadHandler(handlerThread.getLooper());
    }

    /**
     * 初始化控件
     */
    private void initView(View rootView) {
        topLine = rootView.findViewById(R.id.ci_top_line);
        backIv = rootView.findViewById(R.id.ci_iv_back);
        inputView = rootView.findViewById(R.id.ci_input_FL);
        commentIv = rootView.findViewById(R.id.ci_iv_comment);
        commentNumTv = rootView.findViewById(R.id.ci_tv_comment_num);
        commentNumLayout = rootView.findViewById(R.id.ll_comment_count);
        likeIv = rootView.findViewById(R.id.ci_iv_like);
        likeNumTv = rootView.findViewById(R.id.ci_tv_like_num);
        likeNumLayout = rootView.findViewById(R.id.ll_like_count);
        collectIv = rootView.findViewById(R.id.ci_iv_collect);
        flCollectIv = rootView.findViewById(R.id.fl_ci_iv_collect);
        shareView = rootView.findViewById(R.id.ci_iv_share);

        // 检查登录
        likeIv.setNeedLogin(true);
        collectIv.setNeedLogin(true);
        if(!PDUtils.isLogin()){
            //未登录也要设置点赞样式
            likeIcon(false);
        }
    }

    /**
     * 增加接口回调监听
     */
    private void addListener() {
        backIv.setOnClickListener(v -> {
            if (commentFunctionListener != null) {
                commentFunctionListener.backClick();
            }
        });
        inputView.setOnClickListener(v -> {
            if (commentFunctionListener != null) {
                commentFunctionListener.inputClick();
            }
        });
        commentIv.setOnClickListener(v -> {
            if (commentFunctionListener != null) {
                commentFunctionListener.commentClick();
            }
        });
        likeIv.setOnClickListener(v -> {
            //用户点击
            if (!PDUtils.isLogin()) {
                if (commentFunctionListener != null) {
                    commentFunctionListener.likeClick("-1");
                }
                ProcessUtils.toOneKeyLoginActivity();
                return;
            }

            //点赞不等接口结果,直接改变状态

//            likeIv.handleClick();
            if ("0".equals(likeStatus)) {
                likeIcon(true);
                likeStatus = "1";
                likeCount++;
            } else {
                likeIcon(false);
                likeStatus = "0";
                likeCount--;
            }
            setLikeNum(likeCount);
            if (commentFunctionListener != null) {
                commentFunctionListener.likeClick(likeStatus);
            }

            Message message = new Message();
            message.what = 1;
            if (null != mHandler) {
                mHandler.sendMessage(message);
            }
        });
        flCollectIv.setOnClickListener(v -> {
            //用户点击
            if (!PDUtils.isLogin()) {
                if (commentFunctionListener != null) {
                    commentFunctionListener.collectClick("-1");
                }
                ProcessUtils.toOneKeyLoginActivity();
                return;
            }
            Message message = new Message();
            message.what = 2;
            if (null != mHandler) {
                mHandler.sendMessage(message);
            }
        });
        shareView.setOnClickListener(v -> {
            if (commentFunctionListener != null) {
                commentFunctionListener.shareClick();
            }
        });
    }

    /**
     * 关闭返回
     */
    public void hideBack() {
        backIv.setVisibility(GONE);
    }

    /**
     * 关闭点赞
     */
    public void closeLike() {
        likeIv.setVisibility(GONE);
        ViewUtils.setVisible(likeNumLayout,GONE);
    }

    /**
     * 打开点赞
     */
    public void openLike() {
        likeIv.setVisibility(VISIBLE);
    }

    /**
     * 关闭收藏
     */
    public void closeCollect() {
        flCollectIv.setVisibility(GONE);
    }

    /**
     * 关闭分享
     */
    public void closeShare() {
        shareView.setVisibility(GONE);
    }

    public void setShareMoreIcon(){
        if (shareView != null){
            shareView.setImageResource(R.mipmap.share_more_icon_40);
            shareView.setVisibility(VISIBLE);
        }
    }

    /**
     * 打开收藏
     */
    public void openCollect() {
        flCollectIv.setVisibility(VISIBLE);
    }

    public void openShare() {

        shareView.setVisibility(VISIBLE);
    }

    /**
     * 关闭评论输入、图标、记录
     */
    public void closeComment() {
        inputView.setVisibility(INVISIBLE);
        commentIv.setVisibility(INVISIBLE);
        commentNumShow(false);
    }

    /**
     * 不显示评论图标、记录个数
     */
    public void hideCommentBtn() {
        commentIv.setVisibility(INVISIBLE);
        commentNumShow(false);
    }

    /**
     * 显示评论图标、记录个数
     */
    public void openCommentBtn() {
        commentIv.setVisibility(VISIBLE);
        commentNumShow(true);
    }

    /**
     * 不显示评论输入框
     */
    public void hideInputView() {
        inputView.setVisibility(INVISIBLE);
    }

    /**
     * 显示评论输入框
     */
    public void openInputView() {
        inputView.setVisibility(VISIBLE);
    }

    /**
     *  使用interact接口的数量
     *  设置评论数
     * @param commentNum
     * @param increment 0 原始数据,1增加,-1减少
     */
    public void setCommentNum(String commentNum, int...increment) {
        if (increment == null || increment.length == 0){
            //兼容原来的
            setInteractCommentNum(commentNum);
            try {
                this.interactCommentNum = Long.parseLong(commentNum);
            }catch (Exception e){
                e.printStackTrace();
            }
        }else {
            int i = increment[0];
            if (i == 0){
                setInteractCommentNum(commentNum);
                try {
                    this.interactCommentNum = Long.parseLong(commentNum);
                }catch (Exception e){
                    e.printStackTrace();
                }
            }else if (i == 1){
                //增加1
                interactCommentNum = interactCommentNum + 1;
                setInteractCommentNum(interactCommentNum + "");
            }else if (i == -1){
                //增加-1
                interactCommentNum = interactCommentNum - 1;
                if (interactCommentNum < 0){
                    interactCommentNum = 0;
                }
                setInteractCommentNum(interactCommentNum  + "");
            }

        }
    }

    /**
     * 评论数
     * @param interactCommentNum
     */
    public void setInteractCommentNum(String interactCommentNum){
        String comment = NumberStrUtils.Companion.getINSTANCE().handlerNumber(String.valueOf(interactCommentNum));
        if ("0".equals(comment)) {
            comment = "";
        }
        if (!TextUtils.isEmpty(comment)) {
            commentNumTv.setText(comment);
            commentNumShow(true);
        } else {
            commentNumShow(false);
        }
    }

    /**
     * 获取评论数据
     * @return
     */
    public long getCommentNum(){
        return interactCommentNum;
    }

    /**
     * 点赞数
     * @param likeNum
     */
    public void setLikeNum(long likeNum){
        if (likeNum < 0){
            likeNum = 0;
        }
        likeCount = likeNum;
        String like = NumberStrUtils.Companion.getINSTANCE().handlerNumber(String.valueOf(likeNum));
        if("0".equals(like)){
            like="";
        }
        if (!TextUtils.isEmpty(like)) {
            likeNumTv.setText(like+"");
            likeNumShow(true);
        } else {
            likeNumShow(false);
        }

    }

    public void likeNumShow(boolean isShow){
        if (likeNumTv != null && !TextUtils.isEmpty(likeNumTv.getText().toString()) ){
            likeNumLayout.setVisibility(isShow ?  VISIBLE: GONE);
        }
    }

    /**
     * 设置收藏图标
     */
    public void collectIcon(boolean isCollect) {
        if (collectIv != null) {
            if (isCollect) {
                collectIv.setSelectImageResId(ToolsUtil.getCollectStyle(0,true));
            }else {
                collectIv.setUnselectImageResId(ToolsUtil.getCollectStyle(0,false));
            }
            collectIv.setSelected(isCollect);
        }
    }

    /**
     * 设置点赞图标
     */
    public void likeIcon(boolean isLike) {
        if (likeIv != null) {
            int likeStyleNormalIcon = ToolsUtil.getLikeStyle(likesStyle,0,false);
            int likeStyleSelIcon = ToolsUtil.getLikeStyle(likesStyle,0,true);
            if (likesStyle == 4 ||likeStyleNormalIcon == 4  || likeStyleSelIcon==4){
                closeLike();
                return;
            }
            if (isLike) {
                likeIv.setSelectImageResId(likeStyleSelIcon);
            }else {
                likeIv.setUnselectImageResId(likeStyleNormalIcon);
            }
            likeIv.setSelected(isLike);
        }
    }

    public void setCommentFunctionListener(CommentFunctionListener commentFunctionListener) {
        this.commentFunctionListener = commentFunctionListener;
    }

    public void setAddFavoriteLabelCallback(AddFavoriteLabelCallback addFavoriteLabelCallback) {
        this.addFavoriteLabelCallback = addFavoriteLabelCallback;
    }

    public abstract static class CommentFunctionListener {

        /**
         * 返回
         */
        public  abstract void backClick();

        /**
         * 输入
         */
        public  abstract void inputClick();

        /**
         * 评论
         */
        public  abstract void commentClick();

        /**
         * 点赞
         *
         * @param status -1:只是点了按钮  0、1为点赞状态
         */
        public  abstract void likeClick(String status);

        /**
         * 收藏
         *
         * @param status -1:只是点了按钮  0、1为收藏状态
         */
        public  abstract void collectClick(String status);

        /**
         * 分享
         */
        public  abstract void shareClick();

        /**
         * @param like true点赞、false取消点赞
         * */
        public void likeStateChange(boolean like){

        }
    }

    /**
     * 传递内容id 、内容类型
     */
    public void setContentAndType(TransparentBean bean) {
        //评论跳登录后,崩溃优化
        if(bean == null)
        {
            return;
        }
        likesStyle = bean.getLikesStyle();
        contentId = bean.getContentId();
        contentType = bean.getContentType();
        contentRelId = bean.getTargetRelId();
        relType = bean.getTargetRelType();
        commentDisplay = bean.getCommentDisplay();
        isDetail = bean.getIsDetail();
        rmhPlatform = bean.getRmhPlatform();
        title = bean.getContentTitle();
        channelId = bean.getChannelId();
        menuShow = bean.getMenuShow();

        //设置点赞动画样式
        String likeStyleSelJson = ToolsUtil.getLikeStyleSelJson(likesStyle);
        if(!StringUtils.isEmpty(likeStyleSelJson)){
            likeIv.setLottieFileName(likeStyleSelJson);
        }

        ThreadPoolUtils.postToMain(() -> {
            //用户没有登录
            if (!PDUtils.isLogin()) {
                return;
            }
            if (!StringUtils.isEmpty(contentId) && !StringUtils.isEmpty(contentType)) {
                Message message = new Message();
                message.what = 0;
                mHandler.sendMessage(message);
            }
        });
    }


    /**
     * 工作线程
     */
    class WorkThreadHandler extends Handler {

        public WorkThreadHandler(Looper looper) {
            super(looper);
        }

        @Override
        public void handleMessage(Message msg) {
            try {
                switch (msg.what) {
                    case 0://查询收藏、点赞
                        if (!StringUtils.isEmpty(SpUtils.getUserToken())) {
                            queryLikeAndCollectStatus();
                        }
                        break;
                    case 1://点赞
                        if (!StringUtils.isEmpty(SpUtils.getUserToken())) {
                            userClickLikeStatus();
                        }
                        break;
                    case 2://收藏
                        if (!StringUtils.isEmpty(SpUtils.getUserToken())) {
                            userClickCollectStatus();
                        }

                        break;
                    default:
                        break;

                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    /**
     * 查询当前内容、用户点赞、收藏状态
     */
    private void queryLikeAndCollectStatus() {
        if (StringUtils.isEmpty(contentId) || StringUtils.isEmpty(contentType)) {
            return;
        }
        List<DisplayWorkInfoBean> workList = new ArrayList<>();
        DisplayWorkInfoBean workInfoBean = new DisplayWorkInfoBean();
        workInfoBean.setContentId(contentId);
        workInfoBean.setContentSource(contentType);
        workInfoBean.setContentRelId(contentRelId);
        workInfoBean.setRelType(String.valueOf(relType));
        workList.add(workInfoBean);
//        showLoading();
        QueryLikeStatusTools.getInstance().queryLikeStatus(workList, new QueryLikeStatusCallback() {
            @Override
            public void onSuccess(List<DisplayWorkInfoBean> dataBeans) {
                dismissLoading();
                if (null != dataBeans && dataBeans.size() > 0) {
                    setLikeAndCollect(dataBeans.get(0));
                }
            }

            @Override
            public void onFailed(String msg) {
                dismissLoading();
            }
        });
    }

    /**
     * 用户点赞
     */
    private void userClickLikeStatus() {
        if(FastClickUtil.isFastClick()){
            return;
        }
        if (StringUtils.isEmpty(contentId) || StringUtils.isEmpty(contentType)) {
            return;
        }
//        if ("0".equals(likeStatus)) {
//            likeStatus = "1";
//        } else {
//            likeStatus = "0";
//        }
        LikeTools.getInstance().userContentExecuteLike(contentId, contentType, contentRelId,
                relType, likeStatus, title, channelId,
                new LikeCallback() {
            @Override
            public void onSuccess(String msg, String oldLikeStatus, String newLikeStatus) {
//                if (commentFunctionListener != null) {
//                    commentFunctionListener.likeStateChange("0".equals(likeStatus));
//                }
            }

            @Override
            public void onFailed(String msg) {
                dismissLoading();
            }
        });
//        runOnUiThread(new Runnable() {
//            @Override
//            public void run() {
//                updateLikeState();
//            }
//        });
//
//        if (commentFunctionListener != null) {
//            commentFunctionListener.likeClick(likeStatus);
//        }
    }

//    public void updateLikeState(boolean like){
//        if(like){
//            this.likeStatus = "1";
//        }else{
//            this.likeStatus = "0";
//        }
//        updateLikeState();
//    }

//    private void updateLikeState() {
//        if ("0".equals(likeStatus)) {
//            likeIcon(false);
//            if (likeNumTv != null){
//                likeCount--;
//            }
//        } else {
//            likeIcon(true);
//            if (likeNumTv != null){
//                likeCount++;
//            }
//        }
//        setLikeNum(likeCount);
//    }

    /**
     * 用户收藏
     */
    private void userClickCollectStatus() {
        if (StringUtils.isEmpty(contentId) || StringUtils.isEmpty(contentType)) {
            return;
        }
        if ("0".equals(collectStatus)) {
            collectStatus = "1";
        } else {
            collectStatus = "0";
        }
        // 展示加载进度条
//        showLoading();
        //添加、删除单个收藏
        AddDelCollectBean bean = new AddDelCollectBean();
        bean.setStatus(collectStatus);
        List<AddDelCollectBean.ContentListBean> beanList = new ArrayList<>();
        AddDelCollectBean.ContentListBean listBean = new AddDelCollectBean.ContentListBean();
        listBean.setContentId(contentId);
        listBean.setContentType(contentType);
        listBean.setContentRelId(contentRelId);
        listBean.setRelType(relType);
        beanList.add(listBean);
        bean.setContentList(beanList);
        //收藏工具类
        CollectTools.getInstance().addToDelCollect(getContext(),bean, new CollectCallback() {
            @Override
            public void onSuccess(String msg) {
                // 取消进度条
                dismissLoading();
                // 处理收藏动画点击事件
                collectIv.handleClick();
                // 更新收藏状态
                if ("0".equals(collectStatus)) {
                    collectIcon(false);
                } else {
                    collectIcon(true);
                }
//                //接口回调
//                if (commentFunctionListener != null) {
//                    commentFunctionListener.collectClick(collectStatus);
//                }
            }

            @Override
            public void onFailed(String msg) {
                dismissLoading();
                // 接口后台返回的失败
                ToastNightUtil.showShort(ResUtils.getString(R.string.tips_check_network));
            }
        },addFavoriteLabelCallback);

        if (commentFunctionListener != null) {
            commentFunctionListener.collectClick(collectStatus);
        }
    }

    /**
     * 移除线程操作
     */
    public void cancelHandler() {
        if (null != mHandler) {
            mHandler.removeCallbacksAndMessages(null);
            mHandler = null;
        }
        dismissLoading();
    }

    /**
     * 设置点赞、收藏图标状态
     */
    private void setLikeAndCollect(DisplayWorkInfoBean infoBean) {
        //点赞状态
        if (!StringUtils.isEmpty(infoBean.getLikeStatus())) {
            likeStatus = infoBean.getLikeStatus();
            if ("0".equals(likeStatus)) {
                likeIcon(false);
            } else {
                likeIcon(true);
            }
        }
        //收藏状态
        if (!StringUtils.isEmpty(infoBean.getCollectStatus())) {
            collectStatus = infoBean.getCollectStatus();
            if ("0".equals(collectStatus)) {
                collectIcon(false);
            } else {
                collectIcon(true);
            }
        }
    }


    /**
     * 设置点赞状态
     */
    public void setLikeStatusIcon(boolean isLike, String value) {
        likeStatus = value;
        likeIcon(isLike);
    }

    /**
     * 设置点赞状态
     */
    public void setLikeStatusIcon(String value) {
        likeStatus = value;
        if(StringUtils.isEqual("0",value)){
            likeIcon(false);
        }else if(StringUtils.isEqual("1",value)){
            likeIcon(true);
        }
    }

    /**
     * 设置收藏状态
     */
    public void setCollectStatusIcon(String value) {
        collectStatus = value;
        if(StringUtils.isEqual("0",value)){
            collectIcon(false);
        }else if(StringUtils.isEqual("1",value)){
            collectIcon(true);
        }
    }

    /**
     * 显示loading框
     */
    public void showLoading() {
        ThreadPoolUtils.postToMain(() -> {
            if (null != mLoadingDialog && !mLoadingDialog.isShowing()) {
                mLoadingDialog.show();
            }
        });
    }

    /**
     * 隐藏loading框
     */
    public void dismissLoading() {
        ThreadPoolUtils.postToMain(() -> {
            if (null != mLoadingDialog) {
                mLoadingDialog.dismiss();
            }
        });

    }

    /**
     * 查询内容动态数据
     */
    public void queryContentDyNumber() {
        InteractFetcher interactFetcher = new InteractFetcher(new IInteractDataListener() {
            @Override
            public void onInteractDataSuccess(List<InteractResponseDataBean> dataList) {
                InteractResponseDataBean interactResponseDataBean = ArrayUtils.getListElement(dataList, 0);
                if (interactResponseDataBean == null) {
                    return;
                }
                //评论数
                String commentNum = interactResponseDataBean.getCommentNum();
                setCommentNum(commentNum);
                //点赞数
                long likeNum = interactResponseDataBean.getLikeNum();
                setLikeNum(likeNum);
            }

            @Override
            public void onInteractDataError(String errorMsg) {

            }
        });
        int type = Integer.parseInt(contentType);
        interactFetcher.oneInteractData(contentId, type, isDetail, rmhPlatform);
    }

    public void commentNumShow(boolean isShow){
        if(commentNumLayout == null){
            return;
        }
        if(isShow && commentIv.getVisibility() == VISIBLE &&
                commentNumTv != null &&
                !TextUtils.isEmpty(commentNumTv.getText().toString())){
            commentNumLayout.setVisibility(VISIBLE);
        }else {
            commentNumLayout.setVisibility(GONE);
        }
    }

    public long getLikeCount() {
        return likeCount;
    }

    /**
     * 隐藏功能菜单
     */
    public void closeMenuShow(){
        closeComment();
        closeLike();
        closeCollect();
        closeShare();
    }

    /**
     * 获取点赞状态
     * @return
     */
    public String getLikeStatus(){
        return likeStatus;
    }

    /**
     * 获取收藏状态
     * @return
     */
    public String getCollectStatus(){
        return collectStatus;
    }
}