Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_flowbox
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_flowbox
Commits
7e74c21e
Commit
7e74c21e
authored
Jul 21, 2021
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加插屏功能
parent
884561f5
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
112 additions
and
159 deletions
+112
-159
FullGroManager.java
...c/main/java/com/mints/flowbox/ad/full/FullGroManager.java
+9
-60
InterstitialGroManager.java
...com/mints/flowbox/ad/inscreen/InterstitialGroManager.java
+8
-6
WifiAdManager.kt
app/src/main/java/com/mints/flowbox/ad/wifi/WifiAdManager.kt
+87
-85
CsjGroMoreManager.kt
.../main/java/com/mints/flowbox/manager/CsjGroMoreManager.kt
+7
-7
ic_loading.gif
app/src/main/res/drawable-xhdpi/ic_loading.gif
+0
-0
loadingdialog.xml
app/src/main/res/layout/loadingdialog.xml
+1
-1
No files found.
app/src/main/java/com/mints/flowbox/ad/full/FullGroManager.java
View file @
7e74c21e
...
...
@@ -42,8 +42,6 @@ public class FullGroManager {
private
boolean
isMain
=
false
;
private
String
fullId
;
private
ArrayList
<
WeightBean
>
weightList
;
public
void
loadFullAd
(
Activity
activity
,
boolean
isMain
)
{
// 加载到广告且未展示 则返回
if
(
isLoadSuccess
)
return
;
...
...
@@ -66,10 +64,6 @@ public class FullGroManager {
activity
=
null
;
isLoadSuccess
=
false
;
if
(
weightList
!=
null
)
{
weightList
.
clear
();
}
weightList
=
null
;
}
/**
...
...
@@ -84,7 +78,7 @@ public class FullGroManager {
};
private
void
loadAd
()
{
fullId
=
getFullId
(
getRandomWeightType
()
);
fullId
=
getFullId
();
/**
* 选择的模板类型
...
...
@@ -96,8 +90,8 @@ public class FullGroManager {
* 注:每次加载全屏视频广告的时候需要新建一个TTFullVideoAd,否则可能会出现广告填充问题
* ( 例如:mTTFullVideoAd = new TTFullVideoAd(this, adUnitId);)
*/
// mTTFullVideoAd = new TTFullVideoAd(activity, CsjGroMoreManager.INSTANCE.getAPP_IN_COMMON_AD_UNIT
_INTERSTITIAL_ID());
mTTFullVideoAd
=
new
TTFullVideoAd
(
activity
,
fullId
);
mTTFullVideoAd
=
new
TTFullVideoAd
(
activity
,
CsjGroMoreManager
.
INSTANCE
.
getAPP_OUT_AD_UNIT_NEW
_INTERSTITIAL_ID
());
//
mTTFullVideoAd = new TTFullVideoAd(activity, fullId);
// mTTFullVideoAd = new TTFullVideoAd(activity, "946369785");
//声音控制 模板 2.0
// TTVideoOption videoOption = VideoOptionUtil.getTTVideoOption();
...
...
@@ -138,64 +132,19 @@ public class FullGroManager {
});
}
private
String
getFullId
(
String
type
)
{
String
id
=
CsjGroMoreManager
.
INSTANCE
.
getAPP_IN_COMMON_AD_FULL_UNIT_NEW_INTERSTITIAL_ID
();
switch
(
type
)
{
case
Constant
.
GROMORE_NEW_FULL_AD
:
private
String
getFullId
()
{
String
id
;
if
(
isMain
)
{
id
=
CsjGroMoreManager
.
INSTANCE
.
getAPP_IN_COMMON_AD_FULL_UNIT_NEW_INTERSTITIAL_ID
();
}
else
{
id
=
CsjGroMoreManager
.
INSTANCE
.
getAPP_OUT_AD_UNIT_FULL_NEW_INTERSTITIAL_ID
();
}
break
;
case
Constant
.
GROMORE_NEW_INSERTSCREEN_AD
:
if
(
isMain
)
{
id
=
CsjGroMoreManager
.
INSTANCE
.
getAPP_IN_COMMON_AD_UNIT_NEW_INTERSTITIAL_ID
();
}
else
{
id
=
CsjGroMoreManager
.
INSTANCE
.
getAPP_OUT_AD_UNIT_NEW_INTERSTITIAL_ID
();
}
break
;
}
LogUtil
.
d
(
"id:"
+
id
);
return
id
;
}
private
String
getRandomWeightType
()
{
if
(
weightList
!=
null
)
{
weightList
.
clear
();
}
else
{
weightList
=
new
ArrayList
<>();
}
int
weight
=
0
;
int
fullInterstitialWeight
=
CsjGroMoreManager
.
INSTANCE
.
getAPP_FULL_NEW_INTERSTITIAL_WEIGHT
();
if
(
fullInterstitialWeight
>
0
)
{
weightList
.
add
(
new
WeightBean
(
fullInterstitialWeight
,
Constant
.
GROMORE_NEW_FULL_AD
));
weight
=
weight
+
fullInterstitialWeight
;
}
int
interstitialWeight
=
CsjGroMoreManager
.
INSTANCE
.
getAPP_NEW_INTERSTITIAL_WEIGHT
();
if
(
interstitialWeight
>
0
)
{
weightList
.
add
(
new
WeightBean
(
interstitialWeight
,
Constant
.
GROMORE_NEW_INSERTSCREEN_AD
));
weight
=
weight
+
interstitialWeight
;
}
if
(
weightList
!=
null
&&
weightList
.
size
()
>
0
&&
weight
>
0
)
{
LogUtil
.
d
(
TAG
,
"1、权重总值:"
+
weight
);
Random
r
=
new
Random
();
int
randomWeight
=
r
.
nextInt
(
weight
)
+
1
;
LogUtil
.
d
(
TAG
,
"2、权重随机值:"
+
randomWeight
);
// ToastUtil.show(MintsApplication.getContext(),"权重随机值:" + randomWeight);
for
(
WeightBean
weightBean
:
weightList
)
{
randomWeight
-=
weightBean
.
getWeight
();
if
(
randomWeight
<=
0
)
{
LogUtil
.
d
(
TAG
,
"3、权重结果:"
+
weightBean
.
getType
());
return
weightBean
.
getType
();
}
}
}
return
Constant
.
GROMORE_NEW_FULL_AD
;
}
public
void
showFullAd
()
{
if
(
BuildConfig
.
DEBUG
)
{
...
...
app/src/main/java/com/mints/flowbox/ad/inscreen/InterstitialGroManager.java
View file @
7e74c21e
...
...
@@ -36,6 +36,7 @@ public class InterstitialGroManager {
private
boolean
isLoadSuccess
=
false
;
private
boolean
isMain
=
false
;
private
String
interstitialId
;
public
void
loadInsertScreenAd
(
Activity
activity
,
boolean
isMain
)
{
// 加载到广告且未展示 则返回
...
...
@@ -77,8 +78,13 @@ public class InterstitialGroManager {
* 注:每次加载插屏广告的时候需要新建一个TTInterstitialAd,否则可能会出现广告填充问题
* ( 例如:mInterstitialAd = new TTInterstitialAd(this, adUnitId);)
*/
if
(
isMain
)
{
interstitialId
=
CsjGroMoreManager
.
INSTANCE
.
getAPP_IN_COMMON_AD_UNIT_NEW_INTERSTITIAL_ID
();
}
else
{
interstitialId
=
CsjGroMoreManager
.
INSTANCE
.
getAPP_OUT_AD_UNIT_NEW_INTERSTITIAL_ID
();
}
// mInterstitialAd = new TTInterstitialAd(activity, CsjGroMoreManager.INSTANCE.getAPP_IN_MAIN_AD_UNIT_INTERSTITIAL_ID());
mInterstitialAd
=
new
TTInterstitialAd
(
activity
,
"946369785"
);
mInterstitialAd
=
new
TTInterstitialAd
(
activity
,
interstitialId
);
//模板1.0
TTVideoOption
videoOption
=
VideoOptionUtil
.
getTTVideoOption
();
...
...
@@ -153,11 +159,7 @@ public class InterstitialGroManager {
vo
.
put
(
"ecpm"
,
mInterstitialAd
.
getPreEcpm
());
vo
.
put
(
"adSource"
,
mInterstitialAd
.
getAdNetworkPlatformId
());
vo
.
put
(
"adType"
,
Constant
.
GRO_MORE_ADTYPE3
);
if
(
isMain
)
{
vo
.
put
(
"adid"
,
CsjGroMoreManager
.
INSTANCE
.
getAPP_IN_MAIN_AD_UNIT_INTERSTITIAL_ID
());
}
else
{
vo
.
put
(
"adid"
,
CsjGroMoreManager
.
INSTANCE
.
getAPP_IN_MAIN_AD_UNIT_INTERSTITIAL_ID
());
}
vo
.
put
(
"adid"
,
interstitialId
);
TrackManager
.
getInstance
().
cmtGroMoreInfo
(
vo
);
}
else
{
// 当加载到广告后 ,长时间未展示失效时 改变状态
...
...
app/src/main/java/com/mints/flowbox/ad/wifi/WifiAdManager.kt
View file @
7e74c21e
...
...
@@ -2,6 +2,12 @@ package com.mints.flowbox.ad.wifi
import
android.app.Activity
import
com.mints.flowbox.ad.full.FullGroManager
import
com.mints.flowbox.ad.inscreen.InterstitialGroManager
import
com.mints.flowbox.common.Constant
import
com.mints.flowbox.manager.CsjGroMoreManager
import
com.mints.flowbox.mvp.model.WeightBean
import
com.mints.flowbox.utils.LogUtil
import
java.util.*
/**
* wifi广告管理
...
...
@@ -10,6 +16,9 @@ import com.mints.flowbox.ad.full.FullGroManager
*/
class
WifiAdManager
private
constructor
()
{
private
val
TAG
=
WifiAdManager
::
class
.
java
.
simpleName
companion
object
{
val
instance
:
WifiAdManager
by
lazy
(
mode
=
LazyThreadSafetyMode
.
SYNCHRONIZED
)
{
WifiAdManager
()
...
...
@@ -19,58 +28,79 @@ class WifiAdManager private constructor() {
private
var
wifiAdStatusListener
:
WifiAdStatusListener
?
=
null
// groMore插屏
//
private var interstitialGroManager: InterstitialGroManager? = null
private
var
interstitialGroManager
:
InterstitialGroManager
?
=
null
// groMore全屏
private
var
fullGroManager
:
FullGroManager
?
=
null
// 当前广告类型
// private var currentAdType = ""
private
var
currentAdType
=
""
private
var
weightList
:
ArrayList
<
WeightBean
>?
=
null
/**
* 预加载广告,必须传入activity
*/
fun
loadWifiAd
(
activity
:
Activity
)
{
// currentAdType = getCurrentAdType()
//
// when (currentAdType) {
// Constant.GROMORE_INSERTSCREEN_AD -> {
// preLoadInterstitialGroMore(activity)
// }
// Constant.GROMORE_FULL_AD -> {
// preLoadFullGroMore(activity,true)
// }
// }
currentAdType
=
getRandomWeightType
()
when
(
currentAdType
)
{
Constant
.
GROMORE_INSERTSCREEN_AD
->
{
preLoadInterstitialGroMore
(
activity
,
true
)
}
Constant
.
GROMORE_FULL_AD
->
{
preLoadFullGroMore
(
activity
,
true
)
}
}
}
/**
* 定义广告类型规则
*/
// private fun getCurrentAdType(): String {
// var tempAdType = ""
// val randomInt = Random().nextInt(10)
// if (randomInt % 2 == 0) {
// tempAdType = Constant.GROMORE_INSERTSCREEN_AD
// } else {
// tempAdType = Constant.GROMORE_FULL_AD
// }
//
// return tempAdType
// return Constant.GROMORE_FULL_AD
// }
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
=
weight
+
fullInterstitialWeight
}
val
interstitialWeight
=
CsjGroMoreManager
.
APP_NEW_INTERSTITIAL_WEIGHT
if
(
interstitialWeight
>
0
)
{
weightList
!!
.
add
(
WeightBean
(
interstitialWeight
,
Constant
.
GROMORE_NEW_INSERTSCREEN_AD
))
weight
=
weight
+
interstitialWeight
}
if
(
weightList
!=
null
&&
weightList
!!
.
size
>
0
&&
weight
>
0
)
{
LogUtil
.
d
(
TAG
,
"1、权重总值:$weight"
)
val
r
=
Random
()
var
randomWeight
=
r
.
nextInt
(
weight
)
+
1
LogUtil
.
d
(
TAG
,
"2、权重随机值:$randomWeight"
)
// ToastUtil.show(MintsApplication.getContext(),"权重随机值:" + randomWeight);
for
(
weightBean
in
weightList
!!
)
{
randomWeight
-=
weightBean
.
weight
if
(
randomWeight
<=
0
)
{
LogUtil
.
d
(
TAG
,
"3、权重结果:"
+
weightBean
.
type
)
return
weightBean
.
type
}
}
}
return
Constant
.
GROMORE_FULL_AD
}
/**
* 插屏
*/
// private fun preLoadInterstitialGroMore(activity: Activity
) {
//
if (interstitialGroManager != null) {
//
interstitialGroManager?.onDestroy()
//
}
//
interstitialGroManager = InterstitialGroManager()
// interstitialGroManager?.loadInsertScreenAd(activity, false
)
//
}
private
fun
preLoadInterstitialGroMore
(
activity
:
Activity
,
isMain
:
Boolean
)
{
if
(
interstitialGroManager
!=
null
)
{
interstitialGroManager
?.
onDestroy
()
}
interstitialGroManager
=
InterstitialGroManager
()
interstitialGroManager
?.
loadInsertScreenAd
(
activity
,
isMain
)
}
/**
* 全屏
...
...
@@ -87,62 +117,34 @@ class WifiAdManager private constructor() {
/**
* 展示广告
*/
fun
showInterstitial
()
{
// when (currentAdType) {
//// Constant.GROMORE_INSERTSCREEN_AD -> {
//// interstitialGroManager?.setWifiAdStatusListener(object : WifiAdStatusListener {
//// override fun adSuccess() {
////
//// }
////
//// override fun adFail() {
////
//// }
////
//// override fun adClose() {
//// wifiAdStatusListener?.adClose()
//// }
//// })
//// interstitialGroManager?.showInteractionAd()
//// }
// Constant.GROMORE_FULL_AD -> {
fullGroManager
?.
setWifiAdStatusListener
(
wifiAdStatusListener
)
fullGroManager
?.
showFullAd
()
// }
// }
fun
showInterstitial
(
_activity
:
Activity
)
{
when
(
currentAdType
)
{
Constant
.
GROMORE_INSERTSCREEN_AD
->
{
interstitialGroManager
?.
setWifiAdStatusListener
(
object
:
WifiAdStatusListener
{
override
fun
adSuccess
()
{
wifiAdStatusListener
?.
adSuccess
()
}
/**
* 展示广告
*/
fun
showInterstitial
(
_activity
:
Activity
)
{
// when (currentAdType) {
// Constant.GROMORE_INSERTSCREEN_AD -> {
// interstitialGroManager?.setWifiAdStatusListener(object : WifiAdStatusListener {
// override fun adSuccess() {
//
// }
//
// override fun adFail() {
//
// }
//
// override fun adClose() {
// wifiAdStatusListener?.adClose()
// }
// })
// interstitialGroManager?.showInteractionAd(_activity)
// }
// Constant.GROMORE_FULL_AD -> {
override
fun
adFail
()
{
wifiAdStatusListener
?.
adFail
()
}
override
fun
adClose
()
{
wifiAdStatusListener
?.
adClose
()
}
})
interstitialGroManager
?.
showInteractionAd
(
_activity
)
}
Constant
.
GROMORE_FULL_AD
->
{
fullGroManager
?.
showFullAd
(
_activity
,
wifiAdStatusListener
)
//
}
//
}
}
}
}
fun
onDestroy
()
{
//
interstitialGroManager?.onDestroy()
//
interstitialGroManager?.setWifiAdStatusListener(null)
//
interstitialGroManager = null
interstitialGroManager
?.
onDestroy
()
interstitialGroManager
?.
setWifiAdStatusListener
(
null
)
interstitialGroManager
=
null
fullGroManager
?.
onDestroy
()
fullGroManager
=
null
...
...
app/src/main/java/com/mints/flowbox/manager/CsjGroMoreManager.kt
View file @
7e74c21e
...
...
@@ -14,8 +14,8 @@ object CsjGroMoreManager {
* 老用户代码位-- ↓
* 应用内:
* 普通:
* 新插屏
(全屏)
-> 946333578
*
新插屏(插屏)
->
* 新插屏 -> 946333578
*
插屏
->
* 信息流 -> 946265897
* 网赚:
* 激励视频 -> 946265896
...
...
@@ -24,8 +24,8 @@ object CsjGroMoreManager {
* 开屏 -> 887506685
* 应用外:
* 普通:
* 新插屏
(全屏)
-> 946333773
*
新插屏(插屏) ->
* 新插屏 -> 946333773
*
插屏 -> 946369728
* 信息流 -> 946333992
* 锁屏:
* 信息流 -> 946334023
...
...
@@ -34,10 +34,10 @@ object CsjGroMoreManager {
var
APP_OUT_AD_UNIT_EXPRESS_ID
=
"946333992"
// 应用外普通信息流
var
APP_OUT_AD_UNIT_LOCK_EXPRESS_ID
=
"946334023"
// 应用外锁屏信息流
var
APP_OUT_AD_UNIT_FULL_NEW_INTERSTITIAL_ID
=
"946333773"
// 应用外新插屏(全屏)
var
APP_OUT_AD_UNIT_NEW_INTERSTITIAL_ID
=
"
"
// 应用外新插屏(插屏)
var
APP_OUT_AD_UNIT_NEW_INTERSTITIAL_ID
=
"
946369728"
// 应用外插屏
var
APP_IN_COMMON_AD_FULL_UNIT_NEW_INTERSTITIAL_ID
=
"946333578"
// 应用内 普通 新插屏(全屏)
var
APP_IN_COMMON_AD_UNIT_NEW_INTERSTITIAL_ID
=
"
"
// 应用内 普通 新插屏(插屏)
var
APP_IN_COMMON_AD_UNIT_NEW_INTERSTITIAL_ID
=
"
946369787"
// 应用内 普通 插屏
var
APP_IN_COMMON_AD_UNIT_EXPRESS_ID
=
"946265897"
// 应用内 普通 信息流
var
APP_IN_MAIN_AD_UNIT_VIDEO_ID
=
"946265896"
// 应用内 网赚 激励视频
var
APP_IN_MAIN_AD_UNIT_EXPRESS_ID
=
"946334121"
// 应用内 网赚 信息流
...
...
@@ -45,7 +45,7 @@ object CsjGroMoreManager {
var
APP_IN_MAIN_AD_UNIT_SPLASH_ID
=
"887506685"
// 应用内 网赚 开屏
var
APP_FULL_NEW_INTERSTITIAL_WEIGHT
=
2
// 新插屏(全屏)权重
var
APP_NEW_INTERSTITIAL_WEIGHT
=
1
//
新插屏(插屏)
权重
var
APP_NEW_INTERSTITIAL_WEIGHT
=
1
//
插屏
权重
fun
init
(
application
:
MintsApplication
)
{
TTGroMoreAdManagerHolder
.
init
(
application
)
...
...
app/src/main/res/drawable-xhdpi/ic_loading.gif
View replaced file @
884561f5
View file @
7e74c21e
445 KB
|
W:
|
H:
374 KB
|
W:
|
H:
2-up
Swipe
Onion skin
app/src/main/res/layout/loadingdialog.xml
View file @
7e74c21e
...
...
@@ -35,7 +35,7 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"加载中..."
android:textColor=
"
@color/color_3D5AFE
"
android:textColor=
"
#1ba0fc
"
android:textSize=
"14sp"
/>
</LinearLayout>
...
...
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