From 2f1ab8af88cae4e723126ea5cf2f7d42dff7dbdc Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 30 九月 2021 13:43:56 +0800 Subject: [PATCH] 穿山甲广告SDK更新,隐私合规修改 --- library-BaiduCPU/src/main/java/com/yeshi/ec/library_baiducpu/fragment/BaiDuCPUContentFragment.java | 40 ++++++++++++++++++++++++++++++++-------- 1 files changed, 32 insertions(+), 8 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 9be7994..51b5cb8 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 @@ -4,10 +4,10 @@ import android.graphics.Color; import android.graphics.Rect; import android.os.Bundle; -import android.support.v4.widget.SwipeRefreshLayout; -import android.support.v7.widget.GridLayoutManager; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import android.util.Log; import android.view.Gravity; import android.view.View; @@ -56,13 +56,26 @@ 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, 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); @@ -163,7 +176,12 @@ 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); + srl_news.setColorSchemeColors(bundle.getInt("refreshColor")); + bundle.clear(); mChannelId = item.getId(); @@ -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 @@ -290,4 +313,5 @@ } + } -- Gitblit v1.8.0