package com.gh.gamecenter.message.view.concern;

import static com.gh.gamecenter.common.constant.Constants.LOGIN_TAG;

import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.MenuItem;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;

import com.therouter.TheRouter;
import com.gh.gamecenter.common.base.activity.ToolBarActivity;
import com.gh.gamecenter.common.base.fragment.ToolbarFragment;
import com.gh.gamecenter.common.callback.OnRequestCallBackListener;
import com.gh.gamecenter.common.constant.EntranceConsts;
import com.gh.gamecenter.common.constant.RouteConsts;
import com.gh.gamecenter.common.eventbus.EBNetworkState;
import com.gh.gamecenter.common.eventbus.EBReuse;
import com.gh.gamecenter.common.retrofit.Response;
import com.gh.gamecenter.common.utils.ExtensionsKt;
import com.gh.gamecenter.common.view.CustomDividerItemDecoration;
import com.gh.gamecenter.core.provider.IAppProvider;
import com.gh.gamecenter.core.provider.IConcernProvider;
import com.gh.gamecenter.core.provider.IConcernShareNewsProvider;
import com.gh.gamecenter.core.provider.IGameTrendsHelperProvider;
import com.gh.gamecenter.core.provider.IWebProvider;
import com.gh.gamecenter.core.utils.StringUtils;
import com.gh.gamecenter.feature.adapter.MyConcernRecommendAdapter;
import com.gh.gamecenter.feature.entity.ConcernEntity;
import com.gh.gamecenter.feature.entity.GameEntity;
import com.gh.gamecenter.feature.entity.LibaoEntity;
import com.gh.gamecenter.feature.entity.LibaoStatusEntity;
import com.gh.gamecenter.feature.entity.MeEntity;
import com.gh.gamecenter.feature.entity.UserDataLibaoEntity;
import com.gh.gamecenter.feature.eventbus.EBAddComment;
import com.gh.gamecenter.feature.eventbus.EBConcernChanged;
import com.gh.gamecenter.feature.eventbus.EBDeleteComment;
import com.gh.gamecenter.feature.provider.IDataCollectionProvider;
import com.gh.gamecenter.feature.provider.IGameDetailProvider;
import com.gh.gamecenter.feature.provider.IMessageDetailProvider;
import com.gh.gamecenter.feature.provider.IMessageUnreadRepositoryProvider;
import com.gh.gamecenter.feature.provider.IRegionSettingHelperProvider;
import com.gh.gamecenter.feature.utils.ApkActiveUtils;
import com.gh.gamecenter.feature.view.Concern_LinearLayout;
import com.gh.gamecenter.login.user.UserManager;
import com.gh.gamecenter.message.R;
import com.gh.gamecenter.message.databinding.FragmentInfoConcernBinding;
import com.gh.gamecenter.message.retrofit.RetrofitManager;
import com.gh.gamecenter.message.utils.NewFlatLogUtils;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

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

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by khy on 2016/8/15.
 * 游戏动态页面
 */
public class ConcernFragment extends ToolbarFragment implements SwipeRefreshLayout.OnRefreshListener, OnConcernContentEventListener {

    private FragmentInfoConcernBinding mBinding;

    public final static int NEWS_MESSAGE_LIBAO_REQUEST = 3; // 刷新礼包状态
    public final static int NEWS_MESSAGE_ARTICLE_REQUEST = 4; // 刷新文章评论数

    private ConcernAdapter mAdapter;
    private MyConcernRecommendAdapter mConcernRecommendAdapter;

    private LinearLayoutManager layoutManager;
    private RecyclerView.ItemDecoration mItemDecoration;
    private boolean mIsLogEnter = false;

    Runnable mRunnable = new Runnable() {
        @Override
        public void run() {
            mAdapter = new ConcernAdapter(getContext(), ConcernFragment.this, ConcernFragment.this, ConcernFragment.this);
            mBinding.news1RvList.setAdapter(mAdapter);
        }
    };

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

    @Override
    protected View getInflatedLayout() {
        mBinding = FragmentInfoConcernBinding.inflate(getLayoutInflater());
        return mBinding.getRoot();
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        if ("ConcernInfoActivity".equals(requireActivity().getClass().getSimpleName())) {
            setNavigationTitle(R.string.discover_game_trends);
        }
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mBinding.news1SrlRefresh.setColorSchemeResources(com.gh.gamecenter.common.R.color.primary_theme);
        mBinding.news1SrlRefresh.setOnRefreshListener(this);

        mBinding.news1RvList.setHasFixedSize(true);
        layoutManager = new LinearLayoutManager(getActivity());
        mBinding.news1RvList.setLayoutManager(layoutManager);

        mBinding.news1RvList.addItemDecoration(getItemDecoration());
        mAdapter = new ConcernAdapter(getContext(), this, this, this);
        mBinding.news1RvList.setAdapter(mAdapter);
        mBinding.news1RvList.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                if (newState == RecyclerView.SCROLL_STATE_IDLE
                        && layoutManager.findLastVisibleItemPosition() + 1 == mAdapter.getItemCount()) {
                    if (!mAdapter.isOver() && !mAdapter.isLoading() && !mAdapter.isNetworkError()) {
                        mAdapter.addList();
                    }
                }
            }
        });

        mBinding.reuseNoneData.reuseResetLoadTv.setOnClickListener(v -> {
            if (mBinding.reuseNoneData.reuseNoneDataTv.getText().equals(getString(com.gh.gamecenter.feature.R.string.login_hint))) {
                ExtensionsKt.ifLogin(requireContext(), "游戏动态-请先登录", null);
            }
        });

        mBinding.reuseNoConnection.getRoot().setOnClickListener(v -> refresh());

        mBinding.concernRlTitle.setOnClickListener(v -> {
            if (mBinding.concernRvRecommend.getVisibility() == View.VISIBLE) {
                ((Concern_LinearLayout) mCachedView).hideRecyclerView();
            } else {
                ((Concern_LinearLayout) mCachedView).showRecyclerView();
            }
        });
    }

    @Override
    public void onResume() {
        super.onResume();

        ((ToolBarActivity) requireActivity()).clearMenu();
        initMenu(R.menu.menu_concern);

        IMessageUnreadRepositoryProvider messageUnreadRepositoryProvider = TheRouter.get(IMessageUnreadRepositoryProvider.class);
        if (messageUnreadRepositoryProvider != null && messageUnreadRepositoryProvider.getZixunConcernLiveData() != null && !mIsLogEnter) {
            boolean hasUnread = Boolean.TRUE.equals(messageUnreadRepositoryProvider.getZixunConcernLiveData().getValue());
            NewFlatLogUtils.logGameActivityEnter(mEntrance, hasUnread ? 1 : 0);
            mIsLogEnter = true;
        }
    }

    @Override
    public void onPause() {
        super.onPause();

        // 更新已读时间
        IGameTrendsHelperProvider gameTrendsHelperProvider = TheRouter.get(IGameTrendsHelperProvider.class);
        if (gameTrendsHelperProvider != null) {
            gameTrendsHelperProvider.updateReadPostTime();
        }
    }

    public RecyclerView.ItemDecoration getItemDecoration() {
        Drawable insetDivider = ContextCompat.getDrawable(requireContext(), com.gh.gamecenter.common.R.drawable.divider_item_line_space_16);
        CustomDividerItemDecoration itemDecoration = new CustomDividerItemDecoration(requireContext(), false, false, true, false);
        itemDecoration.setDrawable(insetDivider);
        mItemDecoration = itemDecoration;
        return mItemDecoration;
    }

    @Override
    public void onMenuItemClick(MenuItem menuItem) {
        if (menuItem.getItemId() == R.id.menu_concern) {
            IConcernProvider concernProvider = TheRouter.get(IConcernProvider.class);
            if (concernProvider != null) {
                startActivity(concernProvider.getIntent(requireContext(), "(游戏动态：工具栏)"));
            }
        }
    }

    @Override
    public void loadDone() { // 数据加载成功回调
        mBinding.news1SrlRefresh.setEnabled(true);
        mBinding.news1SrlRefresh.setRefreshing(false);
        mBinding.reuseNoneData.reuseNoneData.setVisibility(View.GONE);
        mBinding.concernRvRecommend.setVisibility(View.GONE);
        mBinding.concernRlTitle.setVisibility(View.GONE);
        mBinding.reuseLoading.getRoot().setVisibility(View.GONE);
        mBinding.news1RvList.setVisibility(View.VISIBLE);
    }

    @Override
    public void loadError() { // 数据加载失败回调
        mBinding.news1SrlRefresh.setRefreshing(false);
        mBinding.reuseLoading.getRoot().setVisibility(View.GONE);
        mBinding.news1RvList.setVisibility(View.GONE);
        mBinding.reuseNoConnection.getRoot().setVisibility(View.VISIBLE);
    }

    @Override
    public void loadNotFound() {
        mBinding.news1SrlRefresh.setRefreshing(false);
        mBinding.reuseLoading.getRoot().setVisibility(View.GONE);
        mBinding.news1RvList.setVisibility(View.GONE);
        mBinding.reuseDataException.getRoot().setVisibility(View.VISIBLE);
    }

    @Override
    public void loadEmpty() { // 数据为空回调
        mBinding.news1SrlRefresh.setRefreshing(false);
        mBinding.reuseLoading.getRoot().setVisibility(View.GONE);
        mBinding.news1RvList.setVisibility(View.GONE);
        mBinding.reuseNoneData.reuseNoneData.setVisibility(View.VISIBLE);
        mBinding.news1SrlRefresh.setEnabled(false);

        showRecommendGames();

        if (TextUtils.isEmpty(UserManager.getInstance().getToken())) {
            mBinding.reuseNoneData.reuseNoneDataIv.setVisibility(View.GONE);
            mBinding.reuseNoneData.reuseResetLoadTv.setVisibility(View.GONE);
            mBinding.reuseNoneData.reuseNoneDataDescTv.setVisibility(View.GONE);
            mBinding.reuseNoneData.reuseNoneDataTv.setText(getString(com.gh.gamecenter.feature.R.string.login_hint));
            mBinding.reuseNoneData.reuseNoneDataTv.setTextColor(getResources().getColor(com.gh.gamecenter.common.R.color.text_theme));
        } else {
            mBinding.reuseNoneData.reuseNoneDataIv.setVisibility(View.VISIBLE);
            mBinding.reuseNoneData.reuseResetLoadTv.setVisibility(View.GONE);
            mBinding.reuseNoneData.reuseNoneDataDescTv.setVisibility(View.VISIBLE);
            mBinding.reuseNoneData.reuseNoneDataDescTv.setText(getString(R.string.my_game_dynamics_no_data_desc));
            mBinding.reuseNoneData.reuseNoneDataTv.setText(getString(R.string.my_game_dynamics_no_data));
            mBinding.reuseNoneData.reuseNoneDataTv.setTextColor(getResources().getColor(com.gh.gamecenter.common.R.color.text_primary));
        }

        ((ToolBarActivity) requireActivity()).clearMenu();
    }

    private void showRecommendGames() {
        IRegionSettingHelperProvider regionSettingHelperProvider = TheRouter.get(IRegionSettingHelperProvider.class);

        // 先请求用户已关注的游戏数据
        RetrofitManager.Companion.getInstance().getApi()
                .getConcern(UserManager.getInstance().getUserId())
                .map(ApkActiveUtils.filterMapperList)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Response<List<GameEntity>>() {
                    @Override
                    public void onResponse(List<GameEntity> response) {
                        List<GameEntity> filterGameList = regionSettingHelperProvider.filterGame(response);
                        initRecommendAdapter(filterGameList);
                    }

                    @Override
                    public void onError(Throwable e) {
                        initRecommendAdapter(new ArrayList<>());
                    }
                });
    }

    private void initRecommendAdapter(List<GameEntity> response) {
        if (!isAdded()) return;

        mConcernRecommendAdapter = new MyConcernRecommendAdapter(getContext(),
                new OnRequestCallBackListener() {
                    @Override
                    public void loadDone() {
                        mBinding.concernRlTitle.setVisibility(View.VISIBLE);
                        mBinding.concernRvRecommend.setVisibility(View.VISIBLE);

                        int size = mConcernRecommendAdapter.getItemCount();
                        mBinding.concernRvRecommend.setAdapter(mConcernRecommendAdapter);
                        mBinding.concernRvRecommend.setLayoutManager(new GridLayoutManager(getContext(), Math.min(size, 4)));
                        mConcernRecommendAdapter.notifyDataSetChanged();
                    }

                    @Override
                    public void loadDone(Object obj) {
                        mBinding.concernRlTitle.setVisibility(View.VISIBLE);
                        mBinding.concernRvRecommend.setVisibility(View.VISIBLE);

                        int size = mConcernRecommendAdapter.getItemCount();
                        mBinding.concernRvRecommend.setAdapter(mConcernRecommendAdapter);
                        mBinding.concernRvRecommend.setLayoutManager(new GridLayoutManager(getContext(), Math.min(size, 4)));
                        mConcernRecommendAdapter.notifyDataSetChanged();
                    }

                    @Override
                    public void loadError() {

                    }

                    @Override
                    public void loadEmpty() {
                        onRefresh();
                    }

                    @Override
                    public void loadNotFound() {
                        // do nothing
                    }
                },
                response,
                mEntrance);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (mAdapter.getSkipPosition() == -1) {
            return;
        }

        switch (requestCode) {
            case NEWS_MESSAGE_ARTICLE_REQUEST:
                // 更新对应位置
                mAdapter.notifyItemChanged(mAdapter.getSkipPosition());
                mAdapter.setSkipPosition(-1);
                break;
            case NEWS_MESSAGE_LIBAO_REQUEST:
                if (resultCode != Activity.RESULT_OK) break;
                UserDataLibaoEntity resultUserLibaoData = data.getParcelableExtra(UserDataLibaoEntity.TAG);
                ConcernEntity skipEntity = mAdapter.getSkipEntity();
                if (skipEntity != null) { // 插入礼包详情返回的礼包数据
                    MeEntity userData = skipEntity.getMe();
                    if (userData == null) {
                        userData = new MeEntity();
                        ArrayList<UserDataLibaoEntity> libaoList = new ArrayList<>();
                        libaoList.add(resultUserLibaoData);
                        userData.setUserDataLibaoList(libaoList);
                    } else {
                        if (userData.getUserDataLibaoList() == null) {
                            ArrayList<UserDataLibaoEntity> libaoList = new ArrayList<>();
                            libaoList.add(resultUserLibaoData);
                            userData.setUserDataLibaoList(libaoList);
                        } else {
                            userData.getUserDataLibaoList().add(resultUserLibaoData);
                        }
                    }
                    skipEntity.setMe(userData); // 要重新设回去 不然没效果 0.0
                }
                mAdapter.notifyItemChanged(mAdapter.getSkipPosition());
                mAdapter.setSkipPosition(-1);
                break;
        }
    }

    // 连接上网络事件
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventMainThread(EBNetworkState busNetworkState) {
        if (busNetworkState.isNetworkConnected()) {
            if (mBinding.reuseNoConnection.getRoot().getVisibility() == View.VISIBLE) {
                refresh();
            } else if (mAdapter.isNetworkError()) {
                mAdapter.setNetworkError(false);
                mAdapter.notifyItemChanged(mAdapter.getItemCount() - 1);
                mAdapter.addList();
            }
        }
    }

    private void refresh() {
        mBinding.news1SrlRefresh.setRefreshing(true);
        mBinding.news1RvList.setVisibility(View.VISIBLE);
        mBinding.reuseLoading.getRoot().setVisibility(View.VISIBLE);
        mBinding.reuseNoConnection.getRoot().setVisibility(View.GONE);
        postRunnable(mRunnable);
    }

    // 关注事件
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventMainThread(EBConcernChanged changed) {
        if (!isResumed()) {
            refresh();
        } else {
            if (mAdapter.getItemCount() == 0) {
                mBinding.reuseNoneData.reuseNoneDataIv.setVisibility(View.GONE);
                mBinding.reuseNoneData.reuseNoneDataTv.setVisibility(View.GONE);
                mBinding.reuseNoneData.reuseNoneDataDescTv.setVisibility(View.GONE);
                mBinding.reuseNoneData.reuseResetLoadTv.setVisibility(View.VISIBLE);
                mBinding.reuseNoneData.reuseResetLoadTv.setText("点击刷新");
                mBinding.reuseNoneData.reuseResetLoadTv.setTextColor(getResources().getColor(com.gh.gamecenter.common.R.color.ui_surface));
                mBinding.reuseNoneData.reuseResetLoadTv.setOnClickListener(v -> {
                    refresh();
                    mBinding.reuseNoneData.reuseResetLoadTv.setOnClickListener(null);
                });
            }
        }
        mConcernRecommendAdapter.concernGame(changed.getGameId());
    }

    // 登录事件
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventMainThread(EBReuse reuse) {
        if (reuse.getType().equals(LOGIN_TAG)) { // 登入
            mBinding.reuseNoneData.reuseNoneDataIv.setVisibility(View.GONE);
            mBinding.news1SrlRefresh.setEnabled(true);
            mBinding.news1SrlRefresh.setRefreshing(true);
            mBinding.news1RvList.setVisibility(View.VISIBLE);
            mBinding.reuseLoading.getRoot().setVisibility(View.VISIBLE);
            postRunnable(mRunnable);
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onAddComment(EBAddComment event) {
        mAdapter.getNewsCommentnum(mAdapter.getConcernList());
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onDeleteComment(EBDeleteComment event) {
        mAdapter.getNewsCommentnum(mAdapter.getConcernList());
    }

    @Override
    public void onRefresh() {
        postDelayedRunnable(mRunnable, 1000);
    }

    @Override
    public void onListClick(View view, int position, Object data) {
        super.onListClick(view, position, data);
        ConcernEntity concernEntity = (ConcernEntity) data;

        int id = view.getId();// 默认是 viewholder item
        if (id == com.gh.gamecenter.feature.R.id.news_digest_comment) {
            comment(position, concernEntity);
        } else if (id == com.gh.gamecenter.feature.R.id.news_digest_share) {
            share(position, concernEntity);
        } else {
        }
    }

    @Override
    public void onArticleClick(int position, @NonNull ConcernEntity concernEntity) {
        navigateToArticleDetailPage(position, concernEntity);
    }

    @Override
    public void onGiftPackageClick(int position, @NonNull ConcernEntity concernEntity) {
        NewFlatLogUtils.logGameActivityClick(mEntrance, concernEntity.getId(), concernEntity.getType(), position + 1, "查看详情", concernEntity.getGameId(), concernEntity.getGameName());

        mAdapter.setSkipPosition(position);
        LibaoEntity entity = null;
        for (LibaoStatusEntity libaoStatusEntity : mAdapter.getLibaoStatusList()) {
            if (concernEntity.getId().equals(libaoStatusEntity.getId())) {
                entity = LibaoEntity.Companion.createLibaoEntity(concernEntity, libaoStatusEntity);
            }
        }
        IAppProvider appProvider = TheRouter.get(IAppProvider.class);
        if (appProvider != null && entity != null) {
            appProvider.put(LibaoEntity.TAG, entity);
        }
        TheRouter.build(RouteConsts.activity.libaoDetailActivity)
                .withString(EntranceConsts.KEY_ENTRANCE, buildEntrance(position))
                .withBoolean(EntranceConsts.KEY_IS_CLICK_RECEIVE_BTN, false)
                .navigation(requireActivity(), NEWS_MESSAGE_LIBAO_REQUEST);
    }

    @Override
    public void onGameCLick(int position, @Nullable GameEntity gameEntity) {
        if (gameEntity == null) {
            return;
        }
        IGameDetailProvider gameDetailProvider = TheRouter.get(IGameDetailProvider.class);
        if (gameDetailProvider != null) {
            gameDetailProvider.startGameDetailActivity(requireContext(), gameEntity.getId(), buildEntrance(position), null);
        }
    }

    @Override
    public void onComment(int position, @NonNull ConcernEntity concernEntity) {
        comment(position, concernEntity);
    }

    @Override
    public void onShare(int position, ConcernEntity concernEntity) {
        share(position, concernEntity);
    }

    private void navigateToArticleDetailPage(int position, ConcernEntity concernEntity) {
        IDataCollectionProvider dataCollectionUtils = TheRouter.get(IDataCollectionProvider.class);
        IWebProvider webProvider = TheRouter.get(IWebProvider.class);
        if (dataCollectionUtils != null) {
            dataCollectionUtils.uploadClick(requireContext(), "列表", "资讯-关注", concernEntity.getTitle());
        }

        //统计阅读量
        mAdapter.statNewsViews(concernEntity, position);
        if (concernEntity.getLink() != null) {
            Intent intent = webProvider.getIntentByNews(getContext(), concernEntity.getLink(), concernEntity.getGameName(), concernEntity.getId(), buildEntrance(position));
            startActivityForResult(intent, NEWS_MESSAGE_ARTICLE_REQUEST);
        } else {
            TheRouter.build(RouteConsts.activity.newsDetailActivity)
                    .withString(EntranceConsts.KEY_NEWSID, concernEntity.getId())
                    .withString(EntranceConsts.KEY_ENTRANCE, buildEntrance(position))
                    .navigation(requireActivity(), NEWS_MESSAGE_ARTICLE_REQUEST);
        }
    }

    private void comment(int position, ConcernEntity concernEntity) {
        NewFlatLogUtils.logGameActivityClick(mEntrance, concernEntity.getId(), concernEntity.getType(), position + 1, "查看评论", concernEntity.getGameId(), concernEntity.getGameName());
        IMessageDetailProvider messageDetailProvider = TheRouter.get(IMessageDetailProvider.class);
        mAdapter.setSkipPosition(position);
        if (messageDetailProvider != null) {
            Intent intent = messageDetailProvider.getIntentByEntity(requireContext(), concernEntity, buildEntrance(position));
            startActivityForResult(intent, NEWS_MESSAGE_ARTICLE_REQUEST);
        }
    }

    private void share(int position, ConcernEntity concernEntity) {
        NewFlatLogUtils.logGameActivityClick(mEntrance, concernEntity.getId(), concernEntity.getType(), position + 1, "分享", concernEntity.getGameId(), concernEntity.getGameName());

        IConcernShareNewsProvider shareNewsProvider = TheRouter.get(IConcernShareNewsProvider.class);
        if (shareNewsProvider != null) {
            shareNewsProvider.share((AppCompatActivity) requireActivity(), concernEntity.getShortId(), concernEntity.getId(), concernEntity.getGameIcon(), concernEntity.getTitle());
        }
    }

    private String buildEntrance(int position) {
        return StringUtils.buildString("(资讯:关注[" + position + "])");
    }


    @Override
    protected void onDarkModeChanged() {
        super.onDarkModeChanged();
        mAdapter.notifyItemRangeChanged(0, mAdapter.getItemCount());
        if (mConcernRecommendAdapter != null)
            mConcernRecommendAdapter.notifyItemRangeChanged(0, mConcernRecommendAdapter.getItemCount());
        mBinding.news1RvList.removeItemDecoration(mItemDecoration);
        mBinding.news1RvList.addItemDecoration(getItemDecoration());
        mBinding.getRoot().setBackgroundColor(ContextCompat.getColor(requireContext(), com.gh.gamecenter.common.R.color.ui_surface));
        mBinding.divider.setBackgroundColor(ContextCompat.getColor(requireContext(), com.gh.gamecenter.common.R.color.ui_divider));
    }
}
