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
68c773e1
Commit
68c773e1
authored
Jun 30, 2021
by
mengcuiguang2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化广告信息流逻辑
parent
4832d8b2
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
391 additions
and
428 deletions
+391
-428
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-1
MintsApplication.java
app/src/main/java/com/mints/flowbox/MintsApplication.java
+9
-9
ExpressManager.kt
.../main/java/com/mints/flowbox/ad/express/ExpressManager.kt
+27
-0
GroMoreCarrierExpressManager.kt
.../mints/flowbox/ad/express/GroMoreCarrierExpressManager.kt
+107
-159
GroMoreExpressManager.kt
...ava/com/mints/flowbox/ad/express/GroMoreExpressManager.kt
+107
-159
KsPreLoadExpressManager.kt
...a/com/mints/flowbox/ad/express/KsPreLoadExpressManager.kt
+28
-32
PreLoadExpressManager.kt
...ava/com/mints/flowbox/ad/express/PreLoadExpressManager.kt
+14
-5
TTPreLoadCarrierExpressManager.java
...ts/flowbox/ad/express/TTPreLoadCarrierExpressManager.java
+1
-1
TTPreLoadExpressManager.java
...com/mints/flowbox/ad/express/TTPreLoadExpressManager.java
+2
-1
YlhPreLoadExpressManager.kt
.../com/mints/flowbox/ad/express/YlhPreLoadExpressManager.kt
+35
-32
TTGroMoreAdManagerHolder.java
...om/mints/flowbox/manager/ad/TTGroMoreAdManagerHolder.java
+1
-1
FoodSubsidyActivity.kt
...ava/com/mints/flowbox/ui/activitys/FoodSubsidyActivity.kt
+5
-6
SplashGroMoreActivity.java
...com/mints/flowbox/ui/activitys/SplashGroMoreActivity.java
+2
-2
WalkActivity.kt
.../main/java/com/mints/flowbox/ui/activitys/WalkActivity.kt
+5
-6
WaterActivity.kt
...main/java/com/mints/flowbox/ui/activitys/WaterActivity.kt
+5
-6
HomeFragment.kt
...c/main/java/com/mints/flowbox/ui/fragment/HomeFragment.kt
+5
-8
network_security_config.xml
app/src/main/res/xml/network_security_config.xml
+37
-0
No files found.
app/src/main/AndroidManifest.xml
View file @
68c773e1
...
@@ -303,7 +303,7 @@
...
@@ -303,7 +303,7 @@
</provider>
</provider>
<!-- 常驻通知栏service -->
<!-- 常驻通知栏service -->
<service
android:name=
"com.mints.flowbox.keepalive.NotificationService"
/
>
<!-- <service android:name="com.mints.flowbox.keepalive.NotificationService" />--
>
</application>
</application>
...
...
app/src/main/java/com/mints/flowbox/MintsApplication.java
View file @
68c773e1
...
@@ -248,11 +248,11 @@ public class MintsApplication extends BaseApp {
...
@@ -248,11 +248,11 @@ public class MintsApplication extends BaseApp {
}
}
}
}
//
@Override
@Override
//
public void onLowMemory() {
public
void
onLowMemory
()
{
//
android.os.Process.killProcess(android.os.Process.myPid());
android
.
os
.
Process
.
killProcess
(
android
.
os
.
Process
.
myPid
());
//
super.onLowMemory();
super
.
onLowMemory
();
//
}
}
@Override
@Override
protected
void
attachBaseContext
(
Context
base
)
{
protected
void
attachBaseContext
(
Context
base
)
{
...
@@ -264,7 +264,7 @@ public class MintsApplication extends BaseApp {
...
@@ -264,7 +264,7 @@ public class MintsApplication extends BaseApp {
KeepAliveHelper
.
Companion
.
preInit
(
base
,
this
,
NotificationService
.
class
);
KeepAliveHelper
.
Companion
.
preInit
(
base
,
this
,
NotificationService
.
class
);
// 9.0之后不可多进程使用一个目录下的WebView,写在SDK初始化之前
// 9.0之后不可多进程使用一个目录下的WebView,写在SDK初始化之前
androidPWebView
();
//
androidPWebView();
}
}
/*
/*
...
@@ -281,7 +281,7 @@ public class MintsApplication extends BaseApp {
...
@@ -281,7 +281,7 @@ public class MintsApplication extends BaseApp {
initMiitHelper
();
initMiitHelper
();
// 优量汇
// 优量汇
//
YlhAdManager.INSTANCE.initYlhAd(this);
YlhAdManager
.
INSTANCE
.
initYlhAd
(
this
);
// GroMore
// GroMore
CsjGroMoreManager
.
INSTANCE
.
init
(
this
);
CsjGroMoreManager
.
INSTANCE
.
init
(
this
);
...
@@ -290,10 +290,10 @@ public class MintsApplication extends BaseApp {
...
@@ -290,10 +290,10 @@ public class MintsApplication extends BaseApp {
OwManager
.
INSTANCE
.
init
(
this
);
OwManager
.
INSTANCE
.
init
(
this
);
// 穿山甲
// 穿山甲
//
TtCsjAdManager.init(this);
TtCsjAdManager
.
init
(
this
);
// 快手
// 快手
//
KsManager.INSTANCE.initKs(this);
KsManager
.
INSTANCE
.
initKs
(
this
);
// 闪电盒子
// 闪电盒子
WnManager
.
INSTANCE
.
initWn
(
this
);
WnManager
.
INSTANCE
.
initWn
(
this
);
...
...
app/src/main/java/com/mints/flowbox/ad/express/ExpressManager.kt
0 → 100644
View file @
68c773e1
package
com.mints.flowbox.ad.express
import
android.widget.FrameLayout
import
com.mints.flowbox.common.AppConfig
import
com.mints.flowbox.manager.TtCsjAdManager
/**
* 能用信息流加载
*/
object
ExpressManager
{
fun
loadExpress
()
{
if
(
AppConfig
.
groMoreVideoAdCount
>
0
)
{
GroMoreCarrierExpressManager
.
instance
.
loadADFrameLayout
()
}
else
{
TTPreLoadCarrierExpressManager
.
getInstance
().
loadTtFrameLayout
(
TtCsjAdManager
.
TT_AD_NATIVEEXPRESS_WATER
)
}
}
fun
getExpressFrameLayout
():
FrameLayout
?
{
if
(
AppConfig
.
groMoreVideoAdCount
>
0
)
{
return
GroMoreCarrierExpressManager
.
instance
.
getADFrameLayout
()
}
else
{
return
TTPreLoadCarrierExpressManager
.
getInstance
().
ttFrameLayout
}
}
}
\ No newline at end of file
app/src/main/java/com/mints/flowbox/ad/express/GroMoreCarrierExpressManager.kt
View file @
68c773e1
...
@@ -12,8 +12,9 @@ import com.bumptech.glide.Glide
...
@@ -12,8 +12,9 @@ import com.bumptech.glide.Glide
import
com.bytedance.msdk.adapter.util.UIUtils
import
com.bytedance.msdk.adapter.util.UIUtils
import
com.bytedance.msdk.api.*
import
com.bytedance.msdk.api.*
import
com.bytedance.msdk.api.nativeAd.*
import
com.bytedance.msdk.api.nativeAd.*
import
com.mints.flowbox.MintsApplication
import
com.mints.flowbox.R
import
com.mints.flowbox.R
import
com.mints.flowbox.MintsApplication
import
com.mints.flowbox.common.AppConfig
import
com.mints.flowbox.common.Constant
import
com.mints.flowbox.common.Constant
import
com.mints.flowbox.manager.CsjGroMoreManager
import
com.mints.flowbox.manager.CsjGroMoreManager
import
com.mints.flowbox.manager.TrackManager
import
com.mints.flowbox.manager.TrackManager
...
@@ -67,8 +68,7 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
...
@@ -67,8 +68,7 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
}
}
private
fun
loadAd
()
{
private
fun
loadAd
()
{
mTTAdNative
=
mTTAdNative
=
TTUnifiedNativeAd
(
MintsApplication
.
getContext
(),
CsjGroMoreManager
.
AD_UNIT_EXPRESS_ID
)
TTUnifiedNativeAd
(
MintsApplication
.
getContext
(),
CsjGroMoreManager
.
AD_UNIT_EXPRESS_ID
)
//视频声音控制设置
//视频声音控制设置
var
videoOption
:
TTVideoOption
=
VideoOptionUtil
.
getTTVideoOption
()
var
videoOption
:
TTVideoOption
=
VideoOptionUtil
.
getTTVideoOption
()
...
@@ -82,16 +82,14 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
...
@@ -82,16 +82,14 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
//针对Admob Native的特殊配置项
//针对Admob Native的特殊配置项
val
admobNativeAdOptions
=
AdmobNativeAdOptions
()
val
admobNativeAdOptions
=
AdmobNativeAdOptions
()
admobNativeAdOptions
.
setAdChoicesPlacement
(
AdmobNativeAdOptions
.
ADCHOICES_TOP_RIGHT
)
//设置广告小标默认情况下,广告选择叠加层会显示在右上角。
admobNativeAdOptions
.
setAdChoicesPlacement
(
AdmobNativeAdOptions
.
ADCHOICES_TOP_RIGHT
)
//设置广告小标默认情况下,广告选择叠加层会显示在右上角。
.
setRequestMultipleImages
(
true
).
isReturnUrlsForImageAssets
=
.
setRequestMultipleImages
(
true
).
isReturnUrlsForImageAssets
=
true
//设置为true,SDK会仅提供Uri字段的值,允许自行决定是否下载实际图片,同时不会提供Drawable字段的值
true
//设置为true,SDK会仅提供Uri字段的值,允许自行决定是否下载实际图片,同时不会提供Drawable字段的值
// 针对Gdt Native自渲染广告,可以自定义gdt logo的布局参数。该参数可选,非必须。
// 针对Gdt Native自渲染广告,可以自定义gdt logo的布局参数。该参数可选,非必须。
val
gdtNativeAdLogUtiloParams
=
FrameLayout
.
LayoutParams
(
val
gdtNativeAdLogUtiloParams
=
FrameLayout
.
LayoutParams
(
BubbleUtils
.
dp2px
(
40
),
BubbleUtils
.
dp2px
(
40
),
BubbleUtils
.
dp2px
(
14
),
BubbleUtils
.
dp2px
(
14
),
Gravity
.
END
or
Gravity
.
TOP
Gravity
.
END
or
Gravity
.
TOP
)
// 例如,放在右上角
)
// 例如,放在右上角
/**
/**
* 创建feed广告请求类型参数AdSlot,具体参数含义参考文档
* 创建feed广告请求类型参数AdSlot,具体参数含义参考文档
...
@@ -106,13 +104,13 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
...
@@ -106,13 +104,13 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
* 2:如果是信息流模板广告,宽度设置为希望的宽度,高度设置为0(0为高度选择自适应参数)
* 2:如果是信息流模板广告,宽度设置为希望的宽度,高度设置为0(0为高度选择自适应参数)
*/
*/
val
adSlot
=
AdSlot
.
Builder
()
val
adSlot
=
AdSlot
.
Builder
()
.
setTTVideoOption
(
videoOption
)
//视频声音相关的配置
.
setTTVideoOption
(
videoOption
)
//视频声音相关的配置
.
setAdmobNativeAdOptions
(
admobNativeAdOptions
)
.
setAdmobNativeAdOptions
(
admobNativeAdOptions
)
.
setAdStyleType
(
mAdStyle
)
//必传,表示请求的模板广告还是原生广告,AdSlot.TYPE_EXPRESS_AD:模板广告 ; AdSlot.TYPE_NATIVE_AD:原生广告
.
setAdStyleType
(
mAdStyle
)
//必传,表示请求的模板广告还是原生广告,AdSlot.TYPE_EXPRESS_AD:模板广告 ; AdSlot.TYPE_NATIVE_AD:原生广告
.
setImageAdSize
(
340
,
0
)
// 必选参数 单位dp ,详情见上面备注解释
.
setImageAdSize
(
340
,
0
)
// 必选参数 单位dp ,详情见上面备注解释
.
setAdCount
(
1
)
//请求广告数量为1到3条
.
setAdCount
(
1
)
//请求广告数量为1到3条
.
setGdtNativeAdLogoParams
(
gdtNativeAdLogUtiloParams
)
// 设置gdt logo布局参数。
.
setGdtNativeAdLogoParams
(
gdtNativeAdLogUtiloParams
)
// 设置gdt logo布局参数。
.
build
()
.
build
()
//请求广告,调用feed广告异步请求接口,加载到广告后,拿到广告素材自定义渲染
//请求广告,调用feed广告异步请求接口,加载到广告后,拿到广告素材自定义渲染
/**
/**
...
@@ -122,6 +120,8 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
...
@@ -122,6 +120,8 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
mTTAdNative
?.
loadAd
(
adSlot
,
object
:
TTNativeAdLoadCallback
{
mTTAdNative
?.
loadAd
(
adSlot
,
object
:
TTNativeAdLoadCallback
{
override
fun
onAdLoadedFial
(
adError
:
AdError
?)
{
override
fun
onAdLoadedFial
(
adError
:
AdError
?)
{
LogUtil
.
e
(
TAG
,
"load feed ad error : "
+
adError
?.
code
+
", "
+
adError
?.
message
)
LogUtil
.
e
(
TAG
,
"load feed ad error : "
+
adError
?.
code
+
", "
+
adError
?.
message
)
AppConfig
.
isPreExpressAwardActivity
=
false
}
}
override
fun
onAdLoaded
(
ads
:
MutableList
<
TTNativeAd
>?)
{
override
fun
onAdLoaded
(
ads
:
MutableList
<
TTNativeAd
>?)
{
...
@@ -132,10 +132,7 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
...
@@ -132,10 +132,7 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
for
(
ttNativeAd
in
ads
)
{
for
(
ttNativeAd
in
ads
)
{
LogUtil
.
e
(
TAG
,
" "
)
LogUtil
.
e
(
TAG
,
" "
)
LogUtil
.
e
(
LogUtil
.
e
(
TAG
,
"adNetworkPlatformId: "
+
ttNativeAd
.
adNetworkPlatformId
+
" adNetworkRitId:"
+
ttNativeAd
.
adNetworkRitId
+
" preEcpm: "
+
ttNativeAd
.
preEcpm
)
TAG
,
"adNetworkPlatformId: "
+
ttNativeAd
.
adNetworkPlatformId
+
" adNetworkRitId:"
+
ttNativeAd
.
adNetworkRitId
+
" preEcpm: "
+
ttNativeAd
.
preEcpm
)
}
}
if
(
ads
.
size
>
0
)
{
if
(
ads
.
size
>
0
)
{
...
@@ -147,6 +144,7 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
...
@@ -147,6 +144,7 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
vo
[
"ecpm"
]
=
ttNativeAd
.
preEcpm
vo
[
"ecpm"
]
=
ttNativeAd
.
preEcpm
vo
[
"adSource"
]
=
ttNativeAd
.
adNetworkPlatformId
vo
[
"adSource"
]
=
ttNativeAd
.
adNetworkPlatformId
vo
[
"adType"
]
=
Constant
.
GRO_MORE_ADTYPE1
vo
[
"adType"
]
=
Constant
.
GRO_MORE_ADTYPE1
vo
[
"adid"
]
=
CsjGroMoreManager
.
AD_UNIT_EXPRESS_ID
TrackManager
.
getInstance
().
cmtGroMoreInfo
(
vo
)
TrackManager
.
getInstance
().
cmtGroMoreInfo
(
vo
)
}
}
}
}
...
@@ -207,12 +205,10 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
...
@@ -207,12 +205,10 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
//渲染模板广告
//渲染模板广告
private
fun
getExpressAdView
(
ad
:
TTNativeAd
):
View
?
{
private
fun
getExpressAdView
(
ad
:
TTNativeAd
):
View
?
{
val
adViewHolder
:
ExpressAdViewHolder
val
adViewHolder
:
ExpressAdViewHolder
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_native_express
,
null
,
false
)
.
inflate
(
R
.
layout
.
listitem_ad_native_express
,
null
,
false
)
try
{
try
{
adViewHolder
=
ExpressAdViewHolder
()
adViewHolder
=
ExpressAdViewHolder
()
adViewHolder
.
mAdContainerView
=
adViewHolder
.
mAdContainerView
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_express
)
as
FrameLayout
convertView
.
findViewById
(
R
.
id
.
iv_listitem_express
)
as
FrameLayout
convertView
.
tag
=
adViewHolder
convertView
.
tag
=
adViewHolder
//判断是否存在dislike按钮
//判断是否存在dislike按钮
...
@@ -240,14 +236,8 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
...
@@ -240,14 +236,8 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
LogUtil
.
d
(
TAG
,
"onAdClick"
)
LogUtil
.
d
(
TAG
,
"onAdClick"
)
}
}
override
fun
onAdShow
()
{
// ** 注意点 ** 不要在广告加载成功回调里进行广告view展示,要在onRenderSucces进行广告view展示,否则会导致广告无法展示。
LogUtil
.
d
(
TAG
,
"onAdShow"
)
// 另外,不要直接使用参数view,而是通过ad.getExpressView()来获取广告view。
}
override
fun
onRenderFail
(
view
:
View
,
msg
:
String
,
code
:
Int
)
{
LogUtil
.
d
(
TAG
,
"onRenderFail code=$code,msg=$msg"
)
}
override
fun
onRenderSuccess
(
width
:
Float
,
height
:
Float
)
{
override
fun
onRenderSuccess
(
width
:
Float
,
height
:
Float
)
{
LogUtil
.
d
(
TAG
,
"onRenderSuccess"
)
LogUtil
.
d
(
TAG
,
"onRenderSuccess"
)
//回调渲染成功后将模板布局添加的父View中
//回调渲染成功后将模板布局添加的父View中
...
@@ -273,6 +263,13 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
...
@@ -273,6 +263,13 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
}
}
}
}
override
fun
onAdShow
()
{
LogUtil
.
d
(
TAG
,
"onAdShow"
)
}
override
fun
onRenderFail
(
view
:
View
,
msg
:
String
,
code
:
Int
)
{
LogUtil
.
d
(
TAG
,
"onRenderFail code=$code,msg=$msg"
)
}
})
})
...
@@ -311,36 +308,30 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
...
@@ -311,36 +308,30 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
* @return
* @return
*/
*/
private
fun
getVerticalAdView
(
ad
:
TTNativeAd
):
View
?
{
private
fun
getVerticalAdView
(
ad
:
TTNativeAd
):
View
?
{
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_vertical_pic
,
null
,
false
)
.
inflate
(
R
.
layout
.
listitem_ad_vertical_pic
,
null
,
false
)
val
adViewHolder
=
VerticalAdViewHolder
()
val
adViewHolder
=
VerticalAdViewHolder
()
adViewHolder
.
mTitle
=
convertView
!!
.
findViewById
(
R
.
id
.
tv_listitem_ad_title
)
as
TextView
adViewHolder
.
mTitle
=
convertView
!!
.
findViewById
(
R
.
id
.
tv_listitem_ad_title
)
as
TextView
adViewHolder
.
mSource
=
convertView
.
findViewById
(
R
.
id
.
tv_listitem_ad_source
)
as
TextView
adViewHolder
.
mSource
=
convertView
.
findViewById
(
R
.
id
.
tv_listitem_ad_source
)
as
TextView
adViewHolder
.
mDescription
=
adViewHolder
.
mDescription
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_desc
)
as
TextView
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_desc
)
as
TextView
adViewHolder
.
mVerticalImage
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_image
)
adViewHolder
.
mVerticalImage
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_image
)
adViewHolder
.
mIcon
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mIcon
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mDislike
=
adViewHolder
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_vertical_pic
)
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_vertical_pic
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
build
()
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
convertView
.
tag
=
adViewHolder
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
if
(
ad
.
imageUrl
!=
null
)
{
if
(
ad
.
imageUrl
!=
null
)
{
adViewHolder
.
mVerticalImage
?.
let
{
adViewHolder
.
mVerticalImage
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
}
}
return
convertView
return
convertView
}
}
...
@@ -349,36 +340,28 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
...
@@ -349,36 +340,28 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
private
fun
getVideoView
(
ad
:
TTNativeAd
):
View
?
{
private
fun
getVideoView
(
ad
:
TTNativeAd
):
View
?
{
val
adViewHolder
:
VideoAdViewHolder
val
adViewHolder
:
VideoAdViewHolder
val
viewBinder
:
TTViewBinder
val
viewBinder
:
TTViewBinder
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_large_video
,
null
,
false
)
.
inflate
(
R
.
layout
.
listitem_ad_large_video
,
null
,
false
)
try
{
try
{
adViewHolder
=
VideoAdViewHolder
()
adViewHolder
=
VideoAdViewHolder
()
adViewHolder
.
mTitle
=
adViewHolder
.
mTitle
=
convertView
!!
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_title
)
as
TextView
convertView
!!
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_title
)
as
TextView
adViewHolder
.
mDescription
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_desc
)
as
TextView
adViewHolder
.
mDescription
=
adViewHolder
.
mSource
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_source
)
as
TextView
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_desc
)
as
TextView
adViewHolder
.
videoView
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_video
)
as
FrameLayout
adViewHolder
.
mSource
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_source
)
as
TextView
adViewHolder
.
videoView
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_video
)
as
FrameLayout
adViewHolder
.
mIcon
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mIcon
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mDislike
=
adViewHolder
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mCreativeButton
=
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
//TTViewBinder 是必须类,需要开发者在确定好View之后把Id设置给TTViewBinder类,并在注册事件时传递给SDK
//TTViewBinder 是必须类,需要开发者在确定好View之后把Id设置给TTViewBinder类,并在注册事件时传递给SDK
viewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_large_video
)
viewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_large_video
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
mediaViewIdId
(
R
.
id
.
iv_listitem_video
)
.
mediaViewIdId
(
R
.
id
.
iv_listitem_video
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
convertView
.
tag
=
adViewHolder
...
@@ -414,46 +397,36 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
...
@@ -414,46 +397,36 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
}
}
private
fun
getLargeAdView
(
ad
:
TTNativeAd
):
View
?
{
private
fun
getLargeAdView
(
ad
:
TTNativeAd
):
View
?
{
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_large_pic
,
null
,
false
)
.
inflate
(
R
.
layout
.
listitem_ad_large_pic
,
null
,
false
)
val
adViewHolder
=
LargeAdViewHolder
()
val
adViewHolder
=
LargeAdViewHolder
()
adViewHolder
.
mTitle
=
adViewHolder
.
mTitle
=
convertView
!!
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_title
)
as
TextView
convertView
!!
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_title
)
as
TextView
adViewHolder
.
mDescription
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_desc
)
as
TextView
adViewHolder
.
mDescription
=
adViewHolder
.
mSource
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_source
)
as
TextView
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_desc
)
as
TextView
adViewHolder
.
mLargeImage
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_image
)
as
ImageView
adViewHolder
.
mSource
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_source
)
as
TextView
adViewHolder
.
mLargeImage
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_image
)
as
ImageView
adViewHolder
.
mIcon
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mIcon
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mDislike
=
adViewHolder
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_large_pic
)
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_large_pic
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
convertView
.
tag
=
adViewHolder
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
if
(
ad
.
imageUrl
!=
null
)
{
if
(
ad
.
imageUrl
!=
null
)
{
adViewHolder
.
mLargeImage
?.
let
{
adViewHolder
.
mLargeImage
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
}
}
return
convertView
return
convertView
}
}
private
fun
getGroupAdView
(
ad
:
TTNativeAd
):
View
?
{
private
fun
getGroupAdView
(
ad
:
TTNativeAd
):
View
?
{
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_group_pic
,
null
,
false
)
.
inflate
(
R
.
layout
.
listitem_ad_group_pic
,
null
,
false
)
val
adViewHolder
=
GroupAdViewHolder
()
val
adViewHolder
=
GroupAdViewHolder
()
adViewHolder
.
mTitle
=
convertView
!!
.
findViewById
(
R
.
id
.
tv_listitem_ad_title
)
as
TextView
adViewHolder
.
mTitle
=
convertView
!!
.
findViewById
(
R
.
id
.
tv_listitem_ad_title
)
as
TextView
adViewHolder
.
mSource
=
convertView
.
findViewById
(
R
.
id
.
tv_listitem_ad_source
)
as
TextView
adViewHolder
.
mSource
=
convertView
.
findViewById
(
R
.
id
.
tv_listitem_ad_source
)
as
TextView
...
@@ -463,18 +436,17 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
...
@@ -463,18 +436,17 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
adViewHolder
.
mGroupImage3
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_image3
)
as
ImageView
adViewHolder
.
mGroupImage3
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_image3
)
as
ImageView
adViewHolder
.
mIcon
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mIcon
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mDislike
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mDislike
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
(
R
.
id
.
btn_listitem_creative
)
as
Button
convertView
.
findViewById
(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_group_pic
)
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_group_pic
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
//传第一张即可
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
//传第一张即可
.
mainImageId
(
R
.
id
.
iv_listitem_image1
)
.
mainImageId
(
R
.
id
.
iv_listitem_image1
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
convertView
.
tag
=
adViewHolder
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
...
@@ -483,68 +455,48 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
...
@@ -483,68 +455,48 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
val
image2
=
ad
.
imageList
[
1
]
val
image2
=
ad
.
imageList
[
1
]
val
image3
=
ad
.
imageList
[
2
]
val
image3
=
ad
.
imageList
[
2
]
if
(
image1
!=
null
)
{
if
(
image1
!=
null
)
{
adViewHolder
.
mGroupImage1
?.
let
{
adViewHolder
.
mGroupImage1
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image1
).
into
(
it
)
}
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image1
).
into
(
it
)
}
}
}
if
(
image2
!=
null
)
{
if
(
image2
!=
null
)
{
adViewHolder
.
mGroupImage2
?.
let
{
adViewHolder
.
mGroupImage2
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image2
).
into
(
it
)
}
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image2
).
into
(
it
)
}
}
}
if
(
image3
!=
null
)
{
if
(
image3
!=
null
)
{
adViewHolder
.
mGroupImage3
?.
let
{
adViewHolder
.
mGroupImage3
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image3
).
into
(
it
)
}
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image3
).
into
(
it
)
}
}
}
}
}
return
convertView
return
convertView
}
}
private
fun
getSmallAdView
(
ad
:
TTNativeAd
):
View
?
{
private
fun
getSmallAdView
(
ad
:
TTNativeAd
):
View
?
{
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_small_pic
,
null
,
false
)
.
inflate
(
R
.
layout
.
listitem_ad_small_pic
,
null
,
false
)
val
adViewHolder
=
SmallAdViewHolder
()
val
adViewHolder
=
SmallAdViewHolder
()
adViewHolder
.
mTitle
=
adViewHolder
.
mTitle
=
convertView
!!
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_title
)
as
TextView
convertView
!!
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_title
)
as
TextView
adViewHolder
.
mSource
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_source
)
as
TextView
adViewHolder
.
mSource
=
adViewHolder
.
mDescription
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_desc
)
as
TextView
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_source
)
as
TextView
adViewHolder
.
mSmallImage
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_image
)
as
ImageView
adViewHolder
.
mDescription
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_desc
)
as
TextView
adViewHolder
.
mSmallImage
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_image
)
as
ImageView
adViewHolder
.
mIcon
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mIcon
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mDislike
=
adViewHolder
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_small_pic
)
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_small_pic
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议为GroupView 类型
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议为GroupView 类型
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
convertView
.
tag
=
adViewHolder
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
if
(
ad
.
imageUrl
!=
null
)
{
if
(
ad
.
imageUrl
!=
null
)
{
adViewHolder
.
mSmallImage
?.
let
{
adViewHolder
.
mSmallImage
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
}
}
return
convertView
return
convertView
}
}
private
fun
bindData
(
private
fun
bindData
(
convertView
:
View
,
adViewHolder
:
AdViewHolder
,
ad
:
TTNativeAd
,
viewBinder
:
TTViewBinder
)
{
convertView
:
View
,
adViewHolder
:
AdViewHolder
,
ad
:
TTNativeAd
,
viewBinder
:
TTViewBinder
)
{
//设置dislike弹窗,如果有
//设置dislike弹窗,如果有
// if (ad.hasDislike()) {
// if (ad.hasDislike()) {
// val ttAdDislike = ad.getDislikeDialog( MintsApplication.getContext() as Activity?)
// val ttAdDislike = ad.getDislikeDialog( MintsApplication.getContext() as Activity?)
...
@@ -604,16 +556,13 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
...
@@ -604,16 +556,13 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
adViewHolder
.
mSource
?.
text
=
if
(
TextUtils
.
isEmpty
(
ad
.
source
))
"广告来源"
else
ad
.
source
adViewHolder
.
mSource
?.
text
=
if
(
TextUtils
.
isEmpty
(
ad
.
source
))
"广告来源"
else
ad
.
source
val
icon
=
ad
.
iconUrl
val
icon
=
ad
.
iconUrl
if
(
icon
!=
null
)
{
if
(
icon
!=
null
)
{
adViewHolder
.
mIcon
?.
let
{
adViewHolder
.
mIcon
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
icon
).
into
(
it
)
}
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
icon
).
into
(
it
)
}
}
}
val
adCreativeButton
:
Button
?
=
adViewHolder
.
mCreativeButton
val
adCreativeButton
:
Button
?
=
adViewHolder
.
mCreativeButton
when
(
ad
.
interactionType
)
{
when
(
ad
.
interactionType
)
{
TTAdConstant
.
INTERACTION_TYPE_DOWNLOAD
->
{
TTAdConstant
.
INTERACTION_TYPE_DOWNLOAD
->
{
adCreativeButton
?.
visibility
=
View
.
VISIBLE
adCreativeButton
?.
visibility
=
View
.
VISIBLE
adCreativeButton
?.
text
=
adCreativeButton
?.
text
=
if
(
TextUtils
.
isEmpty
(
ad
.
actionText
))
"立即下载"
else
ad
.
actionText
if
(
TextUtils
.
isEmpty
(
ad
.
actionText
))
"立即下载"
else
ad
.
actionText
}
}
TTAdConstant
.
INTERACTION_TYPE_DIAL
->
{
TTAdConstant
.
INTERACTION_TYPE_DIAL
->
{
adCreativeButton
?.
visibility
=
View
.
VISIBLE
adCreativeButton
?.
visibility
=
View
.
VISIBLE
...
@@ -621,8 +570,7 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
...
@@ -621,8 +570,7 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
}
}
TTAdConstant
.
INTERACTION_TYPE_LANDING_PAGE
,
TTAdConstant
.
INTERACTION_TYPE_BROWSER
->
{
TTAdConstant
.
INTERACTION_TYPE_LANDING_PAGE
,
TTAdConstant
.
INTERACTION_TYPE_BROWSER
->
{
adCreativeButton
?.
visibility
=
View
.
VISIBLE
adCreativeButton
?.
visibility
=
View
.
VISIBLE
adCreativeButton
?.
text
=
adCreativeButton
?.
text
=
if
(
TextUtils
.
isEmpty
(
ad
.
actionText
))
"查看详情"
else
ad
.
actionText
if
(
TextUtils
.
isEmpty
(
ad
.
actionText
))
"查看详情"
else
ad
.
actionText
}
}
else
->
{
else
->
{
adCreativeButton
?.
visibility
=
View
.
GONE
adCreativeButton
?.
visibility
=
View
.
GONE
...
...
app/src/main/java/com/mints/flowbox/ad/express/GroMoreExpressManager.kt
View file @
68c773e1
...
@@ -10,8 +10,9 @@ import com.bumptech.glide.Glide
...
@@ -10,8 +10,9 @@ import com.bumptech.glide.Glide
import
com.bytedance.msdk.adapter.util.UIUtils
import
com.bytedance.msdk.adapter.util.UIUtils
import
com.bytedance.msdk.api.*
import
com.bytedance.msdk.api.*
import
com.bytedance.msdk.api.nativeAd.*
import
com.bytedance.msdk.api.nativeAd.*
import
com.mints.flowbox.MintsApplication
import
com.mints.flowbox.R
import
com.mints.flowbox.R
import
com.mints.flowbox.MintsApplication
import
com.mints.flowbox.common.AppConfig
import
com.mints.flowbox.common.Constant
import
com.mints.flowbox.common.Constant
import
com.mints.flowbox.manager.CsjGroMoreManager
import
com.mints.flowbox.manager.CsjGroMoreManager
import
com.mints.flowbox.manager.TrackManager
import
com.mints.flowbox.manager.TrackManager
...
@@ -62,8 +63,7 @@ class GroMoreExpressManager : TTSettingConfigCallback {
...
@@ -62,8 +63,7 @@ class GroMoreExpressManager : TTSettingConfigCallback {
}
}
private
fun
loadAd
()
{
private
fun
loadAd
()
{
mTTAdNative
=
mTTAdNative
=
TTUnifiedNativeAd
(
MintsApplication
.
getContext
(),
CsjGroMoreManager
.
AD_UNIT_EXPRESS_ID
)
TTUnifiedNativeAd
(
MintsApplication
.
getContext
(),
CsjGroMoreManager
.
AD_UNIT_EXPRESS_ID
)
//视频声音控制设置
//视频声音控制设置
var
videoOption
:
TTVideoOption
=
VideoOptionUtil
.
getTTVideoOption
()
var
videoOption
:
TTVideoOption
=
VideoOptionUtil
.
getTTVideoOption
()
...
@@ -77,16 +77,14 @@ class GroMoreExpressManager : TTSettingConfigCallback {
...
@@ -77,16 +77,14 @@ class GroMoreExpressManager : TTSettingConfigCallback {
//针对Admob Native的特殊配置项
//针对Admob Native的特殊配置项
val
admobNativeAdOptions
=
AdmobNativeAdOptions
()
val
admobNativeAdOptions
=
AdmobNativeAdOptions
()
admobNativeAdOptions
.
setAdChoicesPlacement
(
AdmobNativeAdOptions
.
ADCHOICES_TOP_RIGHT
)
//设置广告小标默认情况下,广告选择叠加层会显示在右上角。
admobNativeAdOptions
.
setAdChoicesPlacement
(
AdmobNativeAdOptions
.
ADCHOICES_TOP_RIGHT
)
//设置广告小标默认情况下,广告选择叠加层会显示在右上角。
.
setRequestMultipleImages
(
true
).
isReturnUrlsForImageAssets
=
.
setRequestMultipleImages
(
true
).
isReturnUrlsForImageAssets
=
true
//设置为true,SDK会仅提供Uri字段的值,允许自行决定是否下载实际图片,同时不会提供Drawable字段的值
true
//设置为true,SDK会仅提供Uri字段的值,允许自行决定是否下载实际图片,同时不会提供Drawable字段的值
// 针对Gdt Native自渲染广告,可以自定义gdt logo的布局参数。该参数可选,非必须。
// 针对Gdt Native自渲染广告,可以自定义gdt logo的布局参数。该参数可选,非必须。
val
gdtNativeAdLogUtiloParams
=
FrameLayout
.
LayoutParams
(
val
gdtNativeAdLogUtiloParams
=
FrameLayout
.
LayoutParams
(
BubbleUtils
.
dp2px
(
40
),
BubbleUtils
.
dp2px
(
40
),
BubbleUtils
.
dp2px
(
14
),
BubbleUtils
.
dp2px
(
14
),
Gravity
.
END
or
Gravity
.
TOP
Gravity
.
END
or
Gravity
.
TOP
)
// 例如,放在右上角
)
// 例如,放在右上角
/**
/**
* 创建feed广告请求类型参数AdSlot,具体参数含义参考文档
* 创建feed广告请求类型参数AdSlot,具体参数含义参考文档
...
@@ -101,13 +99,13 @@ class GroMoreExpressManager : TTSettingConfigCallback {
...
@@ -101,13 +99,13 @@ class GroMoreExpressManager : TTSettingConfigCallback {
* 2:如果是信息流模板广告,宽度设置为希望的宽度,高度设置为0(0为高度选择自适应参数)
* 2:如果是信息流模板广告,宽度设置为希望的宽度,高度设置为0(0为高度选择自适应参数)
*/
*/
val
adSlot
=
AdSlot
.
Builder
()
val
adSlot
=
AdSlot
.
Builder
()
.
setTTVideoOption
(
videoOption
)
//视频声音相关的配置
.
setTTVideoOption
(
videoOption
)
//视频声音相关的配置
.
setAdmobNativeAdOptions
(
admobNativeAdOptions
)
.
setAdmobNativeAdOptions
(
admobNativeAdOptions
)
.
setAdStyleType
(
mAdStyle
)
//必传,表示请求的模板广告还是原生广告,AdSlot.TYPE_EXPRESS_AD:模板广告 ; AdSlot.TYPE_NATIVE_AD:原生广告
.
setAdStyleType
(
mAdStyle
)
//必传,表示请求的模板广告还是原生广告,AdSlot.TYPE_EXPRESS_AD:模板广告 ; AdSlot.TYPE_NATIVE_AD:原生广告
.
setImageAdSize
(
340
,
0
)
// 必选参数 单位dp ,详情见上面备注解释
.
setImageAdSize
(
340
,
0
)
// 必选参数 单位dp ,详情见上面备注解释
.
setAdCount
(
1
)
//请求广告数量为1到3条
.
setAdCount
(
1
)
//请求广告数量为1到3条
.
setGdtNativeAdLogoParams
(
gdtNativeAdLogUtiloParams
)
// 设置gdt logo布局参数。
.
setGdtNativeAdLogoParams
(
gdtNativeAdLogUtiloParams
)
// 设置gdt logo布局参数。
.
build
()
.
build
()
//请求广告,调用feed广告异步请求接口,加载到广告后,拿到广告素材自定义渲染
//请求广告,调用feed广告异步请求接口,加载到广告后,拿到广告素材自定义渲染
/**
/**
...
@@ -117,6 +115,8 @@ class GroMoreExpressManager : TTSettingConfigCallback {
...
@@ -117,6 +115,8 @@ class GroMoreExpressManager : TTSettingConfigCallback {
mTTAdNative
?.
loadAd
(
adSlot
,
object
:
TTNativeAdLoadCallback
{
mTTAdNative
?.
loadAd
(
adSlot
,
object
:
TTNativeAdLoadCallback
{
override
fun
onAdLoadedFial
(
adError
:
AdError
?)
{
override
fun
onAdLoadedFial
(
adError
:
AdError
?)
{
LogUtil
.
e
(
TAG
,
"load feed ad error : "
+
adError
?.
code
+
", "
+
adError
?.
message
)
LogUtil
.
e
(
TAG
,
"load feed ad error : "
+
adError
?.
code
+
", "
+
adError
?.
message
)
AppConfig
.
isPreExpressAwardActivity
=
false
}
}
override
fun
onAdLoaded
(
ads
:
MutableList
<
TTNativeAd
>?)
{
override
fun
onAdLoaded
(
ads
:
MutableList
<
TTNativeAd
>?)
{
...
@@ -127,10 +127,7 @@ class GroMoreExpressManager : TTSettingConfigCallback {
...
@@ -127,10 +127,7 @@ class GroMoreExpressManager : TTSettingConfigCallback {
for
(
ttNativeAd
in
ads
)
{
for
(
ttNativeAd
in
ads
)
{
LogUtil
.
e
(
TAG
,
" "
)
LogUtil
.
e
(
TAG
,
" "
)
LogUtil
.
e
(
LogUtil
.
e
(
TAG
,
"adNetworkPlatformId: "
+
ttNativeAd
.
adNetworkPlatformId
+
" adNetworkRitId:"
+
ttNativeAd
.
adNetworkRitId
+
" preEcpm: "
+
ttNativeAd
.
preEcpm
)
TAG
,
"adNetworkPlatformId: "
+
ttNativeAd
.
adNetworkPlatformId
+
" adNetworkRitId:"
+
ttNativeAd
.
adNetworkRitId
+
" preEcpm: "
+
ttNativeAd
.
preEcpm
)
}
}
if
(
ads
.
size
>
0
)
{
if
(
ads
.
size
>
0
)
{
...
@@ -143,6 +140,7 @@ class GroMoreExpressManager : TTSettingConfigCallback {
...
@@ -143,6 +140,7 @@ class GroMoreExpressManager : TTSettingConfigCallback {
vo
[
"ecpm"
]
=
ttNativeAd
.
getPreEcpm
()
vo
[
"ecpm"
]
=
ttNativeAd
.
getPreEcpm
()
vo
[
"adSource"
]
=
ttNativeAd
.
getAdNetworkPlatformId
()
vo
[
"adSource"
]
=
ttNativeAd
.
getAdNetworkPlatformId
()
vo
[
"adType"
]
=
Constant
.
GRO_MORE_ADTYPE1
vo
[
"adType"
]
=
Constant
.
GRO_MORE_ADTYPE1
vo
[
"adid"
]
=
CsjGroMoreManager
.
AD_UNIT_EXPRESS_ID
TrackManager
.
getInstance
().
cmtGroMoreInfo
(
vo
)
TrackManager
.
getInstance
().
cmtGroMoreInfo
(
vo
)
// sAdFrameLayout.addView(createAdView(ads[0]))
// sAdFrameLayout.addView(createAdView(ads[0]))
}
}
...
@@ -151,7 +149,7 @@ class GroMoreExpressManager : TTSettingConfigCallback {
...
@@ -151,7 +149,7 @@ class GroMoreExpressManager : TTSettingConfigCallback {
})
})
}
}
fun
getADFrameLayout
():
FrameLayout
{
fun
getADFrameLayout
():
FrameLayout
?
{
return
sAdFrameLayout
return
sAdFrameLayout
}
}
...
@@ -204,14 +202,12 @@ class GroMoreExpressManager : TTSettingConfigCallback {
...
@@ -204,14 +202,12 @@ class GroMoreExpressManager : TTSettingConfigCallback {
}
}
//渲染模板广告
//渲染模板广告
private
fun
getExpressAdView
(
ad
:
TTNativeAd
):
View
{
private
fun
getExpressAdView
(
ad
:
TTNativeAd
):
View
?
{
val
adViewHolder
:
ExpressAdViewHolder
val
adViewHolder
:
ExpressAdViewHolder
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_native_express
,
null
,
false
)
.
inflate
(
R
.
layout
.
listitem_ad_native_express
,
null
,
false
)
try
{
try
{
adViewHolder
=
ExpressAdViewHolder
()
adViewHolder
=
ExpressAdViewHolder
()
adViewHolder
.
mAdContainerView
=
adViewHolder
.
mAdContainerView
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_express
)
as
FrameLayout
convertView
.
findViewById
(
R
.
id
.
iv_listitem_express
)
as
FrameLayout
convertView
.
tag
=
adViewHolder
convertView
.
tag
=
adViewHolder
//判断是否存在dislike按钮
//判断是否存在dislike按钮
...
@@ -247,6 +243,8 @@ class GroMoreExpressManager : TTSettingConfigCallback {
...
@@ -247,6 +243,8 @@ class GroMoreExpressManager : TTSettingConfigCallback {
LogUtil
.
d
(
TAG
,
"onRenderFail code=$code,msg=$msg"
)
LogUtil
.
d
(
TAG
,
"onRenderFail code=$code,msg=$msg"
)
}
}
// ** 注意点 ** 不要在广告加载成功回调里进行广告view展示,要在onRenderSucces进行广告view展示,否则会导致广告无法展示。
// 另外,不要直接使用参数view,而是通过ad.getExpressView()来获取广告view。
override
fun
onRenderSuccess
(
width
:
Float
,
height
:
Float
)
{
override
fun
onRenderSuccess
(
width
:
Float
,
height
:
Float
)
{
LogUtil
.
d
(
TAG
,
"onRenderSuccess"
)
LogUtil
.
d
(
TAG
,
"onRenderSuccess"
)
//回调渲染成功后将模板布局添加的父View中
//回调渲染成功后将模板布局添加的父View中
...
@@ -259,7 +257,7 @@ class GroMoreExpressManager : TTSettingConfigCallback {
...
@@ -259,7 +257,7 @@ class GroMoreExpressManager : TTSettingConfigCallback {
sWidth
=
FrameLayout
.
LayoutParams
.
MATCH_PARENT
sWidth
=
FrameLayout
.
LayoutParams
.
MATCH_PARENT
sHeight
=
FrameLayout
.
LayoutParams
.
WRAP_CONTENT
sHeight
=
FrameLayout
.
LayoutParams
.
WRAP_CONTENT
}
else
{
}
else
{
sWidth
=
UIUtils
.
getScreenWidth
(
MintsApplication
.
getContext
())
sWidth
=
UIUtils
.
getScreenWidth
(
MintsApplication
.
getContext
())
.
toInt
()
sHeight
=
(
sWidth
*
height
/
width
).
toInt
()
sHeight
=
(
sWidth
*
height
/
width
).
toInt
()
}
}
if
(
video
!=
null
)
{
if
(
video
!=
null
)
{
...
@@ -271,7 +269,6 @@ class GroMoreExpressManager : TTSettingConfigCallback {
...
@@ -271,7 +269,6 @@ class GroMoreExpressManager : TTSettingConfigCallback {
}
}
}
}
}
}
})
})
...
@@ -308,37 +305,31 @@ class GroMoreExpressManager : TTSettingConfigCallback {
...
@@ -308,37 +305,31 @@ class GroMoreExpressManager : TTSettingConfigCallback {
* @param ad
* @param ad
* @return
* @return
*/
*/
private
fun
getVerticalAdView
(
ad
:
TTNativeAd
):
View
{
private
fun
getVerticalAdView
(
ad
:
TTNativeAd
):
View
?
{
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_vertical_pic
,
null
,
false
)
.
inflate
(
R
.
layout
.
listitem_ad_vertical_pic
,
null
,
false
)
val
adViewHolder
=
VerticalAdViewHolder
()
val
adViewHolder
=
VerticalAdViewHolder
()
adViewHolder
.
mTitle
=
convertView
!!
.
findViewById
(
R
.
id
.
tv_listitem_ad_title
)
as
TextView
adViewHolder
.
mTitle
=
convertView
!!
.
findViewById
(
R
.
id
.
tv_listitem_ad_title
)
as
TextView
adViewHolder
.
mSource
=
convertView
.
findViewById
(
R
.
id
.
tv_listitem_ad_source
)
as
TextView
adViewHolder
.
mSource
=
convertView
.
findViewById
(
R
.
id
.
tv_listitem_ad_source
)
as
TextView
adViewHolder
.
mDescription
=
adViewHolder
.
mDescription
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_desc
)
as
TextView
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_desc
)
as
TextView
adViewHolder
.
mVerticalImage
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_image
)
adViewHolder
.
mVerticalImage
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_image
)
adViewHolder
.
mIcon
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mIcon
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mDislike
=
adViewHolder
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_vertical_pic
)
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_vertical_pic
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
build
()
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
convertView
.
tag
=
adViewHolder
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
if
(
ad
.
imageUrl
!=
null
)
{
if
(
ad
.
imageUrl
!=
null
)
{
adViewHolder
.
mVerticalImage
?.
let
{
adViewHolder
.
mVerticalImage
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
}
}
return
convertView
return
convertView
}
}
...
@@ -347,36 +338,28 @@ class GroMoreExpressManager : TTSettingConfigCallback {
...
@@ -347,36 +338,28 @@ class GroMoreExpressManager : TTSettingConfigCallback {
private
fun
getVideoView
(
ad
:
TTNativeAd
):
View
?
{
private
fun
getVideoView
(
ad
:
TTNativeAd
):
View
?
{
val
adViewHolder
:
VideoAdViewHolder
val
adViewHolder
:
VideoAdViewHolder
val
viewBinder
:
TTViewBinder
val
viewBinder
:
TTViewBinder
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_large_video
,
null
,
false
)
.
inflate
(
R
.
layout
.
listitem_ad_large_video
,
null
,
false
)
try
{
try
{
adViewHolder
=
VideoAdViewHolder
()
adViewHolder
=
VideoAdViewHolder
()
adViewHolder
.
mTitle
=
adViewHolder
.
mTitle
=
convertView
!!
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_title
)
as
TextView
convertView
!!
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_title
)
as
TextView
adViewHolder
.
mDescription
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_desc
)
as
TextView
adViewHolder
.
mDescription
=
adViewHolder
.
mSource
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_source
)
as
TextView
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_desc
)
as
TextView
adViewHolder
.
videoView
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_video
)
as
FrameLayout
adViewHolder
.
mSource
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_source
)
as
TextView
adViewHolder
.
videoView
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_video
)
as
FrameLayout
adViewHolder
.
mIcon
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mIcon
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mDislike
=
adViewHolder
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mCreativeButton
=
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
//TTViewBinder 是必须类,需要开发者在确定好View之后把Id设置给TTViewBinder类,并在注册事件时传递给SDK
//TTViewBinder 是必须类,需要开发者在确定好View之后把Id设置给TTViewBinder类,并在注册事件时传递给SDK
viewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_large_video
)
viewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_large_video
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
mediaViewIdId
(
R
.
id
.
iv_listitem_video
)
.
mediaViewIdId
(
R
.
id
.
iv_listitem_video
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
convertView
.
tag
=
adViewHolder
...
@@ -411,47 +394,37 @@ class GroMoreExpressManager : TTSettingConfigCallback {
...
@@ -411,47 +394,37 @@ class GroMoreExpressManager : TTSettingConfigCallback {
return
convertView
return
convertView
}
}
private
fun
getLargeAdView
(
ad
:
TTNativeAd
):
View
{
private
fun
getLargeAdView
(
ad
:
TTNativeAd
):
View
?
{
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_large_pic
,
null
,
false
)
.
inflate
(
R
.
layout
.
listitem_ad_large_pic
,
null
,
false
)
val
adViewHolder
=
LargeAdViewHolder
()
val
adViewHolder
=
LargeAdViewHolder
()
adViewHolder
.
mTitle
=
adViewHolder
.
mTitle
=
convertView
!!
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_title
)
as
TextView
convertView
!!
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_title
)
as
TextView
adViewHolder
.
mDescription
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_desc
)
as
TextView
adViewHolder
.
mDescription
=
adViewHolder
.
mSource
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_source
)
as
TextView
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_desc
)
as
TextView
adViewHolder
.
mLargeImage
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_image
)
as
ImageView
adViewHolder
.
mSource
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_source
)
as
TextView
adViewHolder
.
mLargeImage
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_image
)
as
ImageView
adViewHolder
.
mIcon
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mIcon
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mDislike
=
adViewHolder
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_large_pic
)
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_large_pic
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
convertView
.
tag
=
adViewHolder
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
if
(
ad
.
imageUrl
!=
null
)
{
if
(
ad
.
imageUrl
!=
null
)
{
adViewHolder
.
mLargeImage
?.
let
{
adViewHolder
.
mLargeImage
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
}
}
return
convertView
return
convertView
}
}
private
fun
getGroupAdView
(
ad
:
TTNativeAd
):
View
{
private
fun
getGroupAdView
(
ad
:
TTNativeAd
):
View
?
{
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_group_pic
,
null
,
false
)
.
inflate
(
R
.
layout
.
listitem_ad_group_pic
,
null
,
false
)
val
adViewHolder
=
GroupAdViewHolder
()
val
adViewHolder
=
GroupAdViewHolder
()
adViewHolder
.
mTitle
=
convertView
!!
.
findViewById
(
R
.
id
.
tv_listitem_ad_title
)
as
TextView
adViewHolder
.
mTitle
=
convertView
!!
.
findViewById
(
R
.
id
.
tv_listitem_ad_title
)
as
TextView
adViewHolder
.
mSource
=
convertView
.
findViewById
(
R
.
id
.
tv_listitem_ad_source
)
as
TextView
adViewHolder
.
mSource
=
convertView
.
findViewById
(
R
.
id
.
tv_listitem_ad_source
)
as
TextView
...
@@ -461,18 +434,17 @@ class GroMoreExpressManager : TTSettingConfigCallback {
...
@@ -461,18 +434,17 @@ class GroMoreExpressManager : TTSettingConfigCallback {
adViewHolder
.
mGroupImage3
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_image3
)
as
ImageView
adViewHolder
.
mGroupImage3
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_image3
)
as
ImageView
adViewHolder
.
mIcon
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mIcon
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mDislike
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mDislike
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
(
R
.
id
.
btn_listitem_creative
)
as
Button
convertView
.
findViewById
(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_group_pic
)
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_group_pic
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
//传第一张即可
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
//传第一张即可
.
mainImageId
(
R
.
id
.
iv_listitem_image1
)
.
mainImageId
(
R
.
id
.
iv_listitem_image1
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
convertView
.
tag
=
adViewHolder
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
...
@@ -481,68 +453,48 @@ class GroMoreExpressManager : TTSettingConfigCallback {
...
@@ -481,68 +453,48 @@ class GroMoreExpressManager : TTSettingConfigCallback {
val
image2
=
ad
.
imageList
[
1
]
val
image2
=
ad
.
imageList
[
1
]
val
image3
=
ad
.
imageList
[
2
]
val
image3
=
ad
.
imageList
[
2
]
if
(
image1
!=
null
)
{
if
(
image1
!=
null
)
{
adViewHolder
.
mGroupImage1
?.
let
{
adViewHolder
.
mGroupImage1
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image1
).
into
(
it
)
}
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image1
).
into
(
it
)
}
}
}
if
(
image2
!=
null
)
{
if
(
image2
!=
null
)
{
adViewHolder
.
mGroupImage2
?.
let
{
adViewHolder
.
mGroupImage2
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image2
).
into
(
it
)
}
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image2
).
into
(
it
)
}
}
}
if
(
image3
!=
null
)
{
if
(
image3
!=
null
)
{
adViewHolder
.
mGroupImage3
?.
let
{
adViewHolder
.
mGroupImage3
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image3
).
into
(
it
)
}
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image3
).
into
(
it
)
}
}
}
}
}
return
convertView
return
convertView
}
}
private
fun
getSmallAdView
(
ad
:
TTNativeAd
):
View
{
private
fun
getSmallAdView
(
ad
:
TTNativeAd
):
View
?
{
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_small_pic
,
null
,
false
)
.
inflate
(
R
.
layout
.
listitem_ad_small_pic
,
null
,
false
)
val
adViewHolder
=
SmallAdViewHolder
()
val
adViewHolder
=
SmallAdViewHolder
()
adViewHolder
.
mTitle
=
adViewHolder
.
mTitle
=
convertView
!!
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_title
)
as
TextView
convertView
!!
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_title
)
as
TextView
adViewHolder
.
mSource
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_source
)
as
TextView
adViewHolder
.
mSource
=
adViewHolder
.
mDescription
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_desc
)
as
TextView
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_source
)
as
TextView
adViewHolder
.
mSmallImage
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_image
)
as
ImageView
adViewHolder
.
mDescription
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_desc
)
as
TextView
adViewHolder
.
mSmallImage
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_image
)
as
ImageView
adViewHolder
.
mIcon
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mIcon
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mDislike
=
adViewHolder
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_small_pic
)
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_small_pic
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议为GroupView 类型
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议为GroupView 类型
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
convertView
.
tag
=
adViewHolder
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
if
(
ad
.
imageUrl
!=
null
)
{
if
(
ad
.
imageUrl
!=
null
)
{
adViewHolder
.
mSmallImage
?.
let
{
adViewHolder
.
mSmallImage
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
}
}
return
convertView
return
convertView
}
}
private
fun
bindData
(
private
fun
bindData
(
convertView
:
View
,
adViewHolder
:
AdViewHolder
,
ad
:
TTNativeAd
,
viewBinder
:
TTViewBinder
)
{
convertView
:
View
,
adViewHolder
:
AdViewHolder
,
ad
:
TTNativeAd
,
viewBinder
:
TTViewBinder
)
{
//设置dislike弹窗,如果有
//设置dislike弹窗,如果有
// if (ad.hasDislike()) {
// if (ad.hasDislike()) {
// val ttAdDislike = ad.getDislikeDialog( MintsApplication.getContext() as Activity?)
// val ttAdDislike = ad.getDislikeDialog( MintsApplication.getContext() as Activity?)
...
@@ -602,16 +554,13 @@ class GroMoreExpressManager : TTSettingConfigCallback {
...
@@ -602,16 +554,13 @@ class GroMoreExpressManager : TTSettingConfigCallback {
adViewHolder
.
mSource
?.
text
=
if
(
TextUtils
.
isEmpty
(
ad
.
source
))
"广告来源"
else
ad
.
source
adViewHolder
.
mSource
?.
text
=
if
(
TextUtils
.
isEmpty
(
ad
.
source
))
"广告来源"
else
ad
.
source
val
icon
=
ad
.
iconUrl
val
icon
=
ad
.
iconUrl
if
(
icon
!=
null
)
{
if
(
icon
!=
null
)
{
adViewHolder
.
mIcon
?.
let
{
adViewHolder
.
mIcon
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
icon
).
into
(
it
)
}
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
icon
).
into
(
it
)
}
}
}
val
adCreativeButton
:
Button
?
=
adViewHolder
.
mCreativeButton
val
adCreativeButton
:
Button
?
=
adViewHolder
.
mCreativeButton
when
(
ad
.
interactionType
)
{
when
(
ad
.
interactionType
)
{
TTAdConstant
.
INTERACTION_TYPE_DOWNLOAD
->
{
TTAdConstant
.
INTERACTION_TYPE_DOWNLOAD
->
{
adCreativeButton
?.
visibility
=
View
.
VISIBLE
adCreativeButton
?.
visibility
=
View
.
VISIBLE
adCreativeButton
?.
text
=
adCreativeButton
?.
text
=
if
(
TextUtils
.
isEmpty
(
ad
.
actionText
))
"立即下载"
else
ad
.
actionText
if
(
TextUtils
.
isEmpty
(
ad
.
actionText
))
"立即下载"
else
ad
.
actionText
}
}
TTAdConstant
.
INTERACTION_TYPE_DIAL
->
{
TTAdConstant
.
INTERACTION_TYPE_DIAL
->
{
adCreativeButton
?.
visibility
=
View
.
VISIBLE
adCreativeButton
?.
visibility
=
View
.
VISIBLE
...
@@ -619,8 +568,7 @@ class GroMoreExpressManager : TTSettingConfigCallback {
...
@@ -619,8 +568,7 @@ class GroMoreExpressManager : TTSettingConfigCallback {
}
}
TTAdConstant
.
INTERACTION_TYPE_LANDING_PAGE
,
TTAdConstant
.
INTERACTION_TYPE_BROWSER
->
{
TTAdConstant
.
INTERACTION_TYPE_LANDING_PAGE
,
TTAdConstant
.
INTERACTION_TYPE_BROWSER
->
{
adCreativeButton
?.
visibility
=
View
.
VISIBLE
adCreativeButton
?.
visibility
=
View
.
VISIBLE
adCreativeButton
?.
text
=
adCreativeButton
?.
text
=
if
(
TextUtils
.
isEmpty
(
ad
.
actionText
))
"查看详情"
else
ad
.
actionText
if
(
TextUtils
.
isEmpty
(
ad
.
actionText
))
"查看详情"
else
ad
.
actionText
}
}
else
->
{
else
->
{
adCreativeButton
?.
visibility
=
View
.
GONE
adCreativeButton
?.
visibility
=
View
.
GONE
...
...
app/src/main/java/com/mints/flowbox/ad/express/KsPreLoadExpressManager.kt
View file @
68c773e1
...
@@ -15,6 +15,7 @@ import com.kwad.sdk.api.*
...
@@ -15,6 +15,7 @@ import com.kwad.sdk.api.*
import
com.kwad.sdk.api.KsNativeAd.VideoPlayListener
import
com.kwad.sdk.api.KsNativeAd.VideoPlayListener
import
com.mints.flowbox.MintsApplication
import
com.mints.flowbox.MintsApplication
import
com.mints.flowbox.R
import
com.mints.flowbox.R
import
com.mints.flowbox.common.AppConfig
import
com.mints.flowbox.manager.ad.KsManager
import
com.mints.flowbox.manager.ad.KsManager
import
com.mints.flowbox.utils.LogUtil
import
com.mints.flowbox.utils.LogUtil
import
java.util.*
import
java.util.*
...
@@ -36,12 +37,13 @@ object KsPreLoadExpressManager {
...
@@ -36,12 +37,13 @@ object KsPreLoadExpressManager {
try
{
try
{
var
ksNativeAd
:
KsNativeAd
?
var
ksNativeAd
:
KsNativeAd
?
val
scene
=
KsScene
val
scene
=
KsScene
.
Builder
(
KsManager
.
KS_AD_NATIVEEXPRESS_AWARD
)
.
Builder
(
KsManager
.
KS_AD_NATIVEEXPRESS_AWARD
)
.
adNum
(
1
)
.
adNum
(
1
)
.
build
()
.
build
()
KsAdSDK
.
getLoadManager
().
loadNativeAd
(
scene
,
object
:
KsLoadManager
.
NativeAdListener
{
KsAdSDK
.
getLoadManager
().
loadNativeAd
(
scene
,
object
:
KsLoadManager
.
NativeAdListener
{
override
fun
onError
(
p0
:
Int
,
p1
:
String
?)
{
override
fun
onError
(
p0
:
Int
,
p1
:
String
?)
{
LogUtil
.
d
(
"$p0 -> $p1"
)
LogUtil
.
d
(
"$p0 -> $p1"
)
AppConfig
.
isPreExpressAwardActivity
=
false
}
}
override
fun
onNativeAdLoad
(
p0
:
MutableList
<
KsNativeAd
>?)
{
override
fun
onNativeAdLoad
(
p0
:
MutableList
<
KsNativeAd
>?)
{
...
@@ -51,6 +53,7 @@ object KsPreLoadExpressManager {
...
@@ -51,6 +53,7 @@ object KsPreLoadExpressManager {
})
})
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
AppConfig
.
isPreExpressAwardActivity
=
false
e
.
printStackTrace
()
e
.
printStackTrace
()
}
}
}
}
...
@@ -83,8 +86,7 @@ object KsPreLoadExpressManager {
...
@@ -83,8 +86,7 @@ object KsPreLoadExpressManager {
* 使用SDK渲染的播放控件
* 使用SDK渲染的播放控件
*/
*/
private
fun
getVideoItemView
(
parent
:
ViewGroup
,
ksNativeAd
:
KsNativeAd
):
View
?
{
private
fun
getVideoItemView
(
parent
:
ViewGroup
,
ksNativeAd
:
KsNativeAd
):
View
?
{
val
convertView
:
View
=
val
convertView
:
View
=
LayoutInflater
.
from
(
mContext
).
inflate
(
R
.
layout
.
native_item_video
,
parent
,
false
)
LayoutInflater
.
from
(
mContext
).
inflate
(
R
.
layout
.
native_item_video
,
parent
,
false
)
val
videoViewHolder
=
AdVideoViewHolder
(
convertView
)
val
videoViewHolder
=
AdVideoViewHolder
(
convertView
)
// 设置广告数据
// 设置广告数据
...
@@ -104,9 +106,9 @@ object KsPreLoadExpressManager {
...
@@ -104,9 +106,9 @@ object KsPreLoadExpressManager {
// SDK默认渲染的视频view
// SDK默认渲染的视频view
val
videoPlayConfig
=
KsAdVideoPlayConfig
.
Builder
()
val
videoPlayConfig
=
KsAdVideoPlayConfig
.
Builder
()
.
videoSoundEnable
(
true
)
// 有声播放
.
videoSoundEnable
(
true
)
// 有声播放
.
dataFlowAutoStart
(
false
)
// 流量下自动播放
.
dataFlowAutoStart
(
false
)
// 流量下自动播放
.
build
()
.
build
()
val
videoView
=
ksNativeAd
.
getVideoView
(
mContext
,
videoPlayConfig
)
val
videoView
=
ksNativeAd
.
getVideoView
(
mContext
,
videoPlayConfig
)
if
(
videoView
!=
null
&&
videoView
.
parent
==
null
)
{
if
(
videoView
!=
null
&&
videoView
.
parent
==
null
)
{
videoViewHolder
.
mAdVideoContainer
.
removeAllViews
()
videoViewHolder
.
mAdVideoContainer
.
removeAllViews
()
...
@@ -119,8 +121,7 @@ object KsPreLoadExpressManager {
...
@@ -119,8 +121,7 @@ object KsPreLoadExpressManager {
* 自定义的单图广告
* 自定义的单图广告
*/
*/
private
fun
getSingleImageItemView
(
parent
:
ViewGroup
,
ksNativeAd
:
KsNativeAd
):
View
?
{
private
fun
getSingleImageItemView
(
parent
:
ViewGroup
,
ksNativeAd
:
KsNativeAd
):
View
?
{
val
convertView
:
View
=
val
convertView
:
View
=
LayoutInflater
.
from
(
mContext
).
inflate
(
R
.
layout
.
native_item_single_image
,
parent
,
false
)
LayoutInflater
.
from
(
mContext
).
inflate
(
R
.
layout
.
native_item_single_image
,
parent
,
false
)
val
viewHolder
=
AdSingleImageViewHolder
(
convertView
)
val
viewHolder
=
AdSingleImageViewHolder
(
convertView
)
bindCommonData
(
convertView
as
ViewGroup
,
viewHolder
,
ksNativeAd
)
bindCommonData
(
convertView
as
ViewGroup
,
viewHolder
,
ksNativeAd
)
...
@@ -138,8 +139,7 @@ object KsPreLoadExpressManager {
...
@@ -138,8 +139,7 @@ object KsPreLoadExpressManager {
* 自定义的组图广告
* 自定义的组图广告
*/
*/
private
fun
getGroupImageItemView
(
parent
:
ViewGroup
,
ksNativeAd
:
KsNativeAd
):
View
?
{
private
fun
getGroupImageItemView
(
parent
:
ViewGroup
,
ksNativeAd
:
KsNativeAd
):
View
?
{
val
convertView
:
View
=
val
convertView
:
View
=
LayoutInflater
.
from
(
mContext
).
inflate
(
R
.
layout
.
native_item_group_image
,
parent
,
false
)
LayoutInflater
.
from
(
mContext
).
inflate
(
R
.
layout
.
native_item_group_image
,
parent
,
false
)
val
viewHolder
=
AdGroupImageViewHolder
(
convertView
)
val
viewHolder
=
AdGroupImageViewHolder
(
convertView
)
bindCommonData
(
convertView
as
ViewGroup
,
viewHolder
,
ksNativeAd
)
bindCommonData
(
convertView
as
ViewGroup
,
viewHolder
,
ksNativeAd
)
...
@@ -168,17 +168,14 @@ object KsPreLoadExpressManager {
...
@@ -168,17 +168,14 @@ object KsPreLoadExpressManager {
@SuppressLint
(
"DefaultLocale"
)
@SuppressLint
(
"DefaultLocale"
)
private
fun
getNormalItemView
(
parent
:
ViewGroup
):
View
?
{
private
fun
getNormalItemView
(
parent
:
ViewGroup
):
View
?
{
val
convertView
:
View
=
val
convertView
:
View
=
LayoutInflater
.
from
(
mContext
).
inflate
(
R
.
layout
.
native_item_normal
,
parent
,
false
)
LayoutInflater
.
from
(
mContext
).
inflate
(
R
.
layout
.
native_item_normal
,
parent
,
false
)
val
normalViewHolder
=
NormalViewHolder
(
convertView
)
val
normalViewHolder
=
NormalViewHolder
(
convertView
)
normalViewHolder
.
textView
.
text
=
"没有广告"
normalViewHolder
.
textView
.
text
=
"没有广告"
return
convertView
return
convertView
}
}
private
fun
bindCommonData
(
private
fun
bindCommonData
(
convertView
:
ViewGroup
,
adBaseViewHolder
:
AdBaseViewHolder
,
convertView
:
ViewGroup
,
adBaseViewHolder
:
AdBaseViewHolder
,
ad
:
KsNativeAd
)
{
ad
:
KsNativeAd
)
{
// 点击转换view的集合,传入的view点击时会触发转换操作:app下载, 打开h5页面
// 点击转换view的集合,传入的view点击时会触发转换操作:app下载, 打开h5页面
val
clickViewList
:
MutableList
<
View
>
=
ArrayList
()
val
clickViewList
:
MutableList
<
View
>
=
ArrayList
()
clickViewList
.
add
(
convertView
)
// 点击整个view都可触发转换
clickViewList
.
add
(
convertView
)
// 点击整个view都可触发转换
...
@@ -187,23 +184,23 @@ object KsPreLoadExpressManager {
...
@@ -187,23 +184,23 @@ object KsPreLoadExpressManager {
// 注册View的点击,点击后触发转化
// 注册View的点击,点击后触发转化
ad
.
registerViewForInteraction
(
convertView
,
clickViewList
,
ad
.
registerViewForInteraction
(
convertView
,
clickViewList
,
object
:
KsNativeAd
.
AdInteractionListener
{
object
:
KsNativeAd
.
AdInteractionListener
{
override
fun
onAdClicked
(
view
:
View
,
ad
:
KsNativeAd
)
{
override
fun
onAdClicked
(
view
:
View
,
ad
:
KsNativeAd
)
{
if
(
ad
!=
null
)
{
if
(
ad
!=
null
)
{
// Toast.makeText(WenshuApplication.getContext(), "广告" + ad.appName + "被点击", Toast.LENGTH_SHORT).show()
// Toast.makeText(MintsApplication.getContext(), "广告" + ad.appName + "被点击", Toast.LENGTH_SHORT).show()
}
}
}
}
override
fun
onAdShow
(
ad
:
KsNativeAd
)
{
override
fun
onAdShow
(
ad
:
KsNativeAd
)
{
if
(
ad
!=
null
)
{
if
(
ad
!=
null
)
{
// Toast.makeText(mContext, "广告" + ad.appName + "展示", Toast.LENGTH_SHORT).show()
// Toast.makeText(mContext, "广告" + ad.appName + "展示", Toast.LENGTH_SHORT).show()
}
}
}
}
override
fun
handleDownloadDialog
(
p0
:
DialogInterface
.
OnClickListener
?):
Boolean
{
override
fun
handleDownloadDialog
(
p0
:
DialogInterface
.
OnClickListener
?):
Boolean
{
TODO
(
"Not yet implemented"
)
return
false
}
}
})
})
// 广告描述
// 广告描述
adBaseViewHolder
.
mAdDes
.
text
=
ad
.
adDescription
adBaseViewHolder
.
mAdDes
.
text
=
ad
.
adDescription
...
@@ -236,8 +233,7 @@ object KsPreLoadExpressManager {
...
@@ -236,8 +233,7 @@ object KsPreLoadExpressManager {
adBaseViewHolder
.
mAppIcon
.
visibility
=
View
.
GONE
adBaseViewHolder
.
mAppIcon
.
visibility
=
View
.
GONE
}
else
{
}
else
{
adBaseViewHolder
.
mAppIcon
.
visibility
=
View
.
VISIBLE
adBaseViewHolder
.
mAppIcon
.
visibility
=
View
.
VISIBLE
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
appIconUrl
)
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
appIconUrl
).
into
(
adBaseViewHolder
.
mAppIcon
)
.
into
(
adBaseViewHolder
.
mAppIcon
)
}
}
// app名称
// app名称
if
(!
TextUtils
.
isEmpty
(
ad
.
appName
))
{
if
(!
TextUtils
.
isEmpty
(
ad
.
appName
))
{
...
...
app/src/main/java/com/mints/flowbox/ad/express/PreLoadExpressManager.kt
View file @
68c773e1
...
@@ -15,9 +15,7 @@ import java.util.*
...
@@ -15,9 +15,7 @@ import java.util.*
/**
/**
* 预加载信息流管理类
* 预加载信息流管理类
*/
*/
@SuppressLint
(
"StaticFieldLeak"
)
object
PreLoadExpressManager
:
TTADLoadSuccessListener
,
YLHADLoadSuccessListener
,
KSADLoadSuccessListener
,
GMADLoadSuccessListener
{
object
PreLoadExpressManager
:
TTADLoadSuccessListener
,
YLHADLoadSuccessListener
,
KSADLoadSuccessListener
,
GMADLoadSuccessListener
{
private
val
TAG
=
PreLoadExpressManager
::
class
.
java
.
simpleName
private
val
TAG
=
PreLoadExpressManager
::
class
.
java
.
simpleName
...
@@ -64,8 +62,7 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
...
@@ -64,8 +62,7 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
// }
// }
when
(
getRandomWeight
())
{
when
(
getRandomWeight
())
{
Constant
.
CSJ_EXPRESS_AD
->
TTPreLoadExpressManager
.
getInstance
()
Constant
.
CSJ_EXPRESS_AD
->
TTPreLoadExpressManager
.
getInstance
().
loadTtFrameLayout
(
mAdFrameLayout
)
.
loadTtFrameLayout
(
mAdFrameLayout
)
Constant
.
YLH_EXPRESS_AD
->
YlhPreLoadExpressManager
.
loadYlhFrameLayout
()
Constant
.
YLH_EXPRESS_AD
->
YlhPreLoadExpressManager
.
loadYlhFrameLayout
()
Constant
.
KS_EXPRESS_AD
->
KsPreLoadExpressManager
.
loadKsFrameLayout
(
mAdFrameLayout
as
ViewGroup
)
Constant
.
KS_EXPRESS_AD
->
KsPreLoadExpressManager
.
loadKsFrameLayout
(
mAdFrameLayout
as
ViewGroup
)
Constant
.
GM_EXPRESS_AD
->
GroMoreExpressManager
.
instance
.
loadADFrameLayout
()
Constant
.
GM_EXPRESS_AD
->
GroMoreExpressManager
.
instance
.
loadADFrameLayout
()
...
@@ -138,6 +135,9 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
...
@@ -138,6 +135,9 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
// if (currentIndex == 1) {
// if (currentIndex == 1) {
// mAdFrameLayout = adFrameLayout
// mAdFrameLayout = adFrameLayout
// }
// }
if
(
view
!=
null
){
AppConfig
.
isPreExpressAwardActivity
=
true
}
mAdFrameLayout
=
view
mAdFrameLayout
=
view
}
}
...
@@ -145,6 +145,9 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
...
@@ -145,6 +145,9 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
// if (currentIndex == 2) {
// if (currentIndex == 2) {
// mAdFrameLayout?.addView(view)
// mAdFrameLayout?.addView(view)
// }
// }
if
(
view
!=
null
){
AppConfig
.
isPreExpressAwardActivity
=
true
}
mAdFrameLayout
?.
addView
(
view
)
mAdFrameLayout
?.
addView
(
view
)
}
}
...
@@ -152,6 +155,9 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
...
@@ -152,6 +155,9 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
// if (currentIndex == 3) {
// if (currentIndex == 3) {
// mAdFrameLayout?.addView(view)
// mAdFrameLayout?.addView(view)
// }
// }
if
(
view
!=
null
){
AppConfig
.
isPreExpressAwardActivity
=
true
}
mAdFrameLayout
?.
addView
(
view
)
mAdFrameLayout
?.
addView
(
view
)
}
}
...
@@ -159,6 +165,9 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
...
@@ -159,6 +165,9 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
// if (currentIndex == 3) {
// if (currentIndex == 3) {
// mAdFrameLayout?.addView(view)
// mAdFrameLayout?.addView(view)
// }
// }
if
(
view
!=
null
){
AppConfig
.
isPreExpressAwardActivity
=
true
}
mAdFrameLayout
?.
addView
(
view
)
mAdFrameLayout
?.
addView
(
view
)
}
}
...
...
app/src/main/java/com/mints/flowbox/ad/express/TTPreLoadCarrierExpressManager.java
View file @
68c773e1
...
@@ -106,7 +106,7 @@ public class TTPreLoadCarrierExpressManager {
...
@@ -106,7 +106,7 @@ public class TTPreLoadCarrierExpressManager {
public
void
loadTtFrameLayout
(
String
codeId
)
{
public
void
loadTtFrameLayout
(
String
codeId
)
{
init
();
init
();
// ToastUtil.showLong(
Wenshu
Application.getContext(), "通用信息流:" + codeId);
// ToastUtil.showLong(
Mints
Application.getContext(), "通用信息流:" + codeId);
if
(
mWorkHandler
!=
null
)
{
if
(
mWorkHandler
!=
null
)
{
Message
msg
=
Message
.
obtain
();
Message
msg
=
Message
.
obtain
();
...
...
app/src/main/java/com/mints/flowbox/ad/express/TTPreLoadExpressManager.java
View file @
68c773e1
...
@@ -4,7 +4,7 @@ import android.util.DisplayMetrics;
...
@@ -4,7 +4,7 @@ import android.util.DisplayMetrics;
import
android.widget.FrameLayout
;
import
android.widget.FrameLayout
;
import
com.mints.flowbox.MintsApplication
;
import
com.mints.flowbox.MintsApplication
;
import
com.mints.flowbox.common.AppConfig
;
import
com.mints.flowbox.
ad.express.TTADLoadSuccessListener
;
import
com.mints.flowbox.
common.AppConfig
;
import
com.mints.flowbox.manager.TTNativeExpressManager
;
import
com.mints.flowbox.manager.TTNativeExpressManager
;
import
com.mints.flowbox.manager.TtCsjAdManager
;
import
com.mints.flowbox.manager.TtCsjAdManager
;
...
@@ -62,6 +62,7 @@ public class TTPreLoadExpressManager {
...
@@ -62,6 +62,7 @@ public class TTPreLoadExpressManager {
}
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
AppConfig
.
isPreExpressAwardActivity
=
false
;
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
});
});
...
...
app/src/main/java/com/mints/flowbox/ad/express/YlhPreLoadExpressManager.kt
View file @
68c773e1
package
com.mints.flowbox.ad.express
package
com.mints.flowbox.ad.express
import
com.qq.e.ads.nativ.express2.*
import
com.qq.e.comm.util.AdError
import
com.qq.e.comm.util.AdError
import
com.mints.flowbox.MintsApplication
import
com.mints.flowbox.MintsApplication
import
com.mints.flowbox.common.AppConfig
import
com.mints.flowbox.manager.ad.YlhAdManager
import
com.mints.flowbox.manager.ad.YlhAdManager
import
com.mints.flowbox.utils.LogUtil
import
com.qq.e.ads.nativ.ADSize
import
com.qq.e.ads.nativ.ADSize
import
com.qq.e.ads.nativ.NativeExpressAD
import
com.qq.e.ads.nativ.NativeExpressAD
import
com.qq.e.ads.nativ.NativeExpressADView
import
com.qq.e.ads.nativ.NativeExpressADView
/**
/**
* 优量汇预加载信息流
* 优量汇预加载信息流
*/
*/
...
@@ -23,55 +27,54 @@ object YlhPreLoadExpressManager {
...
@@ -23,55 +27,54 @@ object YlhPreLoadExpressManager {
fun
loadYlhFrameLayout
()
{
fun
loadYlhFrameLayout
()
{
try
{
try
{
nativeExpressAD
=
NativeExpressAD
(
nativeExpressAD
=
NativeExpressAD
(
MintsApplication
.
getContext
(),
ADSize
(
ADSize
.
FULL_WIDTH
,
ADSize
.
AUTO_HEIGHT
),
YlhAdManager
.
YLH_AD_NATIVEEXPRESS_AWARD
,
object
:
NativeExpressAD
.
NativeExpressADListener
{
MintsApplication
.
getContext
(),
override
fun
onNoAD
(
p0
:
AdError
?)
{
ADSize
(
ADSize
.
FULL_WIDTH
,
ADSize
.
AUTO_HEIGHT
),
AppConfig
.
isPreExpressAwardActivity
=
false
YlhAdManager
.
YLH_AD_NATIVEEXPRESS_AWARD
,
}
object
:
NativeExpressAD
.
NativeExpressADListener
{
override
fun
onNoAD
(
p0
:
AdError
?)
{
}
override
fun
onADClicked
(
p0
:
NativeExpressADView
?)
{
override
fun
onADClicked
(
p0
:
NativeExpressADView
?)
{
}
}
override
fun
onADCloseOverlay
(
p0
:
NativeExpressADView
?)
{
override
fun
onADCloseOverlay
(
p0
:
NativeExpressADView
?)
{
}
}
override
fun
onADClosed
(
p0
:
NativeExpressADView
?)
{
override
fun
onADClosed
(
p0
:
NativeExpressADView
?)
{
}
}
override
fun
onADExposure
(
p0
:
NativeExpressADView
?)
{
override
fun
onADExposure
(
p0
:
NativeExpressADView
?)
{
}
}
override
fun
onADLeftApplication
(
p0
:
NativeExpressADView
?)
{
override
fun
onADLeftApplication
(
p0
:
NativeExpressADView
?)
{
}
}
override
fun
onADLoaded
(
p0
:
MutableList
<
NativeExpressADView
>?)
{
override
fun
onADLoaded
(
p0
:
MutableList
<
NativeExpressADView
>?)
{
// 释放前一个展示的NativeExpressADView的资源
// 释放前一个展示的NativeExpressADView的资源
nativeExpressADView
?.
destroy
()
nativeExpressADView
?.
destroy
()
nativeExpressADView
=
p0
?.
get
(
0
)
nativeExpressADView
=
p0
?.
get
(
0
)
// 广告可见才会产生曝光,否则将无法产生收益。
// 广告可见才会产生曝光,否则将无法产生收益。
mADLoadSuccessListener
?.
onYlhAdLoadSuc
(
nativeExpressADView
)
mADLoadSuccessListener
?.
onYlhAdLoadSuc
(
nativeExpressADView
)
nativeExpressADView
?.
render
()
nativeExpressADView
?.
render
()
}
}
override
fun
onADOpenOverlay
(
p0
:
NativeExpressADView
?)
{
override
fun
onADOpenOverlay
(
p0
:
NativeExpressADView
?)
{
}
}
override
fun
onRenderFail
(
p0
:
NativeExpressADView
?)
{
override
fun
onRenderFail
(
p0
:
NativeExpressADView
?)
{
}
AppConfig
.
isPreExpressAwardActivity
=
false
}
override
fun
onRenderSuccess
(
p0
:
NativeExpressADView
?)
{
override
fun
onRenderSuccess
(
p0
:
NativeExpressADView
?)
{
}
}
})
})
nativeExpressAD
?.
loadAD
(
1
)
nativeExpressAD
?.
loadAD
(
1
)
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
e
.
printStackTrace
()
AppConfig
.
isPreExpressAwardActivity
=
false
}
}
}
}
...
...
app/src/main/java/com/mints/flowbox/manager/ad/TTGroMoreAdManagerHolder.java
View file @
68c773e1
...
@@ -23,7 +23,7 @@ import java.util.Map;
...
@@ -23,7 +23,7 @@ import java.util.Map;
*/
*/
public
class
TTGroMoreAdManagerHolder
{
public
class
TTGroMoreAdManagerHolder
{
public
static
final
String
TT_AD_APPID
=
"51
74315
"
;
public
static
final
String
TT_AD_APPID
=
"51
82992
"
;
public
static
final
String
TT_AD_NAME
=
Constant
.
MINTS_APP_NAME
;
public
static
final
String
TT_AD_NAME
=
Constant
.
MINTS_APP_NAME
;
private
static
boolean
sInit
;
private
static
boolean
sInit
;
...
...
app/src/main/java/com/mints/flowbox/ui/activitys/FoodSubsidyActivity.kt
View file @
68c773e1
...
@@ -3,6 +3,7 @@ package com.mints.flowbox.ui.activitys
...
@@ -3,6 +3,7 @@ package com.mints.flowbox.ui.activitys
import
android.os.Bundle
import
android.os.Bundle
import
android.view.View
import
android.view.View
import
com.mints.flowbox.R
import
com.mints.flowbox.R
import
com.mints.flowbox.ad.express.ExpressManager
import
com.mints.flowbox.common.Constant
import
com.mints.flowbox.common.Constant
import
com.mints.flowbox.ad.express.TTPreLoadCarrierExpressManager
import
com.mints.flowbox.ad.express.TTPreLoadCarrierExpressManager
import
com.mints.flowbox.manager.TtCsjAdManager
import
com.mints.flowbox.manager.TtCsjAdManager
...
@@ -88,7 +89,7 @@ class FoodSubsidyActivity : BaseActivity(), View.OnClickListener, FoodSubsidyVie
...
@@ -88,7 +89,7 @@ class FoodSubsidyActivity : BaseActivity(), View.OnClickListener, FoodSubsidyVie
}
}
// 预加载信息流
// 预加载信息流
TTPreLoadCarrierExpressManager
.
getInstance
().
loadTtFrameLayout
(
TtCsjAdManager
.
TT_AD_NATIVEEXPRESS_EAT
)
ExpressManager
.
loadExpress
(
)
}
}
...
@@ -97,11 +98,9 @@ class FoodSubsidyActivity : BaseActivity(), View.OnClickListener, FoodSubsidyVie
...
@@ -97,11 +98,9 @@ class FoodSubsidyActivity : BaseActivity(), View.OnClickListener, FoodSubsidyVie
*/
*/
private
fun
initExpress
()
{
private
fun
initExpress
()
{
try
{
try
{
if
(
TTPreLoadCarrierExpressManager
.
getInstance
().
ttFrameLayout
!=
null
)
{
if
(
flSubsidykAd
!=
null
)
{
if
(
flSubsidykAd
!=
null
)
{
flSubsidykAd
.
removeAllViews
()
flSubsidykAd
.
removeAllViews
()
flSubsidykAd
.
addView
(
ExpressManager
.
getExpressFrameLayout
())
flSubsidykAd
.
addView
(
TTPreLoadCarrierExpressManager
.
getInstance
().
ttFrameLayout
)
}
}
}
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
e
.
printStackTrace
()
...
...
app/src/main/java/com/mints/flowbox/ui/activitys/SplashGroMoreActivity.java
View file @
68c773e1
...
@@ -106,7 +106,7 @@ public class SplashGroMoreActivity extends BaseActivity {
...
@@ -106,7 +106,7 @@ public class SplashGroMoreActivity extends BaseActivity {
public
void
onSplashAdLoadFail
(
AdError
adError
)
{
public
void
onSplashAdLoadFail
(
AdError
adError
)
{
LogUtil
.
d
(
TAG
,
adError
.
message
);
LogUtil
.
d
(
TAG
,
adError
.
message
);
mHasLoaded
=
true
;
mHasLoaded
=
true
;
Log
.
e
(
TAG
,
"load splash ad error : "
+
adError
.
code
+
", "
+
adError
.
message
);
Log
Util
.
d
(
TAG
,
"load splash ad error : "
+
adError
.
code
+
", "
+
adError
.
message
);
// 获取本次waterfall加载中,加载失败的adn错误信息。
// 获取本次waterfall加载中,加载失败的adn错误信息。
if
(
mTTSplashAd
!=
null
)
if
(
mTTSplashAd
!=
null
)
LogUtil
.
d
(
TAG
,
"ad load infos: "
+
mTTSplashAd
.
getAdLoadInfoList
());
LogUtil
.
d
(
TAG
,
"ad load infos: "
+
mTTSplashAd
.
getAdLoadInfoList
());
...
@@ -129,7 +129,7 @@ public class SplashGroMoreActivity extends BaseActivity {
...
@@ -129,7 +129,7 @@ public class SplashGroMoreActivity extends BaseActivity {
vo
.
put
(
"adid"
,
CsjGroMoreManager
.
INSTANCE
.
getAD_UNIT_SPLASH_ID
());
vo
.
put
(
"adid"
,
CsjGroMoreManager
.
INSTANCE
.
getAD_UNIT_SPLASH_ID
());
TrackManager
.
getInstance
().
cmtGroMoreInfo
(
vo
);
TrackManager
.
getInstance
().
cmtGroMoreInfo
(
vo
);
}
}
Log
.
e
(
TAG
,
"load splash ad success "
);
Log
Util
.
d
(
TAG
,
"load splash ad success "
);
}
}
@Override
@Override
...
...
app/src/main/java/com/mints/flowbox/ui/activitys/WalkActivity.kt
View file @
68c773e1
...
@@ -3,6 +3,7 @@ package com.mints.flowbox.ui.activitys
...
@@ -3,6 +3,7 @@ package com.mints.flowbox.ui.activitys
import
android.os.Bundle
import
android.os.Bundle
import
android.view.View
import
android.view.View
import
com.mints.flowbox.R
import
com.mints.flowbox.R
import
com.mints.flowbox.ad.express.ExpressManager
import
com.mints.flowbox.common.Constant
import
com.mints.flowbox.common.Constant
import
com.mints.flowbox.ad.express.TTPreLoadCarrierExpressManager
import
com.mints.flowbox.ad.express.TTPreLoadCarrierExpressManager
import
com.mints.flowbox.manager.TtCsjAdManager
import
com.mints.flowbox.manager.TtCsjAdManager
...
@@ -99,7 +100,7 @@ class WalkActivity : BaseActivity(), View.OnClickListener, WalkView, StepView.St
...
@@ -99,7 +100,7 @@ class WalkActivity : BaseActivity(), View.OnClickListener, WalkView, StepView.St
}
}
// 预加载信息流
// 预加载信息流
TTPreLoadCarrierExpressManager
.
getInstance
().
loadTtFrameLayout
(
TtCsjAdManager
.
TT_AD_NATIVEEXPRESS_WALK
)
ExpressManager
.
loadExpress
(
)
}
}
/**
/**
...
@@ -107,11 +108,9 @@ class WalkActivity : BaseActivity(), View.OnClickListener, WalkView, StepView.St
...
@@ -107,11 +108,9 @@ class WalkActivity : BaseActivity(), View.OnClickListener, WalkView, StepView.St
*/
*/
private
fun
initExpress
()
{
private
fun
initExpress
()
{
try
{
try
{
if
(
TTPreLoadCarrierExpressManager
.
getInstance
().
ttFrameLayout
!=
null
)
{
if
(
flWalkAd
!=
null
)
{
if
(
flWalkAd
!=
null
)
{
flWalkAd
.
removeAllViews
()
flWalkAd
.
removeAllViews
()
flWalkAd
.
addView
(
ExpressManager
.
getExpressFrameLayout
())
flWalkAd
.
addView
(
TTPreLoadCarrierExpressManager
.
getInstance
().
ttFrameLayout
)
}
}
}
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
e
.
printStackTrace
()
...
...
app/src/main/java/com/mints/flowbox/ui/activitys/WaterActivity.kt
View file @
68c773e1
...
@@ -3,6 +3,7 @@ package com.mints.flowbox.ui.activitys
...
@@ -3,6 +3,7 @@ package com.mints.flowbox.ui.activitys
import
android.os.Bundle
import
android.os.Bundle
import
android.view.View
import
android.view.View
import
com.mints.flowbox.R
import
com.mints.flowbox.R
import
com.mints.flowbox.ad.express.ExpressManager
import
com.mints.flowbox.common.Constant
import
com.mints.flowbox.common.Constant
import
com.mints.flowbox.ad.express.TTPreLoadCarrierExpressManager
import
com.mints.flowbox.ad.express.TTPreLoadCarrierExpressManager
import
com.mints.flowbox.manager.TtCsjAdManager
import
com.mints.flowbox.manager.TtCsjAdManager
...
@@ -69,7 +70,7 @@ class WaterActivity : BaseActivity(), View.OnClickListener, WaterView.WaterViewL
...
@@ -69,7 +70,7 @@ class WaterActivity : BaseActivity(), View.OnClickListener, WaterView.WaterViewL
}
}
// 预加载信息流
// 预加载信息流
TTPreLoadCarrierExpressManager
.
getInstance
().
loadTtFrameLayout
(
TtCsjAdManager
.
TT_AD_NATIVEEXPRESS_WATER
)
ExpressManager
.
loadExpress
(
)
}
}
override
fun
clickForWaterSuc
(
waterCoin
:
Int
)
{
override
fun
clickForWaterSuc
(
waterCoin
:
Int
)
{
...
@@ -111,11 +112,9 @@ class WaterActivity : BaseActivity(), View.OnClickListener, WaterView.WaterViewL
...
@@ -111,11 +112,9 @@ class WaterActivity : BaseActivity(), View.OnClickListener, WaterView.WaterViewL
*/
*/
private
fun
initExpress
()
{
private
fun
initExpress
()
{
try
{
try
{
if
(
TTPreLoadCarrierExpressManager
.
getInstance
().
ttFrameLayout
!=
null
)
{
if
(
flWaterAd
!=
null
)
{
if
(
flWaterAd
!=
null
)
{
flWaterAd
.
removeAllViews
()
flWaterAd
.
removeAllViews
()
flWaterAd
.
addView
(
ExpressManager
.
getExpressFrameLayout
())
flWaterAd
.
addView
(
TTPreLoadCarrierExpressManager
.
getInstance
().
ttFrameLayout
)
}
}
}
}
catch
(
e
:
Exception
)
{
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
e
.
printStackTrace
()
...
...
app/src/main/java/com/mints/flowbox/ui/fragment/HomeFragment.kt
View file @
68c773e1
...
@@ -10,6 +10,7 @@ import android.widget.AdapterView
...
@@ -10,6 +10,7 @@ import android.widget.AdapterView
import
android.widget.GridView
import
android.widget.GridView
import
com.mints.flowbox.MintsApplication
import
com.mints.flowbox.MintsApplication
import
com.mints.flowbox.R
import
com.mints.flowbox.R
import
com.mints.flowbox.ad.express.ExpressManager
import
com.mints.flowbox.ad.express.PreLoadExpressManager
import
com.mints.flowbox.ad.express.PreLoadExpressManager
import
com.mints.flowbox.ad.express.TTPreLoadCarrierExpressManager
import
com.mints.flowbox.ad.express.TTPreLoadCarrierExpressManager
import
com.mints.flowbox.ad.video.VideoAdingManager
import
com.mints.flowbox.ad.video.VideoAdingManager
...
@@ -447,26 +448,22 @@ class HomeFragment : BaseFragment(), WifiStateManager.WifiStateCallback,
...
@@ -447,26 +448,22 @@ class HomeFragment : BaseFragment(), WifiStateManager.WifiStateCallback,
// 自有界面
// 自有界面
when
(
hotBean
.
toUrl
)
{
when
(
hotBean
.
toUrl
)
{
Constant
.
HOT_ACTIVITY_WATER
->
{
Constant
.
HOT_ACTIVITY_WATER
->
{
TTPreLoadCarrierExpressManager
.
getInstance
()
ExpressManager
.
loadExpress
()
.
loadTtFrameLayout
(
TtCsjAdManager
.
TT_AD_NATIVEEXPRESS_WATER
)
readyGo
(
WaterActivity
::
class
.
java
)
readyGo
(
WaterActivity
::
class
.
java
)
}
}
Constant
.
HOT_ACTIVITY_WALK
->
{
Constant
.
HOT_ACTIVITY_WALK
->
{
TTPreLoadCarrierExpressManager
.
getInstance
()
ExpressManager
.
loadExpress
()
.
loadTtFrameLayout
(
TtCsjAdManager
.
TT_AD_NATIVEEXPRESS_WALK
)
readyGo
(
WalkActivity
::
class
.
java
)
readyGo
(
WalkActivity
::
class
.
java
)
}
}
Constant
.
HOT_ACTIVITY_CARD
->
{
Constant
.
HOT_ACTIVITY_CARD
->
{
readyGo
(
EraseActivity
::
class
.
java
)
readyGo
(
EraseActivity
::
class
.
java
)
}
}
Constant
.
HOT_ACTIVITY_MORNINGCLOCK
->
{
Constant
.
HOT_ACTIVITY_MORNINGCLOCK
->
{
TTPreLoadCarrierExpressManager
.
getInstance
()
ExpressManager
.
loadExpress
()
.
loadTtFrameLayout
(
TtCsjAdManager
.
TT_AD_NATIVEEXPRESS_MORNINGCLOCK
)
readyGo
(
MorningClockActivity
::
class
.
java
)
readyGo
(
MorningClockActivity
::
class
.
java
)
}
}
Constant
.
HOT_ACTIVITY_EAT
->
{
Constant
.
HOT_ACTIVITY_EAT
->
{
TTPreLoadCarrierExpressManager
.
getInstance
()
ExpressManager
.
loadExpress
()
.
loadTtFrameLayout
(
TtCsjAdManager
.
TT_AD_NATIVEEXPRESS_EAT
)
readyGo
(
FoodSubsidyActivity
::
class
.
java
)
readyGo
(
FoodSubsidyActivity
::
class
.
java
)
}
}
Constant
.
HOT_ACTIVITY_SHARE_NEWS
->
{
Constant
.
HOT_ACTIVITY_SHARE_NEWS
->
{
...
...
app/src/main/res/xml/network_security_config.xml
View file @
68c773e1
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<network-security-config>
<base-config
cleartextTrafficPermitted=
"true"
/>
<base-config
cleartextTrafficPermitted=
"true"
/>
<domain-config>
<domain
includeSubdomains=
"true"
>
i.snssdk.com
</domain>
<domain
includeSubdomains=
"true"
>
is.snssdk.com
</domain>
<domain
includeSubdomains=
"true"
>
pangolin.snssdk.com
</domain>
<domain
includeSubdomains=
"true"
>
extlog.snssdk.com
</domain>
<domain
includeSubdomains=
"true"
>
sf3-ttcdn-tos.pstatp.com
</domain>
<domain
includeSubdomains=
"true"
>
bds.snssdk.com
</domain>
<domain
includeSubdomains=
"true"
>
dig.bdurl.net
</domain>
<domain
includeSubdomains=
"true"
>
api-access.pangolin-sdk-toutiao.com
</domain>
<domain
includeSubdomains=
"true"
>
sf1-fe-tos.pglstatp-toutiao.com
</domain>
<domain
includeSubdomains=
"true"
>
sf1-be-pack.pglstatp-toutiao.com
</domain>
<domain
includeSubdomains=
"true"
>
sf3-fe-tos.pglstatp-toutiao.com
</domain>
<domain
includeSubdomains=
"true"
>
log-api.pangolin-sdk-toutiao.com
</domain>
<domain
includeSubdomains=
"true"
>
s3-fe-scm.pglstatp-toutiao.com
</domain>
<domain
includeSubdomains=
"true"
>
s3a.pstatp.com
</domain>
<domain
includeSubdomains=
"true"
>
api-access.pangolin-sdk-toutiao-b.com
</domain>
<domain
includeSubdomains=
"true"
>
log-api.pangolin-sdk-toutiao-b.com
</domain>
<domain
includeSubdomains=
"true"
>
dm.pstatp.com
</domain>
<domain
includeSubdomains=
"true"
>
toblog.ctobsnssdk.com
</domain>
<domain
includeSubdomains=
"true"
>
sdfp.snssdk.com
</domain>
<domain
includeSubdomains=
"true"
>
tosv.byted.org
</domain>
<domain
includeSubdomains=
"true"
>
sf1-ttcdn-tos.pstatp.com
</domain>
<domain
includeSubdomains=
"true"
>
sf6-fe-tos.pglstatp-toutiao.com
</domain>
<domain
includeSubdomains=
"true"
>
log.snssdk.com
</domain>
<domain
includeSubdomains=
"true"
>
tosv.boe.byted.org
</domain>
<domain
includeSubdomains=
"true"
>
dm.toutiao.com
</domain>
<domain
includeSubdomains=
"true"
>
dm.bytedance.com
</domain>
<trust-anchors>
<certificates
src=
"user"
/>
//信任用户自己安装的证书
<certificates
src=
"system"
/>
</trust-anchors>
</domain-config>
</network-security-config>
</network-security-config>
\ 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