admin
2021-03-09 6aed6290ad05fe2aa125bb8e804e2e8c2f13a613
library-BaiduCPU/src/main/java/com/yeshi/ec/library_baiducpu/fragment/BaiDuCPUContentFragment.java
@@ -56,13 +56,23 @@
    private int viewType;
    private boolean showAd;
    public static BaiDuCPUContentFragment newInstance(BaiDuCPUType spinnerItem, int viewType) {
    private BaiduCPUContentAdapter.IBaiDuCPUItemClickListener baiDuCPUItemClickListener;
    public void setBaiDuCPUItemClickListener(BaiduCPUContentAdapter.IBaiDuCPUItemClickListener baiDuCPUItemClickListener) {
        this.baiDuCPUItemClickListener = baiDuCPUItemClickListener;
    }
    public static BaiDuCPUContentFragment newInstance(BaiDuCPUType spinnerItem, int viewType, boolean showAd, BaiduCPUContentAdapter.IBaiDuCPUItemClickListener baiDuCPUItemClickListener) {
        BaiDuCPUContentFragment fragment = new BaiDuCPUContentFragment();
        Bundle bundle = new Bundle();
        bundle.putSerializable("item", spinnerItem);
        bundle.putInt("viewType", viewType);
        bundle.putBoolean("showAd", showAd);
        fragment.setArguments(bundle);
        fragment.setBaiDuCPUItemClickListener(baiDuCPUItemClickListener);
        return fragment;
    }
@@ -166,6 +176,7 @@
        if (item == null)
            return;
        viewType = bundle.getInt("viewType");
        showAd = bundle.getBoolean("showAd", true);
        bundle.clear();
        mChannelId = item.getId();
@@ -175,7 +186,7 @@
         */
        mCpuManager.setLpFontSize(CpuLpFontSize.SMALL);
        mCpuManager.setLpDarkMode(true);
        adapter = new BaiduCPUContentAdapter(getContext(), viewType, nrAdList);
        adapter = new BaiduCPUContentAdapter(getContext(), viewType, nrAdList, baiDuCPUItemClickListener);
        rv_news.setAdapter(adapter);
        if (viewType == VIEW_TYPE_SMALLVIDEO) {
@@ -242,7 +253,8 @@
        for (int i = list.size() - 1; i >= 0; i--) {
            if ("ad".equalsIgnoreCase(list.get(i).getType())) {
                list.remove(i--);
                break;
                if (showAd)
                    break;
            }
        }
@@ -270,6 +282,10 @@
    @Override
    public void onNoAd(String s, int i) {
        onLoadFinish();
        if (currentPage == 1) {
            nrAdList.clear();
            adapter.notifyDataSetChanged();
        }
    }
    @Override