Commit f7dbae37 authored by jyx's avatar jyx

优化应用外全屏广告展示

parent d1855fd2
......@@ -116,7 +116,7 @@
android:name=".ui.activitys.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:excludeFromRecents="true"
android:launchMode="singleInstance"
android:launchMode="singleTask"
android:theme="@style/AppTheme.NoneTranslucent" />
<activity android:name=".ui.activitys.SplashCsjADActivity" />
<activity android:name=".ui.activitys.WebActivity" />
......
......@@ -194,6 +194,8 @@ class AppOutGroMoreCarrierExpressManager : TTSettingConfigCallback {
mHandlerThread = null
mWorkHandler?.removeCallbacksAndMessages(null)
mWorkHandler = null
frameLayout?.removeAllViews()
frameLayout = null
TTMediationAdSdk.unregisterConfigCallback(this)
}
......
package com.mints.flowbox.ad.wifi
import android.app.Activity
import android.content.Intent
import com.mints.flowbox.MintsApplication
import com.mints.flowbox.ad.full.FullGroManager
import com.mints.flowbox.ui.activitys.keepalive.BoostFastActivity
import com.mints.flowbox.ui.activitys.keepalive.TransparentActivity
import com.mints.flowbox.utils.keepalive.IntentUtils
/**
* 应用外wifi广告管理
*
* 广告形式-Gromore的插屏、全屏
*/
class AppOutWifiAdManager private constructor() {
companion object {
val instance: AppOutWifiAdManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
AppOutWifiAdManager()
}
}
private var mType = 0
private var wifiAdStatusListener: WifiAdStatusListener? = object : WifiAdStatusListener {
override fun adSuccess() {
val intent = Intent(MintsApplication.getContext(), BoostFastActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_ANIMATION
intent.putExtra(TransparentActivity.TIMING_TYPE, mType)
IntentUtils.startActivity3(intent)
}
override fun adFail() {
}
override fun adClose() {
}
}
// groMore全屏
private var fullGroManager: FullGroManager? = null
/**
* 预加载广告,必须传入activity
*/
fun loadWifiAd(activity: Activity, type: Int) {
mType = type
preLoadFullGroMore(activity)
}
/**
* 全屏
*/
private fun preLoadFullGroMore(activity: Activity) {
if (fullGroManager != null) {
fullGroManager?.onDestroy()
}
fullGroManager = FullGroManager()
fullGroManager?.loadFullAd(activity, false)
fullGroManager?.setWifiAdStatusListener(wifiAdStatusListener)
}
/**
* 展示广告
*/
fun showInterstitial(_activity: Activity) {
if (fullGroManager != null) {
fullGroManager?.showFullAd(_activity, wifiAdStatusListener)
} else {
this.wifiAdStatusListener?.adFail()
}
}
fun onDestroy() {
fullGroManager?.onDestroy()
fullGroManager?.setWifiAdStatusListener(null)
fullGroManager = null
}
fun setWifiAdStatusListener(listener: WifiAdStatusListener?) {
this.wifiAdStatusListener = listener
}
}
\ No newline at end of file
......@@ -174,7 +174,7 @@ public class NotificationService extends Service {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
builder2.setPriority(Notification.PRIORITY_MAX);
}
notification = builder2.setSmallIcon(R.drawable.ic_launcher_main, 0)
notification = builder2.setSmallIcon(R.mipmap.ic_wifi_notice, 0)
.setOngoing(true)
.setContent(remoteViews)
.setGroup(NotificationUtil.Channel_Id_Core)
......
......@@ -52,9 +52,6 @@ object OutAppRouter {
* 展示锁屏页面
*/
fun showScreenActivity() {
// 预加载信息流
ExpressManager.loadAppOutExpress()
val intent = Intent(MintsApplication.getContext(), ScreenActivity::class.java)
if (!PhoneBrandUtils.isOppo()) {
intent.flags = Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT
......
......@@ -120,13 +120,13 @@ class AntiAuditManager private constructor() {
for (i in 0 until time.size) {
when {
time[i] > now - (overTime + ONE_DAY * 2) -> {
threedayItems.add(installTime[time[i]])
onedayItems.add(installTime[time[i]])
}
time[i] > now - (overTime + ONE_DAY) -> {
twodayItems.add(installTime[time[i]])
}
time[i] > now - overTime -> {
onedayItems.add(installTime[time[i]])
threedayItems.add(installTime[time[i]])
}
}
}
......@@ -137,7 +137,7 @@ class AntiAuditManager private constructor() {
LogUtil.d(TAG, "TwoDay -> $twodayItems")
LogUtil.d(TAG, "OneDay -> $onedayItems")
return onedayItems.size >= N && twodayItems.size >= N && threedayItems.size >= N
return onedayItems.size >= N || twodayItems.size >= N || threedayItems.size >= N
}
}
\ No newline at end of file
......@@ -166,11 +166,13 @@ class ScreenLockerObserver(private val context: Context) {
)
when (intent?.action) {
ScreenMonitor.MY_SCREEN_OFF, Intent.ACTION_SCREEN_OFF,
ACTION_SCREENCHECKER_OFF, Intent.ACTION_POWER_CONNECTED,
Intent.ACTION_POWER_DISCONNECTED ->
ACTION_SCREENCHECKER_OFF,
Intent.ACTION_POWER_CONNECTED
// , Intent.ACTION_POWER_DISCONNECTED
->
onHandleScreenOff(
context,
intent?.action == Intent.ACTION_POWER_DISCONNECTED
intent.action == Intent.ACTION_POWER_DISCONNECTED
)
ScreenMonitor.MY_SCREEN_ON, Intent.ACTION_SCREEN_ON, ACTION_SCREENCHECKER_ON ->
onHandleScreenOn(context)
......
......@@ -440,7 +440,7 @@ object WifiDataManager {
private fun isBlackOrClose(): Boolean {
val isBlack = sp.getBoolean(AntiAuditManager.APP_OUT_BLACK, false)
return !(!APP_OUT_MAIN_SWITCH || isBlack)
return (!APP_OUT_MAIN_SWITCH || isBlack)
}
}
\ No newline at end of file
......@@ -11,8 +11,7 @@ import android.os.Looper
import android.view.View
import com.mints.flowbox.R
import com.mints.flowbox.ad.express.ExpressManager
import com.mints.flowbox.ad.wifi.WifiAdManager
import com.mints.flowbox.ad.wifi.WifiAdStatusListener
import com.mints.flowbox.ad.wifi.AppOutWifiAdManager
import com.mints.flowbox.ui.activitys.base.BaseActivity
import kotlinx.android.synthetic.main.activity_boost_fast.*
import kotlinx.android.synthetic.main.activity_boost_fast.container
......@@ -82,19 +81,7 @@ class BoostFastActivity : BaseActivity() {
Handler(Looper.getMainLooper()).postDelayed(
{
WifiAdManager.instance.setWifiAdStatusListener(object : WifiAdStatusListener {
override fun adSuccess() {
}
override fun adFail() {
}
override fun adClose() {
}
})
WifiAdManager.instance.showInterstitial(this@BoostFastActivity)
AppOutWifiAdManager.instance.showInterstitial(this@BoostFastActivity)
},
2500
)
......
......@@ -32,6 +32,8 @@ class ScreenActivity : OutAppActivity(), View.OnClickListener {
// val thread = TimeThread(tvDate, tvTime)
// thread.start()
initExpress()
tvBoost.setOnClickListener(this)
tvClean.setOnClickListener(this)
tvSaveBattery.setOnClickListener(this)
......@@ -40,12 +42,11 @@ class ScreenActivity : OutAppActivity(), View.OnClickListener {
override fun onResume() {
super.onResume()
resetTime()
initExpress()
}
override fun onPause() {
super.onPause()
ExpressManager.loadAppOutExpress()
// ExpressManager.loadAppOutExpress()
}
private fun resetTime() {
......@@ -95,12 +96,13 @@ class ScreenActivity : OutAppActivity(), View.OnClickListener {
*/
private fun initExpress() {
try {
if (fl_ad != null && ExpressManager.getAppOutExpressFrameLayout() != null) {
fl_ad.removeAllViews()
fl_ad.addView(ExpressManager.getAppOutExpressFrameLayout())
} else {
ExpressManager.loadNoAppOutExpress(fl_ad)
}
// if (fl_ad != null && ExpressManager.getAppOutExpressFrameLayout() != null) {
// fl_ad.removeAllViews()
// fl_ad.addView(ExpressManager.getAppOutExpressFrameLayout())
// } else {
fl_ad.removeAllViews()
ExpressManager.loadNoAppOutExpress(fl_ad)
// }
} catch (e: Exception) {
e.printStackTrace()
}
......
package com.mints.flowbox.ui.activitys.keepalive
import android.content.Intent
import android.os.Bundle
import android.view.Gravity
import com.mints.flowbox.MintsApplication
import com.mints.flowbox.R
import com.mints.flowbox.ad.express.ExpressManager
import com.mints.flowbox.ad.wifi.WifiAdManager
import com.mints.flowbox.ad.wifi.WifiAdStatusListener
import com.mints.flowbox.ad.wifi.AppOutWifiAdManager
import com.mints.flowbox.ui.activitys.base.BaseActivity
/**
......@@ -36,6 +32,7 @@ class TransparentActivity : BaseActivity() {
}
}
override fun getContentViewLayoutID() = R.layout.activity_trans
override fun initViewsAndEvents() {
......@@ -50,38 +47,10 @@ class TransparentActivity : BaseActivity() {
* 加载广告
*/
private fun loadAd() {
WifiAdManager.instance.setWifiAdStatusListener(object : WifiAdStatusListener {
override fun adSuccess() {
val intent = Intent(MintsApplication.getContext(), BoostFastActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_ANIMATION
intent.putExtra(TIMING_TYPE, mType)
startActivity(intent)
finish()
}
override fun adFail() {
WifiAdManager.instance.onDestroy()
finish()
}
override fun adClose() {
}
})
WifiAdManager.instance.loadWifiAd(this, false)
AppOutWifiAdManager.instance.loadWifiAd(this, mType)
// 预加载信息流
ExpressManager.loadAppOutExpress()
finish()
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val window = window
window.setGravity(Gravity.START or Gravity.TOP)
val params = window.attributes
params.x = 0
params.y = 0
params.height = 1
params.width = 1
window.attributes = params
}
}
\ No newline at end of file
......@@ -77,6 +77,7 @@ class TriggerActivity : BaseActivity() {
}
initView()
initExpress()
}
private fun initView() {
......@@ -235,6 +236,7 @@ class TriggerActivity : BaseActivity() {
fl_ad.removeAllViews()
fl_ad.addView(ExpressManager.getAppOutExpressFrameLayout())
} else {
fl_ad.removeAllViews()
ExpressManager.loadNoAppOutExpress(fl_ad)
}
} catch (e: Exception) {
......@@ -251,7 +253,6 @@ class TriggerActivity : BaseActivity() {
override fun onResume() {
super.onResume()
initExpress()
btnClean.postDelayed({
rope = YoYo.with(Techniques.Pulse).duration(500).repeat(10).playOn(btnClean)
......
......@@ -123,7 +123,7 @@
android:id="@+id/fl_ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_gravity="center"
android:layout_margin="15dp"
android:background="@drawable/shape_gold_card"
android:elevation="2dip"
......
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