Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_fiveworld
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_fiveworld
Commits
b62ff519
Commit
b62ff519
authored
Oct 20, 2021
by
jyx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新通知栏广告为新插屏半屏
parent
d333c73c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
421 additions
and
8 deletions
+421
-8
Notice_NewOutSceneFull.java
...a/com/mints/fiveworld/ad/half/Notice_NewOutSceneFull.java
+414
-0
WifiAdManager.kt
...rc/main/java/com/mints/fiveworld/ad/wifi/WifiAdManager.kt
+6
-7
CycleProgress.java
...in/java/com/mints/fiveworld/ui/widgets/CycleProgress.java
+1
-1
No files found.
app/src/main/java/com/mints/fiveworld/ad/half/Notice_NewOutSceneFull.java
0 → 100644
View file @
b62ff519
package
com
.
mints
.
fiveworld
.
ad
.
half
;
import
android.app.Activity
;
import
android.util.Log
;
import
com.bytedance.msdk.api.AdError
;
import
com.bytedance.msdk.api.AdSlot
;
import
com.bytedance.msdk.api.TTAdConstant
;
import
com.bytedance.msdk.api.TTMediationAdSdk
;
import
com.bytedance.msdk.api.TTSettingConfigCallback
;
import
com.bytedance.msdk.api.TTVideoOption
;
import
com.bytedance.msdk.api.fullVideo.TTFullVideoAd
;
import
com.bytedance.msdk.api.fullVideo.TTFullVideoAdListener
;
import
com.bytedance.msdk.api.fullVideo.TTFullVideoAdLoadCallback
;
import
com.mints.fiveworld.ad.AdHelper
;
import
com.mints.fiveworld.ad.AdReportManager
;
import
com.mints.fiveworld.ad.wifi.WifiAdStatusListener
;
import
com.mints.fiveworld.common.Constant
;
import
com.mints.fiveworld.manager.TrackManager
;
import
com.mints.fiveworld.manager.UserManager
;
import
com.mints.fiveworld.manager.ad.CsjGroMoreManager
;
import
com.mints.fiveworld.utils.LogUtil
;
import
com.mints.fiveworld.utils.TimeRender
;
import
com.mints.fiveworld.utils.VideoOptionUtil
;
import
java.lang.ref.WeakReference
;
import
java.util.HashMap
;
/**
* 应用内外-全屏广告(新插屏 半屏) 通知栏
*/
public
class
Notice_NewOutSceneFull
{
private
static
Notice_NewOutSceneFull
_inst
;
public
static
Notice_NewOutSceneFull
getInstance
()
{
if
(
_inst
==
null
)
{
_inst
=
new
Notice_NewOutSceneFull
();
}
return
_inst
;
}
private
static
final
String
TAG
=
Notice_NewOutSceneFull
.
class
.
getSimpleName
();
private
WifiAdStatusListener
wifiAdStatusListener
;
private
TTFullVideoAd
mTTFullVideoAd
;
private
WeakReference
<
Activity
>
activity
;
private
String
fullId
;
private
boolean
isClickScreen
=
true
;
// 是否点击屏幕跳转广告
private
String
mCarrier
=
""
;
private
String
adcode
=
""
;
private
String
ecpm
=
""
;
private
int
adSource
=
0
;
private
int
isLoadSuccess
=
0
;
//0-加载失败/未加载 1-加载中 2-加载成功
private
long
adLoadTime
=
0
;
// 广告展示时间,45分钟后当前广告失效,重新预加载广告
private
long
adPreingTime
=
0
;
// 防止预加载超时 2分钟
public
void
preloadFullAd
(
Activity
activity
,
String
carrier
)
{
this
.
mCarrier
=
carrier
;
this
.
activity
=
new
WeakReference
<>(
activity
);
boolean
isOversped
=
TimeRender
.
isOverspedMin
(
adLoadTime
,
AdHelper
.
AD_NO_SHOWTIME_OUT
);
boolean
isPreingOversped
=
TimeRender
.
isOverspedMin
(
adPreingTime
,
AdHelper
.
AD_REQUEST_TIME_OUT
);
LogUtil
.
d
(
TAG
,
"gromore应用内新插屏半屏广告-> 1、进入预加载 isLoadSuccess="
+
isLoadSuccess
+
" isOversped="
+
isOversped
+
" activity="
+
this
.
activity
.
get
()
+
" isPreingOversped="
+
isPreingOversped
);
if
((
isLoadSuccess
==
0
// 加载失败
||
(
adLoadTime
>
0
&&
isOversped
)
// 超过45分钟
||
(
adPreingTime
>
0
&&
isPreingOversped
&&
isLoadSuccess
==
1
))
// 预加载超时
&&
this
.
activity
.
get
()
!=
null
)
{
adPreingTime
=
System
.
currentTimeMillis
();
isLoadSuccess
=
1
;
LogUtil
.
d
(
TAG
,
"gromore应用内新插屏半屏广告-> 2、执行预加载去了="
+
isLoadSuccess
);
if
(
TTMediationAdSdk
.
configLoadSuccess
())
{
loadAd
();
}
else
{
TTMediationAdSdk
.
registerConfigCallback
(
mSettingConfigCallback
);
}
}
}
/**
* config回调
*/
private
final
TTSettingConfigCallback
mSettingConfigCallback
=
this
::
loadAd
;
private
void
loadAd
()
{
fullId
=
getFullId
();
isClickScreen
=
true
;
AdReportManager
.
INSTANCE
.
eventFull
(
getInner
(),
AdReportManager
.
EVENT_TYPE_REQUEST
,
""
,
fullId
,
""
,
""
,
System
.
currentTimeMillis
(),
mCarrier
,
""
,
""
,
""
);
/**
* 选择的模板类型
* 如果服务端配置了模板类型跟随服务端配置
* 有效值 0 客户端设置生效 1 原生 2 模板 1.0 3 模板 2.0
* 服务端没有下发数值客户端设置模板版本才会生效
*/
/**
* 注:每次加载全屏视频广告的时候需要新建一个TTFullVideoAd,否则可能会出现广告填充问题
* ( 例如:mTTFullVideoAd = new TTFullVideoAd(this, adUnitId);)
*/
mTTFullVideoAd
=
new
TTFullVideoAd
(
activity
.
get
(),
fullId
);
//声音控制 模板 2.0
TTVideoOption
videoOption
=
VideoOptionUtil
.
getTTVideoOption2
();
//创建广告请求参数AdSlot,具体参数含义参考文档
AdSlot
.
Builder
adSlotBuilder
=
new
AdSlot
.
Builder
()
.
setAdStyleType
(
AdSlot
.
TYPE_EXPRESS_AD
)
.
setTTVideoOption
(
videoOption
)
//设置声音控制
.
setUserID
(
UserManager
.
getInstance
().
getUserID
())
//用户id,必传参数
.
setMediaExtra
(
"media_extra"
)
//附加参数,可选
.
setOrientation
(
TTAdConstant
.
VERTICAL
);
//必填参数,期望视频的播放方向:TTAdConstant.HORIZONTAL 或 TTAdConstant.VERTICAL;
//请求广告
mTTFullVideoAd
.
loadFullAd
(
adSlotBuilder
.
build
(),
new
TTFullVideoAdLoadCallback
()
{
@Override
public
void
onFullVideoLoadFail
(
AdError
adError
)
{
LogUtil
.
d
(
TAG
,
"gromore应用内新插屏半屏广告--> 3、onFullVideoLoadFail onError "
+
adError
.
code
+
adError
.
message
);
AdReportManager
.
INSTANCE
.
eventFull
(
getInner
(),
AdReportManager
.
EVENT_TYPE_FAIL
,
adcode
,
fullId
,
ecpm
,
String
.
valueOf
(
adSource
),
System
.
currentTimeMillis
(),
mCarrier
,
"onFullVideoLoadFail"
,
String
.
valueOf
(
adError
.
code
),
adError
.
message
);
isLoadSuccess
=
0
;
// if (wifiAdStatusListener != null) {
// wifiAdStatusListener.adFail();
// }
}
@Override
public
void
onFullVideoAdLoad
()
{
LogUtil
.
d
(
TAG
,
"gromore应用内新插屏半屏广告--> 3、Gromore 新插屏onFullVideoAdLoad "
);
if
(
mTTFullVideoAd
!=
null
)
{
adcode
=
mTTFullVideoAd
.
getAdNetworkRitId
();
ecpm
=
mTTFullVideoAd
.
getPreEcpm
();
adSource
=
mTTFullVideoAd
.
getAdNetworkPlatformId
();
}
AdReportManager
.
INSTANCE
.
eventFull
(
getInner
(),
AdReportManager
.
EVENT_TYPE_SUC
,
adcode
,
fullId
,
ecpm
,
String
.
valueOf
(
adSource
),
System
.
currentTimeMillis
(),
mCarrier
,
""
,
""
,
""
);
isLoadSuccess
=
2
;
adLoadTime
=
System
.
currentTimeMillis
();
if
(
wifiAdStatusListener
!=
null
)
{
wifiAdStatusListener
.
adSuccess
();
}
}
@Override
public
void
onFullVideoCached
()
{
isLoadSuccess
=
2
;
adLoadTime
=
System
.
currentTimeMillis
();
LogUtil
.
d
(
TAG
,
"gromore应用内新插屏半屏广告--> 3、Gromore 新插屏onFullVideoCached "
);
}
});
}
private
String
getFullId
()
{
return
CsjGroMoreManager
.
INSTANCE
.
getOutCommonNewInterstitialId
();
}
public
void
showFullAd
(
Activity
_activity
,
WifiAdStatusListener
wifiAdStatusListener
,
String
carrier
)
{
mCarrier
=
carrier
;
this
.
activity
=
new
WeakReference
<>(
_activity
);
boolean
isOversped
=
TimeRender
.
isOverspedMin
(
adLoadTime
,
AdHelper
.
AD_NO_SHOWTIME_OUT
);
this
.
wifiAdStatusListener
=
wifiAdStatusListener
;
// 若上一个广告还在加载中则返回
if
(
isLoadSuccess
==
1
)
{
if
(
this
.
wifiAdStatusListener
!=
null
)
this
.
wifiAdStatusListener
.
adFail
();
return
;
}
// 预加载广告成功 且 预加载广告时长未超过45分钟
if
(
isLoadSuccess
==
2
&&
!
isOversped
&&
mTTFullVideoAd
!=
null
&&
mTTFullVideoAd
.
isReady
()
&&
this
.
activity
.
get
()
!=
null
)
{
isClickScreen
=
true
;
LogUtil
.
d
(
TAG
,
"gromore应用内新插屏半屏广告--> 4、展示广告LoadSuccess="
+
isLoadSuccess
+
" isReady="
+
mTTFullVideoAd
.
isReady
()
+
" isOversped="
+
isOversped
+
" activity="
+
this
.
activity
.
get
());
//在获取到广告后展示,强烈建议在onRewardVideoCached回调后,展示广告,提升播放体验
//该方法直接展示广告
//展示广告,并传入广告展示的场景
mTTFullVideoAd
.
showFullAd
(
this
.
activity
.
get
(),
mTTFullVideoAdListener
);
}
else
{
LogUtil
.
d
(
TAG
,
"gromore应用内新插屏半屏广告--> 5、展示广告时失败了,广告可能超时45分钟 onError "
);
AdReportManager
.
INSTANCE
.
eventFull
(
getInner
(),
AdReportManager
.
EVENT_TYPE_SHOWFAIL
,
adcode
,
fullId
,
ecpm
,
String
.
valueOf
(
adSource
),
System
.
currentTimeMillis
(),
mCarrier
,
"LoadSuccess="
+
isLoadSuccess
+
" isOversped="
+
isOversped
,
"999995"
,
"showFail"
);
if
(
this
.
wifiAdStatusListener
!=
null
)
this
.
wifiAdStatusListener
.
adFail
();
}
// 状态重置
isLoadSuccess
=
0
;
}
public
int
getLoadStatus
()
{
return
isLoadSuccess
;
}
/**
* 激励视频交互回调
*/
private
final
TTFullVideoAdListener
mTTFullVideoAdListener
=
new
TTFullVideoAdListener
()
{
@Override
public
void
onFullVideoAdShow
()
{
if
(
mTTFullVideoAd
!=
null
)
{
adcode
=
mTTFullVideoAd
.
getAdNetworkRitId
();
ecpm
=
mTTFullVideoAd
.
getPreEcpm
();
adSource
=
mTTFullVideoAd
.
getAdNetworkPlatformId
();
HashMap
<
String
,
Object
>
vo
=
new
HashMap
<>();
vo
.
put
(
"adcode"
,
adcode
);
vo
.
put
(
"ecpm"
,
ecpm
);
vo
.
put
(
"adSource"
,
adSource
);
vo
.
put
(
"adType"
,
Constant
.
GRO_MORE_ADTYPE4
);
vo
.
put
(
"adid"
,
fullId
);
TrackManager
.
getInstance
().
cmtGroMoreInfo
(
vo
);
AdReportManager
.
INSTANCE
.
eventFull
(
getInner
(),
AdReportManager
.
EVENT_TYPE_SHOW
,
adcode
,
fullId
,
ecpm
,
String
.
valueOf
(
adSource
),
System
.
currentTimeMillis
(),
mCarrier
,
""
,
""
,
""
);
}
Log
.
d
(
TAG
,
"onFullVideoAdShow"
);
// 应用内展示时预加载下一个
if
(
activity
.
get
()
!=
null
&&
!
activity
.
get
().
isFinishing
())
{
preloadFullAd
(
activity
.
get
(),
mCarrier
);
}
}
@Override
public
void
onFullVideoAdShowFail
(
AdError
adError
)
{
AdReportManager
.
INSTANCE
.
eventFull
(
getInner
(),
AdReportManager
.
EVENT_TYPE_SHOWFAIL
,
adcode
,
fullId
,
ecpm
,
String
.
valueOf
(
adSource
),
System
.
currentTimeMillis
(),
mCarrier
,
"onFullVideoAdShowFail"
,
String
.
valueOf
(
adError
.
code
),
adError
.
message
);
if
(
wifiAdStatusListener
!=
null
)
wifiAdStatusListener
.
adFail
();
}
@Override
public
void
onFullVideoAdClick
()
{
Log
.
d
(
TAG
,
"onFullVideoAdClick"
);
AdReportManager
.
INSTANCE
.
eventFull
(
getInner
(),
AdReportManager
.
EVENT_TYPE_CLICK
,
adcode
,
fullId
,
ecpm
,
String
.
valueOf
(
adSource
),
System
.
currentTimeMillis
(),
mCarrier
,
""
,
""
,
""
);
if
(
isClickScreen
)
{
// 防止重复
AdReportManager
.
INSTANCE
.
eventFull
(
getInner
(),
AdReportManager
.
EVENT_TYPE_REPEAT
,
adcode
,
fullId
,
ecpm
,
String
.
valueOf
(
adSource
),
System
.
currentTimeMillis
(),
mCarrier
,
""
,
""
,
""
);
isClickScreen
=
false
;
}
}
@Override
public
void
onFullVideoAdClosed
()
{
if
(
wifiAdStatusListener
!=
null
)
wifiAdStatusListener
.
adClose
();
Log
.
d
(
TAG
,
"onFullVideoAdClosed"
);
AdReportManager
.
INSTANCE
.
eventFull
(
getInner
(),
AdReportManager
.
EVENT_TYPE_CLOSE
,
adcode
,
fullId
,
ecpm
,
String
.
valueOf
(
adSource
),
System
.
currentTimeMillis
(),
mCarrier
,
""
,
""
,
""
);
}
@Override
public
void
onVideoComplete
()
{
Log
.
d
(
TAG
,
"onVideoComplete"
);
}
@Override
public
void
onVideoError
()
{
isLoadSuccess
=
0
;
AdReportManager
.
INSTANCE
.
eventFull
(
getInner
(),
AdReportManager
.
EVENT_TYPE_SHOWFAIL
,
adcode
,
fullId
,
ecpm
,
String
.
valueOf
(
adSource
),
System
.
currentTimeMillis
(),
mCarrier
,
"onVideoError"
,
"999999"
,
"onVideoError"
);
Log
.
d
(
TAG
,
"onVideoError"
);
}
@Override
public
void
onSkippedVideo
()
{
Log
.
d
(
TAG
,
"onSkippedVideo"
);
}
};
private
String
getInner
()
{
return
AdReportManager
.
INNER_IN
;
}
public
void
setWifiAdStatusListener
(
WifiAdStatusListener
wifiAdStatusListener
)
{
this
.
wifiAdStatusListener
=
wifiAdStatusListener
;
}
}
app/src/main/java/com/mints/fiveworld/ad/wifi/WifiAdManager.kt
View file @
b62ff519
...
...
@@ -5,10 +5,9 @@ import android.os.Bundle
import
com.mints.fiveworld.ad.full.OutSceneFull
import
com.mints.fiveworld.ad.full.InSceneFull
import
com.mints.fiveworld.ad.full.Notice_OutSceneFull
import
com.mints.fiveworld.ad.inscreen.InSceneInterstitial
import
com.mints.fiveworld.ad.half.NewInSceneFull
import
com.mints.fiveworld.ad.half.NewOutSceneFull
import
com.mints.fiveworld.ad.
inscreen.Notice_OutSceneInterstitia
l
import
com.mints.fiveworld.ad.
half.Notice_NewOutSceneFul
l
import
com.mints.fiveworld.common.Constant
import
com.mints.fiveworld.common.random.HitChanceKeeper
import
com.mints.fiveworld.manager.ad.CsjGroMoreManager
...
...
@@ -110,7 +109,7 @@ class WifiAdManager private constructor() {
fun
getInCurrentAdStatus
():
Boolean
{
when
(
inCurrentAdType
)
{
Constant
.
GROMORE_INSERTSCREEN_AD
->
{
return
InSceneInterstitia
l
.
getInstance
().
loadStatus
==
2
return
NewInSceneFul
l
.
getInstance
().
loadStatus
==
2
}
Constant
.
GROMORE_FULL_AD
->
{
return
InSceneFull
.
getInstance
().
loadStatus
==
2
...
...
@@ -198,7 +197,7 @@ class WifiAdManager private constructor() {
fun
getOutCurrentAdStatus
():
Boolean
{
when
(
outCurrentAdType
)
{
Constant
.
GROMORE_INSERTSCREEN_AD
->
{
return
Notice_
OutSceneInterstitia
l
.
getInstance
().
loadStatus
==
2
return
Notice_
NewOutSceneFul
l
.
getInstance
().
loadStatus
==
2
}
Constant
.
GROMORE_FULL_AD
->
{
return
Notice_OutSceneFull
.
getInstance
().
loadStatus
==
2
...
...
@@ -266,7 +265,7 @@ class WifiAdManager private constructor() {
when
(
noticeOutCurrentAdType
)
{
Constant
.
GROMORE_INSERTSCREEN_AD
->
{
Notice_
OutSceneInterstitial
.
getInstance
().
preloadInsertScreen
Ad
(
activity
,
carrier
)
Notice_
NewOutSceneFull
.
getInstance
().
preloadFull
Ad
(
activity
,
carrier
)
}
Constant
.
GROMORE_FULL_AD
->
{
Notice_OutSceneFull
.
getInstance
().
preloadFullAd
(
activity
,
carrier
)
...
...
@@ -285,8 +284,8 @@ class WifiAdManager private constructor() {
)
{
when
(
noticeOutCurrentAdType
)
{
Constant
.
GROMORE_INSERTSCREEN_AD
->
{
Notice_
OutSceneInterstitia
l
.
getInstance
()
.
show
Interaction
Ad
(
_activity
,
wifiAdStatusListener
,
carrier
)
Notice_
NewOutSceneFul
l
.
getInstance
()
.
show
Full
Ad
(
_activity
,
wifiAdStatusListener
,
carrier
)
}
Constant
.
GROMORE_FULL_AD
->
{
Notice_OutSceneFull
.
getInstance
()
...
...
app/src/main/java/com/mints/fiveworld/ui/widgets/CycleProgress.java
View file @
b62ff519
...
...
@@ -104,7 +104,7 @@ public class CycleProgress extends View {
pathMeasure
.
getSegment
(
0
,
pathMeasure
.
getLength
()
*
mAnimatorValue
,
dstPath
,
true
);
//渐变
Shader
mShader
=
new
LinearGradient
(
mStrokeWidth
/
2
,
mStrokeWidth
/
2
,
mProgressWidth
,
mHeight
-
mStrokeWidth
/
2
,
Color
.
parseColor
(
"#
DEAEC5"
),
Color
.
parseColor
(
"#FB918A
"
),
Shader
.
TileMode
.
REPEAT
);
Color
.
parseColor
(
"#
38A8F5"
),
Color
.
parseColor
(
"#468df8
"
),
Shader
.
TileMode
.
REPEAT
);
//遮罩
mProgressPaint
.
setXfermode
(
new
PorterDuffXfermode
(
PorterDuff
.
Mode
.
SRC_IN
));
mProgressPaint
.
setShader
(
mShader
);
...
...
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