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
259f4d8a
Commit
259f4d8a
authored
Oct 26, 2020
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加优量汇广告
parent
dcc3ef90
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
573 additions
and
73 deletions
+573
-73
AndroidManifest.xml
GoodMoney/app/src/main/AndroidManifest.xml
+18
-11
MintsApplication.java
...p/src/main/java/com/mints/goodmoney/MintsApplication.java
+1
-1
YlhVedioAdManager.java
...c/main/java/com/mints/goodmoney/ad/YlhVedioAdManager.java
+15
-6
AppConfig.java
...p/src/main/java/com/mints/goodmoney/common/AppConfig.java
+2
-6
LiebaoManager.java
.../main/java/com/mints/goodmoney/manager/LiebaoManager.java
+6
-6
YlhAdManager.kt
...src/main/java/com/mints/goodmoney/manager/YlhAdManager.kt
+9
-11
AwardActivity.kt
...in/java/com/mints/goodmoney/ui/activitys/AwardActivity.kt
+2
-2
SplashADActivity.kt
...java/com/mints/goodmoney/ui/activitys/SplashADActivity.kt
+175
-0
SplashYlhActivity.kt
...ava/com/mints/goodmoney/ui/activitys/SplashYlhActivity.kt
+197
-0
MainFragment.kt
...main/java/com/mints/goodmoney/ui/fragment/MainFragment.kt
+1
-1
MyFragment.kt
...c/main/java/com/mints/goodmoney/ui/fragment/MyFragment.kt
+24
-14
ForegroundOrBackground.java
...ava/com/mints/goodmoney/utils/ForegroundOrBackground.java
+16
-15
background_circle.xml
GoodMoney/app/src/main/res/drawable/background_circle.xml
+19
-0
activity_splash_ylh.xml
GoodMoney/app/src/main/res/layout/activity_splash_ylh.xml
+88
-0
No files found.
GoodMoney/app/src/main/AndroidManifest.xml
View file @
259f4d8a
...
...
@@ -87,10 +87,8 @@
android:value=
"${JPUSH_CHANNEL}"
/>
<activity
android:name=
".ui.activitys.SplashActivity"
android:configChanges=
"keyboard|orientation|screenSize"
android:screenOrientation=
"portrait"
android:windowSoftInputMode=
"adjustPan|stateHidden"
>
android:name=
".ui.activitys.SplashYlhActivity"
android:screenOrientation=
"portrait"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
...
...
@@ -121,13 +119,22 @@
android:name=
".ui.activitys.AboutusActivity"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".ui.activitys.GuideActivity"
/>
<activity
android:name=
".ui.activitys.LiebaoGameActivity"
/>
<activity
android:name=
".ui.activitys.DrawcashActivity"
/>
<activity
android:name=
".ui.activitys.WaterActivity"
/>
<activity
android:name=
".ui.activitys.WalkActivity"
/>
<activity
android:name=
".ui.activitys.EraseActivity"
/>
<activity
android:name=
".ui.activitys.DrawcashRecordActivity"
/>
<activity
android:name=
".ui.activitys.CoinRecordActivity"
/>
<activity
android:name=
".ui.activitys.LiebaoGameActivity"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".ui.activitys.DrawcashActivity"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".ui.activitys.WaterActivity"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".ui.activitys.WalkActivity"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".ui.activitys.EraseActivity"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".ui.activitys.DrawcashRecordActivity"
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"
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/MintsApplication.java
View file @
259f4d8a
...
...
@@ -101,7 +101,7 @@ public class MintsApplication extends MultiDexApplication {
}
// 优量汇
//
initYlh();
initYlh
();
// 穿山甲
initCsj
();
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ad/YlhVedioAdManager.java
View file @
259f4d8a
...
...
@@ -85,16 +85,25 @@ public class YlhVedioAdManager implements VedioAdManagerView {
String
ylhPostId
;
switch
(
carrierType
)
{
case
Constant
.
CARRIER_VERSUS_VIDEO
:
// 每日任务视频
ylhPostId
=
YlhAdManager
.
YLH_AD_VEDIO_MAIN_POSTID
;
break
;
case
Constant
.
CARRIER_OFFLINE_DOUBLE
:
// 离线收益翻倍
case
Constant
.
CARRIER_SIGNIN_HOMEPAGE_CARD
:
// 签到翻倍
case
Constant
.
CARRIER_
CHALLENGE_TURN
:
// 挑战大转盘
ylhPostId
=
YlhAdManager
.
YLH_AD_VEDIO_
VERSUS_PAN
_POSTID
;
case
Constant
.
CARRIER_
WALK_BUBBLE
:
// 汽泡
ylhPostId
=
YlhAdManager
.
YLH_AD_VEDIO_
MOREDIALOG
_POSTID
;
break
;
case
Constant
.
CARRIER_CHALLENGE_CARD
:
// 挑战刮刮乐
ylhPostId
=
YlhAdManager
.
YLH_AD_VEDIO_VERSUS_ERASE_POSTID
;
case
Constant
.
CARRIER_HOMEWATER
:
// 喝水
ylhPostId
=
YlhAdManager
.
YLH_AD_VEDIO_DRINK_POSTID
;
break
;
case
Constant
.
CARRIER_CHALLENGE_TURN
:
// 大转盘
ylhPostId
=
YlhAdManager
.
YLH_AD_VEDIO_TURNABLE_POSTID
;
break
;
case
Constant
.
CARRIER_CHALLENGE_CARD
:
// 刮刮乐
ylhPostId
=
YlhAdManager
.
YLH_AD_VEDIO_ERASE_POSTID
;
break
;
default
:
// 在线收益翻倍
ylhPostId
=
YlhAdManager
.
YLH_AD_VEDIO_M
AIN_PAN
_POSTID
;
ylhPostId
=
YlhAdManager
.
YLH_AD_VEDIO_M
OREDIALOG
_POSTID
;
break
;
}
...
...
@@ -102,7 +111,7 @@ public class YlhVedioAdManager implements VedioAdManagerView {
rewardVideoAD
=
null
;
}
rewardVideoAD
=
new
RewardVideoAD
(
activity
,
YlhAdManager
.
YLH_AD_APPID
,
ylhPostId
,
new
RewardVideoADListener
()
{
rewardVideoAD
=
new
RewardVideoAD
(
activity
,
ylhPostId
,
new
RewardVideoADListener
()
{
@Override
public
void
onADLoad
()
{
//广告加载成功,可在此回调后进行广告展示,此时广告过期时间确定,可通过RewardVideoAD.getExpireTimestamp()获取
try
{
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/common/AppConfig.java
View file @
259f4d8a
...
...
@@ -22,14 +22,10 @@ public class AppConfig {
/**
* ylh 剩余广告播放数
*/
public
static
int
ylhAdCount
=
0
;
/**
* csjFull 剩余广告播放数
*/
public
static
int
csjFullAdCount
=
5
;
public
static
int
ylhAdCount
=
5
;
/**
* csjVedio 剩余广告播放数
*/
public
static
int
csjVedioAdCount
=
5
;
public
static
int
csjVedioAdCount
=
0
;
}
GoodMoney/app/src/main/java/com/mints/goodmoney/manager/LiebaoManager.java
View file @
259f4d8a
...
...
@@ -92,14 +92,14 @@ public class LiebaoManager {
// 需要支持广点通广告时,才需下面代码
// 【设置广点通广告id】
//
CmGameAppInfo.GDTAdInfo gdtAdInfo = new CmGameAppInfo.GDTAdInfo();
//
gdtAdInfo.setAppId(YlhAdManager.YLH_AD_APPID); // 广点通的APPID
//
// 游戏内广告场景;
//
gdtAdInfo.setRewardVideoId(YlhAdManager.YLH_AD_VEDIO_GAME_POSTID); // 激励视频
CmGameAppInfo
.
GDTAdInfo
gdtAdInfo
=
new
CmGameAppInfo
.
GDTAdInfo
();
gdtAdInfo
.
setAppId
(
YlhAdManager
.
YLH_AD_APPID
);
// 广点通的APPID
// 游戏内广告场景;
gdtAdInfo
.
setRewardVideoId
(
YlhAdManager
.
YLH_AD_VEDIO_GAME_POSTID
);
// 激励视频
// gdtAdInfo.setGameLoadInterId(YlhAdManager.YLH_AD_INTERSTITIALAD_LIEBAO);//游戏加载中的插屏
// gdtAdInfo.setBannerId(YlhAdManager.YLH_AD_BANNER_LIEBAO); // banner广告
// gdtAdInfo.setPlayGameInterId(YlhAdManager.YLH_AD_INTERSTITIALAD_LIEBAO);//游戏进行中关卡插屏
//
cmGameAppInfo.setGdtAdInfo(gdtAdInfo);
cmGameAppInfo
.
setGdtAdInfo
(
gdtAdInfo
);
//
// // 【设置广点通和穿山甲广告占比】
...
...
@@ -107,7 +107,7 @@ public class LiebaoManager {
// // 0: 全部使用穿山甲广告
// // 100: 全部采用广点通广告
// // 40:穿山甲广告命中概率是60%,广点通是40%,如果一方没广告,则用另一方补量。
cmGameAppInfo
.
setRewardAdProbability
(
0
);
// 默认值为0,全部采用穿山甲激励视频广告
cmGameAppInfo
.
setRewardAdProbability
(
4
0
);
// 默认值为0,全部采用穿山甲激励视频广告
//
//
// // 戏关卡间插屏广告概率设置建议,代码默认值为20
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/manager/YlhAdManager.kt
View file @
259f4d8a
...
...
@@ -10,26 +10,24 @@ import com.qq.e.comm.managers.GDTADManager
object
YlhAdManager
{
/* 优量汇appid */
const
val
YLH_AD_APPID
=
"111
0341375
"
const
val
YLH_AD_APPID
=
"111
1046903
"
/* splash-postid */
const
val
YLH_AD_SPLASH_POSTID
=
"
1071325672800900
"
const
val
YLH_AD_SPLASH_POSTID
=
"
2081332802214692
"
/* vedio-postid */
const
val
YLH_AD_VEDIO_MAIN_PAN_POSTID
=
"5071107856089058"
//首页大转盘
const
val
YLH_AD_VEDIO_VERSUS_PAN_POSTID
=
"2011506866980034"
//挑战大转盘
const
val
YLH_AD_VEDIO_VERSUS_ERASE_POSTID
=
"6031208866083065"
//挑战刮刮乐
const
val
YLH_AD_VEDIO_GAME_POSTID
=
"7011114415121322"
//猎豹游戏
const
val
YLH_AD_VEDIO_DRINK_POSTID
=
"5071107856089058"
//喝水打卡
const
val
YLH_AD_VEDIO_MAIN_POSTID
=
"3091434802115910"
//我的界面视频
const
val
YLH_AD_VEDIO_ERASE_POSTID
=
"4061637892217932"
//挑战刮刮乐
const
val
YLH_AD_VEDIO_TURNABLE_POSTID
=
"5021539812411906"
//大转盘
const
val
YLH_AD_VEDIO_MOREDIALOG_POSTID
=
"8081132842926080"
//签到、气泡、离线弹框
const
val
YLH_AD_VEDIO_GAME_POSTID
=
"4021234882122091"
//猎豹游戏
/* 插屏 */
const
val
YLH_AD_INTERSTITIALAD_LIEBAO
=
"4091610929319085"
//猎豹
/* banner */
const
val
YLH_AD_BANNER_LIEBAO
=
"1091518939518038"
//猎豹
const
val
YLH_AD_INTERSTITIALAD_LIEBAO
=
""
//猎豹
/**
* 广告初始化
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/activitys/AwardActivity.kt
View file @
259f4d8a
...
...
@@ -171,8 +171,8 @@ class AwardActivity : BaseActivity(), AwardView, View.OnClickListener {
Constant
.
CARRIER_CHALLENGE_TURN
,
Constant
.
CARRIER_CHALLENGE_CARD
,
Constant
.
CARRIER_VERSUS_VIDEO
,
Constant
.
CARRIER_WALK_BUBBLE
,
Constant
.
CARRIER_CHALLENGE_SHAREFRIEND_DOUBLE
,
Constant
.
CARRIER_HOMEVEDIO_BIG
->
{
//
awardVedio()
finish
()
awardVedio
()
//
finish()
}
else
->
{
finish
()
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/activitys/SplashADActivity.kt
0 → 100644
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/SplashYlhActivity.kt
0 → 100644
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.common.Constant
import
com.mints.goodmoney.common.DeviceInfo
import
com.mints.goodmoney.manager.YlhAdManager
import
com.mints.goodmoney.ui.activitys.base.BaseActivity
import
com.mints.goodmoney.utils.LogUtil
import
com.qq.e.ads.splash.SplashAD
import
com.qq.e.ads.splash.SplashADListener
import
com.qq.e.comm.util.AdError
import
kotlinx.android.synthetic.main.activity_splash_ylh.*
import
net.grandcentrix.tray.AppPreferences
/**
* 启动页 开屏展示
*/
class
SplashYlhActivity
:
BaseActivity
(),
SplashADListener
{
companion
object
{
private
const
val
SKIP_TEXT
=
"点击跳过 %d"
}
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
/**
* 为防止无广告时造成视觉上类似于"闪退"的情况,设定无广告时页面跳转根据需要延迟一定时间,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
(!
isTaskRoot
)
{
//点击Home键后再点击App图标,会回到原来的界面。今天重新打包后,但是在Debug模式下,一切正常,
// 但是把打完包的apk(Release)安装在其他手机上时,回到桌面后点击图标会重新打开启动页
finish
()
return
}
// 校验APP签名
checkAppSign
()
}
override
fun
isApplyKitKatTranslucency
():
Boolean
{
return
false
}
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签名
*/
private
fun
checkAppSign
()
{
val
deviceInfo
:
DeviceInfo
=
DeviceInfo
.
instance
!!
if
(!
deviceInfo
.
signInfo
)
{
baseApplication
.
exitApp
()
}
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
()
}
}
}
/**
* 拉取开屏广告,开屏广告的构造方法有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
()
{
}
override
fun
onADClicked
()
{
}
/**
* 倒计时回调,返回广告还将被展示的剩余时间。
* 通过这个接口,开发者可以自行决定是否显示倒计时提示,或者还剩几秒的时候显示倒计时
*
* @param millisUntilFinished 剩余毫秒数
*/
override
fun
onADTick
(
millisUntilFinished
:
Long
)
{
skipView
?.
setText
(
String
.
format
(
SKIP_TEXT
,
Math
.
round
(
millisUntilFinished
/
1000f
)))
}
override
fun
onADExposure
()
{
}
override
fun
onADLoaded
(
expireTimestamp
:
Long
)
{
}
override
fun
onADDismissed
()
{
next
()
}
override
fun
onNoAD
(
error
:
AdError
)
{
val
str
=
String
.
format
(
"LoadSplashADFail, eCode=%d, errorMsg=%s"
,
error
.
errorCode
,
error
.
errorMsg
)
LogUtil
.
d
(
"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
.
toLong
())
}
/**
* 设置一个变量来控制当前开屏页面是否可以跳转,当开屏广告为普链类广告时,点击会打开一个广告落地页,此时开发者还不能打开自己的App主页。当从广告落地页返回以后,
* 才可以跳转到开发者自己的App主页;当开屏广告是App类广告时只会下载App。
*/
private
operator
fun
next
()
{
if
(
canJump
)
{
readyGoOtherActivity
()
finish
()
}
else
{
canJump
=
true
}
}
/**
* 开屏页一定要禁止用户对返回按钮的控制,否则将可能导致用户手动退出了App而广告无法正常曝光和计费
*/
override
fun
onKeyDown
(
keyCode
:
Int
,
event
:
KeyEvent
):
Boolean
{
return
if
(
keyCode
==
KeyEvent
.
KEYCODE_BACK
)
{
true
}
else
super
.
onKeyDown
(
keyCode
,
event
)
}
private
fun
readyGoOtherActivity
()
{
val
customVersion
:
Int
=
ps
.
getInt
(
Constant
.
CUSTOM_VERSION
,
0
)
val
isFirstEnter
:
Boolean
=
ps
.
getBoolean
(
Constant
.
ISFIRSTENTER
+
customVersion
,
true
)
if
(
isFirstEnter
)
{
readyGoThenKill
(
GuideActivity
::
class
.
java
)
}
else
{
readyGoThenKill
(
MainActivity
::
class
.
java
)
}
}
}
\ No newline at end of file
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/fragment/MainFragment.kt
View file @
259f4d8a
...
...
@@ -114,7 +114,7 @@ class MainFragment : BaseFragment(), HomeView, AdVideoCallback, View.OnClickList
override
fun
onPause
()
{
super
.
onPause
()
littleVideoFragment
?.
onPause
()
cdvvYilanTime
?.
paus
e
()
pauseDownloadTim
e
()
}
override
fun
setUserVisibleHint
(
isVisibleToUser
:
Boolean
)
{
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/fragment/MyFragment.kt
View file @
259f4d8a
...
...
@@ -398,22 +398,22 @@ class MyFragment : BaseFragment(), MyView, OnItemChildClickListener, OnRefreshLi
}
}
val
task3
=
TaskBean
(
R
.
mipmap
.
icon_my_video
,
"看福利视频赚金币"
,
progressStrVideo
,
task3Str
,
3
)
//
// 玩游戏,赚金币
//
var task4Str = ""
//
if (userConfig != null) {
//
task4Str = if (userConfig!!.taskGame.status == 0) "赚金币" else "立即领取"
//
}
//
val task4 = TaskBean(R.mipmap.icon_my_game, "玩游戏,赚金币", "", task4Str, 4)
//
// 小说免费看,金币大家赚
//
//
val task5 = TaskBean(R.mipmap.icon_my_fiction, "小说免费看,金币大家赚", "", "去阅读", 5)
//
// 试玩平台
//
val task6 = TaskBean(R.mipmap.icon_my_demo, "试玩平台", "", "赚金币", 5)
// 玩游戏,赚金币
var
task4Str
=
""
if
(
userConfig
!=
null
)
{
task4Str
=
if
(
userConfig
!!
.
taskGame
.
status
==
0
)
"赚金币"
else
"立即领取"
}
val
task4
=
TaskBean
(
R
.
mipmap
.
icon_my_game
,
"玩游戏,赚金币"
,
""
,
task4Str
,
4
)
// 小说免费看,金币大家赚
// val task5 = TaskBean(R.mipmap.icon_my_fiction, "小说免费看,金币大家赚", "", "去阅读", 5)
// 试玩平台
val
task6
=
TaskBean
(
R
.
mipmap
.
icon_my_demo
,
"试玩平台"
,
""
,
"赚金币"
,
5
)
dataList
.
add
(
task1
)
dataList
.
add
(
task2
)
dataList
.
add
(
task3
)
//
dataList.add(task4)
//
//
dataList.add(task5)
//
dataList.add(task6)
dataList
.
add
(
task4
)
// dataList.add(task5)
dataList
.
add
(
task6
)
mainMyAdapter
?.
notifyDataSetChanged
()
}
...
...
@@ -491,7 +491,17 @@ class MyFragment : BaseFragment(), MyView, OnItemChildClickListener, OnRefreshLi
// }
// 试玩平台
MainMyAdapter
.
TASK_TYPE_FICTION
->
{
activity
?.
let
{
open
(
it
)
}
if
(!
userManager
.
userIsLogin
())
{
readyGo
(
LoginActivity
::
class
.
java
)
return
}
try
{
activity
?.
let
{
open
(
it
)
}
}
catch
(
e
:
Exception
){
e
.
printStackTrace
()
showToast
(
"请重新退出账号登录"
)
}
}
}
}
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/utils/ForegroundOrBackground.java
View file @
259f4d8a
...
...
@@ -8,6 +8,7 @@ import android.text.TextUtils;
import
com.mints.goodmoney.manager.TrackManager
;
import
com.mints.goodmoney.mvp.presenters.VersionUpdatePresenter
;
import
com.mints.goodmoney.ui.activitys.SplashADActivity
;
import
java.lang.ref.WeakReference
;
...
...
@@ -68,21 +69,21 @@ public class ForegroundOrBackground implements Application.ActivityLifecycleCall
return
;
// 每次返回应用时 都展示开屏广告
//
String simpleName = activity.getClass().getSimpleName();
//
if (TextUtils.equals(simpleName, "SplashYlhActivity") ||
//
TextUtils.equals(simpleName, "GuideActivity") ||
// TextUtils.equals(simpleName, "BuyVip
Activity") ||
// TextUtils.equals(simpleName, "Vip
Activity") ) {
//
count++;
//
return;
//
}
//
//
if (count == 0) {
//
if(intent==null){
//
intent = new Intent(activity, SplashADActivity.class);
//
}
//
activity.startActivity(intent);
//
}
String
simpleName
=
activity
.
getClass
().
getSimpleName
();
if
(
TextUtils
.
equals
(
simpleName
,
"SplashYlhActivity"
)
||
TextUtils
.
equals
(
simpleName
,
"GuideActivity"
)
||
TextUtils
.
equals
(
simpleName
,
"Award
Activity"
)
||
TextUtils
.
equals
(
simpleName
,
"Drawcash
Activity"
)
)
{
count
++;
return
;
}
if
(
count
==
0
)
{
if
(
intent
==
null
){
intent
=
new
Intent
(
activity
,
SplashADActivity
.
class
);
}
activity
.
startActivity
(
intent
);
}
count
++;
}
...
...
GoodMoney/app/src/main/res/drawable/background_circle.xml
0 → 100644
View file @
259f4d8a
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"rectangle"
>
<solid
android:color=
"#80000000"
/>
<padding
android:bottom=
"3dp"
android:left=
"8dp"
android:right=
"8dp"
android:top=
"3dp"
/>
<corners
android:bottomLeftRadius=
"45dp"
android:bottomRightRadius=
"45dp"
android:topLeftRadius=
"45dp"
android:topRightRadius=
"45dp"
/>
</shape>
\ No newline at end of file
GoodMoney/app/src/main/res/layout/activity_splash_ylh.xml
0 → 100644
View file @
259f4d8a
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/fl_splash"
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_marginLeft=
"10dp"
android:layout_marginTop=
"400px"
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"
android:src=
"@drawable/splash_bg"
/>
<!-- 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:layout_height=
"wrap_content"
android:layout_alignParentTop=
"true"
android:layout_alignParentEnd=
"true"
android:layout_margin=
"16dp"
android:background=
"@drawable/background_circle"
android:gravity=
"center"
android:text=
"点击跳过"
android:textColor=
"@android:color/white"
android:textSize=
"14sp"
android:visibility=
"gone"
/>
<!-- 本示例省略了自定义的倒计时,和跳过按钮放在一起实现了。开发者也可以实现自己的倒计时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>
</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