Commit 472242f3 authored by jyx's avatar jyx

添加Home键场景

parent 2d6598ef
......@@ -237,6 +237,18 @@
android:launchMode="singleTask"
android:taskAffinity="com.a.b.c.t10"
android:theme="@style/OutTransparentTheme" />
<activity
android:name=".ui.activitys.keepalive.HomeTempTransparentActivity"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:taskAffinity="com.a.b.c.t12"
android:theme="@style/OutTransparentTheme" />
<activity
android:name=".ui.activitys.keepalive.TranHomeActivity"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:taskAffinity="com.a.b.c.t11"
android:theme="@style/OutTransparentTheme" />
<activity
android:name="com.mints.mingce.world.widget.WorldActivity"
......
......@@ -240,6 +240,7 @@ public class MintsApplication extends BaseApp {
ForegroundOrBackground.resetAppOutCount();
WifiAdManager.Companion.getInstance().resetAdLoadOk();
AppOutWifiAdManager.Companion.getInstance().resetAdLoadOk();
LogUtil.d(TAG, "HomeKeyWatch home键");
}
@Override
......@@ -248,7 +249,8 @@ public class MintsApplication extends BaseApp {
WifiAdManager.Companion.getInstance().resetAdLoadOk();
AppOutWifiAdManager.Companion.getInstance().resetAdLoadOk();
// HomePopManager.getInstance().startUserHomePop();
LogUtil.d(TAG, "HomeKeyWatch home列表");
HomePopManager.getInstance().startUserHomePop();
}
});
......
......@@ -16,6 +16,7 @@ import com.mints.fiveworld.ad.AdReportManager;
import com.mints.fiveworld.ad.wifi.AppOutWifiAdManager;
import com.mints.fiveworld.ad.wifi.WifiAdStatusListener;
import com.mints.fiveworld.common.Constant;
import com.mints.fiveworld.keepalive.AlarmManager;
import com.mints.fiveworld.keepalive.OutAppRouter;
import com.mints.fiveworld.manager.UmengManager;
import com.mints.fiveworld.manager.ad.CsjGroMoreManager;
......@@ -132,6 +133,7 @@ public class OutTimeFull {
@Override
public void onFullVideoLoadFail(AdError adError) {
AlarmManager.getInstance().closeAlarming();
LogUtil.d(TAG, "gromore体外定时全屏广告--> 3、onFullVideoLoadFail onError " + adError.code + adError.message);
AdReportManager.INSTANCE.eventFull(
......@@ -160,6 +162,8 @@ public class OutTimeFull {
@Override
public void onFullVideoAdLoad() {
AlarmManager.getInstance().closeAlarming();
LogUtil.d(TAG, "gromore体外定时全屏广告--> 3、Gromore 新插屏onFullVideoAdLoad ");
if (mTTFullVideoAd != null) {
adcode = mTTFullVideoAd.getAdNetworkRitId();
......
package com.mints.fiveworld.ad.wifi
import android.app.Activity
import android.os.Bundle
import com.mints.fiveworld.ad.AdReportManager
import com.mints.fiveworld.ad.full.Home_OutTimeFull
import com.mints.fiveworld.ad.half.Home_NewOutTimeFull
import com.mints.fiveworld.common.Constant
import com.mints.fiveworld.common.random.HitChanceKeeper
import com.mints.fiveworld.manager.UmengManager
import com.mints.fiveworld.manager.ad.CsjGroMoreManager
import com.mints.fiveworld.mvp.model.WeightBean
import com.mints.fiveworld.ui.activitys.keepalive.*
import com.mints.fiveworld.utils.ForegroundOrBackground
import com.mints.fiveworld.utils.TimeRender
import com.mints.fiveworld.utils.IntentUtils
import com.mints.fiveworld.utils.LogUtil
import java.util.*
/**
*
* 应用外定时
*
* 广告形式-Gromore的插屏、全屏
*/
class HomeAppOutAdManager private constructor() {
companion object {
val instance: HomeAppOutAdManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
HomeAppOutAdManager()
}
}
// 当前广告类型
private var currentAdType = ""
private var weightList: ArrayList<WeightBean>? = null
private var mType = 0
private var mTransparentType: String? = null
@Volatile
private var isAdLoadOk = true
private var lastLoadAdTime = 0L
fun getAdLoadOk(): Boolean {
if (!TimeRender.isOverspedMin2(lastLoadAdTime, 1)) {
LogUtil.d("定时广告是否加载中...$isAdLoadOk")
return isAdLoadOk
}
LogUtil.d("定时广告未在加载中...")
return true
}
fun resetAdLoadOk() {
isAdLoadOk = true
}
/**
* 体外定时广告加载成功,开始调用sdk
*/
fun routeToHomeClick() {
val curClz = BoostHomeActivity::class.java
// 应用外定时动画 载体优化
val bundle = Bundle()
bundle.putInt(TransparentActivity.TIMING_TYPE, mType)
bundle.putString(TransparentActivity.TRANSPARENT_TYPE, mTransparentType)
IntentUtils.startActivity3(
Constant.CARRIER_OUT_HOME_CLICK,
bundle,
curClz,
true,
IntentUtils.SCENE_TYPE_ANIM
)
}
/**
* 体外定时加载广告,必须传入activity
*/
fun loadWifiAd(
activity: Activity,
type: Int,
transparentType: String? = TransparentActivity.TRANSPARENT_TYPE_HOME_CLICK
) {
mType = type
mTransparentType = transparentType
currentAdType = getRandomWeightType()
isAdLoadOk = false
lastLoadAdTime = System.currentTimeMillis()
when (currentAdType) {
Constant.GROMORE_INSERTSCREEN_AD -> {
preLoadInterstitialGroMore(activity)
}
Constant.GROMORE_FULL_AD -> {
preLoadFullGroMore(activity)
}
}
}
/**
* 体外定时插屏
*/
private fun preLoadInterstitialGroMore(activity: Activity) {
Home_NewOutTimeFull.getInstance().loadFullAd(activity)
}
/**
* 体外定时全屏
*/
private fun preLoadFullGroMore(activity: Activity) {
Home_OutTimeFull.getInstance().loadFullAd(activity)
}
/**
* 体外定时广告展示
*/
fun tempShowAd(_activity: Activity) {
// 前台 正常
if (ForegroundOrBackground.isForeground2()) {
UmengManager.onEvent(AdReportManager.EventType.EVENT_TYPE_HOME_CLICK_CSJ_CACHE_SUC_FOREGROUND.name)
showInterstitial(_activity, null)
return
}
// 用户手动 最小化 调用sdk展示广告
UmengManager.onEvent(AdReportManager.EventType.EVENT_TYPE_HOME_CLICK_CSJ_CACHE_SUC_BACKGROUND.name)
val bundle = Bundle()
bundle.putBoolean(HomeTempTransparentActivity.TEMP_TYPE, true)
IntentUtils.startActivity3(
Constant.CARRIER_OUT_TRANSPARENT_ACTIVITY,
bundle,
HomeTempTransparentActivity::class.java,
true,
IntentUtils.TIME_TYPE_HANDS_TRANS
)
}
/**
* 展示广告
*/
fun showInterstitial(_activity: Activity, wifiAdStatusListener: WifiAdStatusListener?) {
when (currentAdType) {
Constant.GROMORE_INSERTSCREEN_AD -> {
Home_NewOutTimeFull.getInstance()
.showFullAd(
_activity,
wifiAdStatusListener,
Constant.CARRIER_OUT_HOME_CLICK
)
}
Constant.GROMORE_FULL_AD -> {
Home_OutTimeFull.getInstance()
.showFullAd(_activity, wifiAdStatusListener, Constant.CARRIER_OUT_HOME_CLICK)
}
else -> {
wifiAdStatusListener?.adFail()
}
}
}
/**
* 定义广告类型规则
*/
private fun getRandomWeightType(): String {
if (weightList != null) {
weightList!!.clear()
} else {
weightList = ArrayList<WeightBean>()
}
var weight = 0
val fullInterstitialWeight = CsjGroMoreManager.APP_FULL_NEW_INTERSTITIAL_WEIGHT
if (fullInterstitialWeight > 0) {
weightList!!.add(WeightBean(fullInterstitialWeight, Constant.GROMORE_FULL_AD))
weight += fullInterstitialWeight
}
val interstitialWeight = CsjGroMoreManager.APP_NEW_INTERSTITIAL_WEIGHT
if (interstitialWeight > 0) {
weightList!!.add(WeightBean(interstitialWeight, Constant.GROMORE_INSERTSCREEN_AD))
weight += interstitialWeight
}
return HitChanceKeeper.getRandomWeightChance(weight, weightList, Constant.GROMORE_FULL_AD)
}
}
\ No newline at end of file
......@@ -56,6 +56,8 @@ public class AlarmManager implements Handler.Callback {
private static final String KEY_HANDLER_SEND_MILLIS = "handler_send_millis"; // 定时send时间戳
private static final int HANDLER_TIMEOUT_TIME_INTERVAL = 1; //单位分钟 定时器超时时间
public static boolean isAlarming = false;//定时出发中-true表示请求中,只校验广告成功,失败,3分钟
/**
* 但凡有这个接口就代表这个activity是由当前这个manager触发的,并且会导致计时器更新
*/
......@@ -459,6 +461,9 @@ public class AlarmManager implements Handler.Callback {
if (expire) {
// home键场景需要判断
isAlarming = true;
UmengManager.INSTANCE.onEvent(AdReportManager.EventType.EVENT_TYPE_SCENCE_OUT_TIME10.name());
AdReportManager.INSTANCE.eventScene(ForegroundOrBackground.isForeground2() ? AdReportManager.INNER_IN : AdReportManager.INNER_OUT,
......@@ -487,6 +492,14 @@ public class AlarmManager implements Handler.Callback {
return false;
}
//定时请求中-防止界面重叠,因为把加载成功的拦截去掉了
if (AlarmManager.isAlarming) {
LogUtil.d(TAG, "***当前类型:HOME-CLICK *** ->>>>>>>10分钟定时请求中 -防止界面重叠,因为把加载成功的拦截去掉了<<<<<<<-");
UmengManager.INSTANCE.onEvent(AdReportManager.EventType.EVENT_TYPE_HOME_CLICK_TIMER.name());
return false;
}
// 体外场景或定时 进入透明页加载广告时,防止此段空白时间弹出广告
if (!AppOutWifiAdManager.Companion.getInstance().getAdLoadOk() ||
!WifiAdManager.Companion.getInstance().getAdLoadOk()) {
......@@ -644,6 +657,9 @@ public class AlarmManager implements Handler.Callback {
Log.d(TAG, "exeActionForTime() called with: wifiActionTime = [" + wifiActionTime + "]");
long now = System.currentTimeMillis();
if (BaseUtils.INSTANCE.isExpire(wifiActionTime, WIFI_MINTER * 60 * 1000L)) {
closeAlarming();
//每3分钟 wifi界面功能重置
AdReportManager.INSTANCE.eventScene(
AdReportManager.INNER_OUT,
......@@ -723,4 +739,11 @@ public class AlarmManager implements Handler.Callback {
mSettings.writeLong(KEY_USER_ACTION_TIME, 0L);
}
/**
* home键场景 关闭定时请求
*/
public void closeAlarming() {
isAlarming = false;
}
}
......@@ -14,6 +14,7 @@ import com.mints.fiveworld.ad.wifi.WifiAdManager;
import com.mints.fiveworld.common.Constant;
import com.mints.fiveworld.manager.UmengManager;
import com.mints.fiveworld.manager.wifi.WifiDataManager;
import com.mints.fiveworld.ui.activitys.keepalive.TranHomeActivity;
import com.mints.fiveworld.ui.activitys.keepalive.TransparentActivity;
import com.mints.fiveworld.utils.ForegroundOrBackground;
import com.mints.fiveworld.utils.IntentUtils;
......@@ -242,13 +243,15 @@ public class HomePopManager implements Handler.Callback {
currentType = 0;
}
UmengManager.INSTANCE.onEvent(AdReportManager.EventType.EVENT_TYPE_HOME_CLICK_AFTER_CHECK.name());
LogUtil.d(TAG, "home键 showTimingActivity: START!");
// 展示透明界面去预加载广告
Bundle bundle = new Bundle();
bundle.putInt(TransparentActivity.TIMING_TYPE, currentType++);
bundle.putString(TransparentActivity.TRANSPARENT_TYPE, TransparentActivity.TRANSPARENT_TYPE_HOME_CLICK);
IntentUtils.startActivity3(Constant.CARRIER_OUT_TRANSPARENT_ACTIVITY, bundle, TransparentActivity.class, false, IntentUtils.SCENE_TYPE_TRANS);
IntentUtils.startActivity3(Constant.CARRIER_OUT_TRANSPARENT_ACTIVITY, bundle, TranHomeActivity.class, false, IntentUtils.SCENE_TYPE_TRANS);
}
/**
......
......@@ -10,6 +10,7 @@ import com.mints.fiveworld.R
import com.mints.fiveworld.ad.AdReportManager
import com.mints.fiveworld.ad.express.ExpressAdCallback
import com.mints.fiveworld.ad.express.OutSimpleExpress
import com.mints.fiveworld.ad.wifi.HomeAppOutAdManager
import com.mints.fiveworld.common.Constant
import com.mints.fiveworld.keepalive.AlarmManager
import com.mints.fiveworld.keepalive.HomePopManager
......@@ -83,10 +84,10 @@ class BoostHomeActivity : BaseOutActivity(), AlarmManager.AlarmManagerManagedAct
private fun initView() {
frameLayout = findViewById<RoundRectLayout>(R.id.fl_ad_boost_home)
ccav_speed = findViewById<CircleCleanAnimationView>(R.id.ccav_speed_home)
iv_close_boost = findViewById<ImageView>(R.id.iv_close_boost_home)
tvContent_boost = findViewById<TextView>(R.id.tvContent_boost_home)
adContainer = findViewById<LinearLayoutCompat>(R.id.adContainer_home)
ccav_speed = findViewById(R.id.ccav_speed_home)
iv_close_boost = findViewById(R.id.iv_close_boost_home)
tvContent_boost = findViewById(R.id.tvContent_boost_home)
adContainer = findViewById(R.id.adContainer_home)
iv_close_boost?.setOnClickListener {
finish()
overridePendingTransition(0, 0)
......@@ -152,7 +153,7 @@ class BoostHomeActivity : BaseOutActivity(), AlarmManager.AlarmManagerManagedAct
// 动画结束
UmengManager.onEvent(AdReportManager.EventType.EVENT_TYPE_HOME_CLICK_TRANSPARENT_ANIMATION_END.name)
// HomeAppOutAdManager.instance.tempShowAd(this@BoostHomeActivity)
HomeAppOutAdManager.instance.tempShowAd(this@BoostHomeActivity)
}
}
......
package com.mints.fiveworld.ui.activitys.keepalive
import android.app.Activity
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import com.mints.fiveworld.R
import com.mints.fiveworld.ad.AdReportManager
import com.mints.fiveworld.ad.wifi.HomeAppOutAdManager
import com.mints.fiveworld.ad.wifi.WifiAdStatusListener
import com.mints.fiveworld.manager.UmengManager
import com.mints.fiveworld.utils.StatusBarUtil
/**
*
* 描述:透明activity,用于加载广告,用户手动最小化 HomeClick场景
*/
class HomeTempTransparentActivity : Activity(), OutManagedActivity {
companion object {
const val TEMP_TYPE = "TEMP_TYPE"
const val CARRIER_TYPE = "CARRIER_TYPE"
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_trans_home_temp)
StatusBarUtil.transparencyBar(this)
// 透明页展示
UmengManager.onEvent(AdReportManager.EventType.EVENT_TYPE_HOME_CLICK_SHOW_AD_TRANS.name)
HomeAppOutAdManager.instance.showInterstitial(this, object : WifiAdStatusListener {
override fun adSuccess() {
}
override fun adFail() {
finish()
overridePendingTransition(0, 0)
}
override fun adClose() {
finish()
overridePendingTransition(0, 0)
}
})
Handler(Looper.getMainLooper()).postDelayed({
if (!this.isFinishing) {
// 透明页自动页面
UmengManager.onEvent(AdReportManager.EventType.EVENT_TYPE_HOME_CLICK_SHOW_AD_TRANS_AUTO_CLOSE.name)
finish()
overridePendingTransition(0, 0)
}
}, 5000);
}
}
package com.mints.fiveworld.ui.activitys.keepalive
import android.app.Activity
import android.os.Bundle
import com.mints.fiveworld.MintsApplication
import com.mints.fiveworld.R
import com.mints.fiveworld.ad.express.OutSimpleExpress
import com.mints.fiveworld.ad.AdReportManager
import com.mints.fiveworld.ad.wifi.HomeAppOutAdManager
import com.mints.fiveworld.common.Constant
import com.mints.fiveworld.manager.UmengManager
import com.mints.fiveworld.utils.StatusBarUtil
/**
* 描述:HomeClick 透明activity,用于加载广告
*/
class TranHomeActivity : Activity(), OutManagedActivity {
private var mType = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_trans_home)
StatusBarUtil.transparencyBar(this)
// base extras
intent.extras?.let {
// 当前定时type
mType = it.getInt(TransparentActivity.TIMING_TYPE, 0)
}
loadTimeAd()
finish()
overridePendingTransition(0, 0)
}
/**
* 加载定时广告
*/
private fun loadTimeAd() {
AdReportManager.eventScene(
AdReportManager.INNER_OUT,
System.currentTimeMillis(),
Constant.CARRIER_OUT_TRANSPARENT_ACTIVITY,
"HomeClick透明页",
AdReportManager.EVENT_TYPE_SCENCE_SHOW
)
UmengManager.onEvent(AdReportManager.EventType.EVENT_TYPE_HOME_CLICK_TRANSPARENT_SHOW_SUC.name)
HomeAppOutAdManager.instance.loadWifiAd(
this,
mType,
TransparentActivity.TRANSPARENT_TYPE_HOME_CLICK
)
// 预加载信息流
OutSimpleExpress.instance.loadADFrameLayout(
MintsApplication.getContext(),
Constant.CARRIER_OUT_HOME_CLICK
)
}
}
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="1px"
android:layout_height="1px"
android:background="@color/transparent" />
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="1px"
android:layout_height="1px"
android:background="@color/transparent" />
\ 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