Commit 775481e4 authored by mengcuiguang's avatar mengcuiguang

Merge branch 'dev_ad' of http://39.97.65.143:81/android/android_goodmoney into dev_ad

parents 0120cce4 706d5c80
...@@ -194,6 +194,9 @@ ...@@ -194,6 +194,9 @@
<activity <activity
android:name=".ui.activitys.SplashKsADActivity" android:name=".ui.activitys.SplashKsADActivity"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<activity
android:name=".ui.activitys.SplashCsjADActivity"
android:screenOrientation="portrait" />
<activity <activity
android:name=".ui.activitys.MorningClockActivity" android:name=".ui.activitys.MorningClockActivity"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
......
...@@ -12,7 +12,6 @@ import androidx.multidex.MultiDexApplication; ...@@ -12,7 +12,6 @@ import androidx.multidex.MultiDexApplication;
import com.hjq.toast.ToastUtils; import com.hjq.toast.ToastUtils;
import com.mints.goodmoney.common.Constant; import com.mints.goodmoney.common.Constant;
import com.mints.goodmoney.manager.ChannelManager;
import com.mints.goodmoney.manager.KsManager; import com.mints.goodmoney.manager.KsManager;
import com.mints.goodmoney.manager.LiebaoManager; import com.mints.goodmoney.manager.LiebaoManager;
import com.mints.goodmoney.manager.MhManager; import com.mints.goodmoney.manager.MhManager;
...@@ -23,7 +22,6 @@ import com.mints.goodmoney.manager.TzManager; ...@@ -23,7 +22,6 @@ import com.mints.goodmoney.manager.TzManager;
import com.mints.goodmoney.manager.WnManager; import com.mints.goodmoney.manager.WnManager;
import com.mints.goodmoney.manager.YlVideoManager; import com.mints.goodmoney.manager.YlVideoManager;
import com.mints.goodmoney.manager.YlhAdManager; import com.mints.goodmoney.manager.YlhAdManager;
import com.mints.goodmoney.manager.ZhangyueManager;
import com.mints.goodmoney.net.LoanService; import com.mints.goodmoney.net.LoanService;
import com.mints.goodmoney.utils.ForegroundOrBackground; import com.mints.goodmoney.utils.ForegroundOrBackground;
import com.mints.goodmoney.utils.LogUtil; import com.mints.goodmoney.utils.LogUtil;
......
package com.mints.goodmoney.ui.activitys
import android.view.KeyEvent
import android.view.View
import android.view.ViewGroup
import com.bytedance.sdk.openadsdk.AdSlot
import com.bytedance.sdk.openadsdk.TTAdNative
import com.bytedance.sdk.openadsdk.TTSplashAd
import com.mints.goodmoney.R
import com.mints.goodmoney.manager.TTNativeExpressManager
import com.mints.goodmoney.manager.TtCsjAdManager
import com.mints.goodmoney.ui.activitys.base.BaseActivity
import com.mints.library.net.netstatus.NetUtils
private val TAG = SplashCsjADActivity::class.java.simpleName
/**
* 后台返回时每次都展示 快手广告
*/
class SplashCsjADActivity : BaseActivity() {
private var container: ViewGroup? = null
private var mIsPaused = false
var canJump = false
private var mTTAdNative: TTAdNative? = null
override fun getContentViewLayoutID(): Int {
return R.layout.activity_splash_ylh
}
override fun initViewsAndEvents() {
if (!NetUtils.isNetworkConnected(context)) {
finish()
} else {
try {
container = findViewById<View>(R.id.splash_container) as ViewGroup
//step2:创建TTAdNative对象
val ttNativeExpressManager = TTNativeExpressManager()
mTTAdNative = ttNativeExpressManager.initTTAd(false)
loadSplashAd()
} catch (e: Exception) {
readyGoOtherActivity()
}
}
}
override fun isApplyKitKatTranslucency(): Boolean {
return false
}
private fun loadSplashAd() {
//step3:创建开屏广告请求参数AdSlot
var adSlot: AdSlot? = AdSlot.Builder()
.setCodeId(TtCsjAdManager.TT_AD_SPLASH)
.setImageAcceptedSize(1080, 1920)
.build()
mTTAdNative!!.loadSplashAd(adSlot, object : TTAdNative.SplashAdListener {
override fun onError(p0: Int, p1: String?) {
readyGoOtherActivity()
}
override fun onTimeout() {
readyGoOtherActivity()
}
override fun onSplashAdLoad(ad: TTSplashAd?) {
if (ad == null) {
readyGoOtherActivity()
return
}
val splashView = ad.splashView
if (container != null && !isFinishing) {
container!!.removeAllViews()
//把SplashView 添加到ViewGroup中,注意开屏广告view:width >=70%屏幕宽;height >=50%屏幕高
container!!.addView(splashView)
//设置不开启开屏广告倒计时功能以及不显示跳过按钮,如果这么设置,您需要自定义倒计时逻辑
//ad.setNotAllowSdkCountdown();
} else {
readyGoOtherActivity()
}
ad.setSplashInteractionListener(object : TTSplashAd.AdInteractionListener {
override fun onAdClicked(p0: View?, p1: Int) {
}
override fun onAdShow(p0: View?, p1: Int) {
}
override fun onAdSkip() {
readyGoOtherActivity()
}
override fun onAdTimeOver() {
readyGoOtherActivity()
}
})
}
}, 3000)
}
/**
* 设置一个变量来控制当前开屏页面是否可以跳转,当开屏广告为普链类广告时,点击会打开一个广告落地页,此时开发者还不能打开自己的App主页。当从广告落地页返回以后,
* 才可以跳转到开发者自己的App主页;当开屏广告是App类广告时只会下载App。
*/
private operator fun next() {
if (mIsPaused) {
canJump = true
} else {
readyGoOtherActivity()
}
}
override fun onPause() {
super.onPause()
mIsPaused = true
}
override fun onResume() {
super.onResume()
mIsPaused = false
if (canJump) {
next()
}
}
/**
* 开屏页一定要禁止用户对返回按钮的控制,否则将可能导致用户手动退出了App而广告无法正常曝光和计费
*/
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
return if (keyCode == KeyEvent.KEYCODE_BACK) {
true
} else super.onKeyDown(keyCode, event)
}
private fun readyGoOtherActivity() {
finish()
}
}
\ No newline at end of file
...@@ -9,6 +9,7 @@ import android.text.TextUtils; ...@@ -9,6 +9,7 @@ import android.text.TextUtils;
import com.mints.goodmoney.manager.TrackManager; import com.mints.goodmoney.manager.TrackManager;
import com.mints.goodmoney.mvp.presenters.VersionUpdatePresenter; import com.mints.goodmoney.mvp.presenters.VersionUpdatePresenter;
import com.mints.goodmoney.ui.activitys.SplashADActivity; import com.mints.goodmoney.ui.activitys.SplashADActivity;
import com.mints.goodmoney.ui.activitys.SplashCsjADActivity;
import com.mints.goodmoney.ui.activitys.SplashKsADActivity; import com.mints.goodmoney.ui.activitys.SplashKsADActivity;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
...@@ -23,14 +24,15 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall ...@@ -23,14 +24,15 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
private static ForegroundOrBackground instance; private static ForegroundOrBackground instance;
public int count = 0; public int count = 0;
private volatile boolean isKsSplash = false; private volatile boolean isYlhSplash = false;
//获取当前最上层的activity //获取当前最上层的activity
private static WeakReference<Activity> app_activity; private static WeakReference<Activity> app_activity;
private VersionUpdatePresenter vup; private VersionUpdatePresenter vup;
private WeakReference<Activity> reference; private WeakReference<Activity> reference;
private Intent ylhIntent; private Intent ylhIntent;
private Intent ksIntent; // private Intent ksIntent;
private Intent csjIntent;
public static ForegroundOrBackground init(Application application) { public static ForegroundOrBackground init(Application application) {
if (instance == null) { if (instance == null) {
...@@ -101,10 +103,10 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall ...@@ -101,10 +103,10 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
if (count == 0) { if (count == 0) {
// LogUtil.d("ForegroundOrBackground", System.currentTimeMillis() - leaveTime + " onActivityStarted"); // LogUtil.d("ForegroundOrBackground", System.currentTimeMillis() - leaveTime + " onActivityStarted");
// 60秒后打开应用 显示开屏广告 // 60秒后打开应用 显示开屏广告
if (System.currentTimeMillis() - leaveTime >= 60000) { if (System.currentTimeMillis() - leaveTime >= 3000) {
if (isKsSplash) { if (isYlhSplash) {
isKsSplash = false; isYlhSplash = false;
if (ylhIntent == null) { if (ylhIntent == null) {
// 优量汇广告 // 优量汇广告
...@@ -112,13 +114,19 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall ...@@ -112,13 +114,19 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
} }
activity.startActivity(ylhIntent); activity.startActivity(ylhIntent);
} else { } else {
isKsSplash = true; isYlhSplash = true;
if (ksIntent == null) { if (csjIntent == null) {
// 快手广告 // 快手广告
ksIntent = new Intent(activity, SplashKsADActivity.class); csjIntent = new Intent(activity, SplashCsjADActivity.class);
} }
activity.startActivity(ksIntent); activity.startActivity(csjIntent);
// if (ksIntent == null) {
// // 快手广告
// ksIntent = new Intent(activity, SplashKsADActivity.class);
// }
// activity.startActivity(ksIntent);
} }
} }
......
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