Commit 81a3d44c authored by jyx's avatar jyx

优量汇信息流集成

parent 8df2e49c
package com.mints.goodmoney.manager
import android.view.View
import android.widget.FrameLayout
import com.mints.goodmoney.MintsApplication
import com.qq.e.ads.nativ.ADSize
import com.qq.e.ads.nativ.NativeExpressAD
import com.qq.e.ads.nativ.NativeExpressADView
import com.qq.e.comm.util.AdError
object YlhPreLoadExpressManager {
private var ylhFrameLayout: FrameLayout? = null
private var nativeExpressAD: NativeExpressAD? = null
private var nativeExpressADView: NativeExpressADView? = null
fun getYlhFrameLayout(): FrameLayout? {
return ylhFrameLayout
}
fun loadYlhFrameLayout() {
val context = MintsApplication.getContext()
try {
ylhFrameLayout = FrameLayout(context)
nativeExpressAD = NativeExpressAD(MintsApplication.getContext(), ADSize(320, ADSize.AUTO_HEIGHT), YlhAdManager.YLH_AD_SPLASH_POSTID, object : NativeExpressAD.NativeExpressADListener {
override fun onNoAD(p0: AdError?) {
}
override fun onADClicked(p0: NativeExpressADView?) {
}
override fun onADCloseOverlay(p0: NativeExpressADView?) {
}
override fun onADClosed(p0: NativeExpressADView?) {
}
override fun onADExposure(p0: NativeExpressADView?) {
}
override fun onADLeftApplication(p0: NativeExpressADView?) {
}
override fun onADLoaded(p0: MutableList<NativeExpressADView>?) {
// 释放前一个展示的NativeExpressADView的资源
nativeExpressADView?.destroy()
if (ylhFrameLayout!!.visibility != View.VISIBLE) {
ylhFrameLayout!!.visibility = View.VISIBLE
}
if (ylhFrameLayout!!.childCount > 0) {
ylhFrameLayout!!.removeAllViews()
}
// 广告可见才会产生曝光,否则将无法产生收益。
ylhFrameLayout!!.addView(nativeExpressADView)
nativeExpressADView!!.render()
}
override fun onADOpenOverlay(p0: NativeExpressADView?) {
}
override fun onRenderFail(p0: NativeExpressADView?) {
}
override fun onRenderSuccess(p0: NativeExpressADView?) {
}
})
nativeExpressAD?.loadAD(1)
} catch (e: Exception) {
e.printStackTrace()
}
ylhFrameLayout = null
}
/**
* 在页面销毁时调用 destroy
*/
fun destoryADView() {
// 使用完了每一个NativeExpressADView之后都要释放掉资源
nativeExpressADView?.destroy()
}
}
\ No newline at end of file
...@@ -5,7 +5,7 @@ import android.view.View ...@@ -5,7 +5,7 @@ import android.view.View
import com.mints.goodmoney.R import com.mints.goodmoney.R
import com.mints.goodmoney.common.Constant import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.manager.TTNativeExpressManager import com.mints.goodmoney.manager.TTNativeExpressManager
import com.mints.goodmoney.manager.TtCsjAdManager import com.mints.goodmoney.manager.YlhPreLoadExpressManager
import com.mints.goodmoney.mvp.model.MealBean import com.mints.goodmoney.mvp.model.MealBean
import com.mints.goodmoney.mvp.presenters.FoodSubsidyPresenter import com.mints.goodmoney.mvp.presenters.FoodSubsidyPresenter
import com.mints.goodmoney.mvp.views.FoodSubsidyView import com.mints.goodmoney.mvp.views.FoodSubsidyView
...@@ -101,7 +101,9 @@ class FoodSubsidyActivity : BaseActivity(), View.OnClickListener, FoodSubsidyVie ...@@ -101,7 +101,9 @@ class FoodSubsidyActivity : BaseActivity(), View.OnClickListener, FoodSubsidyVie
private fun initExpress() { private fun initExpress() {
try { try {
// ttNativeExpressManager.initTTAd(false) // ttNativeExpressManager.initTTAd(false)
ttNativeExpressManager.getNativeExpressInit(TtCsjAdManager.TT_AD_NATIVEEXPRESS_EAT, flWalkAd, 320f, 0f) // ttNativeExpressManager.getNativeExpressInit(TtCsjAdManager.TT_AD_NATIVEEXPRESS_EAT, flWalkAd, 320f, 0f)
YlhPreLoadExpressManager.loadYlhFrameLayout()
flWalkAd.addView(YlhPreLoadExpressManager.getYlhFrameLayout())
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
} }
......
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