Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_goodmoney
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
android
android_goodmoney
Commits
cce54922
Commit
cce54922
authored
Oct 26, 2020
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优量汇升级最新版
parent
259f4d8a
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
658 additions
and
188 deletions
+658
-188
build.gradle
GoodMoney/app/build.gradle
+2
-3
GDTSDK.unionNoPlugin.4.270.1140.aar
GoodMoney/app/libs/GDTSDK.unionNoPlugin.4.270.1140.aar
+0
-0
GDTSDK.unionNormal.4.232.1102.aar
GoodMoney/app/libs/GDTSDK.unionNormal.4.232.1102.aar
+0
-0
AndroidManifest.xml
GoodMoney/app/src/main/AndroidManifest.xml
+4
-5
SplashADActivity.kt
...java/com/mints/goodmoney/ui/activitys/SplashADActivity.kt
+0
-175
SplashADActivity2.kt
...ava/com/mints/goodmoney/ui/activitys/SplashADActivity2.kt
+175
-0
SplashActivity2.java
...ava/com/mints/goodmoney/ui/activitys/SplashActivity2.java
+356
-0
SplashYlhActivity.kt
...ava/com/mints/goodmoney/ui/activitys/SplashYlhActivity.kt
+4
-5
activity_splash2.xml
GoodMoney/app/src/main/res/layout/activity_splash2.xml
+117
-0
No files found.
GoodMoney/app/build.gradle
View file @
cce54922
...
...
@@ -184,9 +184,8 @@ dependencies {
implementation
(
name:
'msa_mdid_1.0.13'
,
ext:
'aar'
)
// 穿山甲广告
implementation
(
name:
'open_ad_sdk'
,
ext:
'aar'
)
// implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.6'
// 广点通广告 腾讯
implementation
(
name:
'GDTSDK.unionNo
rmal.4.232.1102
'
,
ext:
'aar'
)
implementation
(
name:
'GDTSDK.unionNo
Plugin.4.270.1140
'
,
ext:
'aar'
)
// shareSdk
implementation
project
(
':shareSdkLib'
)
// umeng
...
...
@@ -196,7 +195,7 @@ dependencies {
// TalkingDada
implementation
files
(
'libs/SaaS_AppAnalytics_Android_SDK_V4.0.36.jar'
)
// 一览视频
implementation
(
"com.yilan.sdk:ui:2.
0.0.4
"
)
{
implementation
(
"com.yilan.sdk:ui:2.
5.0.10
"
)
{
exclude
group:
'com.yilan.sdk'
,
module:
'toutiao'
exclude
group:
'com.yilan.sdk'
,
module:
'gdt'
}
...
...
GoodMoney/app/libs/GDTSDK.unionNoPlugin.4.270.1140.aar
0 → 100644
View file @
cce54922
File added
GoodMoney/app/libs/GDTSDK.unionNormal.4.232.1102.aar
deleted
100644 → 0
View file @
259f4d8a
File deleted
GoodMoney/app/src/main/AndroidManifest.xml
View file @
cce54922
...
...
@@ -87,7 +87,7 @@
android:value=
"${JPUSH_CHANNEL}"
/>
<activity
android:name=
".ui.activitys.Splash
YlhActivity
"
android:name=
".ui.activitys.Splash
Activity2
"
android:screenOrientation=
"portrait"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
...
...
@@ -133,8 +133,6 @@
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".ui.activitys.CoinRecordActivity"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".ui.activitys.SplashADActivity"
android:screenOrientation=
"portrait"
/>
<service
android:name=
".service.UpdateService"
...
...
@@ -239,14 +237,14 @@
android:resource=
"@xml/file_paths"
/>
</provider>
<!-- 广点通广告 -->
<uses-library
android:name=
"org.apache.http.legacy"
android:required=
"false"
/>
<!-- 声明SDK所需要的组件 -->
<service
android:name=
"com.qq.e.comm.DownloadService"
android:exported=
"false"
/>
<!-- 请开发者注意字母的大小写,ADActivity,而不是AdActivity -->
<activity
android:name=
"com.qq.e.ads.ADActivity"
android:configChanges=
"keyboard|keyboardHidden|orientation|screenSize"
/>
...
...
@@ -256,6 +254,7 @@
android:screenOrientation=
"portrait"
/>
<activity
android:name=
"com.qq.e.ads.LandscapeADActivity"
tools:replace=
"android:screenOrientation"
android:configChanges=
"keyboard|keyboardHidden|orientation|screenSize"
android:screenOrientation=
"landscape"
/>
</application>
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/activitys/SplashADActivity.kt
deleted
100644 → 0
View file @
259f4d8a
package
com.mints.goodmoney.ui.activitys
import
android.app.Activity
import
android.os.Handler
import
android.os.Looper
import
android.util.Log
import
android.view.KeyEvent
import
android.view.View
import
android.view.ViewGroup
import
android.widget.TextView
import
com.mints.goodmoney.R
import
com.mints.goodmoney.manager.YlhAdManager
import
com.mints.goodmoney.ui.activitys.base.BaseActivity
import
com.mints.library.net.netstatus.NetUtils
import
com.qq.e.ads.splash.SplashAD
import
com.qq.e.ads.splash.SplashADListener
import
com.qq.e.comm.util.AdError
/**
* 后台返回时每次都展示
*/
class
SplashADActivity
:
BaseActivity
(),
SplashADListener
{
private
var
splashAD
:
SplashAD
?
=
null
private
var
container
:
ViewGroup
?
=
null
private
val
skipView
:
TextView
?
=
null
var
canJump
=
false
/**
* 为防止无广告时造成视觉上类似于"闪退"的情况,设定无广告时页面跳转根据需要延迟一定时间,demo
* 给出的延时逻辑是从拉取广告开始算开屏最少持续多久,仅供参考,开发者可自定义延时逻辑,如果开发者采用demo
* 中给出的延时逻辑,也建议开发者考虑自定义minSplashTimeWhenNoAD的值(单位ms)
*/
private
val
minSplashTimeWhenNoAD
=
3000
/**
* 记录拉取广告的时间
*/
private
var
fetchSplashADTime
:
Long
=
0
private
val
handler
=
Handler
(
Looper
.
getMainLooper
())
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
fetchSplashAD
(
this
,
container
,
skipView
,
YlhAdManager
.
YLH_AD_SPLASH_POSTID
,
this
,
0
)
}
catch
(
e
:
Exception
)
{
readyGoOtherActivity
()
}
}
}
override
fun
isApplyKitKatTranslucency
():
Boolean
{
return
false
}
/**
* 拉取开屏广告,开屏广告的构造方法有3种,详细说明请参考开发者文档。
*
* @param activity 展示广告的activity
* @param adContainer 展示广告的大容器
* @param skipContainer 自定义的跳过按钮:传入该view给SDK后,SDK会自动给它绑定点击跳过事件。SkipView的样式可以由开发者自由定制,其尺寸限制请参考activity_splash.xml或者接入文档中的说明。
* @param posId 广告位ID
* @param adListener 广告状态监听器
* @param fetchDelay 拉取广告的超时时长:取值范围[3000, 5000],设为0表示使用广点通SDK默认的超时时长。
*/
private
fun
fetchSplashAD
(
activity
:
Activity
,
adContainer
:
ViewGroup
?,
skipContainer
:
View
?,
posId
:
String
,
adListener
:
SplashADListener
,
fetchDelay
:
Int
)
{
fetchSplashADTime
=
System
.
currentTimeMillis
()
splashAD
=
SplashAD
(
activity
,
skipContainer
,
posId
,
adListener
,
fetchDelay
)
splashAD
!!
.
fetchAndShowIn
(
adContainer
)
}
override
fun
onADPresent
()
{
Log
.
i
(
"AD_DEMO"
,
"SplashADPresent"
)
}
override
fun
onADClicked
()
{
Log
.
i
(
"AD_DEMO"
,
"SplashADClicked clickUrl: "
+
if
(
splashAD
!!
.
ext
!=
null
)
splashAD
!!
.
ext
[
"clickUrl"
]
else
""
)
}
/**
* 倒计时回调,返回广告还将被展示的剩余时间。
* 通过这个接口,开发者可以自行决定是否显示倒计时提示,或者还剩几秒的时候显示倒计时
*
* @param millisUntilFinished 剩余毫秒数
*/
override
fun
onADTick
(
millisUntilFinished
:
Long
)
{
Log
.
i
(
"AD_DEMO"
,
"SplashADTick "
+
millisUntilFinished
+
"ms"
)
if
(
skipView
!=
null
)
{
skipView
.
text
=
String
.
format
(
SKIP_TEXT
,
Math
.
round
(
millisUntilFinished
/
1000f
))
}
}
override
fun
onADExposure
()
{
Log
.
i
(
"AD_DEMO"
,
"SplashADExposure"
)
}
override
fun
onADLoaded
(
expireTimestamp
:
Long
)
{
Log
.
i
(
"AD_DEMO"
,
"SplashADFetch expireTimestamp: "
+
expireTimestamp
+
", eCPMLevel = "
+
splashAD
!!
.
ecpmLevel
)
}
override
fun
onADDismissed
()
{
Log
.
i
(
"AD_DEMO"
,
"SplashADDismissed"
)
next
()
}
override
fun
onNoAD
(
error
:
AdError
)
{
val
str
=
String
.
format
(
"LoadSplashADFail, eCode=%d, errorMsg=%s"
,
error
.
errorCode
,
error
.
errorMsg
)
Log
.
i
(
"AD_DEMO"
,
str
)
/**
* 为防止无广告时造成视觉上类似于"闪退"的情况,设定无广告时页面跳转根据需要延迟一定时间,demo
* 给出的延时逻辑是从拉取广告开始算开屏最少持续多久,仅供参考,开发者可自定义延时逻辑,如果开发者采用demo
* 中给出的延时逻辑,也建议开发者考虑自定义minSplashTimeWhenNoAD的值
*/
val
alreadyDelayMills
=
System
.
currentTimeMillis
()
-
fetchSplashADTime
//从拉广告开始到onNoAD已经消耗了多少时间
val
shouldDelayMills
=
if
(
alreadyDelayMills
>
minSplashTimeWhenNoAD
)
0
else
minSplashTimeWhenNoAD
-
alreadyDelayMills
//为防止加载广告失败后立刻跳离开屏可能造成的视觉上类似于"闪退"的情况,根据设置的minSplashTimeWhenNoAD
// 计算出还需要延时多久
handler
.
postDelayed
({
readyGoOtherActivity
()
},
shouldDelayMills
)
}
/**
* 设置一个变量来控制当前开屏页面是否可以跳转,当开屏广告为普链类广告时,点击会打开一个广告落地页,此时开发者还不能打开自己的App主页。当从广告落地页返回以后,
* 才可以跳转到开发者自己的App主页;当开屏广告是App类广告时只会下载App。
*/
private
operator
fun
next
()
{
if
(
canJump
)
{
readyGoOtherActivity
()
}
else
{
canJump
=
true
}
}
override
fun
onPause
()
{
super
.
onPause
()
canJump
=
false
}
override
fun
onResume
()
{
super
.
onResume
()
if
(
canJump
)
{
next
()
}
canJump
=
true
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
handler
.
removeCallbacksAndMessages
(
null
)
}
/**
* 开屏页一定要禁止用户对返回按钮的控制,否则将可能导致用户手动退出了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
()
}
companion
object
{
private
const
val
SKIP_TEXT
=
"点击跳过 %d"
}
}
\ No newline at end of file
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/activitys/SplashADActivity2.kt
0 → 100644
View file @
cce54922
//package com.mints.goodmoney.ui.activitys
//
//import android.app.Activity
//import android.os.Handler
//import android.os.Looper
//import android.util.Log
//import android.view.KeyEvent
//import android.view.View
//import android.view.ViewGroup
//import android.widget.TextView
//import com.mints.goodmoney.R
//import com.mints.goodmoney.manager.YlhAdManager
//import com.mints.goodmoney.ui.activitys.base.BaseActivity
//import com.mints.library.net.netstatus.NetUtils
//import com.qq.e.ads.splash.SplashAD
//import com.qq.e.ads.splash.SplashADListener
//import com.qq.e.comm.util.AdError
//
///**
// * 后台返回时每次都展示
// */
//class SplashADActivity2 : BaseActivity(), SplashADListener {
// private var splashAD: SplashAD? = null
// private var container: ViewGroup? = null
// private val skipView: TextView? = null
// var canJump = false
//
// /**
// * 为防止无广告时造成视觉上类似于"闪退"的情况,设定无广告时页面跳转根据需要延迟一定时间,demo
// * 给出的延时逻辑是从拉取广告开始算开屏最少持续多久,仅供参考,开发者可自定义延时逻辑,如果开发者采用demo
// * 中给出的延时逻辑,也建议开发者考虑自定义minSplashTimeWhenNoAD的值(单位ms)
// */
// private val minSplashTimeWhenNoAD = 3000
//
// /**
// * 记录拉取广告的时间
// */
// private var fetchSplashADTime: Long = 0
// private val handler = Handler(Looper.getMainLooper())
// 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
// fetchSplashAD(this, container, skipView, YlhAdManager.YLH_AD_SPLASH_POSTID, this, 0)
// } catch (e: Exception) {
// readyGoOtherActivity()
// }
// }
// }
//
// override fun isApplyKitKatTranslucency(): Boolean {
// return false
// }
//
// /**
// * 拉取开屏广告,开屏广告的构造方法有3种,详细说明请参考开发者文档。
// *
// * @param activity 展示广告的activity
// * @param adContainer 展示广告的大容器
// * @param skipContainer 自定义的跳过按钮:传入该view给SDK后,SDK会自动给它绑定点击跳过事件。SkipView的样式可以由开发者自由定制,其尺寸限制请参考activity_splash.xml或者接入文档中的说明。
// * @param posId 广告位ID
// * @param adListener 广告状态监听器
// * @param fetchDelay 拉取广告的超时时长:取值范围[3000, 5000],设为0表示使用广点通SDK默认的超时时长。
// */
// private fun fetchSplashAD(activity: Activity, adContainer: ViewGroup?, skipContainer: View?,
// posId: String, adListener: SplashADListener, fetchDelay: Int) {
// fetchSplashADTime = System.currentTimeMillis()
// splashAD = SplashAD(activity, skipContainer, posId, adListener, fetchDelay)
// splashAD!!.fetchAndShowIn(adContainer)
// }
//
// override fun onADPresent() {
// Log.i("AD_DEMO", "SplashADPresent")
// }
//
// override fun onADClicked() {
// Log.i("AD_DEMO", "SplashADClicked clickUrl: "
// + if (splashAD!!.ext != null) splashAD!!.ext["clickUrl"] else "")
// }
//
// /**
// * 倒计时回调,返回广告还将被展示的剩余时间。
// * 通过这个接口,开发者可以自行决定是否显示倒计时提示,或者还剩几秒的时候显示倒计时
// *
// * @param millisUntilFinished 剩余毫秒数
// */
// override fun onADTick(millisUntilFinished: Long) {
// Log.i("AD_DEMO", "SplashADTick " + millisUntilFinished + "ms")
// if (skipView != null) {
// skipView.text = String.format(SKIP_TEXT, Math.round(millisUntilFinished / 1000f))
// }
// }
//
// override fun onADExposure() {
// Log.i("AD_DEMO", "SplashADExposure")
// }
//
// override fun onADLoaded(expireTimestamp: Long) {
// Log.i("AD_DEMO", "SplashADFetch expireTimestamp: " + expireTimestamp
// + ", eCPMLevel = " + splashAD!!.ecpmLevel)
// }
//
// override fun onADDismissed() {
// Log.i("AD_DEMO", "SplashADDismissed")
// next()
// }
//
// override fun onNoAD(error: AdError) {
// val str = String.format("LoadSplashADFail, eCode=%d, errorMsg=%s", error.errorCode,
// error.errorMsg)
// Log.i("AD_DEMO", str)
// /**
// * 为防止无广告时造成视觉上类似于"闪退"的情况,设定无广告时页面跳转根据需要延迟一定时间,demo
// * 给出的延时逻辑是从拉取广告开始算开屏最少持续多久,仅供参考,开发者可自定义延时逻辑,如果开发者采用demo
// * 中给出的延时逻辑,也建议开发者考虑自定义minSplashTimeWhenNoAD的值
// */
// val alreadyDelayMills = System.currentTimeMillis() - fetchSplashADTime //从拉广告开始到onNoAD已经消耗了多少时间
// val shouldDelayMills = if (alreadyDelayMills > minSplashTimeWhenNoAD) 0 else minSplashTimeWhenNoAD - alreadyDelayMills //为防止加载广告失败后立刻跳离开屏可能造成的视觉上类似于"闪退"的情况,根据设置的minSplashTimeWhenNoAD
// // 计算出还需要延时多久
// handler.postDelayed({ readyGoOtherActivity() }, shouldDelayMills)
// }
//
// /**
// * 设置一个变量来控制当前开屏页面是否可以跳转,当开屏广告为普链类广告时,点击会打开一个广告落地页,此时开发者还不能打开自己的App主页。当从广告落地页返回以后,
// * 才可以跳转到开发者自己的App主页;当开屏广告是App类广告时只会下载App。
// */
// private operator fun next() {
// if (canJump) {
// readyGoOtherActivity()
// } else {
// canJump = true
// }
// }
//
// override fun onPause() {
// super.onPause()
// canJump = false
// }
//
// override fun onResume() {
// super.onResume()
// if (canJump) {
// next()
// }
// canJump = true
// }
//
// override fun onDestroy() {
// super.onDestroy()
// handler.removeCallbacksAndMessages(null)
// }
//
// /**
// * 开屏页一定要禁止用户对返回按钮的控制,否则将可能导致用户手动退出了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()
// }
//
// companion object {
// private const val SKIP_TEXT = "点击跳过 %d"
// }
//}
\ No newline at end of file
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/activitys/SplashActivity2.java
0 → 100644
View file @
cce54922
package
com
.
mints
.
goodmoney
.
ui
.
activitys
;
import
android.Manifest
;
import
android.annotation.TargetApi
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Looper
;
import
android.os.SystemClock
;
import
android.provider.Settings
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.KeyEvent
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.Button
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.mints.goodmoney.R
;
import
com.mints.goodmoney.manager.YlhAdManager
;
import
com.qq.e.ads.splash.SplashAD
;
import
com.qq.e.ads.splash.SplashADListener
;
import
com.qq.e.comm.util.AdError
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* 这是demo工程的入口Activity,在这里会首次调用广点通的SDK。
*
* 在调用SDK之前,如果您的App的targetSDKVersion >= 23,那么建议动态申请相关权限。
*/
public
class
SplashActivity2
extends
Activity
implements
SplashADListener
,
View
.
OnClickListener
{
private
SplashAD
splashAD
;
private
ViewGroup
container
;
private
TextView
skipView
;
private
ImageView
splashHolder
;
private
static
final
String
SKIP_TEXT
=
"点击跳过 %d"
;
public
boolean
canJump
=
false
;
private
boolean
needStartDemoList
=
true
;
private
boolean
loadAdOnly
=
false
;
private
boolean
showingAd
=
false
;
private
LinearLayout
loadAdOnlyView
;
private
Button
loadAdOnlyCloseButton
;
private
Button
loadAdOnlyDisplayButton
;
private
Button
loadAdOnlyRefreshButton
;
private
TextView
loadAdOnlyStatusTextView
;
/**
* 为防止无广告时造成视觉上类似于"闪退"的情况,设定无广告时页面跳转根据需要延迟一定时间,demo
* 给出的延时逻辑是从拉取广告开始算开屏最少持续多久,仅供参考,开发者可自定义延时逻辑,如果开发者采用demo
* 中给出的延时逻辑,也建议开发者考虑自定义minSplashTimeWhenNoAD的值(单位ms)
**/
private
int
minSplashTimeWhenNoAD
=
2000
;
/**
* 记录拉取广告的时间
*/
private
long
fetchSplashADTime
=
0
;
private
Handler
handler
=
new
Handler
(
Looper
.
getMainLooper
());
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_splash2
);
container
=
(
ViewGroup
)
this
.
findViewById
(
R
.
id
.
splash_container
);
boolean
customSkipBtn
=
getIntent
().
getBooleanExtra
(
"custom_skip_btn"
,
false
);
if
(
customSkipBtn
)
{
skipView
=
(
TextView
)
findViewById
(
R
.
id
.
skip_view
);
skipView
.
setVisibility
(
View
.
VISIBLE
);
}
splashHolder
=
(
ImageView
)
findViewById
(
R
.
id
.
splash_holder
);
boolean
needLogo
=
getIntent
().
getBooleanExtra
(
"need_logo"
,
true
);
needStartDemoList
=
getIntent
().
getBooleanExtra
(
"need_start_demo_list"
,
true
);
loadAdOnly
=
getIntent
().
getBooleanExtra
(
"load_ad_only"
,
false
);
loadAdOnlyView
=
findViewById
(
R
.
id
.
splash_load_ad_only
);
loadAdOnlyCloseButton
=
findViewById
(
R
.
id
.
splash_load_ad_close
);
loadAdOnlyCloseButton
.
setOnClickListener
(
this
);
loadAdOnlyDisplayButton
=
findViewById
(
R
.
id
.
splash_load_ad_display
);
loadAdOnlyDisplayButton
.
setOnClickListener
(
this
);
loadAdOnlyRefreshButton
=
findViewById
(
R
.
id
.
splash_load_ad_refresh
);
loadAdOnlyRefreshButton
.
setOnClickListener
(
this
);
loadAdOnlyStatusTextView
=
findViewById
(
R
.
id
.
splash_load_ad_status
);
if
(
loadAdOnly
){
loadAdOnlyView
.
setVisibility
(
View
.
VISIBLE
);
loadAdOnlyDisplayButton
.
setEnabled
(
false
);
}
if
(!
needLogo
)
{
findViewById
(
R
.
id
.
app_logo
).
setVisibility
(
View
.
GONE
);
}
if
(
Build
.
VERSION
.
SDK_INT
>=
23
)
{
checkAndRequestPermission
();
}
else
{
// 如果是Android6.0以下的机器,建议在manifest中配置相关权限,这里可以直接调用SDK
fetchSplashAD
(
this
,
container
,
skipView
,
getPosId
(),
this
,
0
);
}
}
private
String
getPosId
()
{
String
posId
=
getIntent
().
getStringExtra
(
"pos_id"
);
return
TextUtils
.
isEmpty
(
posId
)
?
YlhAdManager
.
YLH_AD_SPLASH_POSTID
:
posId
;
}
/**
*
* ----------非常重要----------
*
* Android6.0以上的权限适配简单示例:
*
* 如果targetSDKVersion >= 23,那么建议动态申请相关权限,再调用广点通SDK
*
* SDK不强制校验下列权限(即:无下面权限sdk也可正常工作),但建议开发者申请下面权限,尤其是READ_PHONE_STATE权限
*
* READ_PHONE_STATE权限用于允许SDK获取用户标识,
* 针对单媒体的用户,允许获取权限的,投放定向广告;不允许获取权限的用户,投放通投广告,媒体可以选择是否把用户标识数据提供给优量汇,并承担相应广告填充和eCPM单价下降损失的结果。
*
* Demo代码里是一个基本的权限申请示例,请开发者根据自己的场景合理地编写这部分代码来实现权限申请。
* 注意:下面的`checkSelfPermission`和`requestPermissions`方法都是在Android6.0的SDK中增加的API,如果您的App还没有适配到Android6.0以上,则不需要调用这些方法,直接调用广点通SDK即可。
*/
@TargetApi
(
Build
.
VERSION_CODES
.
M
)
private
void
checkAndRequestPermission
()
{
List
<
String
>
lackedPermission
=
new
ArrayList
<
String
>();
if
(!(
checkSelfPermission
(
Manifest
.
permission
.
READ_PHONE_STATE
)
==
PackageManager
.
PERMISSION_GRANTED
))
{
lackedPermission
.
add
(
Manifest
.
permission
.
READ_PHONE_STATE
);
}
if
(!(
checkSelfPermission
(
Manifest
.
permission
.
ACCESS_FINE_LOCATION
)
==
PackageManager
.
PERMISSION_GRANTED
))
{
lackedPermission
.
add
(
Manifest
.
permission
.
ACCESS_FINE_LOCATION
);
}
// 快手SDK所需相关权限,存储权限,此处配置作用于流量分配功能,关于流量分配,详情请咨询商务;如果您的APP不需要快手SDK的流量分配功能,则无需申请SD卡权限
if
(!(
checkSelfPermission
(
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
)
==
PackageManager
.
PERMISSION_GRANTED
)){
lackedPermission
.
add
(
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
);
}
if
(!(
checkSelfPermission
(
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
==
PackageManager
.
PERMISSION_GRANTED
))
{
lackedPermission
.
add
(
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
);
}
// 如果需要的权限都已经有了,那么直接调用SDK
if
(
lackedPermission
.
size
()
==
0
)
{
fetchSplashAD
(
this
,
container
,
skipView
,
getPosId
(),
this
,
0
);
}
else
{
// 否则,建议请求所缺少的权限,在onRequestPermissionsResult中再看是否获得权限
String
[]
requestPermissions
=
new
String
[
lackedPermission
.
size
()];
lackedPermission
.
toArray
(
requestPermissions
);
requestPermissions
(
requestPermissions
,
1024
);
}
}
private
boolean
hasAllPermissionsGranted
(
int
[]
grantResults
)
{
for
(
int
grantResult
:
grantResults
)
{
if
(
grantResult
==
PackageManager
.
PERMISSION_DENIED
)
{
return
false
;
}
}
return
true
;
}
@Override
public
void
onRequestPermissionsResult
(
int
requestCode
,
String
[]
permissions
,
int
[]
grantResults
)
{
super
.
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
if
(
requestCode
==
1024
&&
hasAllPermissionsGranted
(
grantResults
))
{
fetchSplashAD
(
this
,
container
,
skipView
,
getPosId
(),
this
,
0
);
}
else
{
Toast
.
makeText
(
this
,
"应用缺少必要的权限!请点击\"权限\",打开所需要的权限。"
,
Toast
.
LENGTH_LONG
).
show
();
Intent
intent
=
new
Intent
(
Settings
.
ACTION_APPLICATION_DETAILS_SETTINGS
);
intent
.
setData
(
Uri
.
parse
(
"package:"
+
getPackageName
()));
startActivity
(
intent
);
finish
();
}
}
/**
* 拉取开屏广告,开屏广告的构造方法有3种,详细说明请参考开发者文档。
*
* @param activity 展示广告的activity
* @param adContainer 展示广告的大容器
* @param skipContainer 自定义的跳过按钮:传入该view给SDK后,SDK会自动给它绑定点击跳过事件。SkipView的样式可以由开发者自由定制,其尺寸限制请参考activity_splash.xml或者接入文档中的说明。
* @param posId 广告位ID
* @param adListener 广告状态监听器
* @param fetchDelay 拉取广告的超时时长:取值范围[3000, 5000],设为0表示使用广点通SDK默认的超时时长。
*/
private
void
fetchSplashAD
(
Activity
activity
,
ViewGroup
adContainer
,
View
skipContainer
,
String
posId
,
SplashADListener
adListener
,
int
fetchDelay
)
{
fetchSplashADTime
=
System
.
currentTimeMillis
();
splashAD
=
new
SplashAD
(
activity
,
skipContainer
,
YlhAdManager
.
YLH_AD_APPID
,
posId
,
adListener
,
fetchDelay
);
if
(
loadAdOnly
)
{
splashAD
.
fetchAdOnly
();
}
else
{
splashAD
.
fetchAndShowIn
(
adContainer
);
}
}
@Override
public
void
onADPresent
()
{
Log
.
i
(
"AD_DEMO"
,
"SplashADPresent"
);
}
@Override
public
void
onADClicked
()
{
Log
.
i
(
"AD_DEMO"
,
"SplashADClicked clickUrl: "
+
(
splashAD
.
getExt
()
!=
null
?
splashAD
.
getExt
().
get
(
"clickUrl"
)
:
""
));
}
/**
* 倒计时回调,返回广告还将被展示的剩余时间。
* 通过这个接口,开发者可以自行决定是否显示倒计时提示,或者还剩几秒的时候显示倒计时
*
* @param millisUntilFinished 剩余毫秒数
*/
@Override
public
void
onADTick
(
long
millisUntilFinished
)
{
Log
.
i
(
"AD_DEMO"
,
"SplashADTick "
+
millisUntilFinished
+
"ms"
);
if
(
skipView
!=
null
)
{
skipView
.
setText
(
String
.
format
(
SKIP_TEXT
,
Math
.
round
(
millisUntilFinished
/
1000
f
)));
}
}
@Override
public
void
onADExposure
()
{
Log
.
i
(
"AD_DEMO"
,
"SplashADExposure"
);
}
@Override
public
void
onADLoaded
(
long
expireTimestamp
)
{
// Log.i("AD_DEMO", "SplashADFetch expireTimestamp: " + expireTimestamp
// + ", eCPMLevel = " + splashAD.getECPMLevel());
if
(
loadAdOnly
)
{
loadAdOnlyDisplayButton
.
setEnabled
(
true
);
long
timeIntervalSec
=
(
expireTimestamp
-
SystemClock
.
elapsedRealtime
())/
1000
;
long
min
=
timeIntervalSec
/
60
;
long
second
=
timeIntervalSec
-(
min
*
60
);
loadAdOnlyStatusTextView
.
setText
(
"加载成功,广告将在:"
+
min
+
"分"
+
second
+
"秒后过期,请在此之前展示(showAd)"
);
}
}
@Override
public
void
onADDismissed
()
{
Log
.
i
(
"AD_DEMO"
,
"SplashADDismissed"
);
next
();
}
@Override
public
void
onNoAD
(
AdError
error
)
{
String
str
=
String
.
format
(
"LoadSplashADFail, eCode=%d, errorMsg=%s"
,
error
.
getErrorCode
(),
error
.
getErrorMsg
());
Log
.
i
(
"AD_DEMO"
,
str
);
handler
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
Toast
.
makeText
(
SplashActivity2
.
this
.
getApplicationContext
(),
str
,
Toast
.
LENGTH_SHORT
).
show
();
}
});
if
(
loadAdOnly
&&
!
showingAd
)
{
loadAdOnlyStatusTextView
.
setText
(
str
);
return
;
//只拉取广告时,不终止activity
}
/**
* 为防止无广告时造成视觉上类似于"闪退"的情况,设定无广告时页面跳转根据需要延迟一定时间,demo
* 给出的延时逻辑是从拉取广告开始算开屏最少持续多久,仅供参考,开发者可自定义延时逻辑,如果开发者采用demo
* 中给出的延时逻辑,也建议开发者考虑自定义minSplashTimeWhenNoAD的值
**/
long
alreadyDelayMills
=
System
.
currentTimeMillis
()
-
fetchSplashADTime
;
//从拉广告开始到onNoAD已经消耗了多少时间
long
shouldDelayMills
=
alreadyDelayMills
>
minSplashTimeWhenNoAD
?
0
:
minSplashTimeWhenNoAD
-
alreadyDelayMills
;
//为防止加载广告失败后立刻跳离开屏可能造成的视觉上类似于"闪退"的情况,根据设置的minSplashTimeWhenNoAD
// 计算出还需要延时多久
handler
.
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
needStartDemoList
)
{
SplashActivity2
.
this
.
startActivity
(
new
Intent
(
SplashActivity2
.
this
,
MainActivity
.
class
));
}
SplashActivity2
.
this
.
finish
();
}
},
shouldDelayMills
);
}
/**
* 设置一个变量来控制当前开屏页面是否可以跳转,当开屏广告为普链类广告时,点击会打开一个广告落地页,此时开发者还不能打开自己的App主页。当从广告落地页返回以后,
* 才可以跳转到开发者自己的App主页;当开屏广告是App类广告时只会下载App。
*/
private
void
next
()
{
if
(
canJump
)
{
if
(
needStartDemoList
)
{
this
.
startActivity
(
new
Intent
(
this
,
MainActivity
.
class
));
}
this
.
finish
();
}
else
{
canJump
=
true
;
}
}
@Override
protected
void
onPause
()
{
super
.
onPause
();
canJump
=
false
;
}
@Override
protected
void
onResume
()
{
super
.
onResume
();
if
(
canJump
)
{
next
();
}
canJump
=
true
;
}
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
handler
.
removeCallbacksAndMessages
(
null
);
}
/** 开屏页一定要禁止用户对返回按钮的控制,否则将可能导致用户手动退出了App而广告无法正常曝光和计费 */
@Override
public
boolean
onKeyDown
(
int
keyCode
,
KeyEvent
event
)
{
if
(
keyCode
==
KeyEvent
.
KEYCODE_BACK
||
keyCode
==
KeyEvent
.
KEYCODE_HOME
)
{
if
(
keyCode
==
KeyEvent
.
KEYCODE_BACK
&&
loadAdOnlyView
.
getVisibility
()
==
View
.
VISIBLE
){
return
super
.
onKeyDown
(
keyCode
,
event
);
}
return
true
;
}
return
super
.
onKeyDown
(
keyCode
,
event
);
}
@Override
public
void
onClick
(
View
v
)
{
switch
(
v
.
getId
())
{
case
R
.
id
.
splash_load_ad_close
:
this
.
finish
();
break
;
case
R
.
id
.
splash_load_ad_refresh
:
showingAd
=
false
;
splashAD
.
fetchAdOnly
();
loadAdOnlyDisplayButton
.
setEnabled
(
false
);
break
;
case
R
.
id
.
splash_load_ad_display
:
loadAdOnlyView
.
setVisibility
(
View
.
GONE
);
showingAd
=
true
;
splashAD
.
showAd
(
container
);
break
;
default
:
}
}
}
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/activitys/SplashYlhActivity.kt
View file @
cce54922
...
...
@@ -31,7 +31,6 @@ class SplashYlhActivity : BaseActivity(), SplashADListener {
private
var
splashAD
:
SplashAD
?
=
null
private
var
container
:
ViewGroup
?
=
null
private
val
skipView
:
TextView
?
=
null
private
val
ps
by
lazy
{
AppPreferences
(
context
)
}
var
canJump
=
false
...
...
@@ -96,7 +95,7 @@ class SplashYlhActivity : BaseActivity(), SplashADListener {
}
else
{
try
{
container
=
findViewById
<
View
>(
R
.
id
.
splash_container
)
as
ViewGroup
fetchSplashAD
(
this
,
container
,
skip
V
iew
,
YlhAdManager
.
YLH_AD_SPLASH_POSTID
,
this
,
0
)
fetchSplashAD
(
this
,
container
,
skip
_v
iew
,
YlhAdManager
.
YLH_AD_SPLASH_POSTID
,
this
,
0
)
}
catch
(
e
:
Exception
)
{
readyGoOtherActivity
()
}
...
...
@@ -113,10 +112,10 @@ class SplashYlhActivity : BaseActivity(), SplashADListener {
* @param adListener 广告状态监听器
* @param fetchDelay 拉取广告的超时时长:取值范围[3000, 5000],设为0表示使用广点通SDK默认的超时时长。
*/
private
fun
fetchSplashAD
(
activity
:
Activity
,
adContainer
:
ViewGroup
?,
skipContainer
:
View
?
,
private
fun
fetchSplashAD
(
activity
:
Activity
,
adContainer
:
ViewGroup
?,
skipContainer
:
View
,
posId
:
String
,
adListener
:
SplashADListener
,
fetchDelay
:
Int
)
{
fetchSplashADTime
=
System
.
currentTimeMillis
()
splashAD
=
SplashAD
(
activity
,
skipContainer
,
posId
,
adListener
,
fetchDelay
)
splashAD
=
SplashAD
(
activity
,
skipContainer
,
YlhAdManager
.
YLH_AD_APPID
,
posId
,
adListener
,
fetchDelay
)
splashAD
!!
.
fetchAndShowIn
(
adContainer
)
}
...
...
@@ -133,7 +132,7 @@ class SplashYlhActivity : BaseActivity(), SplashADListener {
* @param millisUntilFinished 剩余毫秒数
*/
override
fun
onADTick
(
millisUntilFinished
:
Long
)
{
skip
V
iew
?.
setText
(
String
.
format
(
SKIP_TEXT
,
Math
.
round
(
millisUntilFinished
/
1000f
)))
skip
_v
iew
?.
setText
(
String
.
format
(
SKIP_TEXT
,
Math
.
round
(
millisUntilFinished
/
1000f
)))
}
override
fun
onADExposure
()
{
...
...
GoodMoney/app/src/main/res/layout/activity_splash2.xml
0 → 100644
View file @
cce54922
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@android:color/white"
>
<!--这里模拟一张oneshot单的焦点图展示-->
<ImageView
android:id=
"@+id/oneshot_image"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"400px"
android:layout_marginLeft=
"10dp"
android:layout_marginRight=
"10dp"
/>
<RelativeLayout
android:id=
"@+id/splash_main"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@android:color/white"
>
<!-- 广点通开屏广告支持“半屏/全屏”展示,开发者可以把Logo区域放在屏幕底部,然后在Logo上方提供一个容器来放置半开屏广告,请注意此容器高度不得小于400dp -->
<!-- 1.Logo区域:展示半开屏广告时使用,如果想展示全开屏广告,可以不需要这个Logo区域 -->
<!-- 注意:如需要这个Logo区域,建议开发者使用自己的Logo资源,而不是联盟的Logo资源@drawable/gdt_splash_logo,资源规格可参照@drawable/gdt_splash_logo -->
<ImageView
android:id=
"@+id/app_logo"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_alignParentBottom=
"true"
android:layout_centerHorizontal=
"true"
/>
<!-- 2.预设开屏图片区域: -->
<!-- 开发者可以把自家App设计开屏图片摆放在这里,本示例中放置了一张静态图片。!-->
<!-- 注意1:直接将此图放在广告容器的下面即可,始终不要将广告容器splash_container的设为invisible,否则将不会展示广告无法计费,返回错误码600。-->
<!-- 注意2:建议开发者使用自己的开屏图片资源,而不是联盟的@drawable/splash_holder,资源规格可参照@drawable/splash_holder -->
<ImageView
android:id=
"@+id/splash_holder"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_above=
"@id/app_logo"
android:scaleType=
"fitXY"
/>
<!-- 3.开屏广告容器区域:-->
<!-- 注意:该区域高度不得小于400dp。在本示例中没有写死splash_container的高度值,是因为第1部分的app_logo区域是一个高度很小的图片。 -->
<FrameLayout
android:id=
"@+id/splash_container"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_above=
"@id/app_logo"
/>
<!-- 4.自定义跳过按钮区域:开发者可以根据需要自己实现不同样式的跳过按钮 -->
<!-- 注意1:根据广告法规定,跳过按钮必须在屏幕当中出现。因此广告展示的时候,必须让将SkipView显示出来,即visible,否则将SDK将不展示广告,返回错误码608。。 -->
<!-- 注意2:SDK除了会检查跳过按钮的可见性,还将检测它的尺寸,其尺寸不得小于3dp*3dp,否则将SDK将不展示广告,返回错误码608。 -->
<TextView
android:id=
"@+id/skip_view"
android:layout_width=
"96dp"
android:visibility=
"gone"
android:layout_height=
"wrap_content"
android:layout_alignParentRight=
"true"
android:layout_alignParentTop=
"true"
android:layout_margin=
"16dp"
android:background=
"@drawable/background_circle"
android:gravity=
"center"
android:textColor=
"@android:color/white"
android:textSize=
"14sp"
/>
<!-- 本示例省略了自定义的倒计时,和跳过按钮放在一起实现了。开发者也可以实现自己的倒计时View,方法是在onADTick回调中获得广告剩余的展示时间,并自由决定倒计时View的样式,SDK对倒计时的View没有要求。 -->
<!-- 自定义wifi预加载按钮,需设置状态为不显示,当素材为视频且视频开始播放时,SDK内部会处理为显示状态-->
<TextView
android:id=
"@+id/preload_view"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentLeft=
"true"
android:layout_alignParentTop=
"true"
android:layout_margin=
"16dp"
android:background=
"@drawable/background_circle"
android:gravity=
"center"
android:text=
"已Wi-Fi预加载"
android:textColor=
"@android:color/white"
android:textSize=
"14sp"
android:visibility=
"gone"
/>
</RelativeLayout>
<!--只加载广告接口,这里展示下加载结果-->
<LinearLayout
android:id=
"@+id/splash_load_ad_only"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:paddingBottom=
"@dimen/activity_vertical_margin"
android:paddingLeft=
"@dimen/activity_horizontal_margin"
android:paddingRight=
"@dimen/activity_horizontal_margin"
android:paddingTop=
"@dimen/activity_vertical_margin"
android:visibility=
"gone"
>
<Button
android:id=
"@+id/splash_load_ad_close"
android:text=
"关闭"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<Button
android:id=
"@+id/splash_load_ad_refresh"
android:text=
"刷新"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<Button
android:id=
"@+id/splash_load_ad_display"
android:text=
"显示广告"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<TextView
android:id=
"@+id/splash_load_ad_status"
android:hint=
"当前状态"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
</LinearLayout>
</FrameLayout>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment