From cbb88109494ffc7916f6639c20ce05c0cec941a9 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 07 四月 2021 15:07:45 +0800 Subject: [PATCH] 3.9.1bug修复 --- library-BaiduCPU/src/main/java/com/yeshi/ec/library_baiducpu/fragment/BaiDuCPUContentFragment.java | 37 ++++++++++++++++++++++++++++++------- 1 files changed, 30 insertions(+), 7 deletions(-) diff --git a/library-BaiduCPU/src/main/java/com/yeshi/ec/library_baiducpu/fragment/BaiDuCPUContentFragment.java b/library-BaiduCPU/src/main/java/com/yeshi/ec/library_baiducpu/fragment/BaiDuCPUContentFragment.java index 03af61a..3f1e788 100644 --- a/library-BaiduCPU/src/main/java/com/yeshi/ec/library_baiducpu/fragment/BaiDuCPUContentFragment.java +++ b/library-BaiduCPU/src/main/java/com/yeshi/ec/library_baiducpu/fragment/BaiDuCPUContentFragment.java @@ -24,7 +24,7 @@ import com.ut.device.UTDevice; import com.yeshi.ec.library_baiducpu.R; import com.yeshi.ec.library_baiducpu.adapter.BaiduCPUContentAdapter; -import com.yeshi.ec.library_baiducpu.entity.SpinnerItem; +import com.yeshi.ec.library_baiducpu.entity.BaiDuCPUType; import java.util.ArrayList; import java.util.List; @@ -56,13 +56,26 @@ private int viewType; + private boolean showAd; - public static BaiDuCPUContentFragment newInstance(SpinnerItem 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, int refreshColor, BaiduCPUContentAdapter.IBaiDuCPUItemClickListener baiDuCPUItemClickListener) { BaiDuCPUContentFragment fragment = new BaiDuCPUContentFragment(); Bundle bundle = new Bundle(); bundle.putSerializable("item", spinnerItem); bundle.putInt("viewType", viewType); + bundle.putBoolean("showAd", showAd); + bundle.putInt("refreshColor", refreshColor); + + fragment.setArguments(bundle); + fragment.setBaiDuCPUItemClickListener(baiDuCPUItemClickListener); return fragment; } @@ -108,7 +121,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); @@ -162,10 +175,15 @@ private void initData() { Bundle bundle = getArguments(); - SpinnerItem item = (SpinnerItem) bundle.getSerializable("item"); + BaiDuCPUType item = (BaiDuCPUType) bundle.getSerializable("item"); + if (item == null) + return; viewType = bundle.getInt("viewType"); + showAd = bundle.getBoolean("showAd", true); + srl_news.setColorSchemeColors(bundle.getInt("refreshColor")); + bundle.clear(); - mChannelId = item.getmId(); + mChannelId = item.getId(); mCpuManager = new NativeCPUManager(getContext(), YOUR_APP_ID, this); /** @@ -173,7 +191,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 +258,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 +287,10 @@ @Override public void onNoAd(String s, int i) { onLoadFinish(); + if (currentPage == 1) { + nrAdList.clear(); + adapter.notifyDataSetChanged(); + } } @Override -- Gitblit v1.8.0