ItemThemeSubjectLayoutManager.java 30.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
/*
 * Copyright (c) People Technologies Co., Ltd. 2019-2022. All rights reserved.
 */

package com.wd.display.comp.page;

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

import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.LinearLayoutCompat;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;

import com.google.android.material.appbar.AppBarLayout;
import com.orhanobut.logger.Logger;
import com.people.comment.comment.listener.ICommentDataNewListener;
import com.people.comment.comment.vm.CommentViewModel;
import com.people.comment.dialog.CommentCommitDialog;
import com.people.comment.dialog.CommentSheetDialog;
import com.people.comment.listener.CommitDialogListener;
import com.people.common.ProcessUtils;
import com.people.common.analytics.CommonTrack;
import com.people.common.base.BaseActivity;
import com.people.common.constant.DefaultViewConstant;
import com.people.common.constant.IntentConstants;
import com.people.common.statusbar.StatusBarStyleEnum;
import com.people.common.widget.BottomCommentFunctionBar;
import com.people.common.widget.CommomLoadMoreFooter;
import com.people.common.widget.CommonRefreshHeader;
import com.people.common.widget.CustomSmartRefreshLayout;
import com.people.common.widget.CustomTitleBar;
import com.people.common.widget.DefaultView;
import com.people.common.widget.ExpandableTextView;
import com.people.common.widget.customtextview.BoldTextView;
import com.people.common.widget.listener.SimpleMultiPurposeListener;
import com.people.component.R;
import com.people.component.comp.layoutmanager.ItemContainerManager;
import com.people.component.ui.channel.listener.PageInforToLayoutManagerCallback;
import com.people.component.ui.fragment.ColumnFragment;
import com.people.component.utils.CompentLogicUtil;
import com.people.entity.analytics.TrackContentBean;
import com.people.entity.comment.CommentListBean;
import com.people.entity.comment.CommentStatusBean;
import com.people.entity.comment.TransparentBean;
import com.people.entity.custom.MenuBean;
import com.people.entity.custom.comp.ChannelInfoBean;
import com.people.entity.custom.comp.PageBean;
import com.people.entity.custom.comp.TopicInfoBean;
import com.people.entity.custom.content.CommentItem;
import com.people.entity.custom.content.ContentTypeConstant;
import com.people.entity.custom.share.ShareBean;
import com.people.entity.livedate.EventMessage;
import com.people.entity.response.PersonalInfoBean;
import com.people.entity.theme.ThemeMessage;
import com.people.livedate.EventConstants;
import com.people.livedate.base.LiveDataBus;
import com.people.network.NetworkUtils;
import com.people.toolset.ScreenUtils;
import com.people.toolset.SpUtils;
import com.people.toolset.UiUtils;
import com.people.toolset.imageglide.ImageUtils;
import com.people.toolset.system.DeviceUtil;
import com.people.umeng.enums.PosterTypeEnum;
import com.scwang.smart.refresh.layout.api.RefreshHeader;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.wondertek.wheat.ability.tools.AppContext;
import com.wondertek.wheat.ability.tools.StringUtils;
import com.wondertek.wheat.ability.tools.ViewUtils;

/**
 * 通用主题专题布局(文章、话题、直播)
 *
 * @author liyubing
 * @version [V1.0.0, 2022/7/7]
 * @since V1.0.0
 */
public class ItemThemeSubjectLayoutManager extends ItemContainerManager<MenuBean> {

    private static final String TAG = "ItemThemeSubjectLayoutManager";

    private AppBarLayout appBarLayout;

    private ColumnFragment mColumnFragment;

    private CustomSmartRefreshLayout refreshLayout;

    private FrameLayout flParent;

    // 页面标题涉及到的控件
    private CustomTitleBar customTitleBar;
    private View viewTitleBg;
    private View ivLine;

    // 头部view 涉及到的控件
    private ImageView ivHeadBg;
    private RelativeLayout scaleImgRL;

    private BoldTextView tvTitle;

    //距离标题栏高度
    private View marginTopView;

    private ExpandableTextView tvMsg;

    private TopicInfoBean topicInfoBean;

    private ThemeMessage pageMessage;

    private DefaultView mErrorView;

    private CommonRefreshHeader commonRefreshHeader;

    private BottomCommentFunctionBar llCommentInput;

    private LinearLayoutCompat llHeadView;

    /**
     * 展开页面评论
     */
    private boolean showPageComment;
    private float currentAlphaValue = -1;

    CommentViewModel commentViewModel;
    TransparentBean transparentBean;
    CommentSheetDialog sheetDialog = null;

    @Override
    public int getItemViewType() {
        return R.layout.page_item_layout_theme_subject;
    }

    @Override
    public void prepareItem(View itemView, int position) {
        Logger.t(TAG).d("prepareItem");

        mErrorView = ViewUtils.findViewById(itemView, R.id.default_view);

        flParent = ViewUtils.findViewById(itemView, R.id.flParent);
        marginTopView = ViewUtils.findViewById(itemView, R.id.marginTop_View);

        llHeadView = ViewUtils.findViewById(itemView, R.id.llHeadView);

        llCommentInput = ViewUtils.findViewById(itemView, R.id.ll_comment_input);
        llCommentInput.closeLike();
      //  llCommentInput.hideBack();
        llCommentInput.setVisibility(View.INVISIBLE);




        tvTitle = ViewUtils.findViewById(itemView, R.id.tvTitle);
        tvMsg = ViewUtils.findViewById(itemView, R.id.tvMsg);

        ivHeadBg = ViewUtils.findViewById(itemView, R.id.ivHeadBg);
        scaleImgRL = ViewUtils.findViewById(itemView, R.id.scaleImg_RL);

        customTitleBar = ViewUtils.findViewById(itemView, R.id.title_bar);
        appBarLayout = ViewUtils.findViewById(itemView, R.id.app_bar_layout);
        ivLine = ViewUtils.findViewById(itemView, R.id.ivLine);
        viewTitleBg = ViewUtils.findViewById(itemView, R.id.viewTitleBg);
        viewTitleBg.setAlpha(0);
        customTitleBar.getTitleView().setAlpha(0);
        refreshLayout = ViewUtils.findViewById(itemView, R.id.refreshLayout);
        refreshLayout.setEnableHeaderTranslationContent(false);
        commonRefreshHeader = new CommonRefreshHeader(getFragmentActivity());
        commonRefreshHeader.setViewPaddTop((int) AppContext.getContext().getResources().getDimension(R.dimen.rmrb_dp40));
        refreshLayout.setRefreshHeader(commonRefreshHeader);
        refreshLayout.setDragRate(0.4f);
        refreshLayout.setHeaderMaxDragRate(2F);
        CommomLoadMoreFooter footView = new CommomLoadMoreFooter(getFragmentActivity());
        footView.setDescTextColor(ContextCompat.getColor(getFragmentActivity(), R.color.color_93959D));
        refreshLayout.setRefreshFooter(footView);
        refreshLayout.setEnableLoadMore(false);

        FrameLayout.LayoutParams scaleImgRLLp = (FrameLayout.LayoutParams) scaleImgRL.getLayoutParams();
        scaleImgRLLp.width = DeviceUtil.getDeviceWidth();
        scaleImgRLLp.height = (int) (scaleImgRLLp.width * 188 / 375);

        //距离高度
        ViewGroup.LayoutParams marginTopParams = marginTopView.getLayoutParams();
        marginTopParams.height = (int) AppContext.getContext().getResources().getDimension(R.dimen.rmrb_dp150);
        marginTopView.setLayoutParams(marginTopParams);


        appBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> {
            float alphaValue = (float) Math.abs(verticalOffset) / (float) UiUtils.dp2px(150);
            //  Log.e("qweqwd", "alphaValue=" + verticalOffset);
            dyAlphaView(alphaValue);
        });
        customTitleBar.setRightImgVisibility(View.GONE);
        refreshLayout.setOnMultiListener(new SimpleMultiPurposeListener() {

            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {
                super.onRefresh(refreshLayout);
                if (mColumnFragment != null) {
                    mColumnFragment.onRefresh();
                }

            }

            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                super.onLoadMore(refreshLayout);
                if (mColumnFragment != null) {
                    mColumnFragment.onLoadMore();
                }
            }

            @Override
            public void onHeaderMoving(RefreshHeader header, boolean isDragging, float percent, int offset, int headerHeight, int maxDragHeight) {
                super.onHeaderMoving(header, isDragging, percent, offset, headerHeight, maxDragHeight);

                // 缩放
                if (scaleImgRL != null) {
                    float scaleXy = 1 + percent / 2;
                    scaleImgRL.setScaleX(scaleXy);
                    scaleImgRL.setScaleY(scaleXy);

                }

                if (null != marginTopView) {
                    ViewGroup.LayoutParams marginTopParams = marginTopView.getLayoutParams();
                    marginTopParams.height = (int) AppContext.getContext().getResources().getDimension(R.dimen.rmrb_dp150) + (offset / 3);
                    marginTopView.setLayoutParams(marginTopParams);

                }

                if (offset < 0) {
                    float alphaValue = (float) Math.abs(offset) / (float) UiUtils.dp2px(150);
                    Log.e("qweqwd", "alphaValue=" + offset);
                    dyAlphaView(alphaValue);
                }


            }
        });


    }


    /**
     * 动态处理视图Alpha值
     *
     * @param alphaValue
     */
    private void dyAlphaView(float alphaValue) {
        currentAlphaValue = alphaValue;
        ivLine.setAlpha(alphaValue);
        viewTitleBg.setAlpha(alphaValue);
        customTitleBar.getTitleView().setAlpha(alphaValue);
        if (getFragmentActivity() != null) {
            if (alphaValue >= 1) {
                ((BaseActivity) fragmentActivity).setStatusBarStyle(StatusBarStyleEnum.FULLSCREEN_DARK_ENUM);

                if (pageMessage != null && !TextUtils.isEmpty(pageMessage.getBackIconUrl())) {
                    customTitleBar.onLineLoadLeftImage(pageMessage.getBackIconUrl(),R.drawable.icon_page_back_left_black);
                } else {
                    customTitleBar.setLeftImg(R.drawable.icon_page_back_left_black);

                }

//                if (pageMessage != null && !TextUtils.isEmpty(pageMessage.getShareIconUrl())) {
//                    customTitleBar.onLineLoadRightImage(pageMessage.getShareIconUrl());
//                } else {
//                    customTitleBar.setRightImg(R.drawable.ic_tab_black_more);
//                }

            } else {

                if (pageMessage != null && !TextUtils.isEmpty(pageMessage.getBackIconUrl())) {
                    customTitleBar.onLineLoadLeftImage(pageMessage.getBackIconUrl(),R.drawable.icon_page_back_left_withe);
                } else {
                    customTitleBar.setLeftImg(R.drawable.icon_page_back_left_withe);
                }

//                if (pageMessage != null && !TextUtils.isEmpty(pageMessage.getShareIconUrl())) {
//                    customTitleBar.onLineLoadRightImage(pageMessage.getShareIconUrl());
//                } else {
//                    customTitleBar.setRightImg(R.drawable.ic_tab_white_more);
//                }
            }
        }

    }

    @Override
    public int bindItem(View itemView, int position, MenuBean data) {
        if (data == null) {
            return position;
        }

        showPageComment = data.pageOpenComment;
        setCustomTitleBar(data.getTopMargin());
        customTitleBar.setTitle(data.getTitle());
        setSummaryContent(data.getTitle(), data.getSummary());

        customTitleBar.setTitleBarClickListener(new CustomTitleBar.TitleBarClickListener() {
            @Override
            public void onLeftClick() {

                getFragmentActivity().finish();
            }

            @Override
            public void onRightClick() {

                if (topicInfoBean != null) {
                    // 分享
                    CompentLogicUtil.shareTopicInfoBean(topicInfoBean, customTitleBar.getContext());
                }

            }
        });
        if (getFragmentActivity() != null) {
            PageBean pageBean = data.getPageInfor();
            mColumnFragment = ColumnFragment.newInstance(data.getNavId(), false, ContentTypeConstant.URL_TYPE_FIVE, pageBean);
            mColumnFragment.setPageLayoutManagerListener(pageInforToLayoutManagerCallback);
            mColumnFragment.setSuperRootLayout(flParent);
            getFragmentActivity().getSupportFragmentManager().beginTransaction().add(R.id.rv_content, mColumnFragment).commit();

        }

        return position;
    }


    private void setCustomTitleBar(int topMargin) {
        ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) customTitleBar.getLayoutParams();
        layoutParams.topMargin = topMargin;

        ConstraintLayout.LayoutParams viewTitleBgLp = (ConstraintLayout.LayoutParams) viewTitleBg.getLayoutParams();
        viewTitleBgLp.height = topMargin + (int) AppContext.getContext().getResources().getDimension(R.dimen.rmrb_dp44);
    }

    private PageInforToLayoutManagerCallback pageInforToLayoutManagerCallback = new PageInforToLayoutManagerCallback() {

        @Override
        public void onPageThemeChange(ThemeMessage message) {
            if (message == null) {
                return;
            }

            pageMessage = message;
            Logger.t(TAG).d("onChangeTheme, getBackgroundColor: " + message.getBackgroundColor());
            setTopOrNavBackgroud(message.getBackgroundImage(), message.getBackgroundColor());

            if (currentAlphaValue == -1) {
                if (!TextUtils.isEmpty(message.getBackIconUrl())) {
                    customTitleBar.onLineLoadLeftImage(message.getBackIconUrl(),R.drawable.icon_page_back_left_withe);
                } else {
                    customTitleBar.setLeftImg(R.drawable.icon_page_back_left_withe);
                }

                //            if (!TextUtils.isEmpty(message.getShareIconUrl())) {
//                customTitleBar.onLineLoadRightImage(message.getShareIconUrl());
//            } else {
//                customTitleBar.setRightImg(R.drawable.ic_tab_white_more);
//            }

            } else {
                dyAlphaView(currentAlphaValue);
            }



        }

        @Override
        public void listenerTopicInfoBean(TopicInfoBean bean) {

            setHeadViewInfor(bean);
        }

        @Override
        public void listenerChannelInfoBean(ChannelInfoBean bean) {

        }

        @Override
        public void fragmentRequestCallback(boolean isRefresh, boolean isOpenLoadMore) {
            refreshLayout.finishRefresh();
            refreshLayout.finishLoadMore();

        }

        @Override
        public void isTop() {

        }

        @Override
        public void failedPage(int errorCode) {
            showErrorView(errorCode);
            setTabTitleRightIcon();
        }
    };


    /**
     * 设置页面头部区域信息
     *
     * @param bean
     */
    private void setHeadViewInfor(TopicInfoBean bean) {
        if (bean == null) {
            return;
        }
        topicInfoBean = bean;
        customTitleBar.setTitle(bean.getTitle());
        setSummaryContent(bean.getTitle(), bean.getSummary());
        setTabTitleRightIcon();
        setCommentLayout();

        if (pageMessage != null) {
            topicInfoBean.setLocalPageId(pageMessage.getPageId());
            topicInfoBean.setLocalPageName(pageMessage.getPageName());
        }
    }

    /**
     * 统一设置顶部背景图或导航栏颜色
     *
     * @param topBackgroundImageUrl
     * @param navBackgroundColor
     */
    public void setTopOrNavBackgroud(String topBackgroundImageUrl, String navBackgroundColor) {
        ImageUtils.getInstance().homeThemeImageLoadAndSave(ivHeadBg, 0, topBackgroundImageUrl, R.drawable.rmrb_placeholder_w2h1);

    }

    /**
     * 显示错误视图
     */
    private void showErrorView(int type) {

        if (!NetworkUtils.isNetAvailable()) {
            type = DefaultViewConstant.TYPE_NO_NETWORK;
        }
        mErrorView.setRetryBtnClickListener(new DefaultView.RetryClickListener() {
            @Override
            public void onRetryClick() {
                hideErrorView();
                if (mColumnFragment != null) {
                    mColumnFragment.requestData();
                }
            }
        });
        mErrorView.show(type);

        ViewUtils.setVisible(refreshLayout, View.GONE);
        dyAlphaView(1);
    }

    /**
     * 隐藏错误视图
     */
    private void hideErrorView() {
        if (mErrorView != null) {
            mErrorView.hide();
        }
        ViewUtils.setVisible(refreshLayout, View.VISIBLE);
    }

    /**
     * 是否显示右边分享图标
     */
    public void setTabTitleRightIcon() {
        if (refreshLayout.getVisibility() == View.VISIBLE) {
            customTitleBar.getTitleView().setAlpha(0);
            ivLine.setAlpha(0);
//            if (null != topicInfoBean) {
//                customTitleBar.setRightImgVisibility(View.VISIBLE);
//            } else {
//                customTitleBar.setRightImgVisibility(View.GONE);
//            }
        } else {
            //customTitleBar.setRightImgVisibility(View.GONE);
            customTitleBar.getTitleView().setAlpha(1);
            ivLine.setAlpha(1);
        }
    }


    private void setSummaryContent(String title, String summary) {

        tvTitle.setText(title);

        int tvMsgWith = ScreenUtils.getRealWidth() - (int) AppContext.getContext().getResources().getDimension(R.dimen.rmrb_dp32);
        tvMsg.updateForRecyclerView(summary, tvMsgWith, ExpandableTextView.STATE_SHRINK);
        tvMsg.setExpandListener(new ExpandableTextView.OnExpandListener() {
            @Override
            public void onExpand(ExpandableTextView view) {
            }

            @Override
            public void onShrink(ExpandableTextView view) {

            }
        });
    }


    /**
     * 弹出评论弹出框
     */
    private void openComment() {
        CommentCommitDialog commitDialog = new CommentCommitDialog(getFragmentActivity());
        //  2023/11/3 设置评论发布点击埋点数据
        if (topicInfoBean != null) {
            TrackContentBean trackContentBean = new TrackContentBean();
            trackContentBean.topicInfoBeanBeantoBean(topicInfoBean);
            commitDialog.setTrackContentBean(trackContentBean);
        }
        commitDialog.setCommitDialogListener(new CommitDialogListener() {
            @Override
            public void publish(String text) {
                commitDialog.dismiss();
                if (null != sheetDialog) {
                    sheetDialog.setInput(transparentBean);
                    sheetDialog.submitComment(text.trim(), "2", "", -1);
                }
            }

            @Override
            public void getUnloadImg(ArrayList<String> images) {
            }
        });
        commitDialog.showDefaultHint(transparentBean.getBestNoticer());
    }



    /**
     * 创建评论布局
     */
    private void setCommentLayout() {

        llCommentInput.setVisibility(View.VISIBLE);

        if (null != topicInfoBean) {
            //给底部view 设置相关数据
            transparentBean = new TransparentBean();
            transparentBean.setContentId(topicInfoBean.getTopicId());
            transparentBean.setContentType(ContentTypeConstant.URL_TYPE_FIVE + "");
            transparentBean.setPreCommentFlag(topicInfoBean.getCommentPreviewFlag());
            transparentBean.setTargetRelId(topicInfoBean.getRelId());
            transparentBean.setTargetRelType(topicInfoBean.getRelType());
            //迭代二新增
            transparentBean.setContentTitle(topicInfoBean.getTitle());
            transparentBean.setTargetRelObjectId(topicInfoBean.getRelId());
            //评论相关
            if (commentViewModel == null) {
                commentViewModel = ((BaseActivity) getFragmentActivity()).getViewModel(CommentViewModel.class);
                sheetDialog = new CommentSheetDialog(getFragmentActivity()).builder();
                sheetDialog.setViewModel(commentViewModel);
                sheetDialog.setDialogHeight(UiUtils.dp2px(550));
                setCommentListener();
            }

//            topicInfoBean.setShareOpen(true);
//            topicInfoBean.setCommentShowFlag(1);
//            topicInfoBean.setCommentFlag(1);

            transparentBean.isBackIcon = true;
            transparentBean.isLikeIcon = true;

            if ("1".equals(topicInfoBean.getShareOpen())) {
                llCommentInput.openShare();
                transparentBean.isShareIcon = false;
            } else {
                llCommentInput.closeShare();
                transparentBean.isShareIcon = true;
            }

            if (1 == topicInfoBean.getCommentShowFlag()) {
                llCommentInput.openCommentBtn();
                transparentBean.isCommentIcon = false;
            } else {
                llCommentInput.hideCommentBtn();
                transparentBean.isCommentIcon = true;
            }

            if (1 == topicInfoBean.getCommentFlag()) {
                llCommentInput.openInputView();
                transparentBean.isCommentNumIcon = false;
            } else {
                llCommentInput.hideInputView();
                transparentBean.isCommentNumIcon = true;
            }

            ShareBean mShareBean = new ShareBean();
            mShareBean.setTitle(topicInfoBean.getShareTitle());
            mShareBean.setDescription(topicInfoBean.getShareSummary());
            mShareBean.setImageUrl(topicInfoBean.getShareCoverUrl());
            mShareBean.setShareUrl(topicInfoBean.getShareUrl());//链接地址
            mShareBean.setContentType(ContentTypeConstant.URL_TYPE_FIVE + "");
            mShareBean.setContentId(topicInfoBean.getTopicId());
            mShareBean.setShareOpen(topicInfoBean.getShareOpen());
            mShareBean.setTargetRelId(topicInfoBean.getRelId());
            mShareBean.setTargetRelType(topicInfoBean.getRelType());
            mShareBean.setShowReport(false);
            mShareBean.setShowPosterType(PosterTypeEnum.CONTENT);
            mShareBean.setShowPoster(topicInfoBean.getPosterFlag() > 0 ? 1 : -1);
            transparentBean.setShareBean(mShareBean);

            llCommentInput.setContentAndType(transparentBean);
            llCommentInput.queryContentDyNumber();
            addInputBarListener();

            //消息监听
            receiveLiveDataMsg();

            // 检测当前专题是否需要展开评论,专题信息是否显示评论入口,检测用户是否登录
            if (showPageComment && 1 == topicInfoBean.getCommentShowFlag() && !TextUtils.isEmpty(SpUtils.getUserToken())) {
                showInputCommentDialog(-1);
            }
        }
    }

    /**
     * 输入弹出框
     */
    private void showInputCommentDialog(int position) {

        //显示评论信息
        sheetDialog.setInitData(transparentBean);
        sheetDialog.setBottomCommentIcon(transparentBean);
        sheetDialog.show();
    }

    /**
     * 接口回调
     */
    private void setCommentListener() {

        commentViewModel.observeCommentListener(getFragmentActivity(), new ICommentDataNewListener() {

            /**
             *获取数据成功
             */
            @Override
            public void onGetCommentListSuccess(CommentListBean commentList) {
                sheetDialog.setCommentData(commentList);
            }

            /**
             * 获取数据失败
             */
            @Override
            public void onGetCommentListFail(int code, String msg) {
                sheetDialog.onGetCommentListFail(code, msg);
            }

            /**
             *获取二级数据成功
             */
            @Override
            public void onGetSecondCommentListSuccess(int position, CommentListBean childCommentList) {
                sheetDialog.onGetSecondCommentListSuccess(position, childCommentList);

            }

            /**
             *获取二级数据失败
             */
            @Override
            public void onGetSecondCommentListFail() {
                sheetDialog.onGetSecondCommentListFail();
            }

            /**
             *发布数据成功
             */
            @Override
            public void onSubmitPushCommentSuccess(CommentItem pushListBean, int position, String msg) {
                sheetDialog.submitCommentSuccess(pushListBean, position, msg);
            }

            /**
             *发布数据失败
             */
            @Override
            public void onSubmitPushCommentFail(int code, String msg) {
                sheetDialog.onSubmitPushCommentFail(code, msg);
            }

            /**
             * 获取号主认证信息
             */
            @Override
            public void onGetMastersAuthenticationListSuccess(List<PersonalInfoBean> masterInfoList, List<CommentItem> originalListData, int freshStartIndex, int listLevel) {
                sheetDialog.setMastersAuthenticationList(masterInfoList, originalListData, freshStartIndex, listLevel);
            }

            /**
             * 获取号主信息失败
             */
            @Override
            public void onGetMastersAuthenticationListFailure(String errorInfo, int listLevel) {
                sheetDialog.onGetMastersAuthenticationListFailure(errorInfo, listLevel);
            }

            /**
             * 重组所有信息
             */
            @Override
            public void onGetAllDataSuccess(List<CommentStatusBean> statusList, List<PersonalInfoBean> masterInfoList, List<CommentItem> originalListData, int freshStartIndex, int listLevel) {
                sheetDialog.setAllList(statusList, masterInfoList, originalListData, freshStartIndex, listLevel);
            }

            /**
             *获取所有评论状态失败
             */
            @Override
            public void onGetCommentStatusListFailure(String errorInfo, int listLevel) {
                sheetDialog.setErrorView(listLevel);
            }

            /**
             *删除评论
             */
            @Override
            public void delCommentSuccess(int freshPosition) {
                sheetDialog.delCommentSuccess(freshPosition);
            }

            /**
             * 删除评论失败
             */
            @Override
            public void delCommentFail(String e) {
                sheetDialog.delCommentFail(e);
            }

            /**
             * 获取单个认证
             */
            @Override
            public void onGetSingleMastersAuthenticationDataSuccess(PersonalInfoBean mMasterInfoBean, int freshPosition) {
                sheetDialog.setSingleMastersAuthentication(mMasterInfoBean, freshPosition);
            }

            @Override
            public void onGetLevelInfoBeanListSuccess(List<CommentItem> data, int freshStartIndex, int listLevel) {

            }
        });
    }

    /**
     * 广播接收
     */
    private void receiveLiveDataMsg() {
        //登录成功
        LiveDataBus.getInstance().with(EventConstants.USER_ALREADY_LOGIN, Boolean.class).observe(getFragmentActivity(), aBoolean -> {
            if (aBoolean && null != llCommentInput) {
                llCommentInput.setContentAndType(transparentBean);
            }
        });


        //评论个数
        LiveDataBus.getInstance().with(EventConstants.COMMENT_NUM, EventMessage.class).observe(getFragmentActivity(), mEventMessage -> {
            if (mEventMessage == null) {
                return;
            }
            String contentId_new = mEventMessage.getStringExtra(IntentConstants.CONTENT_ID);
            String contentType_new = mEventMessage.getStringExtra(IntentConstants.CONTENT_TYPE);
            String num = mEventMessage.getStringExtra(IntentConstants.COMMENT_NUM);
            if (contentId_new.equals(topicInfoBean.getTopicId()) && contentType_new.equals(ContentTypeConstant.URL_TYPE_FIVE + "")) {
                if (!StringUtils.isEmpty(num)) {
                    if (null != llCommentInput) {
                        llCommentInput.setCommentNum(num);
                    }
                }
            }
        });


        //收藏
        LiveDataBus.getInstance().with(EventConstants.COMMNET_FAV + topicInfoBean.getTopicId(), String.class).observe(getFragmentActivity(), s -> {
            llCommentInput.collectIcon("1".equals(s));
        });

    }

    /**
     * 评论输入框、取消监听
     */
    private void addInputBarListener() {
        llCommentInput.setCommentFunctionListener(new BottomCommentFunctionBar.CommentFunctionListener() {
            @Override
            public void backClick() {
                getFragmentActivity().finish();
            }

            @Override
            public void inputClick() {
                // 判断是否登录
                if (TextUtils.isEmpty(SpUtils.getUserToken())) {
                    ProcessUtils.toOneKeyLoginActivity();
                    return;
                }
                openComment();


            }

            @Override
            public void commentClick() {
                // 判断是否登录
                if (TextUtils.isEmpty(SpUtils.getUserToken())) {
                    ProcessUtils.toOneKeyLoginActivity();
                    return;
                }
                showInputCommentDialog(-1);
            }

            @Override
            public void likeClick(String status) {


            }

            @Override
            public void collectClick(String status) {
                // 埋点
                if (topicInfoBean != null) {
                    boolean isCollect = "1".equals(status);
                    TrackContentBean trackContentBean = new TrackContentBean();
                    trackContentBean.topicInfoBeanBeantoBean(topicInfoBean);
                    trackContentBean.collectAction(isCollect);
                    CommonTrack.getInstance().contentCollectionTrack(trackContentBean, isCollect);
                }

            }

            @Override
            public void shareClick() {
                if (topicInfoBean != null) {
                    CompentLogicUtil.shareTopicInfoBean(topicInfoBean, llCommentInput.getContext());
                }

            }
        });

    }

}