Commit dacc956c authored by jyx's avatar jyx

应用内信息流添加关闭按钮

parent 3198ee14
package com.mints.flowbox.ad
import android.os.Handler
import android.os.Looper
import android.text.TextUtils
import android.view.Gravity
import android.view.LayoutInflater
......@@ -182,9 +180,6 @@ class AppOutScreenGroMoreCarrierExpressManager : TTSettingConfigCallback {
val isOversped = TimeRender.isOversped45Min(adLoadTime, 45)
// 若上一个广告还在加载中则返回
if (isLoadSuccess == 1) {
Handler(Looper.getMainLooper()).postDelayed({
getAdView(callback)
}, 1000)
return
}
......
......@@ -182,9 +182,6 @@ class AppOutSimpleGroMoreCarrierExpressManager : TTSettingConfigCallback {
val isOversped = TimeRender.isOversped45Min(adLoadTime, 45)
// 若上一个广告还在加载中则返回
if (isLoadSuccess == 1) {
Handler(Looper.getMainLooper()).postDelayed({
getAdView(callback)
}, 1000)
return
}
......
package com.mints.flowbox.ad.banner
import android.app.Activity
import android.view.View
import android.widget.FrameLayout
import com.bytedance.sdk.openadsdk.AdSlot
import com.bytedance.sdk.openadsdk.TTAdNative
import com.bytedance.sdk.openadsdk.TTAdSdk
import com.bytedance.sdk.openadsdk.TTNativeExpressAd
import com.bytedance.sdk.openadsdk.*
import com.mints.flowbox.MintsApplication
import com.mints.flowbox.manager.TtCsjAdManager
import com.mints.flowbox.ui.activitys.MainActivity
import com.mints.flowbox.utils.LogUtil
/**
......@@ -47,7 +46,7 @@ class BannerManager {
/**
* 获取穿山甲banner
*/
fun getTtBanner(codeId: String, frameLayout: FrameLayout?) {
fun getTtBanner(codeId: String, frameLayout: FrameLayout?, activity: Activity) {
this.frameLayout = frameLayout
var expressViewAcceptedSizeWidth = getViewWidth()
var expressViewAcceptedSizeHeight = 0f
......@@ -78,7 +77,7 @@ class BannerManager {
frameLayout?.let {
mTTAd = ads[0]
bindAdListener()
bindAdListener(activity)
mTTAd?.render()
}
}
......@@ -90,8 +89,20 @@ class BannerManager {
}
}
private fun bindAdListener() {
private fun bindAdListener(activity: Activity) {
mTTAd?.let {
it.setDislikeCallback(activity, object : TTAdDislike.DislikeInteractionCallback {
override fun onShow() {
}
override fun onSelected(p0: Int, p1: String?, p2: Boolean) {
frameLayout?.removeAllViews()
}
override fun onCancel() {
}
})
it.setExpressInteractionListener(object :
TTNativeExpressAd.ExpressAdInteractionListener {
override fun onAdClicked(p0: View?, p1: Int) {
......
......@@ -19,6 +19,7 @@ import com.mints.flowbox.common.Constant
import com.mints.flowbox.manager.CsjGroMoreManager
import com.mints.flowbox.manager.TrackManager
import com.mints.flowbox.ui.widgets.seekbar.BubbleUtils
import com.mints.flowbox.utils.ForegroundOrBackground
import com.mints.flowbox.utils.LogUtil
import com.mints.flowbox.utils.VideoOptionUtil
import java.util.*
......@@ -247,23 +248,26 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
convertView.tag = adViewHolder
//判断是否存在dislike按钮
// if (ad.hasDislike()) {
// ad.setDislikeCallback(MintsApplication.getContext() as Activity?, object : TTDislikeCallback {
// override fun onSelected(position: Int, value: String) {
// //用户选择不喜欢原因后,移除广告展示
// }
//
// override fun onCancel() {
// LogUtil.d(TAG, "dislike 点击了取消")
// }
//
// /**
// * 拒绝再次提交
// */
// override fun onRefuse() {}
// override fun onShow() {}
// })
// }
if (ad.hasDislike() && ForegroundOrBackground.getApp_activity() != null) {
ad.setDislikeCallback(
ForegroundOrBackground.getApp_activity(),
object : TTDislikeCallback {
override fun onSelected(position: Int, value: String) {
//用户选择不喜欢原因后,移除广告展示
frameLayout?.removeAllViews()
}
override fun onCancel() {
LogUtil.d(TAG, "dislike 点击了取消")
}
/**
* 拒绝再次提交
*/
override fun onRefuse() {}
override fun onShow() {}
})
}
//设置点击展示回调监听
ad.setTTNativeAdListener(object : TTNativeExpressAdListener {
......
......@@ -263,7 +263,10 @@ class ScreenLockerObserver(private val context: Context) {
}
private fun onHandleScreenOff(context: Context, isPowerDisconnected: Boolean = false) {
if (IntentUtils.isRunningForeground(context) && ForegroundOrBackground.getApp_activity() != null && ForegroundOrBackground.getApp_activity() !is ScreenActivity) {
if (IntentUtils.isRunningForeground(context) &&
ForegroundOrBackground.getApp_activity() != null &&
ForegroundOrBackground.getApp_activity() !is ScreenActivity
) {
ForegroundOrBackground.getApp_activity().moveTaskToBack(true)
}
......
......@@ -48,6 +48,12 @@ class SpeedFastActivity : BaseActivity(), View.OnClickListener {
override fun adClose() {}
})
WifiAdManager.instance.loadWifiAd(this)
GlideUtils.loadImageViewGif(this, R.drawable.wifi_speed, iv_gif)
tv_tab.text = topStr[1]
btn.visibility = View.INVISIBLE
tv_progress.visibility = View.VISIBLE
startTimer()
}
fun startTimer() {
......@@ -117,15 +123,6 @@ class SpeedFastActivity : BaseActivity(), View.OnClickListener {
}
R.id.btn -> {
when {
mStep == 0 -> {
startTimer()
btn.visibility = View.INVISIBLE
tv_progress.visibility = View.VISIBLE
GlideUtils.loadImageViewGif(this, R.drawable.wifi_speed, iv_gif)
tv_tab.text = topStr[1]
}
mStep >= 4 -> {
finish()
}
......
......@@ -36,9 +36,7 @@ class ScreenActivity : OutAppActivity(), View.OnClickListener {
// thread.start()
initExpress()
ForegroundOrBackground.getMain_activity().moveTaskToBack(true)
tvBoost.setOnClickListener(this)
tvClean.setOnClickListener(this)
tvSaveBattery.setOnClickListener(this)
......
......@@ -120,7 +120,11 @@ class MyFragment : BaseFragment(),
// 防止banner刷新太快
if (AntiShake.check(fl_my_banner?.id)) return
BannerManager.instance.getTtBanner(TtCsjAdManager.TT_AD_BANNER_MY, fl_my_banner)
BannerManager.instance.getTtBanner(
TtCsjAdManager.TT_AD_BANNER_MY,
fl_my_banner,
requireActivity()
)
// 刷新喜马拉雅信息流
TTPreLoadExpressXmlyManager.getInstance().loadTtFrameLayout()
......
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