admin
2021-03-29 405e8b2d2ad9a2d6d51cd65173b42c9fcde0ce4f
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;
    }
@@ -108,7 +118,7 @@
        ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        footerView.setLayoutParams(params);
        footerView.setText("努力加载中...");
        footerView.setTextColor(Color.WHITE);
        footerView.setTextColor(Color.parseColor("#9FA5B3"));
        int padding = DimenUtils.dip2px(getContext(), 10);
        footerView.setPadding(padding, padding, padding, padding);
        footerView.setGravity(Gravity.CENTER);
@@ -163,7 +173,10 @@
    private void initData() {
        Bundle bundle = getArguments();
        BaiDuCPUType item = (BaiDuCPUType) bundle.getSerializable("item");
        if (item == null)
            return;
        viewType = bundle.getInt("viewType");
        showAd = bundle.getBoolean("showAd", true);
        bundle.clear();
        mChannelId = item.getId();
@@ -173,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) {
@@ -240,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;
            }
        }
@@ -268,6 +282,10 @@
    @Override
    public void onNoAd(String s, int i) {
        onLoadFinish();
        if (currentPage == 1) {
            nrAdList.clear();
            adapter.notifyDataSetChanged();
        }
    }
    @Override