TemplateFragment.java 58.8 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 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499
package com.wd.capability.layout.fragment;

import android.content.res.Configuration;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.Observer;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.SimpleItemAnimator;

import com.people.comment.bean.CommentClickShowType;
import com.people.comment.comment.vm.CommentViewModel;
import com.people.comment.dialog.CommentCommitDialog;
import com.people.comment.listener.CommitDialogListener;
import com.people.room.entity.ChannelBean;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener;
import com.wd.base.log.Logger;
import com.wd.capability.layout.R;
import com.wd.capability.layout.comp.layoutdata.AbsGroup;
import com.wd.capability.layout.comp.layoutdata.AbsSection;
import com.wd.capability.layout.comp.layoutdata.Group;
import com.wd.capability.layout.comp.layoutdata.Page;
import com.wd.capability.layout.comp.layoutmanager.BaseAdapter;
import com.wd.capability.layout.comp.layoutmanager.ILayoutRender;
import com.wd.capability.layout.comp.layoutmanager.ItemLayoutManager;
import com.wd.capability.layout.comp.layoutmanager.LayoutAdapter;
import com.wd.capability.layout.comp.layoutmanager.channel.CompBeSimilarMore;
import com.wd.capability.layout.comp.layoutmanager.channel.CompLabel01;
import com.wd.capability.layout.comp.layoutmanager.channel.CompSingleMessageBoard;
import com.wd.capability.layout.ui.commonpage.TemplatePageDataFetcher;
import com.wd.capability.layout.ui.commonpage.TemplatePageDataListener;
import com.wd.capability.layout.ui.commonpage.TemplatePageDataViewModel;
import com.wd.capability.layout.ui.widget.ColumnRecyclerView;
import com.wd.capability.layout.ui.widget.VerticalLoadScrollListener;
import com.wd.capability.layout.ui.widget.itemhelp.ItemStateChangeListener;
import com.wd.capability.layout.ui.widget.progress.PageLoadingView;
import com.wd.capability.layout.uitls.CompentLogicUtil;
import com.wd.capability.network.BaseObserver;
import com.wd.capability.network.bean.MetaBean;
import com.wd.capability.network.constant.EventConstants;
import com.wd.capability.network.utils.NetworkUtil;
import com.wd.common.base.BaseAutoLazyFragment;
import com.wd.common.decoration.Decoration;
import com.wd.common.enums.MoreEnum;
import com.wd.common.interact.ICommentDataNewListener;
import com.wd.common.utils.CommonNetUtils;
import com.wd.common.utils.PDUtils;
import com.wd.common.utils.ProcessUtils;
import com.wd.common.widget.CommomLoadMoreFooter;
import com.wd.common.widget.CommonRefreshHeader;
import com.wd.common.widget.CustomSmartRefreshLayout;
import com.wd.common.widget.DefaultView;
import com.wd.foundation.bean.analytics.TrackContentBean;
import com.wd.foundation.bean.comment.CommentListBean;
import com.wd.foundation.bean.comment.CommentStatusBean;
import com.wd.foundation.bean.comment.TransparentBean;
import com.wd.foundation.bean.convenience.MoreItemBean;
import com.wd.foundation.bean.custom.MenuBean;
import com.wd.foundation.bean.custom.NavigationBeanNews;
import com.wd.foundation.bean.custom.comp.CompDataSourceBean;
import com.wd.foundation.bean.custom.comp.PageBean;
import com.wd.foundation.bean.custom.content.CommentItem;
import com.wd.foundation.bean.custom.content.ContentBean;
import com.wd.foundation.bean.livedate.CommentOperationBean;
import com.wd.foundation.bean.livedate.EventMessage;
import com.wd.foundation.bean.request.PublishCommentParameterBean;
import com.wd.foundation.bean.response.MyAskMarkBean;
import com.wd.foundation.bean.response.PersonalInfoBean;
import com.wd.foundation.bean.utils.TimeUtil;
import com.wd.foundation.wdkit.constant.DefaultViewConstant;
import com.wd.foundation.wdkit.constant.GlobalAppCacheData;
import com.wd.foundation.wdkit.constant.IntentConstants;
import com.wd.foundation.wdkit.json.GsonUtils;
import com.wd.foundation.wdkit.system.DeviceUtil;
import com.wd.foundation.wdkit.utils.SafeBundleUtil;
import com.wd.foundation.wdkit.utils.SpUtils;
import com.wd.foundation.wdkit.utils.ToastNightUtil;
import com.wd.foundation.wdkitcore.livedata.LiveDataBus;
import com.wd.foundation.wdkitcore.thread.ThreadPoolUtils;
import com.wd.foundation.wdkitcore.tools.ResUtils;
import com.wd.foundation.wdkitcore.tools.StringUtils;

import org.jetbrains.annotations.NotNull;
import com.wd.common.dialog.AlertDialog;

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

/**
 * @Description: 信息流页面一个模板(自定义 页面信息 , 便于使用组件和稿件资源) 模板页fragment
 * @Author: Li Yubing
 * @Email: liyubing@wondert.com.cn
 * @CreateDate: 2023/8/14 18:46
 * @Version: 1.0
 * 数据请求:{@link TemplatePageDataFetcher}
 */
public class TemplateFragment extends BaseAutoLazyFragment implements OnRefreshLoadMoreListener {
    private static final String TAG = "TemplateFragment";
    /**
     * 列表
     * mCommentData:处理列表数据供adapter使用
     */
    CommentCommitDialog commitDialog;

    CommentViewModel commentViewModel;
    private CommonRefreshHeader refreshHeader;

    private CommomLoadMoreFooter footView;

    // 页面是否展示了底线
    private boolean haveBottomLine = false;

    private ILayoutRender layoutRender;

    /**
     * 总页面容器
     */
    private LinearLayout container;

    /**
     * 组件和稿件容器
     */
    private FrameLayout mFrameLayout;

    /**
     * 页面头部固定投放容器
     */
    private FrameLayout flTop;

    /**
     * 页面吸顶容器
     */
    private FrameLayout stickyFrameLayout;
    /**
     * 下拉上推布局
     */
    private CustomSmartRefreshLayout refreshLayout;

    /**
     * 缺省页
     */
    private DefaultView defaultView;

    /**
     * 信息流页面容器
     */
    private FrameLayout contentFrameLayout;

    /**
     * 首次加载视图
     */
    private PageLoadingView loadingView;

//    /**
//     * recyclerview背景
//     */
//    protected View viewBg;

    /**
     * 当前页数据
     */
    private PageBean mPageBean;
    private Page mPage;
    /**
     * 页面是否已经有数据显示
     */
    private boolean isHashLoadDataInPage = false;

    /**
     * 内容存储器
     */
    private ColumnRecyclerView mRecyclerView;

    private VerticalLoadScrollListener aheadLoadScrollListener;

    private int pageNum = 1;

    /**
     * 留言级别 0地方 1部委;默认0,前端若不传则默认是地方留言查询
     */
    private int position;

    /**
     * 地方
     */
    public static final int LOCAL = 0;

    /**
     * 部委
     */
    public static final int MINISTRIES = 1;

    private MenuBean menuBean;

    private ChannelBean mChannelBean;

    /**
     * 页面所在的tab id
     */
    private String oneTabChannelId = "";

    private String channelId;
    /**
     * 数据来源
     */
    private String dataSourceType;

    /**
     * 1 开启,2 关闭
     */
    private int bestNoticer = 2;

    private TemplatePageDataViewModel templatePageDataViewModel;

    private boolean headToastFlag = false;

    /*
       吸顶组件
     */
    private CompLabel01 compLabel01;//

    private int textLength;

    /**
     * 获取Fragment实例对象
     *
     * @param menuBean 数据id
     * @return Fragment实例
     */
    public static TemplateFragment newInstance(MenuBean menuBean) {
        TemplateFragment fragment = new TemplateFragment();
        Bundle bundle = new Bundle();
        bundle.putSerializable(IntentConstants.PAGE_INFOR_DATA, menuBean);
        fragment.setArguments(bundle);
        return fragment;
    }

    /**
     * 获取Fragment实例对象
     *
     * @param menuBean 数据id
     * @return Fragment实例
     */
    public static TemplateFragment newInstance(MenuBean menuBean, int topMarginInt, ChannelBean channelBean) {
        TemplateFragment fragment = new TemplateFragment();
        Bundle bundle = new Bundle();
        bundle.putSerializable(IntentConstants.PAGE_INFOR_DATA, menuBean);
        bundle.putInt(IntentConstants.PARAM_TOPMARGININT, topMarginInt);
        bundle.putSerializable(IntentConstants.PARAM_PAGE_OBJ, channelBean);
        fragment.setArguments(bundle);
        return fragment;
    }

    /**
     * 获取Fragment实例对象
     *
     * @param menuBean 数据id
     * @return Fragment实例
     */
    public static TemplateFragment newInstance(MenuBean menuBean, int topMarginInt, ChannelBean channelBean, String channelId) {
        TemplateFragment fragment = new TemplateFragment();
        Bundle bundle = new Bundle();
        bundle.putString(IntentConstants.PARAM_CHANNEL_ID, channelId);
        bundle.putSerializable(IntentConstants.PAGE_INFOR_DATA, menuBean);
        bundle.putInt(IntentConstants.PARAM_TOPMARGININT, topMarginInt);
        bundle.putSerializable(IntentConstants.PARAM_PAGE_OBJ, channelBean);
        fragment.setArguments(bundle);
        return fragment;
    }

    /**
     * 获取Fragment实例对象
     *
     * @param menuBean 数据id
     * @return Fragment实例
     */
    public static TemplateFragment newInstance(MenuBean menuBean, int topMarginInt, ChannelBean channelBean, int textLength) {
        TemplateFragment fragment = new TemplateFragment();
        Bundle bundle = new Bundle();
        bundle.putSerializable(IntentConstants.PAGE_INFOR_DATA, menuBean);
        bundle.putInt(IntentConstants.PARAM_TOPMARGININT, topMarginInt);
        bundle.putSerializable(IntentConstants.PARAM_PAGE_OBJ, channelBean);
        bundle.putInt(IntentConstants.TEXT_LENGTH, textLength);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    protected void perCreate() {
        super.perCreate();
        oneTabChannelId = SafeBundleUtil.getString(getArguments(), IntentConstants.PARAM_CHANNEL_ID, "");
        menuBean = (MenuBean) SafeBundleUtil.getSerializable(getArguments(), IntentConstants.PAGE_INFOR_DATA);
        mChannelBean = (ChannelBean) SafeBundleUtil.getSerializable(getArguments(), IntentConstants.PARAM_PAGE_OBJ);
        textLength = SafeBundleUtil.getInt(getArguments(),IntentConstants.TEXT_LENGTH,0);
        //首页启动速度用户,使用java布局
        setIsjava(true);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        int topMarginInt = SafeBundleUtil.getInt(getArguments(), IntentConstants.PARAM_TOPMARGININT, 0);
        if (topMarginInt != 0) {
            container.setPadding(0, topMarginInt, 0, 0);
        }
    }

    @Override
    protected String getLogTag() {
        return TAG;
    }

    @Override
    protected int getLayout() {
        return 0;
    }

    @Override
    protected void initView(View rootView) {

        if (mChannelBean != null) {
            channelId = mChannelBean.getChannelId();
        }
        if (menuBean != null) {
            dataSourceType = menuBean.dataSourceType;
        }
        if (CompDataSourceBean.LIVE_RESERVATION.equals(dataSourceType)
                || CompDataSourceBean.LOCAL_MY_SUBSCRIBE.equals(dataSourceType)
        ) {
            mFrameLayout.setBackgroundColor(ContextCompat.getColor(mFrameLayout.getContext(), R.color.res_color_common_C7));
        } else if (CompDataSourceBean.LOCAL_HIGHQUALITYCOMMENTSPAGECARD.equals(dataSourceType)) {
            mFrameLayout.setBackgroundColor(ContextCompat.getColor(mFrameLayout.getContext(),R.color.res_color_general_00000000));
        }
        addHeadFootViewRF();
        initViewModel();
        registerBus();
    }

    /**
     * 注册LiveBus
     */
    private void registerBus() {


        // 接收插入稿件
        LiveDataBus.getInstance().with(EventConstants.COMP_MANUSCRIPT_INSERT, Integer.class).observe(getViewLifecycleOwner(), postion -> {

            if (layoutRender != null) {
                List<ItemLayoutManager> layoutManagers = layoutRender.getAllSectionLayoutManager();
                if (postion < layoutManagers.size()) {
                    ItemLayoutManager itemLayoutManager = layoutManagers.get(postion);
                    if (itemLayoutManager instanceof CompBeSimilarMore) {
                        CompBeSimilarMore compBeSimilarMore = (CompBeSimilarMore) itemLayoutManager;
                        List<ContentBean> moreList = compBeSimilarMore.getMoreList();
                        templatePageDataViewModel.contentDataInsertToPositionPage(moreList, postion);

                    }
                }

            }

        });
        //接受关注事件
        LiveDataBus.getInstance().with(EventConstants.FRESH_FOLLOW_CREATOR_EVENT, EventMessage.class).observe(getViewLifecycleOwner(), mEventMessage -> {
            if (mEventMessage == null) {
                return;
            }
            if (null != mRecyclerView && null != mRecyclerView.getAdapter()) {
                // 同步关注信息
                List<ItemLayoutManager> layoutManagers = layoutRender.getAllSectionLayoutManager();
                CompentLogicUtil.updateUserFollowInforLayout(mEventMessage, layoutManagers);
            }
        });

        //接受点赞事件
        LiveDataBus.getInstance().with(EventConstants.FRESH_ZAN_CREATOR_EVENT, EventMessage.class).observe(getViewLifecycleOwner(), mEventMessage -> {
            if (mEventMessage == null) {
                return;
            }
            if (null != mRecyclerView && null != mRecyclerView.getAdapter()) {
                // 同步关注信息
                List<ItemLayoutManager> layoutManagers = layoutRender.getAllSectionLayoutManager();
                CompentLogicUtil.updateUserZanInforLayout(mEventMessage, layoutManagers);
            }
        });

        //接受预约状态事件
        LiveDataBus.getInstance().with(EventConstants.FRESH_APPONINTMENT_STATUS_EVENT, EventMessage.class).observe(getViewLifecycleOwner(), mEventMessage -> {
            if (mEventMessage == null) {
                return;
            }
            if (null != mRecyclerView && null != mRecyclerView.getAdapter()) {
                // 同步关注信息
                List<ItemLayoutManager> layoutManagers = layoutRender.getAllSectionLayoutManager();
                CompentLogicUtil.updateCompLiveAppointStatus(mEventMessage, layoutManagers);
            }
        });

        //刷新直播人数事件
        LiveDataBus.getInstance().with(EventConstants.REFRESH_LIVE_PV, EventMessage.class).observe(getViewLifecycleOwner(), mEventMessage -> {
            if (mEventMessage == null) {
                return;
            }
            if (null != mRecyclerView && null != mRecyclerView.getAdapter()) {
                // 同步关注信息
                List<ItemLayoutManager> layoutManagers = layoutRender.getAllSectionLayoutManager();
                CompentLogicUtil.updateCompLivePV(mEventMessage, layoutManagers);
            }
        });

        //设置文字大小发消息通知刷新
        LiveDataBus.getInstance().with(EventConstants.FONT_SIZE_SET_SUCCESS, Boolean.class).observe(getViewLifecycleOwner(), aBoolean -> {
            if (aBoolean) {
                if (null != mRecyclerView && null != mRecyclerView.getAdapter()) {
                    mRecyclerView.getAdapter().notifyDataSetChanged();
                }
            }
        });

        if (menuBean != null && CompDataSourceBean.LOCAL_HIGHQUALITYCOMMENTSPAGECARD.equals(menuBean.dataSourceType)) {
            //评论操作
            LiveDataBus.getInstance()
                    .with(EventConstants.COMMENT_OPERATION_EVENT, CommentOperationBean.class)
                    .observe(getActivity(), new Observer<CommentOperationBean>() {
                        @Override
                        public void onChanged(CommentOperationBean commentOperationBean) {
                            if (commentOperationBean == null || mPage == null || mPage.getGroups() == null
                                    || mPage.getGroups().size() < 1 || mPage.getGroups().get(0) == null
                                    || mPage.getGroups().get(0).getSections() == null || mPage.getGroups().get(0).getSections().size() < 1) {
                                return;
                            }
                            String commentId = commentOperationBean.getCommentId();
                            int operationType = commentOperationBean.getOperationType();
                            List<AbsSection> newsCompList = mPage.getGroups().get(0).getSections();
                            ContentBean selectCompBean = null;
                            int selectPosition = 0;
                            for (int i = 0; i < newsCompList.size(); i++) {
                                AbsSection compBean = newsCompList.get(i);
                                if (compBean == null || compBean.getCompBean() == null
                                        || compBean.getCompBean().getOperDataList().size() < 1 || compBean.getCompBean().getOperDataList().get(0) == null) {
                                    continue;
                                }
                                ContentBean contentBean = compBean.getCompBean().getOperDataList().get(0);
                                if (contentBean.getCommentInfo() == null) {
                                    continue;
                                }
                                if (commentId.equals(contentBean.getCommentInfo().getCommentId())) {
                                    selectCompBean = contentBean;
                                    selectPosition = i;
                                    break;
                                }
                            }
                            int clickShowType = 0;
                            if (operationType == MoreEnum.REPLY) {
                                clickShowType = CommentClickShowType.reply;
                            } else if (operationType == MoreEnum.DELETE) {
                                clickShowType = CommentClickShowType.delete;
                            } else if (operationType == MoreEnum.COPY_LINK) {
                                clickShowType = CommentClickShowType.copy;
                            } else if (operationType == MoreEnum.REPORT) {
                                clickShowType = CommentClickShowType.report;
                            }
                            if (selectCompBean != null) {
                                judeClickType(selectCompBean, clickShowType, selectPosition);
                            }
                        }
                    });
        }

    }

    private void initViewModel() {

        templatePageDataViewModel = getViewModelThis(TemplatePageDataViewModel.class);
        templatePageDataViewModel.setChannelBean(mChannelBean);
        templatePageDataViewModel.setChannelId(channelId);
        templatePageDataViewModel.observeTemplatePageDataListener(this, new TemplatePageDataListener() {


            @Override
            public void onPageDataSuccess(Page page, PageBean data) {
                mPage = page;
                mPageBean = data;
                hideLoading();
                hidePageLoadingView();
                // Log.e("DDDDSSS", "data.needRefresh=" + data.needRefresh);
                if (data.needRefresh) {
                    hideDefaultView();
                    isHashLoadDataInPage = true;
                    doPageDataSuccess();
                } else {

                    // 加载更多组件
                    List<ItemLayoutManager> layoutManagerList = layoutRender.getAllSectionLayoutManager();
                    // 页面缓存数据量
                    int startIndex = layoutManagerList.size();

                    // page.setDisplayItemCount(startIndex);
                    layoutRender.renderPage(page, false);
                    // 检测是否满足加载更多
                    boolean isLoadMore = checkHaveMoreLoad();
                    if (!isLoadMore) {
                        if (!haveBottomLine) {
                            layoutRender.addBaseLine(mPage);
                            haveBottomLine = true;
                        }
                    } else {
                        haveBottomLine = false;
                    }

                    List<ItemLayoutManager> newList = layoutRender.getAllSectionLayoutManager();
                    // 页面新数据量
                    int endIndex = newList.size();
                    BaseAdapter baseAdapter = (BaseAdapter) layoutRender;
                    baseAdapter.notifyItemRangeChanged(startIndex, endIndex);

                }

                if (pageNum == 1) {
                    AbsGroup absGroup = mPage.getGroups().get(0);
                    Group groupBean = (Group) absGroup;
                    int newCompSize = groupBean.getSections().size();
                    if (newCompSize == 0) {
                        isHashLoadDataInPage = false;
                        if(data != null && data.isWeakNet()){
                            //弱网
                            showDefaultView(DefaultViewConstant.TYPE_NO_NETWORK);
                        }else {
                            showDefaultView(DefaultViewConstant.TYPE_NO_CONTENT);
                        }
                    }
                }
                //检测是否需要开启预先加载
                boolean openLoadMore = checkHaveMoreLoad();
                refreshLayout.setEnableLoadMore(openLoadMore);
                // 检测到有分页数据,启用本地缓存无需要给pagenum加1
                if (openLoadMore) {
                    // 添加页码
                    pageNum = pageNum + 1;
                }

                if (aheadLoadScrollListener != null) {
                    aheadLoadScrollListener.setOneAheadLoadMore(openLoadMore);
                }

            }

            @Override
            public void onInsertDataToPage() {
                // Log.e("DDDDSSS", "onInsertDataToPage  data.insertPosition=" + mPageBean.insertPosition + "  data.insertTotalNum=" + mPageBean.insertTotalNum);
                layoutRender.itemRangeInserted(mPage, mPageBean.insertPosition, mPageBean.insertTotalNum);
                BaseAdapter baseAdapter = (BaseAdapter) layoutRender;
                baseAdapter.notifyItemRangeInserted(mPageBean.insertPosition, mPageBean.insertTotalNum);
                baseAdapter.notifyDataSetChanged();
            }

            @Override
            public void onPageDataSetChanged(int startIndex, int totalNum) {
                if (layoutRender != null) {
                    //  Log.e("DDDDSSS", "onPageDataSetChanged  data.insertPosition=" + mPageBean.insertPosition + "  data.insertTotalNum=" + mPageBean.insertTotalNum);
                    List<ItemLayoutManager> newList = layoutRender.getAllSectionLayoutManager();
                    // 页面中layoutmanager的数据量
                    int chacheLayoutManangerSize = startIndex + totalNum;
                    for (int i = startIndex; i < chacheLayoutManangerSize; i++) {
                        ItemLayoutManager itemLayoutManager = newList.get(i);
                        itemLayoutManager.updateData(i);
                        itemLayoutManager.updateMaterInforView(i);

                    }
                }
            }

            @Override
            public void onGetFailed(int code, String failedMsg) {
                hideLoading();
                hidePageLoadingView();
                if (!isHashLoadDataInPage) {
                    if(code == -1){
                        //弱网
                        showDefaultView(DefaultViewConstant.TYPE_NO_NETWORK);
                    }else {
                        showDefaultView(DefaultViewConstant.TYPE_GET_CONTENT_ERROR);
                    }
                }
            }
        });

    }

    @Override
    protected View getJavaLayout() {
        container = new LinearLayout(activity);
        container.setOrientation(LinearLayout.VERTICAL);
        flTop = new FrameLayout(activity);
        container.addView(flTop, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));

        mFrameLayout = new FrameLayout(activity);
        mFrameLayout.setBackgroundColor(ContextCompat.getColor(mFrameLayout.getContext(), R.color.res_color_common_C8));
        //刷新框架
        refreshLayout = (CustomSmartRefreshLayout) LayoutInflater.from(activity).inflate(R.layout.page_layout_smartrefreshlayout, null);
        FrameLayout subLayout = getSubLayout();
        refreshLayout.addView(subLayout);
        mFrameLayout.addView(refreshLayout);
        //ViewStub
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.gravity = Gravity.CENTER;
        //搜索使用外面的loadding
        loadingView = new PageLoadingView(activity);
        loadingView.setLayoutParams(params);
        loadingView.setVisibility(View.GONE);
        mFrameLayout.addView(loadingView);
        LinearLayout.LayoutParams mFrameLayoutLp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
        mFrameLayoutLp.weight = 1f;
        container.addView(mFrameLayout, mFrameLayoutLp);
        return container;
    }

    private FrameLayout getSubLayout() {
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

        contentFrameLayout = new FrameLayout(activity);
        contentFrameLayout.setLayoutParams(params);

        mRecyclerView = (ColumnRecyclerView) LayoutInflater.from(activity).inflate(R.layout.page_layout_columnrecyclerview, null);
        contentFrameLayout.addView(mRecyclerView);

        // 历史推送-添加一个吸顶容器
        if (CompDataSourceBean.LOCAL_PUSH_MSG_LIST.equals(menuBean.dataSourceType)) {

            stickyFrameLayout = new FrameLayout(activity);
            contentFrameLayout.addView(stickyFrameLayout,
                    new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));

            stickyFrameLayout.removeAllViews();
            compLabel01 = new CompLabel01();
            View compLabel01Layout = LayoutInflater.from(getContext()).inflate(compLabel01.getItemViewType(), stickyFrameLayout, false);
            stickyFrameLayout.addView(compLabel01Layout);
            stickyFrameLayout.setVisibility(View.INVISIBLE);

            compLabel01.prepareItem(compLabel01Layout, 0);
            compLabel01.bindItem(compLabel01Layout, 0, null);
        }

        setRecyclerViewAttribute();

        //DefaultView
        FrameLayout.LayoutParams defaultViewLp = new FrameLayout.LayoutParams(DeviceUtil.getDeviceWidth(), DeviceUtil.getDeviceHeight());
        defaultView = new DefaultView(activity);
        defaultView.setTopViewWeight(120);
        defaultView.setLayoutParams(defaultViewLp);

        FrameLayout pContent = new FrameLayout(activity);
        pContent.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        pContent.addView(defaultView);
        pContent.addView(contentFrameLayout);

        return pContent;
    }

    /**
     * 添加头部和底部view
     */
    private void addHeadFootViewRF() {
        if (refreshHeader == null) {
            refreshHeader = new CommonRefreshHeader(getActivity());
            refreshLayout.setRefreshHeader(refreshHeader);
        }
        if (CompDataSourceBean.LOCAL_SEARCHRESULTTAB.equals(menuBean.dataSourceType) ||
                CompDataSourceBean.LOCAL_HIGHQUALITYCOMMENTSPAGECARD.equals(menuBean.dataSourceType)
                || CompDataSourceBean.LOCAL_SEARCHRESULTPAGE.equals(menuBean.dataSourceType) ||
                CompDataSourceBean.RECOMMEND_LIST_SEARCH.equals(menuBean.dataSourceType)) {
            //禁用下拉刷新功能
            refreshLayout.setEnableRefresh(false);
        } else {
            refreshLayout.setEnableRefresh(true);
        }
        refreshLayout.setOnRefreshLoadMoreListener(this);
        if (footView == null) {
            footView = new CommomLoadMoreFooter(getActivity());
            footView.setDescTextColor(ContextCompat.getColor(getActivity(), R.color.color_93959D));
            refreshLayout.setRefreshFooter(footView);
        }
        refreshLayout.setEnableLoadMore(false);
    }

    private boolean exposure = true;

    /**
     * 留言级别 0地方 1部委;默认0,前端若不传则默认是地方留言查询
     */
    public void setPosition(int position) {
        this.position = position;
        if (menuBean != null) {
            menuBean.setPosition(position);
        }
    }

    /**
     * 留言级别 0地方 1部委;默认0,前端若不传则默认是地方留言查询
     */
    public int getPosition() {
        return position;
    }

    /**
     * 处理数据获取成功后续逻辑
     */
    private void doPageDataSuccess() {

        if (mPage == null) {
            return;
        }
        if (menuBean != null && CompDataSourceBean.LOCAL_HIGHQUALITYCOMMENTSPAGECARD.equals(menuBean.dataSourceType)) {
            //精选评论
            if(mPageBean != null && StringUtils.isEmpty(mPageBean.getBaselineColor())){
                //设置“已显示全部内容”文字设置
                mPageBean.setBaselineColor("#99FFFFFF");
            }
        }
        mPage.setFragment(TemplateFragment.this);

        initCommonRecyclerView();

        if (layoutRender != null) {
            layoutRender.renderPage(mPage, true);
            //
            if (CompDataSourceBean.LOCAL_ACTIVITY_CHANNEL_PAGE.equals(dataSourceType)) {
                List<ItemLayoutManager> layoutManagerList = layoutRender.getAllSectionLayoutManager();
                if (layoutManagerList.size() > 0) {
                    ItemLayoutManager itemLayoutManager = layoutManagerList.get(0);
                    itemLayoutManager.setInChannelFlag(true);
                }
            }
            // 检测是否满足加载更多
            boolean isLoadMore = checkHaveMoreLoad();
            if (!isLoadMore) {
                haveBottomLine = true;
                layoutRender.addBaseLine(mPage);
            } else {
                haveBottomLine = false;
            }
            layoutRender.notifyDataSetChanged();
        }
        // 浏览埋点
//        if (mPageBean != null && !TextUtils.isEmpty(oneTabChannelId) && exposure) {
//            exposure = false;
//            TrackContentBean bean = new TrackContentBean();
//            bean.pageBeanToTrackContentBean(mPageBean);
//            bean.setExposure(duration);
//            CommonTrack.getInstance().channelExposureTrack(bean);
//        }
    }


    /**
     * 设置RecyclerView属性
     */
    private void setRecyclerViewAttribute() {
        mRecyclerView.setItemViewCacheSize(4);//NewsSectionParserHelper.getColumnCacheSize()
        mRecyclerView.setDrawingCacheEnabled(true);
        mRecyclerView.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);

        // mRecyclerView.setHasFixedSize(true);

        //  mRecyclerView.setItemAnimator(new NoAlphaItemAnimator());
        // 关闭动画,防止刷新闪烁
        RecyclerView.ItemAnimator animator = mRecyclerView.getItemAnimator();
        if (animator instanceof SimpleItemAnimator) {
            ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
        }

        RecyclerView.RecycledViewPool pool = new RecyclerView.RecycledViewPool();
        pool.setMaxRecycledViews(0, 10);
        mRecyclerView.setRecycledViewPool(pool);
        mRecyclerView.getItemAnimator().setChangeDuration(0);

        GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 12, RecyclerView.VERTICAL, false);
        // mRecyclerView.setOnAllowEnableLoadMoreListener(onAllowEnableLoadMoreListener);
        layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                if (layoutRender.getAllSectionLayoutManager().size() == 0) {
                    return 0;
                }
                return 12 / layoutRender.getAllSectionLayoutManager().get(position).getItemSpan();
            }
        });
        mRecyclerView.setLayoutManager(layoutManager);


        // 设置分割线
        mRecyclerView.addItemDecoration(new Decoration());


        // 预先加载更多
        if (aheadLoadScrollListener == null) {
            aheadLoadScrollListener = new VerticalLoadScrollListener(onAheadLoadListener);
            mRecyclerView.addOnScrollListener(aheadLoadScrollListener);
        }

        aheadLoadScrollListener.setOneAheadLoadMore(false);

        mRecyclerView.openGlobalLayout();
        mRecyclerView.itemVisibilityHelper.attachToRecyclerView(mRecyclerView, R.id.player_container, true, RecyclerView.VERTICAL, false, new ItemStateChangeListener() {

            @Override
            public void onActivateItem(@NotNull View view, int position) {
                super.onActivateItem(view, position);
                //  Log.e("DDDDSSS", "onActivateItem=" + position);
                ((LayoutAdapter) layoutRender).onItemVisible(position);
            }

            @Override
            public void onDeactivateItem(@NotNull View view, int position) {
                super.onDeactivateItem(view, position);
                //  Log.e("DDDDSSS", "onDeactivateItem=" + position);
                ((LayoutAdapter) layoutRender).onItemInVisible(position);
            }

            @Override
            public void onPauseItem(@NotNull View view, int position) {
                super.onPauseItem(view, position);
                //   Log.e("DDDDSSS", "onPauseItem=" + position);
                ((LayoutAdapter) layoutRender).onItemInVisible(position);
            }

            @Override
            public void onResumeItem(@NotNull View view, int position) {
                super.onResumeItem(view, position);
                // Log.e("DDDDSSS", "onResumeItem=" + position);
                ((LayoutAdapter) layoutRender).onItemVisible(position);
            }
        });

        if (CompDataSourceBean.LOCAL_PUSH_MSG_LIST.equals(menuBean.dataSourceType)) {

            mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

                @Override
                public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                    super.onScrolled(recyclerView, dx, dy);
                    //找到RecyclerView的item中,和RecyclerView的getTop 向下相距5个像素的那个item,
                    //该方法是根据坐标获取item的View,坐标点是以RecyclerView控件作为坐标轴,并不是以屏幕左上角作为坐标原点。
                    if (compLabel01 == null) {
                        return;
                    }
                    View stickyInfoView = recyclerView.findChildViewUnder(compLabel01.getLlItemParent().getMeasuredWidth() / 2, 5);

                    if (stickyInfoView != null && stickyInfoView.getContentDescription() != null) {
                        if (stickyFrameLayout.getVisibility() == View.INVISIBLE) {
                            stickyFrameLayout.setVisibility(View.VISIBLE);
                        }

                        // 避免相同日期重复绘制
                        if(!stickyInfoView.getContentDescription().equals(compLabel01.getRecordDate())){

                            String pushTime = String.valueOf(stickyInfoView.getContentDescription());
                            // 吸顶view 记录发布日期
                            compLabel01.setRecordDate(pushTime);
                            //设置吸顶栏内容
                            compLabel01.setData(TimeUtil.calHistoryTitleData(pushTime));

                        }

                    }

                    //找到固定在顶部的View的下面一个item的View
                    View transInfoView = recyclerView.findChildViewUnder(compLabel01.getLlItemParent().getMeasuredWidth() / 2,
                            compLabel01.getLlItemParent().getMeasuredHeight() + 1);
                    if (transInfoView != null) {
                        //获取该View的tag
                        //    int transViewStatus = (int) transInfoView.getTag();
                        int itemViewType = layoutManager.getItemViewType(transInfoView);
                        int dealtY = transInfoView.getTop() - compLabel01.getLlItemParent().getMeasuredHeight();
                        if (itemViewType == R.layout.comp_label_01) {
                            if (transInfoView.getTop() > 0) {
                                //最上面的itemView没滑出屏幕,给顶部的View设置,
                                //注意setTranslationY移动的ViewGroup,而scrollTo()/scrollBy()移动的是View的内容,如文字、图片等
                                compLabel01.getLlItemParent().setTranslationY(dealtY);
                            } else {
                                //最上面的itemView滑出屏幕,顶部的复位
                                compLabel01.getLlItemParent().setTranslationY(0);
                            }
                        } else {
                            //如果是没有分组,即无吸顶的item,则设置顶部的View移动为0,保持原位置
                            compLabel01.getLlItemParent().setTranslationY(0);
                        }
                    }
                }
            });
        }
    }

    private void initCommonRecyclerView() {

        if (layoutRender != null) {
            layoutRender.releaseLayoutManagers();
        }
        layoutRender = new LayoutAdapter();

        mRecyclerView.setAdapter((BaseAdapter) layoutRender);


    }


    @Override
    protected void lazyLoadData() {
        if (menuBean != null && CompDataSourceBean.LOCAL_HIGHQUALITYCOMMENTSPAGECARD.equals(menuBean.dataSourceType)) {
            //显示loadding
            LiveDataBus.getInstance().with(EventConstants.SHOW_DEFAULT_VIEW).postValue(-2);
        } else if (menuBean != null && CompDataSourceBean.LOCAL_SEARCHRESULTTAB.equals(menuBean.dataSourceType)) {
            //显示loadding
            LiveDataBus.getInstance().with(EventConstants.SHOW_DEFAULT_VIEW).postValue(-2);
        } else {
            // 获取页面数据
            if (loadingView != null) {
                loadingView.setVisibility(View.VISIBLE);
                loadingView.showLoading();
            }
        }

        headToastFlag = false;
        if (IntentConstants.PAGETYPE_MYLEVEWORD.equals(channelId)) {
            //我的留言列表
            refreshAskMarkData();
            //  我的问政-我的留言头部
            flTop.removeAllViews();
            CompSingleMessageBoard compSingleMessageBoard = new CompSingleMessageBoard();
            View topView = LayoutInflater.from(getContext()).inflate(compSingleMessageBoard.getItemViewType(), flTop, false);
//            FrameLayout.LayoutParams compSingleMessageBoardLp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,FrameLayout.LayoutParams.WRAP_CONTENT);
//            compSingleMessageBoardLp.bottomMargin = (int)ResUtils.getDimension(R.dimen.rmrb_dp14);
            flTop.addView(topView);
            NavigationBeanNews navigationBeanNews = new NavigationBeanNews();
            navigationBeanNews.setFromPage(CompDataSourceBean.LOCAL_POLITICS_LEAVEWORD);
            compSingleMessageBoard.prepareItem(topView, 0);
            compSingleMessageBoard.bindItem(topView, 0, navigationBeanNews);
        }
        // 刷新请求数据
        refreshData();
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        refreshHeader = null;
        footView = null;
    }

    /**
     * 刷新请求数据
     */
    private void refreshData() {

        pageNum = 1;
        templatePageDataViewModel.sendPageDataRequest(getContext(), pageNum, 20, position, menuBean,textLength);
    }

    /**
     * 加载更多数据
     */
    private void loadMoreData() {
        if (menuBean != null && CompDataSourceBean.RECOMMEND_LIST_SEARCH.equals(menuBean.dataSourceType)) {
            ThreadPoolUtils.postToMainDelay(new Runnable() {
                @Override
                public void run() {
                    //搜索无结果-推荐
                    templatePageDataViewModel.sendPageDataRequest(getContext(), pageNum, 20, position, menuBean,textLength);
                }
            }, 800);
        } else {
            templatePageDataViewModel.sendPageDataRequest(getContext(), pageNum, 20, position, menuBean,textLength);
        }

    }

    @Override
    public void onLoadMore(@NonNull @NotNull RefreshLayout refreshLayout) {
        loadMoreData();
    }

    @Override
    public void onRefresh(@NonNull @NotNull RefreshLayout refreshLayout) {
        if (defaultView != null) {
            defaultView.hide();
        }
        if (menuBean != null && CompDataSourceBean.LOCAL_HIGHQUALITYCOMMENTSPAGECARD.equals(menuBean.dataSourceType)) {
            LiveDataBus.getInstance().with(EventConstants.SHOW_DEFAULT_VIEW).postValue(-1);
        }
        headToastFlag = true;
        //清理掉缓存的专题请求标识,可以重新请求
        CompentLogicUtil.cleanTopicRequestIds();
        refreshData();
    }

    @Override
    public void onResume() {
        super.onResume();
        if (GlobalAppCacheData.PAGE_NEED_REFRESH) {
            GlobalAppCacheData.PAGE_NEED_REFRESH = false;
            lazyLoadData();
        }
    }

    /**
     * 监听加载更多事件
     */
    private VerticalLoadScrollListener.OnAheadLoadListener onAheadLoadListener =
            new VerticalLoadScrollListener.OnAheadLoadListener() {

                @Override
                public void aheadLoadMoreData() {
                    // 翻页必须大于1
                    if (pageNum > 1) {
                        loadMoreData();
                    }
                }

                @Override
                public void isTop() {

                }
            };

    /**
     * 检测是否有下一页
     *
     * @return
     */
    private boolean checkHaveMoreLoad() {
        // 组件数量
        int requestDataCompSize = mPageBean.totalCompSize;
        boolean openLoadMore = requestDataCompSize > 0;
        return openLoadMore;
    }


    public void hideLoading() {
        if (refreshLayout != null) {
            if (mPageBean != null && mPageBean.needRefresh) {

                if (headToastFlag) {

                    if (refreshHeader != null) {
                        refreshHeader.setTvDesc(getString(R.string.refresh_head_msg_zui_news));
                    }
                    refreshLayout.finishRefresh(1000);
                } else {
                    refreshLayout.finishRefresh();
                }
            } else {
                refreshLayout.finishLoadMore();
                refreshLayout.finishRefresh();
            }
        }
        if (aheadLoadScrollListener != null) {
            aheadLoadScrollListener.setOneAheadLoadMore(true);
        }
    }

    /**
     * 隐藏关闭加载动效
     */
    private void hidePageLoadingView() {
        //隐藏loadding
        LiveDataBus.getInstance().with(EventConstants.SHOW_DEFAULT_VIEW).postValue(-3);
        if (loadingView != null) {
            loadingView.stopLoading();
            loadingView.setVisibility(View.GONE);
        }
    }


    /**
     * 隐藏缺省页
     */
    private void hideDefaultView() {
        if (defaultView != null) {
            defaultView.hide();
        }
        if (menuBean != null && CompDataSourceBean.LOCAL_HIGHQUALITYCOMMENTSPAGECARD.equals(menuBean.dataSourceType)) {
            LiveDataBus.getInstance().with(EventConstants.SHOW_DEFAULT_VIEW).postValue(-1);
        }
        contentFrameLayout.setVisibility(View.VISIBLE);
    }

    /**
     * 显示缺省页
     */
    private void showDefaultView(int type) {
        if (defaultView == null) {
            return;
        }
        contentFrameLayout.setVisibility(View.GONE);

        if (!NetworkUtil.isNetAvailable()) {
            type = DefaultViewConstant.TYPE_NO_NETWORK;
        }
        defaultView.setRetryBtnClickListener(new DefaultView.RetryClickListener() {
            @Override
            public void onRetryClick() {
                // 获取页面数据
                if (loadingView != null) {
                    loadingView.setVisibility(View.VISIBLE);
                    loadingView.showLoading();
                }
                hideDefaultView();
                headToastFlag = false;
                refreshData();
            }
        });
        if (DefaultViewConstant.TYPE_NO_CONTENT == type) {
            //搜索推荐页、搜索tab页、搜索结果页
            if (menuBean != null && (CompDataSourceBean.RECOMMEND_LIST_SEARCH.equals(menuBean.dataSourceType)
                    || CompDataSourceBean.LOCAL_SEARCHRESULTTAB.equals(menuBean.dataSourceType)
                    || CompDataSourceBean.LOCAL_SEARCHRESULTPAGE.equals(menuBean.dataSourceType)
            )) {
                //搜索结果缺省页样式
                defaultView.showWithWeight(DefaultViewConstant.TYPE_NO_CONTENT_FOUND, 154, 392);
            } else if (menuBean != null && CompDataSourceBean.LOCAL_PUSH_MSG_LIST.equals(menuBean.dataSourceType)) {
                defaultView.show(DefaultViewConstant.TYPE_NO_RECORDS_MESSAGE);
            } else if (menuBean != null && CompDataSourceBean.LOCAL_MY_SUBSCRIBE.equals(menuBean.dataSourceType)) {
                //预约列表,暂无预约
                defaultView.show(DefaultViewConstant.TYPE_NO_RESERVATION);
            } else if (menuBean != null && CompDataSourceBean.LOCAL_HIGHQUALITYCOMMENTSPAGECARD.equals(menuBean.dataSourceType)) {
                //不展示默认图
                defaultView.hide();
                LiveDataBus.getInstance().with(EventConstants.SHOW_DEFAULT_VIEW).postValue(type);
            } else if (IntentConstants.PAGETYPE_MYLEVEWORD.equals(channelId) ||
                    IntentConstants.PAGETYPECARELEVEWORD.equals(channelId)) {
                //我的留言为空,暂无留言
                defaultView.show(DefaultViewConstant.TYPE_NO_CONTENT_FOR_MY_LEAVE_WORD);
            } else {
                defaultView.show(type);
            }
        } else {
            defaultView.show(type);
        }
    }


    /**
     * 请求留言板业务数据
     *
     * @param moreSelectList
     * @param fid
     */
    public void requestMessageBoard(List<MoreItemBean> moreSelectList, String fid) {

        if (refreshLayout != null && menuBean != null) {
            menuBean.fid = fid;
            menuBean.moreSelectList = moreSelectList;
            // 滚动到顶部
            if (mRecyclerView.canScrollVertically(-1)) {
                //mRecyclerView.smoothScrollToPosition(0);
                mRecyclerView.scrollToPosition(0);
            }
            boolean isAutoRefresh = refreshLayout.autoRefresh();
            if (!isAutoRefresh) {
                refreshData();
            }
        }

    }


    /**
     * 自动刷
     */
    public void clickTabAutoRefresh() {

        if (mRecyclerView != null) {
            // 滚动到顶部
            if (mRecyclerView.canScrollVertically(-1)) {
                //mRecyclerView.smoothScrollToPosition(0);
                mRecyclerView.scrollToPosition(0);
            }
        }

        if (refreshLayout != null) {
            if (!refreshLayout.isRefreshing()) {
                refreshLayout.autoRefresh();
            }
        }

    }

    /**
     * 刷新个人中心问政小红点
     */
    private void refreshAskMarkData() {
        Logger.t(TAG).d("refreshAskMarkData======>0");
        CommonNetUtils.getInstance().getMyAskMarkData(new BaseObserver<MyAskMarkBean>() {
            @Override
            protected void dealSpecialCode(int code, String message) {

            }

            @Override
            protected void onSuccess(MyAskMarkBean myAskMarkBean) {

            }

            @Override
            protected void onSuccess(MyAskMarkBean myAskMarkBean, MetaBean metaBean, String msg, int code) {
                if (metaBean != null && !StringUtils.isEmpty(metaBean.getMd5())) {
                    SpUtils.saveAskMarkMD5(metaBean.getMd5());
                    Logger.t(TAG).d("refreshAskMarkData======>1");
                }
            }
        });
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
//        if (mPageBean != null) {
//            TrackContentBean bean = new TrackContentBean();
//            bean.pageBeanToTrackContentBean(mPageBean);
//            bean.setExposure(duration);
//            CommonTrack.getInstance().channelExposureTrack(bean);
//        }
        if (menuBean != null && CompDataSourceBean.LOCAL_HIGHQUALITYCOMMENTSPAGECARD.equals(menuBean.dataSourceType)) {
            LiveDataBus.getInstance()
                    .with(EventConstants.COMMENT_OPERATION_EVENT, CommentOperationBean.class).removeObservers(this);
        }

        LiveDataBus.getInstance()
                .with(EventConstants.FRESH_FOLLOW_CREATOR_EVENT, EventMessage.class).removeObservers(this);

        LiveDataBus.getInstance()
                .with(EventConstants.FRESH_ZAN_CREATOR_EVENT, EventMessage.class).removeObservers(this);
        LiveDataBus.getInstance()
                .with(EventConstants.FRESH_APPONINTMENT_STATUS_EVENT, EventMessage.class).removeObservers(this);
        //适老化-设置文字大小
        LiveDataBus.getInstance()
                .with(EventConstants.FONT_SIZE_SET_SUCCESS, Boolean.class).removeObservers(this);

        refreshHeader = null;
        footView = null;
    }

    /**
     * 判断当前点击哪一个
     */
    private void judeClickType(ContentBean selectCompBean, int showType, int position) {
        //回复
        if (showType == CommentClickShowType.reply) {
            if (!PDUtils.isLogin()) {
                ProcessUtils.toOneKeyLoginActivity();
                return;
            }
            showInputDialog(selectCompBean, position);
        }
        //删除评论
        else if (showType == CommentClickShowType.delete) {
            new AlertDialog(getActivity()).builder()
                    .setTitle(ResUtils.getString(com.people.comment.R.string.del_comment_tip))
                    .setPositiveButton(ResUtils.getString(com.people.comment.R.string.res_cancel), v -> {

                    })
                    .setNegativeButton(ResUtils.getString(com.people.comment.R.string.yes_btn), v -> {
                        delComment(selectCompBean, position);
                    })
                    .show();
        }
        //复制信息
        else if (showType == CommentClickShowType.copy) {
            boolean isCopySuccess = false;
            if (!StringUtils.isEmpty(selectCompBean.getCommentInfo().getRealCommentContent())) {
                isCopySuccess = true;
                StringUtils.copy(selectCompBean.getCommentInfo().getRealCommentContent());
            }
            //是否复制成功
            if (isCopySuccess) {
                ToastNightUtil.showShort(ResUtils.getString(com.people.comment.R.string.comment_copy_success));
            } else {
                ToastNightUtil.showShort(ResUtils.getString(com.people.comment.R.string.comment_copy_fail));
            }
        }
        //举报
        else if (showType == CommentClickShowType.report) {
            if (!PDUtils.isLogin()) {
                ProcessUtils.toOneKeyLoginActivity();
                return;
            }
            TransparentBean transparentBean = new TransparentBean();
            transparentBean.setContentId(selectCompBean.getObjectId());
            transparentBean.setContentType(selectCompBean.getObjectType());
            transparentBean.setTargetRelId(selectCompBean.getRelId());
            transparentBean.setTargetRelType(selectCompBean.getRelType() + "");
            transparentBean.setCommentId(String.valueOf(selectCompBean.getCommentInfo().getCommentId()));
            ProcessUtils.goReport(GsonUtils.objectToJson(transparentBean), "0");

        }
    }

    /**
     * 发布评论信息
     */
    public void showInputDialog(ContentBean selectCompBean, int position) {
//        this.submitPos = position;
        // 判断是否登录
        if (TextUtils.isEmpty(SpUtils.getUserToken())) {
            ProcessUtils.toOneKeyLoginActivity();
            return;
        }
        //初始化弹出框
        if (commitDialog == null) {
            commitDialog = new CommentCommitDialog(getActivity());
            // 2023/11/3 设置评论发布点击埋点数据
//            TrackContentBean trackContentBean = CommonTrack.getInstance().getTrackContentBean(selectCompBean.getFromPage(), selectCompBean.getPageId(), selectCompBean.getObjectId(), selectCompBean.getObjectType(), selectCompBean.getNewsTitle(), "");
//            commitDialog.setTrackContentBean(trackContentBean);
            commitDialog.setCommitDialogListener(new CommitDialogListener() {
                @Override
                public void publish(String text,String gifUrl) {
                    commitDialog.dismiss();
                    String comment = text.trim();
                    if (StringUtils.isEmpty(comment) &&  StringUtils.isEmpty(gifUrl)) {
                        ToastNightUtil.showShort(ResUtils.getString(R.string.res_comment_no_input_tips));
                        return;
                    }
                    commitDialog.clearEditText();

                    //发布评论,3是带定制表情,或定制表情+文字,2是普通表情,或普通表情+文字
                    if(StringUtils.isEmpty(gifUrl)) {
                        submitComment(selectCompBean, text, "2", "");
                    }else{
                        submitComment(selectCompBean, text, "3", gifUrl);
                    }
                }

                @Override
                public void getUnloadImg(ArrayList<String> images) {
                }
            });
        }
        //设置弹出框 hint
        if (null != commitDialog) {
            String replyUserName = "";
            if (selectCompBean != null) {
                if (selectCompBean.getRmhInfo() != null) {
                    replyUserName = selectCompBean.getRmhInfo().getRmhName();
                }
            }
            if (position == -1) {
                commitDialog.showDefaultHint(bestNoticer);
            } else {
                if (StringUtils.isNotBlank(replyUserName)) {
                    commitDialog.showUserName(replyUserName);
                } else {
                    commitDialog.showDefaultHint(bestNoticer);
                }
            }
            commitDialog.showWithSoftBoard();
        }

    }

    /**
     * 删除评论
     */
    private void delComment(ContentBean compBean, int position) {
        if (null == commentViewModel) {
            initCommentViewmModel();
        }
        commentViewModel.delComment(compBean.getCommentInfo().getCommentId(),
                compBean.getObjectId(), compBean.getCommentInfo().uuid, position);
    }

    private void initCommentViewmModel() {
        commentViewModel = getViewModel(CommentViewModel.class);
        commentViewModel.observeCommentListener(getActivity(), new ICommentDataNewListener() {
            @Override
            public void onGetCommentListSuccess(CommentListBean commentList) {

            }

            @Override
            public void onGetCommentListFail(int code, String msg) {

            }

            @Override
            public void onGetSecondCommentListSuccess(int position, CommentListBean childCommentList) {

            }

            @Override
            public void onGetSecondCommentListFail() {

            }

            @Override
            public void onSubmitPushCommentSuccess(CommentItem pushListBean, int position, String msg) {

            }

            @Override
            public void onSubmitPushCommentFail(int code, String msg) {

            }

            @Override
            public void onGetMastersAuthenticationListSuccess(List<PersonalInfoBean> masterInfoList, List<CommentItem> originalListData, int freshStartIndex, int listLevel) {

            }

            @Override
            public void onGetMastersAuthenticationListFailure(String errorInfo, int listLevel) {

            }

            @Override
            public void onGetAllDataSuccess(List<CommentStatusBean> statusList, List<PersonalInfoBean> masterInfoList, List<CommentItem> originalListData, int freshStartIndex, int listLevel) {

            }

            @Override
            public void onGetCommentStatusListFailure(String errorInfo, int listLevel) {

            }

            @Override
            public void delCommentSuccess(int freshPosition) {
                headToastFlag = false;
                mPage.getGroups().get(0).getSections().remove(freshPosition);
                layoutRender.itemRemoved(freshPosition);
            }

            @Override
            public void delCommentFail(String e) {
                ToastNightUtil.showShort(e);
            }

            @Override
            public void onGetSingleMastersAuthenticationDataSuccess(PersonalInfoBean mMasterInfoBean, int freshPosition) {

            }

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

            }


        });
    }

    /**
     * 发布评论
     *
     * @param text        内容
     * @param commentType
     * @param commentPics 图片地址
     */
    private void submitComment(ContentBean selectCompBean, String text, String commentType, String commentPics) {
        if (commentViewModel == null) {
            initCommentViewmModel();
        }
        PublishCommentParameterBean parameterBean = new PublishCommentParameterBean();
        parameterBean.setPosition(-1);
        parameterBean.setCommentContent(text);
        parameterBean.setCommentType(commentType);
        parameterBean.setCommentPics(commentPics);
        parameterBean.setTargetId(selectCompBean.getObjectId());
        parameterBean.setTargetType(selectCompBean.getObjectType());
        parameterBean.setTargetRelId(selectCompBean.getRelId());
        parameterBean.setTargetRelType(selectCompBean.getRelType() + "");
        parameterBean.setParentId("-1");
        parameterBean.setRootCommentId("-1");
        parameterBean.setTargetTitle(selectCompBean.getNewsTitle());
        parameterBean.setKeyArticle(selectCompBean.getKeyArticle());
        parameterBean.setTargetRelObjectId(selectCompBean.getContentRelId());
        parameterBean.setLeaderArticle(selectCompBean.getLeaderArticle());
        commentViewModel.submitComment(parameterBean);
    }


    @Override
    public void onConfigurationChanged(@NonNull Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        if (layoutRender != null){
            layoutRender.notifyDataSetChanged();
        }
    }
}