Commit 68c773e1 authored by mengcuiguang2's avatar mengcuiguang2

优化广告信息流逻辑

parent 4832d8b2
......@@ -303,7 +303,7 @@
</provider>
<!-- 常驻通知栏service -->
<service android:name="com.mints.flowbox.keepalive.NotificationService" />
<!-- <service android:name="com.mints.flowbox.keepalive.NotificationService" />-->
</application>
......
......@@ -248,11 +248,11 @@ public class MintsApplication extends BaseApp {
}
}
// @Override
// public void onLowMemory() {
// android.os.Process.killProcess(android.os.Process.myPid());
// super.onLowMemory();
// }
@Override
public void onLowMemory() {
android.os.Process.killProcess(android.os.Process.myPid());
super.onLowMemory();
}
@Override
protected void attachBaseContext(Context base) {
......@@ -264,7 +264,7 @@ public class MintsApplication extends BaseApp {
KeepAliveHelper.Companion.preInit(base, this, NotificationService.class);
// 9.0之后不可多进程使用一个目录下的WebView,写在SDK初始化之前
androidPWebView();
// androidPWebView();
}
/*
......@@ -281,7 +281,7 @@ public class MintsApplication extends BaseApp {
initMiitHelper();
// 优量汇
// YlhAdManager.INSTANCE.initYlhAd(this);
YlhAdManager.INSTANCE.initYlhAd(this);
// GroMore
CsjGroMoreManager.INSTANCE.init(this);
......@@ -290,10 +290,10 @@ public class MintsApplication extends BaseApp {
OwManager.INSTANCE.init(this);
// 穿山甲
// TtCsjAdManager.init(this);
TtCsjAdManager.init(this);
// 快手
// KsManager.INSTANCE.initKs(this);
KsManager.INSTANCE.initKs(this);
// 闪电盒子
WnManager.INSTANCE.initWn(this);
......
package com.mints.flowbox.ad.express
import android.widget.FrameLayout
import com.mints.flowbox.common.AppConfig
import com.mints.flowbox.manager.TtCsjAdManager
/**
* 能用信息流加载
*/
object ExpressManager {
fun loadExpress() {
if (AppConfig.groMoreVideoAdCount > 0) {
GroMoreCarrierExpressManager.instance.loadADFrameLayout()
} else {
TTPreLoadCarrierExpressManager.getInstance().loadTtFrameLayout(TtCsjAdManager.TT_AD_NATIVEEXPRESS_WATER)
}
}
fun getExpressFrameLayout(): FrameLayout? {
if (AppConfig.groMoreVideoAdCount > 0) {
return GroMoreCarrierExpressManager.instance.getADFrameLayout()
} else {
return TTPreLoadCarrierExpressManager.getInstance().ttFrameLayout
}
}
}
\ No newline at end of file
......@@ -15,6 +15,7 @@ import com.kwad.sdk.api.*
import com.kwad.sdk.api.KsNativeAd.VideoPlayListener
import com.mints.flowbox.MintsApplication
import com.mints.flowbox.R
import com.mints.flowbox.common.AppConfig
import com.mints.flowbox.manager.ad.KsManager
import com.mints.flowbox.utils.LogUtil
import java.util.*
......@@ -42,6 +43,7 @@ object KsPreLoadExpressManager {
KsAdSDK.getLoadManager().loadNativeAd(scene, object : KsLoadManager.NativeAdListener {
override fun onError(p0: Int, p1: String?) {
LogUtil.d("$p0 -> $p1")
AppConfig.isPreExpressAwardActivity=false
}
override fun onNativeAdLoad(p0: MutableList<KsNativeAd>?) {
......@@ -51,6 +53,7 @@ object KsPreLoadExpressManager {
})
} catch (e: Exception) {
AppConfig.isPreExpressAwardActivity=false
e.printStackTrace()
}
}
......@@ -83,8 +86,7 @@ object KsPreLoadExpressManager {
* 使用SDK渲染的播放控件
*/
private fun getVideoItemView(parent: ViewGroup, ksNativeAd: KsNativeAd): View? {
val convertView: View =
LayoutInflater.from(mContext).inflate(R.layout.native_item_video, parent, false)
val convertView: View = LayoutInflater.from(mContext).inflate(R.layout.native_item_video, parent, false)
val videoViewHolder = AdVideoViewHolder(convertView)
// 设置广告数据
......@@ -119,8 +121,7 @@ object KsPreLoadExpressManager {
* 自定义的单图广告
*/
private fun getSingleImageItemView(parent: ViewGroup, ksNativeAd: KsNativeAd): View? {
val convertView: View =
LayoutInflater.from(mContext).inflate(R.layout.native_item_single_image, parent, false)
val convertView: View = LayoutInflater.from(mContext).inflate(R.layout.native_item_single_image, parent, false)
val viewHolder = AdSingleImageViewHolder(convertView)
bindCommonData(convertView as ViewGroup, viewHolder, ksNativeAd)
......@@ -138,8 +139,7 @@ object KsPreLoadExpressManager {
* 自定义的组图广告
*/
private fun getGroupImageItemView(parent: ViewGroup, ksNativeAd: KsNativeAd): View? {
val convertView: View =
LayoutInflater.from(mContext).inflate(R.layout.native_item_group_image, parent, false)
val convertView: View = LayoutInflater.from(mContext).inflate(R.layout.native_item_group_image, parent, false)
val viewHolder = AdGroupImageViewHolder(convertView)
bindCommonData(convertView as ViewGroup, viewHolder, ksNativeAd)
......@@ -168,17 +168,14 @@ object KsPreLoadExpressManager {
@SuppressLint("DefaultLocale")
private fun getNormalItemView(parent: ViewGroup): View? {
val convertView: View =
LayoutInflater.from(mContext).inflate(R.layout.native_item_normal, parent, false)
val convertView: View = LayoutInflater.from(mContext).inflate(R.layout.native_item_normal, parent, false)
val normalViewHolder = NormalViewHolder(convertView)
normalViewHolder.textView.text = "没有广告"
return convertView
}
private fun bindCommonData(
convertView: ViewGroup, adBaseViewHolder: AdBaseViewHolder,
ad: KsNativeAd
) {
private fun bindCommonData(convertView: ViewGroup, adBaseViewHolder: AdBaseViewHolder,
ad: KsNativeAd) {
// 点击转换view的集合,传入的view点击时会触发转换操作:app下载, 打开h5页面
val clickViewList: MutableList<View> = ArrayList()
clickViewList.add(convertView) // 点击整个view都可触发转换
......@@ -190,7 +187,7 @@ object KsPreLoadExpressManager {
object : KsNativeAd.AdInteractionListener {
override fun onAdClicked(view: View, ad: KsNativeAd) {
if (ad != null) {
// Toast.makeText(WenshuApplication.getContext(), "广告" + ad.appName + "被点击", Toast.LENGTH_SHORT).show()
// Toast.makeText(MintsApplication.getContext(), "广告" + ad.appName + "被点击", Toast.LENGTH_SHORT).show()
}
}
......@@ -201,7 +198,7 @@ object KsPreLoadExpressManager {
}
override fun handleDownloadDialog(p0: DialogInterface.OnClickListener?): Boolean {
TODO("Not yet implemented")
return false
}
})
......@@ -236,8 +233,7 @@ object KsPreLoadExpressManager {
adBaseViewHolder.mAppIcon.visibility = View.GONE
} else {
adBaseViewHolder.mAppIcon.visibility = View.VISIBLE
Glide.with(MintsApplication.getContext()).load(ad.appIconUrl)
.into(adBaseViewHolder.mAppIcon)
Glide.with(MintsApplication.getContext()).load(ad.appIconUrl).into(adBaseViewHolder.mAppIcon)
}
// app名称
if (!TextUtils.isEmpty(ad.appName)) {
......
......@@ -15,9 +15,7 @@ import java.util.*
/**
* 预加载信息流管理类
*/
@SuppressLint("StaticFieldLeak")
object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener,
KSADLoadSuccessListener, GMADLoadSuccessListener {
object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener, KSADLoadSuccessListener, GMADLoadSuccessListener {
private val TAG = PreLoadExpressManager::class.java.simpleName
......@@ -64,8 +62,7 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
// }
when (getRandomWeight()) {
Constant.CSJ_EXPRESS_AD -> TTPreLoadExpressManager.getInstance()
.loadTtFrameLayout(mAdFrameLayout)
Constant.CSJ_EXPRESS_AD -> TTPreLoadExpressManager.getInstance().loadTtFrameLayout(mAdFrameLayout)
Constant.YLH_EXPRESS_AD -> YlhPreLoadExpressManager.loadYlhFrameLayout()
Constant.KS_EXPRESS_AD -> KsPreLoadExpressManager.loadKsFrameLayout(mAdFrameLayout as ViewGroup)
Constant.GM_EXPRESS_AD -> GroMoreExpressManager.instance.loadADFrameLayout()
......@@ -138,6 +135,9 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
// if (currentIndex == 1) {
// mAdFrameLayout = adFrameLayout
// }
if(view!=null){
AppConfig.isPreExpressAwardActivity=true
}
mAdFrameLayout = view
}
......@@ -145,6 +145,9 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
// if (currentIndex == 2) {
// mAdFrameLayout?.addView(view)
// }
if(view!=null){
AppConfig.isPreExpressAwardActivity=true
}
mAdFrameLayout?.addView(view)
}
......@@ -152,6 +155,9 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
// if (currentIndex == 3) {
// mAdFrameLayout?.addView(view)
// }
if(view!=null){
AppConfig.isPreExpressAwardActivity=true
}
mAdFrameLayout?.addView(view)
}
......@@ -159,6 +165,9 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
// if (currentIndex == 3) {
// mAdFrameLayout?.addView(view)
// }
if(view!=null){
AppConfig.isPreExpressAwardActivity=true
}
mAdFrameLayout?.addView(view)
}
......
......@@ -106,7 +106,7 @@ public class TTPreLoadCarrierExpressManager {
public void loadTtFrameLayout(String codeId) {
init();
// ToastUtil.showLong(WenshuApplication.getContext(), "通用信息流:" + codeId);
// ToastUtil.showLong(MintsApplication.getContext(), "通用信息流:" + codeId);
if (mWorkHandler != null) {
Message msg = Message.obtain();
......
......@@ -4,7 +4,7 @@ import android.util.DisplayMetrics;
import android.widget.FrameLayout;
import com.mints.flowbox.MintsApplication;
import com.mints.flowbox.common.AppConfig;
import com.mints.flowbox.ad.express.TTADLoadSuccessListener;import com.mints.flowbox.common.AppConfig;
import com.mints.flowbox.manager.TTNativeExpressManager;
import com.mints.flowbox.manager.TtCsjAdManager;
......@@ -62,6 +62,7 @@ public class TTPreLoadExpressManager {
}
}
} catch (Exception e) {
AppConfig.isPreExpressAwardActivity=false;
e.printStackTrace();
}
});
......
package com.mints.flowbox.ad.express
import com.qq.e.ads.nativ.express2.*
import com.qq.e.comm.util.AdError
import com.mints.flowbox.MintsApplication
import com.mints.flowbox.common.AppConfig
import com.mints.flowbox.manager.ad.YlhAdManager
import com.mints.flowbox.utils.LogUtil
import com.qq.e.ads.nativ.ADSize
import com.qq.e.ads.nativ.NativeExpressAD
import com.qq.e.ads.nativ.NativeExpressADView
/**
* 优量汇预加载信息流
*/
......@@ -23,12 +27,9 @@ object YlhPreLoadExpressManager {
fun loadYlhFrameLayout() {
try {
nativeExpressAD = NativeExpressAD(
MintsApplication.getContext(),
ADSize(ADSize.FULL_WIDTH, ADSize.AUTO_HEIGHT),
YlhAdManager.YLH_AD_NATIVEEXPRESS_AWARD,
object : NativeExpressAD.NativeExpressADListener {
nativeExpressAD = NativeExpressAD(MintsApplication.getContext(), ADSize(ADSize.FULL_WIDTH, ADSize.AUTO_HEIGHT), YlhAdManager.YLH_AD_NATIVEEXPRESS_AWARD, object : NativeExpressAD.NativeExpressADListener {
override fun onNoAD(p0: AdError?) {
AppConfig.isPreExpressAwardActivity=false
}
override fun onADClicked(p0: NativeExpressADView?) {
......@@ -62,6 +63,7 @@ object YlhPreLoadExpressManager {
}
override fun onRenderFail(p0: NativeExpressADView?) {
AppConfig.isPreExpressAwardActivity=false
}
override fun onRenderSuccess(p0: NativeExpressADView?) {
......@@ -72,6 +74,7 @@ object YlhPreLoadExpressManager {
} catch (e: Exception) {
e.printStackTrace()
AppConfig.isPreExpressAwardActivity=false
}
}
......
......@@ -23,7 +23,7 @@ import java.util.Map;
*/
public class TTGroMoreAdManagerHolder {
public static final String TT_AD_APPID = "5174315";
public static final String TT_AD_APPID = "5182992";
public static final String TT_AD_NAME = Constant.MINTS_APP_NAME;
private static boolean sInit;
......
......@@ -3,6 +3,7 @@ package com.mints.flowbox.ui.activitys
import android.os.Bundle
import android.view.View
import com.mints.flowbox.R
import com.mints.flowbox.ad.express.ExpressManager
import com.mints.flowbox.common.Constant
import com.mints.flowbox.ad.express.TTPreLoadCarrierExpressManager
import com.mints.flowbox.manager.TtCsjAdManager
......@@ -88,7 +89,7 @@ class FoodSubsidyActivity : BaseActivity(), View.OnClickListener, FoodSubsidyVie
}
// 预加载信息流
TTPreLoadCarrierExpressManager.getInstance().loadTtFrameLayout(TtCsjAdManager.TT_AD_NATIVEEXPRESS_EAT)
ExpressManager.loadExpress()
}
......@@ -97,11 +98,9 @@ class FoodSubsidyActivity : BaseActivity(), View.OnClickListener, FoodSubsidyVie
*/
private fun initExpress() {
try {
if (TTPreLoadCarrierExpressManager.getInstance().ttFrameLayout != null) {
if (flSubsidykAd != null) {
flSubsidykAd.removeAllViews()
flSubsidykAd.addView(TTPreLoadCarrierExpressManager.getInstance().ttFrameLayout)
}
flSubsidykAd.addView(ExpressManager.getExpressFrameLayout())
}
} catch (e: Exception) {
e.printStackTrace()
......
......@@ -106,7 +106,7 @@ public class SplashGroMoreActivity extends BaseActivity {
public void onSplashAdLoadFail(AdError adError) {
LogUtil.d(TAG, adError.message);
mHasLoaded = true;
Log.e(TAG, "load splash ad error : " + adError.code + ", " + adError.message);
LogUtil.d(TAG, "load splash ad error : " + adError.code + ", " + adError.message);
// 获取本次waterfall加载中,加载失败的adn错误信息。
if (mTTSplashAd != null)
LogUtil.d(TAG, "ad load infos: " + mTTSplashAd.getAdLoadInfoList());
......@@ -129,7 +129,7 @@ public class SplashGroMoreActivity extends BaseActivity {
vo.put("adid", CsjGroMoreManager.INSTANCE.getAD_UNIT_SPLASH_ID());
TrackManager.getInstance().cmtGroMoreInfo(vo);
}
Log.e(TAG, "load splash ad success ");
LogUtil.d(TAG, "load splash ad success ");
}
@Override
......
......@@ -3,6 +3,7 @@ package com.mints.flowbox.ui.activitys
import android.os.Bundle
import android.view.View
import com.mints.flowbox.R
import com.mints.flowbox.ad.express.ExpressManager
import com.mints.flowbox.common.Constant
import com.mints.flowbox.ad.express.TTPreLoadCarrierExpressManager
import com.mints.flowbox.manager.TtCsjAdManager
......@@ -99,7 +100,7 @@ class WalkActivity : BaseActivity(), View.OnClickListener, WalkView, StepView.St
}
// 预加载信息流
TTPreLoadCarrierExpressManager.getInstance().loadTtFrameLayout(TtCsjAdManager.TT_AD_NATIVEEXPRESS_WALK)
ExpressManager.loadExpress()
}
/**
......@@ -107,11 +108,9 @@ class WalkActivity : BaseActivity(), View.OnClickListener, WalkView, StepView.St
*/
private fun initExpress() {
try {
if (TTPreLoadCarrierExpressManager.getInstance().ttFrameLayout != null) {
if (flWalkAd != null) {
flWalkAd.removeAllViews()
flWalkAd.addView(TTPreLoadCarrierExpressManager.getInstance().ttFrameLayout)
}
flWalkAd.addView(ExpressManager.getExpressFrameLayout())
}
} catch (e: Exception) {
e.printStackTrace()
......
......@@ -3,6 +3,7 @@ package com.mints.flowbox.ui.activitys
import android.os.Bundle
import android.view.View
import com.mints.flowbox.R
import com.mints.flowbox.ad.express.ExpressManager
import com.mints.flowbox.common.Constant
import com.mints.flowbox.ad.express.TTPreLoadCarrierExpressManager
import com.mints.flowbox.manager.TtCsjAdManager
......@@ -69,7 +70,7 @@ class WaterActivity : BaseActivity(), View.OnClickListener, WaterView.WaterViewL
}
// 预加载信息流
TTPreLoadCarrierExpressManager.getInstance().loadTtFrameLayout(TtCsjAdManager.TT_AD_NATIVEEXPRESS_WATER)
ExpressManager.loadExpress()
}
override fun clickForWaterSuc(waterCoin: Int) {
......@@ -111,11 +112,9 @@ class WaterActivity : BaseActivity(), View.OnClickListener, WaterView.WaterViewL
*/
private fun initExpress() {
try {
if (TTPreLoadCarrierExpressManager.getInstance().ttFrameLayout != null) {
if (flWaterAd != null) {
flWaterAd.removeAllViews()
flWaterAd.addView(TTPreLoadCarrierExpressManager.getInstance().ttFrameLayout)
}
flWaterAd.addView(ExpressManager.getExpressFrameLayout())
}
} catch (e: Exception) {
e.printStackTrace()
......
......@@ -10,6 +10,7 @@ import android.widget.AdapterView
import android.widget.GridView
import com.mints.flowbox.MintsApplication
import com.mints.flowbox.R
import com.mints.flowbox.ad.express.ExpressManager
import com.mints.flowbox.ad.express.PreLoadExpressManager
import com.mints.flowbox.ad.express.TTPreLoadCarrierExpressManager
import com.mints.flowbox.ad.video.VideoAdingManager
......@@ -447,26 +448,22 @@ class HomeFragment : BaseFragment(), WifiStateManager.WifiStateCallback,
// 自有界面
when (hotBean.toUrl) {
Constant.HOT_ACTIVITY_WATER -> {
TTPreLoadCarrierExpressManager.getInstance()
.loadTtFrameLayout(TtCsjAdManager.TT_AD_NATIVEEXPRESS_WATER)
ExpressManager.loadExpress()
readyGo(WaterActivity::class.java)
}
Constant.HOT_ACTIVITY_WALK -> {
TTPreLoadCarrierExpressManager.getInstance()
.loadTtFrameLayout(TtCsjAdManager.TT_AD_NATIVEEXPRESS_WALK)
ExpressManager.loadExpress()
readyGo(WalkActivity::class.java)
}
Constant.HOT_ACTIVITY_CARD -> {
readyGo(EraseActivity::class.java)
}
Constant.HOT_ACTIVITY_MORNINGCLOCK -> {
TTPreLoadCarrierExpressManager.getInstance()
.loadTtFrameLayout(TtCsjAdManager.TT_AD_NATIVEEXPRESS_MORNINGCLOCK)
ExpressManager.loadExpress()
readyGo(MorningClockActivity::class.java)
}
Constant.HOT_ACTIVITY_EAT -> {
TTPreLoadCarrierExpressManager.getInstance()
.loadTtFrameLayout(TtCsjAdManager.TT_AD_NATIVEEXPRESS_EAT)
ExpressManager.loadExpress()
readyGo(FoodSubsidyActivity::class.java)
}
Constant.HOT_ACTIVITY_SHARE_NEWS -> {
......
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
<domain-config>
<domain includeSubdomains="true">i.snssdk.com</domain>
<domain includeSubdomains="true">is.snssdk.com</domain>
<domain includeSubdomains="true">pangolin.snssdk.com</domain>
<domain includeSubdomains="true">extlog.snssdk.com</domain>
<domain includeSubdomains="true">sf3-ttcdn-tos.pstatp.com</domain>
<domain includeSubdomains="true">bds.snssdk.com</domain>
<domain includeSubdomains="true">dig.bdurl.net</domain>
<domain includeSubdomains="true">api-access.pangolin-sdk-toutiao.com</domain>
<domain includeSubdomains="true">sf1-fe-tos.pglstatp-toutiao.com</domain>
<domain includeSubdomains="true">sf1-be-pack.pglstatp-toutiao.com</domain>
<domain includeSubdomains="true">sf3-fe-tos.pglstatp-toutiao.com</domain>
<domain includeSubdomains="true">log-api.pangolin-sdk-toutiao.com</domain>
<domain includeSubdomains="true">s3-fe-scm.pglstatp-toutiao.com</domain>
<domain includeSubdomains="true">s3a.pstatp.com</domain>
<domain includeSubdomains="true">api-access.pangolin-sdk-toutiao-b.com</domain>
<domain includeSubdomains="true">log-api.pangolin-sdk-toutiao-b.com</domain>
<domain includeSubdomains="true">dm.pstatp.com</domain>
<domain includeSubdomains="true">toblog.ctobsnssdk.com</domain>
<domain includeSubdomains="true">sdfp.snssdk.com</domain>
<domain includeSubdomains="true">tosv.byted.org</domain>
<domain includeSubdomains="true">sf1-ttcdn-tos.pstatp.com</domain>
<domain includeSubdomains="true">sf6-fe-tos.pglstatp-toutiao.com</domain>
<domain includeSubdomains="true">log.snssdk.com</domain>
<domain includeSubdomains="true">tosv.boe.byted.org</domain>
<domain includeSubdomains="true">dm.toutiao.com</domain>
<domain includeSubdomains="true">dm.bytedance.com</domain>
<trust-anchors>
<certificates src="user" />//信任用户自己安装的证书
<certificates src="system" />
</trust-anchors>
</domain-config>
</network-security-config>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment