ItemLayoutManager.java 31 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

/*
 * Copyright (c) People Technologies Co., Ltd. 2019-2022. All rights reserved.
 */

package com.wd.display.comp.layoutmanager;

import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.view.ViewStub;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;

import com.people.common.CommonNetUtils;
import com.people.common.ProcessUtils;
import com.people.common.analytics.CommonTrack;
import com.people.common.analytics.constants.PageNameConstants;
import com.people.common.constant.Constants;
import com.people.common.interact.like.model.UserLikeFetcher;
import com.people.common.listener.OnCollectCheckedChangeListener;
import com.people.common.util.GrayManager;
import com.people.common.util.PDUtils;
import com.people.common.viewclick.OnMoreClickListener;
import com.people.common.widget.AnimationView;
import com.people.component.R;
import com.people.component.comp.layoutdata.AbsSection;
import com.people.component.comp.layoutmanager.adapter.CompCommonListAdapter;
import com.people.component.utils.CompentLogicUtil;
import com.people.daily.lib_library.CommonUtil;
import com.people.entity.analytics.TrackContentBean;
import com.people.entity.custom.comp.CompBean;
import com.people.entity.custom.comp.ContainerItemBean;
import com.people.entity.custom.content.ContentBean;
import com.people.entity.custom.content.PeopleMasterBean;
import com.people.entity.custom.item.ItemBean;
import com.people.room.MailBookingLiveHelper;
import com.people.room.MailMessageHelper;
import com.people.toolset.SpUtils;
import com.people.toolset.string.StrUtils;
import com.view.text.view.TagTextView;
import com.wondertek.wheat.ability.thread.ThreadPoolUtils;
import com.wondertek.wheat.ability.tools.AppContext;
import com.wondertek.wheat.ability.tools.StringUtils;


public abstract class ItemLayoutManager<T extends ItemBean> {

    private View itemView;

    protected AbsSection section;

    protected ItemIndex index;

    protected Fragment mFragment;

    protected FragmentActivity fragmentActivity;

    // 点赞控件
    private AnimationView praiseBtn;

    /**
     * 稿件头部信息、尾部信息和来源信息视图
     */
    protected View topLayout, bottomLayout, llFromm;

    protected RelativeLayout rlItemParent;

    /**
     * 点赞的状态
     */
    private String likeStatus = "0";


    // 组件内每页最大数量
    protected final int maxCount = 20;

    // 稿件layoutmanager时 contentBean != null
    protected ContentBean contentBean;

    /**
     * getItemViewType
     *
     * @return type
     */
    public abstract int getItemViewType();

    /**
     * 数量
     *
     * @return int
     */
    public abstract int getItemSpan();


    public void setSection(AbsSection section) {
        this.section = section;
    }

    public AbsSection getSection() {
        return section;
    }


    public void setItemIndex(ItemIndex itemIndex) {
        this.index = itemIndex;
    }

    public ItemIndex getItemIndex() {
        return index;
    }

    public Fragment getFragment() {
        return mFragment;
    }

    public void setFragment(Fragment fragment) {
        this.mFragment = fragment;
    }

    public FragmentActivity getFragmentActivity() {
        return fragmentActivity;
    }

    public void setFragmentActivity(FragmentActivity fragmentActivity) {
        this.fragmentActivity = fragmentActivity;
    }

    /**
     * 设置标题
     *
     * @param title    标题内容
     * @param tv_title 标题View
     */
    protected void setTittleValue(String title, TextView tv_title, String keyWords) {
        if (StringUtils.isBlank(keyWords)) {
            tv_title.setText(StrUtils.getStringValue(title));
            return;
        }

        SpannableStringBuilder result = new SpannableStringBuilder(title);

        int keyWordsLength = keyWords.length();
        for (int i = 0; i < title.length(); i++) {
            if (title.regionMatches(true, i, keyWords, 0, keyWordsLength)) {
                result.setSpan(new ForegroundColorSpan(ContextCompat.getColor(tv_title.getContext(), R.color.color_B71D26)),
                        i, i + keyWordsLength, SpannableStringBuilder.SPAN_INCLUSIVE_INCLUSIVE);
            }
        }
        tv_title.setText(result);
    }


    /**
     * 装载数据
     *
     * @param itemView
     * @param position
     */
    public abstract void prepareItem(View itemView, int position);

    /**
     * 绑定
     *
     * @param itemView
     * @param position
     * @param data
     * @return
     */
    public abstract int bindItem(View itemView, int position, T data);

    public void replaceDataListen() {
    }

    public void onResume() {
    }

    public void onPause() {
    }

    public void onDestory() {

    }

    public void onVisible() {
    }

    public void onInvisible() {
    }


    public void onCreateViewHolder(BaseAdapter adapter, View itemView) {

    }

    /**
     * 长按事件
     */
    public CompCommonListAdapter.OnMyLongClickListener mOnLongClickListener;

    public void setOnLongClickListener(CompCommonListAdapter.OnMyLongClickListener mOnLongClickListener) {
        this.mOnLongClickListener = mOnLongClickListener;
    }

    public void setItemViewLongClickListener(View itemView, int position) {
        itemView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                if (mOnLongClickListener != null) {
                    return mOnLongClickListener.OnMyLongClick(position);
                } else {
                    return false;
                }
            }
        });

    }

    public OnMoreClickListener onMoreClickListener;

    public void setOnMoreClickListener(OnMoreClickListener onMoreClickListener) {
        this.onMoreClickListener = onMoreClickListener;
    }

    /**
     * 统一处理稿件的更多按钮
     */
    public void handleMoreButton(ContentBean bean, int position, View llFromm, View topView, String compStyle) {
        ImageView ivMore;
        LinearLayout attentionLay = topView.findViewById(R.id.attention_lay);
        if (CompentLogicUtil.isRmhCompInfo(bean, compStyle)) {
            ivMore = topView.findViewById(R.id.moreBtn);
        } else {
            ivMore = llFromm.findViewById(R.id.moreBtn);
        }

        if (isPersonalHomePage(bean, position, ivMore)) {
            //号主页 统一隐藏关注按钮
            attentionLay.setVisibility(View.GONE);
        } else {
            //非号主页 统一隐藏更多按钮
            ivMore.setVisibility(View.GONE);
        }
    }


    /**
     * 是否是号主页
     */
    private boolean isPersonalHomePage(ContentBean bean, int position, ImageView ivMore) {
        String fromPage = StrUtils.getStringValue(bean.getFromPage());
        if (PageNameConstants.MAIN_PERSONAL_HOME_PAGE.equals(fromPage)) {
            //主态号主页
            if (bean.isShowMoreButton()) {
                bean.position = position;
                ivMore.setVisibility(View.VISIBLE);
                //扩大View的触摸和点击响应范围
                CommonUtil.expandViewTouchDelegate(ivMore, 50);
                ivMore.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        onMoreClickListener.onMoreClick(bean, position);
                    }
                });
            } else {
                ivMore.setVisibility(View.GONE);
            }
            return true;
        } else if (PageNameConstants.CUSTOMER_PERSONAL_HOME_PAGE.equals(fromPage)) {
            //客态号主页
            ivMore.setVisibility(View.GONE);
            return true;
        }

        return false;
    }

    /**
     * 是否收藏、历史页面,长按出现
     *
     * @return
     */
    public boolean isCollectPage(ContentBean contentBean) {
        if (contentBean != null) {
            String fromPage = StrUtils.getStringValue(contentBean.getFromPage());
            if (PageNameConstants.MY_COLLECT_PAGE.equals(fromPage) || PageNameConstants.MY_HISTORY_PAGE.equals(fromPage)) {
                return true;
            }
        }
        return false;
    }

    /**
     * 更新已读状态
     */
    public void updateReadState(TextView tvTitle, ContainerItemBean data) {
        //未读
        if ("2".equals(data.getLocalFiledReadState())) {
            data.setLocalFiledReadState("1");
            if (tvTitle != null) {
                //设置已读、更新已读状态
                tvTitle.setTextColor(ContextCompat.getColor(tvTitle.getContext(), R.color.res_color_common_C3));
            }
            ThreadPoolUtils.submit(new Runnable() {
                @Override
                public void run() {
                    updateReadState(data);
                }
            });
        }
    }

    public void updateReadState(ContainerItemBean data) {
        if ("0".equals(data.getLocalFiledType())) {
            //0站内信-预约直播类型
            String userId = SpUtils.getUserId();
            if (TextUtils.isEmpty(userId)) {
                return;
            }
            MailBookingLiveHelper.getInstance(AppContext.getContext()).updateReadStateByKey(data.getLocalFiledIdType(), userId);
        } else if ("1".equals(data.getLocalFiledType())) {
            //1站内信-推送消息记录类型
            MailMessageHelper.getInstance(AppContext.getContext()).updateReadStateByKey(data.getLocalFiledIdType());
        }
    }

    /**
     * 设置已读状态
     */
    public void setReadState(TextView tvTitle, ContainerItemBean data) {
        if ("1".equals(data.getLocalFiledReadState())) {
            tvTitle.setTextColor(ContextCompat.getColor(tvTitle.getContext(), R.color.res_color_common_C3));
        }
    }

    public OnCollectCheckedChangeListener onCollectCheckedChangeListener;

    public void setOnCollectCheckedChangeListener(OnCollectCheckedChangeListener onCollectCheckedChangeListener) {
        this.onCollectCheckedChangeListener = onCollectCheckedChangeListener;
    }

    /**
     * 组件信息基本埋事件
     *
     * @param isClick
     * @param contentBean
     * @param position
     */
    public void trackItemContent(boolean isClick, ContentBean contentBean, int position) {
        trackItemContent(isClick, contentBean, position, "");
    }

    /**
     * 组件信息基本埋事件
     *
     * @param isClick
     * @param contentBean
     * @param position
     */
    public void trackItemContent(boolean isClick, ContentBean contentBean, int position, String type) {

        // 点击埋点
        TrackContentBean trackContentBean = new TrackContentBean();
        trackContentBean.contentBeantoBean(contentBean, section == null ? null : section.getCompBean());
        trackContentBean.exporeOrClick(isClick);
        if (isClick) {
            if ("0".equals(type)) {
                //站内信-预约直播列表子项点击
                CommonTrack.getInstance().liveSubscribeNoticeClickTrack(trackContentBean);
            } else if ("1".equals(type)) {
                //站内信-推送消息列表子项点击
                CommonTrack.getInstance().followAuthorNoticeClickTrack(trackContentBean);
            } else {
                CommonTrack.getInstance().contentClickTrack(trackContentBean);
            }
        } else {
            if (!contentBean.isExposure()) {
                contentBean.setExposure(true);
                CommonTrack.getInstance().contentShowTrack(trackContentBean);
            }
        }
    }

    /**
     * 稿件喜欢埋点事件
     *
     * @param likeStatus
     * @param contentBean
     * @param position
     */
    private void trackLikeClickContent(boolean likeStatus, ContentBean contentBean, int position) {
        // 点击埋点
        TrackContentBean trackContentBean = new TrackContentBean();
        trackContentBean.contentBeantoBean(contentBean, section == null ? null : section.getCompBean());
        trackContentBean.likeAction(likeStatus);
        CommonTrack.getInstance().contentLikeTrack(trackContentBean, likeStatus);
    }

    /**
     * 号主关注点击埋点事件
     *
     * @param isFollow
     * @param contentBean
     * @param position
     */
    private void trackFollowClickContent(boolean isFollow, ContentBean contentBean, int position) {
        // 点击埋点
        TrackContentBean trackContentBean = new TrackContentBean();
        trackContentBean.contentBeantoBean(contentBean, section == null ? null : section.getCompBean());
        trackContentBean.followAction(isFollow);
        CommonTrack.getInstance().contentFollowTrack(trackContentBean, isFollow);
    }

    /**
     * 稿件评论点击埋点事件
     *
     * @param contentBean
     * @param position
     */
    private void trackCommentClickContent(ContentBean contentBean, int position) {
        // 点击埋点
//        TrackContentBean trackContentBean = new TrackContentBean();
//        trackContentBean.contentBeantoBean(contentBean, section == null ? null : section.getCompBean());
//        trackContentBean.commentAction();
//        CommonTrack.getInstance().contentCommentTrack(trackContentBean);
    }


    /**
     * 检测是否要开启国殇View  && section.getCompBean().isPageGrayFlag()
     */
    public void checkOpenGrayModel(View view, int index) {

        if (section == null) {
            return;
        }
        if (view != null) {
            itemView = view;
        }

        if(itemView != null){
            if (GrayManager.getInstance().switchOpen && index < 8 && section.getCompBean().isPageGrayFlag()) {
                GrayManager.getInstance().setLayerGrayType(itemView);
            } else {
                // 因复用机制,需要统一清理下其他页面的国殇灰
                if (GrayManager.getInstance().switchOpen && section.getCompBean().isPageGrayFlag()) {
                    GrayManager.getInstance().clearLayerGray(itemView);
                }

            }
        }

    }

    /**
     * 设置layoutmanager的view 高度
     *
     * @param view
     * @param h
     */
    protected void setLayoutManagerItemViewHeight(View view, int h) {
        view.getLayoutParams().height = h;
    }


    /**
     * 初始化历史记录复选框
     */
    public CheckBox initEdit(View view) {
        View v = view.findViewById(R.id.cbSelect);
        if (v != null) {
            if (Constants.isEdit) {
                if (v instanceof ViewStub) {
                    ViewStub stub = (ViewStub) v;
                    return (CheckBox) stub.inflate();
                } else if (v instanceof CheckBox) {
                    return (CheckBox) v;
                }
            } else {
                v.setVisibility(View.GONE);
            }
        }
        return null;
    }

    /**
     * 设置编辑状态
     *
     * @param cbSelect
     * @param bean
     */
    public void setEditState(CheckBox cbSelect, ContentBean bean) {
        if (cbSelect == null || bean == null) {
            return;
        }
        // 收藏列表中用到,是否处于编辑模式
        if (Constants.isEdit) {
            // 收藏列表中用到,编辑列表时标记当前item是否选中
            cbSelect.setOnCheckedChangeListener((buttonView, isChecked) -> {
                bean.setChecked(isChecked);
                if (onCollectCheckedChangeListener != null) {
                    onCollectCheckedChangeListener.onCheckedChanged();
                }
            });
            cbSelect.setVisibility(View.VISIBLE);
            cbSelect.setChecked(bean.isChecked());
        }
    }

    /**
     * 处理稿件底线
     *
     * @param view
     */
    public void handlerCompLine(View view) {
        ImageView bottomLine = view.findViewById(R.id.bottomLine);
        if (bottomLine != null) {
            if (section != null && section.getCompBean() != null) {
                CompBean mCompBean = section.getCompBean();
                int specTagVal = mCompBean.getSpecTagVal();
                if (specTagVal == -1) {
                    bottomLine.setVisibility(View.VISIBLE);
                } else if (specTagVal == 2) {
                    bottomLine.setVisibility(View.INVISIBLE);
                } else {
                    bottomLine.setVisibility(View.VISIBLE);
                }
            } else {
                bottomLine.setVisibility(View.VISIBLE);
            }
        }

    }

    boolean followStatus = true;


    /**
     * 查看是否关注
     */
    public void checkFollowState(ContentBean contentBean, View view) {

        if (contentBean.getRmhInfo() == null) {
            return;
        }
        topLayout = view;
        PeopleMasterBean bean = contentBean.getRmhInfo();
        LinearLayout attentionLay = view.findViewById(R.id.attention_lay);

        // 默认显示关注入口
        if (contentBean.isOpenFollowBt()) {
            //当用登录用户是人民号,且是自己发布的直播,不需要显示关注
            boolean isMasterSelf = false;
            if (bean != null) {
                String masUserId = bean.getUserId();
                String userId = SpUtils.getUserId();
                if (!TextUtils.isEmpty(userId) && userId.equals(masUserId)) {
                    isMasterSelf = true;
                }
            }

            if (bean != null && bean.getCnIsAttention() == 1 && !isMasterSelf) {
                attentionLay.setVisibility(View.VISIBLE);
                attentionLay.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (!PDUtils.isLogin()) {

                            ProcessUtils.toOneKeyLoginActivity();
                            return;
                        }
                        String pageId = "";
                        if (section != null) {
                            pageId = section.getCompBean().getCompInforPageId();
                        }
                        CommonNetUtils.getInstance().operation(pageId, bean.getUserId(), bean.getUserType(),
                                bean.getRmhId(), followStatus ? 0 : 1);

                        trackFollowClickContent(!followStatus, contentBean, 0);
                    }
                });
                handleUserFollowStatus(bean, view);
            } else {
                attentionLay.setVisibility(View.GONE);
            }

        } else {
            attentionLay.setVisibility(View.GONE);
        }


    }


    /**
     * 处理用户关注状态
     *
     * @param bean
     * @param view
     */
    private void handleUserFollowStatus(PeopleMasterBean bean, View view) {
        if (view == null) {
            return;
        }
        // 人民号关注状态
        if (bean != null) {
            String tempStatus = bean.followStatus;
            if (StringUtils.isBlank(tempStatus)) {
                return;
            }
            int TempIntStatus = 0;
            try {
                TempIntStatus = Integer.parseInt(tempStatus);
            } catch (NumberFormatException e) {
                TempIntStatus = 0;
            }
            followStatus = TempIntStatus == 1;
        }
        if (PDUtils.isLogin()) {

            if (!SpUtils.getUserId().equals(bean.getUserId())) {
                handleFollowStatus(view);
            } else {
                LinearLayout attentionLay = view.findViewById(R.id.attention_lay);
                attentionLay.setVisibility(View.GONE);
            }

        }
    }


    /**
     * 人民号底部的评论点赞详情和点击事件
     *
     * @param contentBean
     * @param bottomView
     */
    public void checkPeopleStatus(ContentBean contentBean, View bottomView, int position) {
        TextView shareBtn = bottomView.findViewById(R.id.share_btn);
        TagTextView commentLay = bottomView.findViewById(R.id.ttcomment_btn);
        LinearLayout praiseLay = bottomView.findViewById(R.id.praise_lay);
        //TextView   praiseBtnTv = bottomView.findViewById(R.id.praise_btn);
        praiseBtn = bottomView.findViewById(R.id.praise_img);

        // 评论处理
//        if (!TextUtils.isEmpty(contentBean.commentNum) && !"0".equals(contentBean.commentNum)) {
//            commentBtn.setText(NumberStrUtils.Companion.getINSTANCE().handlerNumber(contentBean.commentNum));
//        } else {
//            commentBtn.setText(R.string.comp_bottom_comment_txt);
//        }
        //点赞数量
        handlerLikeNum();
        // 点赞处理
        if (!StringUtils.isEmpty(contentBean.getLikeStatus())) {
            likeStatus = contentBean.getLikeStatus();
            if ("0".equals(likeStatus)) {
                likeIcon(false, praiseBtn);
            } else {
                likeIcon(true, praiseBtn);
            }
        }

        if (contentBean.getRmhInfo() == null) {
            return;
        }
        //分享按钮控制
        if (contentBean.getShareInfo() != null && "1".equals(contentBean.getShareInfo().getShareOpen())) {
            shareBtn.setVisibility(View.VISIBLE);
            shareBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    CompentLogicUtil.shareContent(contentBean, shareBtn.getContext(),
                            section == null ? null : section.getCompBean(), false);
                }
            });
        } else {
            shareBtn.setVisibility(View.GONE);
        }

        PeopleMasterBean rmhInfo = contentBean.getRmhInfo();
        if (rmhInfo != null) {

            if (contentBean.openCommentView() && "1".equals(rmhInfo.getCnIsComment())) {
                commentLay.setVisibility(View.VISIBLE);
                commentLay.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        contentBean.setScrollToBottom(true);
                        ProcessUtils.processPage(contentBean);
                        contentBean.setScrollToBottom(false);
                        trackCommentClickContent(contentBean, position);
                    }
                });

            } else {
                commentLay.setVisibility(View.GONE);
            }

            if (contentBean.openLikeView() && "1".equals(rmhInfo.getCnIsLike())) {
                praiseLay.setVisibility(View.VISIBLE);
                praiseLay.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        clickPraiseBtn(contentBean, position);
                    }
                });
            } else {
                praiseLay.setVisibility(View.GONE);
            }

        }

        if (shareBtn.getVisibility() == View.GONE && commentLay.getVisibility() == View.GONE && praiseLay.getVisibility() == View.GONE) {
            RelativeLayout.LayoutParams layoutParams1 = (RelativeLayout.LayoutParams) bottomView.getLayoutParams();
            layoutParams1.bottomMargin = 0;
            bottomView.setLayoutParams(layoutParams1);
        } else {
            RelativeLayout.LayoutParams layoutParams1 = (RelativeLayout.LayoutParams) bottomView.getLayoutParams();
            layoutParams1.bottomMargin = -(int) AppContext.getContext().getResources().getDimension(R.dimen.rmrb_dp14);
            bottomView.setLayoutParams(layoutParams1);
        }


    }


    /**
     * 点赞、取消点赞
     *
     * @param contentBean
     */
    private void clickPraiseBtn(ContentBean contentBean, int position) {
        if (!PDUtils.isLogin()) {
            ProcessUtils.toOneKeyLoginActivity();
            return;
        }
        // 由点赞变成取消点赞,反之由未点赞变成取消点赞
        if ("0".equals(likeStatus)) {
            likeStatus = "1";
        } else {
            likeStatus = "0";
        }

        // 执行点赞动画
        praiseBtn.performClick();

        int showTip;
        if ("0".equals(likeStatus)) {
            showTip = R.string.toast_cancel_zan;
            trackLikeClickContent(false, contentBean, position);
        } else {
            showTip = R.string.toast_dian_zan;
            trackLikeClickContent(true, contentBean, position);
        }
        dyHandlerLikeStatusView();
      //  ToastNightUtil.showShort(showTip);
        // 发送点赞、取消点赞事件
        UserLikeFetcher fetcher = new UserLikeFetcher();
        String channelId = contentBean.getChannelInfoBean() != null ? contentBean.getChannelInfoBean().getChannelId() : "";
        fetcher.contentExecuteLike(contentBean.getObjectId(), contentBean.getObjectType(),
                contentBean.getContentRelId(), String.valueOf(contentBean.getRelType()), likeStatus, contentBean.getNewsTitle(), channelId);


    }

    /**
     * 设置点赞图标
     *
     * @param isCollect true:点赞;false:取消点赞
     * @param imageView
     */
    private void likeIcon(boolean isCollect, AnimationView imageView) {
        if (imageView != null){
            imageView.setSelected(isCollect);
        }
    }

    /**
     * 设置是否关注
     *
     * @param view
     */
    private void handleFollowStatus(View view) {
        TextView attentionTv = view.findViewById(R.id.attention_tv);
        ImageView addAttention = view.findViewById(R.id.add_attention);
        LinearLayout attentionLay = view.findViewById(R.id.attention_lay);
        if (followStatus) {
            // attentionLay.setBackground(AppContext.getContext().getDrawable(R.drawable.shape_bag_gray_stroke_radious4));
            attentionTv.setText(R.string.comp_followed_txt);
            attentionTv.setTextColor(AppContext.getContext().getResources().getColor(R.color.res_color_common_C5));
            addAttention.setVisibility(View.GONE);
        } else {
            // attentionLay.setBackground(AppContext.getContext().getDrawable(R.drawable.shape_bag_white_stroke_radious4));
            attentionTv.setText(R.string.comp_follow_txt);
            attentionTv.setTextColor(AppContext.getContext().getResources().getColor(R.color.res_color_common_C11));
            addAttention.setVisibility(View.VISIBLE);
        }
    }

    /**
     * 设置页面第一个稿件顶部背景色
     *
     * @param view
     * @param postion
     */
    public void setFirstItemBg(View view, int postion) {
        if (postion == 0) {
            view.setBackgroundResource(R.drawable.shape_square_layout_item_top_radius);
        } else {
            view.setBackgroundColor(ContextCompat.getColor(view.getContext(), R.color.res_color_common_C8));
        }

        // 处理稿件底线
        handlerCompLine(view);
    }

    /**
     * 设置横滑组件在position == 0位置上的左右间距
     *
     * @param position
     * @param llContent
     * @param bottomLine
     */
    public void setHorizontalSlideMargin(int position, LinearLayout llContent, ImageView bottomLine) {

        LinearLayout.LayoutParams bottomLineLp = (LinearLayout.LayoutParams) bottomLine.getLayoutParams();
        LinearLayout.LayoutParams llContentLp = (LinearLayout.LayoutParams) llContent.getLayoutParams();
        if (position == 0) {
            llContentLp.rightMargin = (int) AppContext.getContext().getResources().getDimension(R.dimen.rmrb_dp6);
            llContentLp.leftMargin = (int) AppContext.getContext().getResources().getDimension(R.dimen.rmrb_dp6);
            bottomLineLp.rightMargin = (int) AppContext.getContext().getResources().getDimension(R.dimen.rmrb_dp10);
            bottomLineLp.leftMargin = (int) AppContext.getContext().getResources().getDimension(R.dimen.rmrb_dp10);
        } else {
            llContentLp.leftMargin = 0;
            llContentLp.rightMargin = 0;
            bottomLineLp.rightMargin = (int) AppContext.getContext().getResources().getDimension(R.dimen.rmrb_dp16);
            bottomLineLp.leftMargin = (int) AppContext.getContext().getResources().getDimension(R.dimen.rmrb_dp16);
        }

    }

    /**
     * 更新稿件信息内容关注状态
     *
     * @param createId
     * @param followStatusFlag
     */
    public void updateUserFollow(String createId, boolean followStatusFlag) {


        if (contentBean != null && contentBean.getRmhInfo() != null && !TextUtils.isEmpty(createId)) {
            PeopleMasterBean rmhInfo = contentBean.getRmhInfo();
            if (createId.equals(rmhInfo.getRmhId())) {
                String followStatus = "0";
                if (followStatusFlag) {
                    followStatus = "1";
                }
                rmhInfo.followStatus = followStatus;

                handleUserFollowStatus(rmhInfo, topLayout);
            }
        }
    }

    /**
     * 更新稿件信息内容点赞状态
     *
     * @param contentId
     * @param relId
     * @param isZan     异步获取的点赞状态
     */
    public boolean updateContentZan(String contentId, String relId, boolean isZan) {

        boolean haveContent = false;

        if (contentBean != null && contentBean.getRmhInfo() != null) {

            if (contentBean.getObjectId().equals(contentId)) {
                //&& contentBean.getContentRelId().equals(relId)
                if (isZan) {
                    contentBean.setLikeStatus("1");
                } else {
                    contentBean.setLikeStatus("0");
                }
                likeStatus = contentBean.getLikeStatus();
                dyHandlerLikeStatusView();

                haveContent = true;
            }
        }
        return haveContent;
    }

    /**
     * 依据动态点赞状态修改点赞状态
     */
    private void dyHandlerLikeStatusView() {
        if ("0".equals(likeStatus)) {
            likeIcon(false, praiseBtn);
            long num = contentBean.getLikeNum() - 1;
            contentBean.setLikeNum(num);
        } else {
            likeIcon(true, praiseBtn);
            long addNum = contentBean.getLikeNum() + 1;
            contentBean.setLikeNum(addNum);
        }
        handlerLikeNum();
    }

    /**
     * 依据点赞数量展示
     */
    private void handlerLikeNum() {
        //点赞数量
//        if (contentBean.likeNum > 0) {
//            praiseBtnTv.setText(NumberStrUtils.Companion.getINSTANCE().handlerNumber(contentBean.likeNum + ""));
//        } else {
//            praiseBtnTv.setText(R.string.comp_bottom_praise_txt);
//            contentBean.likeNum = 0;
//        }
    }

    /**
     * 批查获取的数据,更新稿件展示信息
     */
    public void updateData(int position) {

        if (llFromm != null && contentBean != null) {
            //if (contentBean.isExposure()) {
                if (llFromm.getVisibility() != View.GONE) {
                    // 处理频道和发布日期
                    CompentLogicUtil.handlerFromDataInfor(llFromm, contentBean);
                } else {
                    checkFollowState(contentBean, topLayout);
                    checkPeopleStatus(contentBean, bottomLayout, position);
                }
          //  }
        }

    }

}