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
030e7d21
Commit
030e7d21
authored
Jul 12, 2021
by
jyx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
问题修复,更新信息流
parent
5436b3b8
Changes
46
Hide whitespace changes
Inline
Side-by-side
Showing
46 changed files
with
1806 additions
and
500 deletions
+1806
-500
MintsApplication.java
app/src/main/java/com/mints/flowbox/MintsApplication.java
+2
-10
AppOutGroMoreCarrierExpressManager.kt
.../flowbox/ad/express/AppOutGroMoreCarrierExpressManager.kt
+797
-0
ExpressManager.kt
.../main/java/com/mints/flowbox/ad/express/ExpressManager.kt
+27
-6
GroMoreCarrierExpressManager.kt
.../mints/flowbox/ad/express/GroMoreCarrierExpressManager.kt
+172
-99
GroMoreExpressManager.kt
...ava/com/mints/flowbox/ad/express/GroMoreExpressManager.kt
+154
-95
PreLoadExpressManager.kt
...ava/com/mints/flowbox/ad/express/PreLoadExpressManager.kt
+13
-10
TTPreLoadCarrierExpressManager.java
...ts/flowbox/ad/express/TTPreLoadCarrierExpressManager.java
+3
-0
FullGroManager.java
...c/main/java/com/mints/flowbox/ad/full/FullGroManager.java
+4
-4
InsertScreenAdManager.kt
...va/com/mints/flowbox/ad/inscreen/InsertScreenAdManager.kt
+8
-8
InterstitialGroManager.java
...com/mints/flowbox/ad/inscreen/InterstitialGroManager.java
+14
-3
CsjGroMoreVideoAdManager.java
.../com/mints/flowbox/ad/video/CsjGroMoreVideoAdManager.java
+3
-3
WifiAdManager.kt
app/src/main/java/com/mints/flowbox/ad/wifi/WifiAdManager.kt
+2
-2
AppConfig.java
app/src/main/java/com/mints/flowbox/common/AppConfig.java
+5
-0
AlarmManager.java
...c/main/java/com/mints/flowbox/keepalive/AlarmManager.java
+7
-2
CsjGroMoreManager.kt
.../main/java/com/mints/flowbox/manager/CsjGroMoreManager.kt
+47
-13
GroAdcodeBean.java
.../main/java/com/mints/flowbox/mvp/model/GroAdcodeBean.java
+142
-12
ApkActivity.kt
...c/main/java/com/mints/flowbox/ui/activitys/ApkActivity.kt
+1
-1
AwardActivity.kt
...main/java/com/mints/flowbox/ui/activitys/AwardActivity.kt
+4
-10
BoostActivity.kt
...main/java/com/mints/flowbox/ui/activitys/BoostActivity.kt
+23
-20
CleanActivity.kt
...main/java/com/mints/flowbox/ui/activitys/CleanActivity.kt
+16
-11
FoodSubsidyActivity.kt
...ava/com/mints/flowbox/ui/activitys/FoodSubsidyActivity.kt
+1
-1
Increasespeed2Activity.kt
.../com/mints/flowbox/ui/activitys/Increasespeed2Activity.kt
+6
-5
IncreasespeedActivity.kt
...a/com/mints/flowbox/ui/activitys/IncreasespeedActivity.kt
+62
-20
MainActivity.kt
.../main/java/com/mints/flowbox/ui/activitys/MainActivity.kt
+9
-34
ScreenActivity.kt
...ain/java/com/mints/flowbox/ui/activitys/ScreenActivity.kt
+3
-8
SpeedFastActivity.kt
.../java/com/mints/flowbox/ui/activitys/SpeedFastActivity.kt
+1
-1
SpeedTestActivity.kt
.../java/com/mints/flowbox/ui/activitys/SpeedTestActivity.kt
+5
-1
SplashGroMoreActivity.java
...com/mints/flowbox/ui/activitys/SplashGroMoreActivity.java
+2
-3
SplashGroMoreBackgroundActivity.java
...flowbox/ui/activitys/SplashGroMoreBackgroundActivity.java
+3
-3
WalkActivity.kt
.../main/java/com/mints/flowbox/ui/activitys/WalkActivity.kt
+1
-1
WaterActivity.kt
...main/java/com/mints/flowbox/ui/activitys/WaterActivity.kt
+1
-1
BonusFragment.kt
.../main/java/com/mints/flowbox/ui/fragment/BonusFragment.kt
+1
-2
HomeFragment.kt
...c/main/java/com/mints/flowbox/ui/fragment/HomeFragment.kt
+25
-10
MyFragment.kt
...src/main/java/com/mints/flowbox/ui/fragment/MyFragment.kt
+0
-1
TurnTableFragment.kt
...n/java/com/mints/flowbox/ui/fragment/TurnTableFragment.kt
+2
-2
WifiFragment.kt
...c/main/java/com/mints/flowbox/ui/fragment/WifiFragment.kt
+105
-37
CircleCleanAnimationView.kt
.../com/mints/flowbox/ui/widgets/CircleCleanAnimationView.kt
+2
-2
CycleProgress.java
...main/java/com/mints/flowbox/ui/widgets/CycleProgress.java
+5
-0
WifiView.java
app/src/main/java/com/mints/flowbox/ui/widgets/WifiView.java
+12
-0
IntentUtils.java
app/src/main/java/com/mints/flowbox/utils/IntentUtils.java
+24
-11
PermissionUtils.java
...rc/main/java/com/mints/flowbox/utils/PermissionUtils.java
+20
-1
WifiUtils.java
app/src/main/java/com/mints/flowbox/utils/WifiUtils.java
+21
-0
bg_gray_circle.xml
app/src/main/res/drawable/bg_gray_circle.xml
+1
-0
activity_award.xml
app/src/main/res/layout/activity_award.xml
+9
-7
activity_clean.xml
app/src/main/res/layout/activity_clean.xml
+7
-6
activity_increasespeed.xml
app/src/main/res/layout/activity_increasespeed.xml
+34
-34
No files found.
app/src/main/java/com/mints/flowbox/MintsApplication.java
View file @
030e7d21
...
...
@@ -362,15 +362,11 @@ public class MintsApplication extends BaseApp {
*/
private
void
showBoost
()
{
// 预加载信息流
ExpressManager
.
INSTANCE
.
loadExpress
();
ExpressManager
.
INSTANCE
.
load
AppOut
Express
();
Intent
intent
=
new
Intent
(
MintsApplication
.
getContext
(),
BoostActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
IntentUtils
.
startActivity
(
ForegroundOrBackground
.
getMain_activity
(),
intent
);
// Intent intent = new Intent(MintsApplication.getContext(), BoostActivity.class);
// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// MintsApplication.this.startActivity(intent);
}
/**
...
...
@@ -378,15 +374,11 @@ public class MintsApplication extends BaseApp {
*/
private
void
showScreen
()
{
// 预加载信息流
ExpressManager
.
INSTANCE
.
loadExpress
();
ExpressManager
.
INSTANCE
.
load
AppOut
Express
();
Intent
intent
=
new
Intent
(
MintsApplication
.
getContext
(),
ScreenActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
IntentUtils
.
startActivity
(
ForegroundOrBackground
.
getMain_activity
(),
intent
);
// Intent intent = new Intent(MintsApplication.getContext(), ScreenActivity.class);
// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// MintsApplication.this.startActivity(intent);
}
private
void
androidPWebView
()
{
...
...
app/src/main/java/com/mints/flowbox/ad/express/AppOutGroMoreCarrierExpressManager.kt
0 → 100644
View file @
030e7d21
package
com.mints.flowbox.ad.express
import
android.os.Handler
import
android.os.HandlerThread
import
android.text.TextUtils
import
android.view.Gravity
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.*
import
com.bumptech.glide.Glide
import
com.bytedance.msdk.adapter.util.UIUtils
import
com.bytedance.msdk.api.*
import
com.bytedance.msdk.api.nativeAd.*
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.manager.CsjGroMoreManager
import
com.mints.flowbox.manager.TrackManager
import
com.mints.flowbox.ui.widgets.seekbar.BubbleUtils
import
com.mints.flowbox.utils.LogUtil
import
com.mints.flowbox.utils.VideoOptionUtil
import
java.util.ArrayList
import
java.util.HashMap
private
val
TAG
=
GroMoreCarrierExpressManager
::
class
.
java
.
simpleName
class
AppOutGroMoreCarrierExpressManager
:
TTSettingConfigCallback
{
companion
object
{
val
instance
:
AppOutGroMoreCarrierExpressManager
by
lazy
(
mode
=
LazyThreadSafetyMode
.
SYNCHRONIZED
)
{
AppOutGroMoreCarrierExpressManager
()
}
}
private
var
mAdStyle
=
0
private
var
mExpressType
=
0
private
var
frameLayout
:
FrameLayout
?
=
null
private
var
mHandlerThread
:
HandlerThread
?
=
null
private
var
mWorkHandler
:
Handler
?
=
null
private
var
mTTAdNative
:
TTUnifiedNativeAd
?
=
null
init
{
mAdStyle
=
AdSlot
.
TYPE_EXPRESS_AD
}
fun
loadADFrameLayout
()
{
// 销毁及移除事件
destroy
()
frameLayout
=
FrameLayout
(
MintsApplication
.
getContext
())
if
(
TTMediationAdSdk
.
configLoadSuccess
())
{
loadAd
()
}
else
{
TTMediationAdSdk
.
registerConfigCallback
(
this
)
}
}
/**
* config成功,加载信息流
*/
override
fun
configLoad
()
{
loadAd
()
}
private
fun
loadAd
()
{
mTTAdNative
=
TTUnifiedNativeAd
(
MintsApplication
.
getContext
(),
CsjGroMoreManager
.
APP_OUT_AD_UNIT_EXPRESS_ID
)
//视频声音控制设置
var
videoOption
:
TTVideoOption
=
VideoOptionUtil
.
getTTVideoOption
()
//判断是否需要使用GDT Feed 模板渲染2.0;注意!!!!需要向广点通商务申请模渲染2.0权限
// 注意不设置默认使用 GDT Feed 模板渲染1.0,默认情况下无需执行下方代码
if
(
mAdStyle
==
AdSlot
.
TYPE_EXPRESS_AD
&&
mExpressType
==
GDTExtraOption
.
FeedExpressType
.
FEED_EXPRESS_TYPE_2
)
{
videoOption
=
VideoOptionUtil
.
getTTVideoOption2
()
}
//针对Admob Native的特殊配置项
val
admobNativeAdOptions
=
AdmobNativeAdOptions
()
admobNativeAdOptions
.
setAdChoicesPlacement
(
AdmobNativeAdOptions
.
ADCHOICES_TOP_RIGHT
)
//设置广告小标默认情况下,广告选择叠加层会显示在右上角。
.
setRequestMultipleImages
(
true
).
isReturnUrlsForImageAssets
=
true
//设置为true,SDK会仅提供Uri字段的值,允许自行决定是否下载实际图片,同时不会提供Drawable字段的值
// 针对Gdt Native自渲染广告,可以自定义gdt logo的布局参数。该参数可选,非必须。
val
gdtNativeAdLogUtiloParams
=
FrameLayout
.
LayoutParams
(
BubbleUtils
.
dp2px
(
40
),
BubbleUtils
.
dp2px
(
14
),
Gravity
.
END
or
Gravity
.
TOP
)
// 例如,放在右上角
/**
* 创建feed广告请求类型参数AdSlot,具体参数含义参考文档
* 备注
* 1: 如果是信息流自渲染广告,设置广告图片期望的图片宽高 ,不能为0
* 2:如果是信息流模板广告,宽度设置为希望的宽度,高度设置为0(0为高度选择自适应参数)
*/
/**
* 创建feed广告请求类型参数AdSlot,具体参数含义参考文档
* 备注
* 1: 如果是信息流自渲染广告,设置广告图片期望的图片宽高 ,不能为0
* 2:如果是信息流模板广告,宽度设置为希望的宽度,高度设置为0(0为高度选择自适应参数)
*/
val
adSlot
=
AdSlot
.
Builder
()
.
setTTVideoOption
(
videoOption
)
//视频声音相关的配置
.
setAdmobNativeAdOptions
(
admobNativeAdOptions
)
.
setAdStyleType
(
mAdStyle
)
//必传,表示请求的模板广告还是原生广告,AdSlot.TYPE_EXPRESS_AD:模板广告 ; AdSlot.TYPE_NATIVE_AD:原生广告
.
setImageAdSize
(
340
,
0
)
// 必选参数 单位dp ,详情见上面备注解释
.
setAdCount
(
1
)
//请求广告数量为1到3条
.
setGdtNativeAdLogoParams
(
gdtNativeAdLogUtiloParams
)
// 设置gdt logo布局参数。
.
build
()
//请求广告,调用feed广告异步请求接口,加载到广告后,拿到广告素材自定义渲染
/**
* 注:每次加载信息流广告的时候需要新建一个TTUnifiedNativeAd,否则可能会出现广告填充问题
* (例如:mTTAdNative = new TTUnifiedNativeAd(this, mAdUnitId);)
*/
mTTAdNative
?.
loadAd
(
adSlot
,
object
:
TTNativeAdLoadCallback
{
override
fun
onAdLoadedFial
(
adError
:
AdError
?)
{
LogUtil
.
e
(
TAG
,
"load feed ad error : "
+
adError
?.
code
+
", "
+
adError
?.
message
)
AppConfig
.
isPreExpressAwardActivity
=
false
}
override
fun
onAdLoaded
(
ads
:
MutableList
<
TTNativeAd
>?)
{
if
(
ads
==
null
||
ads
.
isEmpty
())
{
LogUtil
.
e
(
TAG
,
"on FeedAdLoaded: ad is null!"
)
return
}
for
(
ttNativeAd
in
ads
)
{
LogUtil
.
e
(
TAG
,
" "
)
LogUtil
.
e
(
TAG
,
"adNetworkPlatformId: "
+
ttNativeAd
.
adNetworkPlatformId
+
" adNetworkRitId:"
+
ttNativeAd
.
adNetworkRitId
+
" preEcpm: "
+
ttNativeAd
.
preEcpm
)
}
if
(
ads
.
size
>
0
)
{
frameLayout
?.
addView
(
createAdView
(
ads
[
0
]))
val
ttNativeAd
=
ads
[
0
]
val
vo
=
HashMap
<
String
,
Any
>()
vo
[
"adcode"
]
=
ttNativeAd
.
adNetworkRitId
vo
[
"ecpm"
]
=
ttNativeAd
.
preEcpm
vo
[
"adSource"
]
=
ttNativeAd
.
adNetworkPlatformId
vo
[
"adType"
]
=
Constant
.
GRO_MORE_ADTYPE1
vo
[
"adid"
]
=
CsjGroMoreManager
.
APP_OUT_AD_UNIT_EXPRESS_ID
TrackManager
.
getInstance
().
cmtGroMoreInfo
(
vo
)
}
}
})
}
fun
getADFrameLayout
():
FrameLayout
?
{
return
frameLayout
}
/**
* 销毁
*/
private
fun
destroy
()
{
mHandlerThread
?.
quit
()
mHandlerThread
=
null
mWorkHandler
?.
removeCallbacksAndMessages
(
null
)
mWorkHandler
=
null
TTMediationAdSdk
.
unregisterConfigCallback
(
this
)
}
private
fun
createAdView
(
ad
:
TTNativeAd
?):
View
?
{
if
(
ad
!=
null
&&
ad
.
isExpressAd
)
{
return
getExpressAdView
(
ad
)
}
return
when
{
ad
==
null
->
{
return
null
}
ad
.
adImageMode
==
TTAdConstant
.
IMAGE_MODE_SMALL_IMG
->
{
return
getSmallAdView
(
ad
)
}
ad
.
adImageMode
==
TTAdConstant
.
IMAGE_MODE_LARGE_IMG
->
{
return
getLargeAdView
(
ad
)
}
ad
.
adImageMode
==
TTAdConstant
.
IMAGE_MODE_GROUP_IMG
->
{
return
getGroupAdView
(
ad
)
}
ad
.
adImageMode
==
TTAdConstant
.
IMAGE_MODE_VIDEO
->
{
return
getVideoView
(
ad
)
}
ad
.
adImageMode
==
TTAdConstant
.
IMAGE_MODE_VERTICAL_IMG
->
{
return
getVerticalAdView
(
ad
)
}
ad
.
adImageMode
==
TTAdConstant
.
IMAGE_MODE_VIDEO_VERTICAL
->
{
return
getVideoView
(
ad
)
}
else
->
{
return
null
}
}
}
//渲染模板广告
private
fun
getExpressAdView
(
ad
:
TTNativeAd
):
View
?
{
val
adViewHolder
:
ExpressAdViewHolder
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
.
inflate
(
R
.
layout
.
listitem_ad_native_express
,
null
,
false
)
try
{
adViewHolder
=
ExpressAdViewHolder
()
adViewHolder
.
mAdContainerView
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_express
)
as
FrameLayout
convertView
.
tag
=
adViewHolder
//判断是否存在dislike按钮
// if (ad.hasDislike()) {
// ad.setDislikeCallback(MintsApplication.getContext() as Activity?, object : TTDislikeCallback {
// override fun onSelected(position: Int, value: String) {
// //用户选择不喜欢原因后,移除广告展示
// }
//
// override fun onCancel() {
// LogUtil.d(TAG, "dislike 点击了取消")
// }
//
// /**
// * 拒绝再次提交
// */
// override fun onRefuse() {}
// override fun onShow() {}
// })
// }
//设置点击展示回调监听
ad
.
setTTNativeAdListener
(
object
:
TTNativeExpressAdListener
{
override
fun
onAdClick
()
{
LogUtil
.
d
(
TAG
,
"onAdClick"
)
}
// ** 注意点 ** 不要在广告加载成功回调里进行广告view展示,要在onRenderSucces进行广告view展示,否则会导致广告无法展示。
// 另外,不要直接使用参数view,而是通过ad.getExpressView()来获取广告view。
override
fun
onRenderSuccess
(
width
:
Float
,
height
:
Float
)
{
LogUtil
.
d
(
TAG
,
"onRenderSuccess"
)
//回调渲染成功后将模板布局添加的父View中
if
(
adViewHolder
.
mAdContainerView
!=
null
)
{
//获取视频播放view,该view SDK内部渲染,在媒体平台可配置视频是否自动播放等设置。
val
sWidth
:
Int
val
sHeight
:
Int
val
video
=
ad
.
expressView
// 使用该方式获取广告view,而不是直接使用onRenderSuccess的参数view。
if
(
width
==
TTAdSize
.
FULL_WIDTH
.
toFloat
()
&&
height
==
TTAdSize
.
AUTO_HEIGHT
.
toFloat
())
{
sWidth
=
FrameLayout
.
LayoutParams
.
MATCH_PARENT
sHeight
=
FrameLayout
.
LayoutParams
.
MATCH_PARENT
}
else
{
sWidth
=
UIUtils
.
getScreenWidth
(
MintsApplication
.
getContext
())
sHeight
=
(
sWidth
*
height
/
width
).
toInt
()
}
if
(
video
!=
null
)
{
if
(
video
.
parent
==
null
)
{
val
layoutParams
=
FrameLayout
.
LayoutParams
(
sWidth
,
sHeight
)
adViewHolder
.
mAdContainerView
!!
.
removeAllViews
()
adViewHolder
.
mAdContainerView
!!
.
addView
(
video
,
layoutParams
)
}
}
}
}
override
fun
onAdShow
()
{
LogUtil
.
d
(
TAG
,
"onAdShow"
)
}
override
fun
onRenderFail
(
view
:
View
,
msg
:
String
,
code
:
Int
)
{
LogUtil
.
d
(
TAG
,
"onRenderFail code=$code,msg=$msg"
)
}
})
//视频广告设置播放状态回调(可选)
ad
.
setTTVideoListener
(
object
:
TTVideoListener
{
override
fun
onVideoStart
()
{
LogUtil
.
d
(
TAG
,
"onVideoStart"
)
}
override
fun
onVideoPause
()
{
LogUtil
.
d
(
TAG
,
"onVideoPause"
)
}
override
fun
onVideoResume
()
{
LogUtil
.
d
(
TAG
,
"onVideoResume"
)
}
override
fun
onVideoCompleted
()
{
LogUtil
.
d
(
TAG
,
"onVideoCompleted"
)
}
override
fun
onVideoError
(
adError
:
AdError
)
{
LogUtil
.
d
(
TAG
,
"onVideoError"
)
}
})
ad
.
render
()
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
return
convertView
}
/**
* @param ad
* @return
*/
private
fun
getVerticalAdView
(
ad
:
TTNativeAd
):
View
?
{
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
.
inflate
(
R
.
layout
.
listitem_ad_vertical_pic
,
null
,
false
)
val
adViewHolder
=
VerticalAdViewHolder
()
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
.
mDescription
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_desc
)
as
TextView
adViewHolder
.
mVerticalImage
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_image
)
adViewHolder
.
mIcon
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_vertical_pic
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
if
(
ad
.
imageUrl
!=
null
)
{
adViewHolder
.
mVerticalImage
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
}
return
convertView
}
//渲染视频广告,以视频广告为例,以下说明
private
fun
getVideoView
(
ad
:
TTNativeAd
):
View
?
{
val
adViewHolder
:
VideoAdViewHolder
val
viewBinder
:
TTViewBinder
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
.
inflate
(
R
.
layout
.
listitem_ad_large_video
,
null
,
false
)
try
{
adViewHolder
=
VideoAdViewHolder
()
adViewHolder
.
mTitle
=
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
.
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
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
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
viewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_large_video
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
mediaViewIdId
(
R
.
id
.
iv_listitem_video
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
//视频广告设置播放状态回调(可选)
ad
.
setTTVideoListener
(
object
:
TTVideoListener
{
override
fun
onVideoStart
()
{
LogUtil
.
d
(
TAG
,
"onVideoStart"
)
}
override
fun
onVideoPause
()
{
LogUtil
.
d
(
TAG
,
"onVideoPause"
)
}
override
fun
onVideoResume
()
{
LogUtil
.
d
(
TAG
,
"onVideoResume"
)
}
override
fun
onVideoCompleted
()
{
LogUtil
.
d
(
TAG
,
"onVideoCompleted"
)
}
override
fun
onVideoError
(
adError
:
AdError
)
{
LogUtil
.
d
(
TAG
,
"onVideoError"
)
}
})
//绑定广告数据、设置交互回调
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
return
convertView
}
private
fun
getLargeAdView
(
ad
:
TTNativeAd
):
View
?
{
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
.
inflate
(
R
.
layout
.
listitem_ad_large_pic
,
null
,
false
)
val
adViewHolder
=
LargeAdViewHolder
()
adViewHolder
.
mTitle
=
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
.
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
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_large_pic
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
if
(
ad
.
imageUrl
!=
null
)
{
adViewHolder
.
mLargeImage
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
}
return
convertView
}
private
fun
getGroupAdView
(
ad
:
TTNativeAd
):
View
?
{
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
.
inflate
(
R
.
layout
.
listitem_ad_group_pic
,
null
,
false
)
val
adViewHolder
=
GroupAdViewHolder
()
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
.
mDescription
=
convertView
.
findViewById
(
R
.
id
.
tv_listitem_ad_desc
)
as
TextView
adViewHolder
.
mGroupImage1
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_image1
)
as
ImageView
adViewHolder
.
mGroupImage2
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_image2
)
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
.
mDislike
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_group_pic
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
//传第一张即可
.
mainImageId
(
R
.
id
.
iv_listitem_image1
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
if
(
ad
.
imageList
!=
null
&&
ad
.
imageList
.
size
>=
3
)
{
val
image1
=
ad
.
imageList
[
0
]
val
image2
=
ad
.
imageList
[
1
]
val
image3
=
ad
.
imageList
[
2
]
if
(
image1
!=
null
)
{
adViewHolder
.
mGroupImage1
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image1
).
into
(
it
)
}
}
if
(
image2
!=
null
)
{
adViewHolder
.
mGroupImage2
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image2
).
into
(
it
)
}
}
if
(
image3
!=
null
)
{
adViewHolder
.
mGroupImage3
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image3
).
into
(
it
)
}
}
}
return
convertView
}
private
fun
getSmallAdView
(
ad
:
TTNativeAd
):
View
?
{
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
.
inflate
(
R
.
layout
.
listitem_ad_small_pic
,
null
,
false
)
val
adViewHolder
=
SmallAdViewHolder
()
adViewHolder
.
mTitle
=
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
.
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
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_small_pic
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议为GroupView 类型
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
if
(
ad
.
imageUrl
!=
null
)
{
adViewHolder
.
mSmallImage
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
}
return
convertView
}
private
fun
bindData
(
convertView
:
View
,
adViewHolder
:
AdViewHolder
,
ad
:
TTNativeAd
,
viewBinder
:
TTViewBinder
)
{
//设置dislike弹窗,如果有
// if (ad.hasDislike()) {
// val ttAdDislike = ad.getDislikeDialog( MintsApplication.getContext() as Activity?)
// adViewHolder.mDislike.setVisibility(View.VISIBLE)
// adViewHolder.mDislike.setOnClickListener(View.OnClickListener {
// //使用接口来展示
// ttAdDislike.showDislikeDialog()
// ttAdDislike.setDislikeCallback(object : TTDislikeCallback {
// override fun onSelected(position: Int, value: String) {}
//
// override fun onCancel() {}
//
// /**
// * 拒绝再次提交
// */
// /**
// * 拒绝再次提交
// */
// override fun onRefuse() {}
// override fun onShow() {}
// })
// })
// } else {
// if (adViewHolder.mDislike != null) adViewHolder.mDislike.setVisibility(View.GONE)
// }
//设置事件回调
ad
.
setTTNativeAdListener
(
mTTNativeAdListener
)
//可以被点击的view, 也可以把convertView放进来意味item可被点击
val
clickViewList
:
MutableList
<
View
>
=
ArrayList
()
clickViewList
.
add
(
convertView
)
adViewHolder
.
mSource
?.
let
{
clickViewList
.
add
(
it
)
}
adViewHolder
.
mTitle
?.
let
{
clickViewList
.
add
(
it
)
}
adViewHolder
.
mDescription
?.
let
{
clickViewList
.
add
(
it
)
}
adViewHolder
.
mIcon
?.
let
{
clickViewList
.
add
(
it
)
}
//添加点击区域
if
(
adViewHolder
is
LargeAdViewHolder
)
{
adViewHolder
.
mLargeImage
?.
let
{
clickViewList
.
add
(
it
)
}
}
else
if
(
adViewHolder
is
SmallAdViewHolder
)
{
adViewHolder
.
mSmallImage
?.
let
{
clickViewList
.
add
(
it
)
}
}
else
if
(
adViewHolder
is
VerticalAdViewHolder
)
{
adViewHolder
.
mVerticalImage
?.
let
{
clickViewList
.
add
(
it
)
}
}
else
if
(
adViewHolder
is
VideoAdViewHolder
)
{
adViewHolder
.
videoView
?.
let
{
clickViewList
.
add
(
it
)
}
}
else
if
(
adViewHolder
is
GroupAdViewHolder
)
{
adViewHolder
.
mGroupImage1
?.
let
{
clickViewList
.
add
(
it
)
}
adViewHolder
.
mGroupImage2
?.
let
{
clickViewList
.
add
(
it
)
}
adViewHolder
.
mGroupImage3
?.
let
{
clickViewList
.
add
(
it
)
}
}
//触发创意广告的view(点击下载或拨打电话)
val
creativeViewList
:
MutableList
<
View
>
=
ArrayList
()
adViewHolder
.
mCreativeButton
?.
let
{
creativeViewList
.
add
(
it
)
}
//重要! 这个涉及到广告计费,必须正确调用。convertView必须使用ViewGroup。
ad
.
registerView
((
convertView
as
ViewGroup
),
clickViewList
,
creativeViewList
,
viewBinder
)
adViewHolder
.
mTitle
?.
text
=
ad
.
title
//title为广告的简单信息提示
adViewHolder
.
mDescription
?.
text
=
ad
.
description
//description为广告的较长的说明
adViewHolder
.
mSource
?.
text
=
if
(
TextUtils
.
isEmpty
(
ad
.
source
))
"广告来源"
else
ad
.
source
val
icon
=
ad
.
iconUrl
if
(
icon
!=
null
)
{
adViewHolder
.
mIcon
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
icon
).
into
(
it
)
}
}
val
adCreativeButton
:
Button
?
=
adViewHolder
.
mCreativeButton
when
(
ad
.
interactionType
)
{
TTAdConstant
.
INTERACTION_TYPE_DOWNLOAD
->
{
adCreativeButton
?.
visibility
=
View
.
VISIBLE
adCreativeButton
?.
text
=
if
(
TextUtils
.
isEmpty
(
ad
.
actionText
))
"立即下载"
else
ad
.
actionText
}
TTAdConstant
.
INTERACTION_TYPE_DIAL
->
{
adCreativeButton
?.
visibility
=
View
.
VISIBLE
adCreativeButton
?.
text
=
"立即拨打"
}
TTAdConstant
.
INTERACTION_TYPE_LANDING_PAGE
,
TTAdConstant
.
INTERACTION_TYPE_BROWSER
->
{
adCreativeButton
?.
visibility
=
View
.
VISIBLE
adCreativeButton
?.
text
=
if
(
TextUtils
.
isEmpty
(
ad
.
actionText
))
"查看详情"
else
ad
.
actionText
}
else
->
{
adCreativeButton
?.
visibility
=
View
.
GONE
}
}
}
private
class
VideoAdViewHolder
:
AdViewHolder
()
{
var
videoView
:
FrameLayout
?
=
null
}
private
class
LargeAdViewHolder
:
AdViewHolder
()
{
var
mLargeImage
:
ImageView
?
=
null
}
private
class
SmallAdViewHolder
:
AdViewHolder
()
{
var
mSmallImage
:
ImageView
?
=
null
}
private
class
VerticalAdViewHolder
:
AdViewHolder
()
{
var
mVerticalImage
:
ImageView
?
=
null
}
private
class
GroupAdViewHolder
:
AdViewHolder
()
{
var
mGroupImage1
:
ImageView
?
=
null
var
mGroupImage2
:
ImageView
?
=
null
var
mGroupImage3
:
ImageView
?
=
null
}
private
class
ExpressAdViewHolder
{
var
mAdContainerView
:
FrameLayout
?
=
null
}
private
open
class
AdViewHolder
{
var
viewBinder
:
TTViewBinder
?
=
null
var
mIcon
:
ImageView
?
=
null
var
mDislike
:
ImageView
?
=
null
var
mCreativeButton
:
Button
?
=
null
var
mTitle
:
TextView
?
=
null
var
mDescription
:
TextView
?
=
null
var
mSource
:
TextView
?
=
null
var
mLogo
:
RelativeLayout
?
=
null
}
private
var
mTTNativeAdListener
:
TTNativeAdListener
=
object
:
TTNativeAdListener
{
override
fun
onAdClick
()
{
LogUtil
.
d
(
TAG
,
"onAdClick"
)
}
override
fun
onAdShow
()
{
LogUtil
.
d
(
TAG
,
"onAdShow"
)
}
}
//渲染模板广告
// private fun getExpressAdView(ad: TTNativeAd): View? {
// val adViewHolder: GroMoreExpressManager.ExpressAdViewHolder
// val convertView = LayoutInflater.from(MintsApplication.getContext()).inflate(R.layout.listitem_ad_native_express, null, false)
// try {
// adViewHolder = GroMoreExpressManager.ExpressAdViewHolder()
// adViewHolder.mAdContainerView = convertView.findViewById(R.id.iv_listitem_express) as FrameLayout
// convertView.tag = adViewHolder
//
// //判断是否存在dislike按钮
//// if (ad.hasDislike()) {
//// ad.setDislikeCallback(MintsApplication.getContext() as Activity?, object : TTDislikeCallback {
//// override fun onSelected(position: Int, value: String) {
//// ToastUtil.show(MintsApplication.getContext(), "点击 $value")
//// //用户选择不喜欢原因后,移除广告展示
//// }
////
//// override fun onCancel() {
//// ToastUtil.show(MintsApplication.getContext(), "dislike 点击了取消")
//// LogUtil.d(TAG, "dislike 点击了取消")
//// }
////
//// /**
//// * 拒绝再次提交
//// */
//// override fun onRefuse() {}
//// override fun onShow() {}
//// })
//// }
//
// //设置点击展示回调监听
// ad.setTTNativeAdListener(object : TTNativeExpressAdListener {
// override fun onAdClick() {
// LogUtil.d(TAG, "onAdClick")
// ToastUtil.show(MintsApplication.getContext(), "模板广告被点击")
// }
//
// override fun onAdShow() {
// LogUtil.d(TAG, "onAdShow")
// ToastUtil.show(MintsApplication.getContext(), "模板广告show")
// }
//
// override fun onRenderFail(view: View, msg: String, code: Int) {
// ToastUtil.show(MintsApplication.getContext(), "模板广告渲染失败code=$code,msg=$msg")
// LogUtil.d(TAG, "onRenderFail code=$code,msg=$msg")
// }
//
// // ** 注意点 ** 不要在广告加载成功回调里进行广告view展示,要在onRenderSucces进行广告view展示,否则会导致广告无法展示。
// // 另外,不要直接使用参数view,而是通过ad.getExpressView()来获取广告view。
// override fun onRenderSuccess(view: View, width: Float, height: Float) {
// LogUtil.d(TAG, "onRenderSuccess")
// ToastUtil.show(MintsApplication.getContext(), "模板广告渲染成功:width=$width,height=$height")
// //回调渲染成功后将模板布局添加的父View中
// if (adViewHolder.mAdContainerView != null) {
// //获取视频播放view,该view SDK内部渲染,在媒体平台可配置视频是否自动播放等设置。
// val sWidth: Int
// val sHeight: Int
// val video = ad.expressView // 使用该方式获取广告view,而不是直接使用onRenderSuccess的参数view。
// if (width == TTAdSize.FULL_WIDTH.toFloat() && height == TTAdSize.AUTO_HEIGHT.toFloat()) {
// sWidth = FrameLayout.LayoutParams.MATCH_PARENT
// sHeight = FrameLayout.LayoutParams.WRAP_CONTENT
// } else {
// sWidth = UIUtils.getScreenWidthDp(MintsApplication.getContext()).toInt()
// sHeight = (sWidth * height / width).toInt()
// }
// if (video != null) {
// if (video.parent == null) {
// val layoutParams = FrameLayout.LayoutParams(sWidth, sHeight)
// adViewHolder.mAdContainerView!!.removeAllViews()
// adViewHolder.mAdContainerView!!.addView(video, layoutParams)
// }
// }
// }
// }
// })
//
//
// //视频广告设置播放状态回调(可选)
// ad.setTTVideoListener(object : TTVideoListener {
// override fun onVideoStart() {
// ToastUtil.show(MintsApplication.getContext(), "模板广告视频开始播放")
// LogUtil.d(TAG, "onVideoStart")
// }
//
// override fun onVideoPause() {
// ToastUtil.show(MintsApplication.getContext(), "模板广告视频暂停")
// LogUtil.d(TAG, "onVideoPause")
// }
//
// override fun onVideoResume() {
// ToastUtil.show(MintsApplication.getContext(), "模板广告视频继续播放")
// LogUtil.d(TAG, "onVideoResume")
// }
//
// override fun onVideoCompleted() {
// ToastUtil.show(MintsApplication.getContext(), "模板播放完成")
// LogUtil.d(TAG, "onVideoCompleted")
// }
//
// override fun onVideoError(adError: AdError) {
// ToastUtil.show(MintsApplication.getContext(), "模板广告视频播放出错")
// LogUtil.d(TAG, "onVideoError")
// }
// })
// ad.render()
// } catch (e: Exception) {
// e.printStackTrace()
// }
// return convertView
// }
}
\ No newline at end of file
app/src/main/java/com/mints/flowbox/ad/express/ExpressManager.kt
View file @
030e7d21
...
...
@@ -2,27 +2,48 @@ 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
()
{
fun
loadExpress
(
isMain
:
Boolean
)
{
if
(
AppConfig
.
groMoreVideoAdCount
>
0
)
{
GroMoreCarrierExpressManager
.
instance
.
loadADFrameLayout
()
GroMoreCarrierExpressManager
.
instance
.
loadADFrameLayout
(
isMain
)
}
else
{
TTPreLoadCarrierExpressManager
.
getInstance
()
.
loadTtFrameLayout
(
TtCsjAdManager
.
TT_AD_NATIVEEXPRESS_WATER
)
PreLoadExpressManager
.
loadADFrameLayout
()
// TTPreLoadCarrierExpressManager.getInstance()
// .loadTtFrameLayout(TtCsjAdManager.TT_AD_NATIVEEXPRESS_WATER)
}
}
fun
loadAppOutExpress
()
{
if
(
AppConfig
.
groMoreVideoAdCount
>
0
)
{
AppOutGroMoreCarrierExpressManager
.
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
return
PreLoadExpressManager
.
getADFrameLayout
()
// return TTPreLoadCarrierExpressManager.getInstance().ttFrameLayout
}
}
fun
getAppOutExpressFrameLayout
():
FrameLayout
?
{
if
(
AppConfig
.
groMoreVideoAdCount
>
0
)
{
return
AppOutGroMoreCarrierExpressManager
.
instance
.
getADFrameLayout
()
}
// else {
// return TTPreLoadCarrierExpressManager.getInstance().ttFrameLayout
// }
return
null
}
}
\ No newline at end of file
app/src/main/java/com/mints/flowbox/ad/express/GroMoreCarrierExpressManager.kt
View file @
030e7d21
...
...
@@ -12,8 +12,8 @@ import com.bumptech.glide.Glide
import
com.bytedance.msdk.adapter.util.UIUtils
import
com.bytedance.msdk.api.*
import
com.bytedance.msdk.api.nativeAd.*
import
com.mints.flowbox.R
import
com.mints.flowbox.MintsApplication
import
com.mints.flowbox.R
import
com.mints.flowbox.common.AppConfig
import
com.mints.flowbox.common.Constant
import
com.mints.flowbox.manager.CsjGroMoreManager
...
...
@@ -21,8 +21,7 @@ import com.mints.flowbox.manager.TrackManager
import
com.mints.flowbox.ui.widgets.seekbar.BubbleUtils
import
com.mints.flowbox.utils.LogUtil
import
com.mints.flowbox.utils.VideoOptionUtil
import
java.util.ArrayList
import
java.util.HashMap
import
java.util.*
private
val
TAG
=
GroMoreCarrierExpressManager
::
class
.
java
.
simpleName
...
...
@@ -37,6 +36,9 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
private
var
mAdStyle
=
0
private
var
mExpressType
=
0
// 是否是网赚
private
var
isFromMain
=
true
private
var
frameLayout
:
FrameLayout
?
=
null
private
var
mHandlerThread
:
HandlerThread
?
=
null
...
...
@@ -48,7 +50,9 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
mAdStyle
=
AdSlot
.
TYPE_EXPRESS_AD
}
fun
loadADFrameLayout
()
{
fun
loadADFrameLayout
(
isMainOrCommon
:
Boolean
)
{
isFromMain
=
isMainOrCommon
// 销毁及移除事件
destroy
()
frameLayout
=
FrameLayout
(
MintsApplication
.
getContext
())
...
...
@@ -68,7 +72,18 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
}
private
fun
loadAd
()
{
mTTAdNative
=
TTUnifiedNativeAd
(
MintsApplication
.
getContext
(),
CsjGroMoreManager
.
AD_UNIT_EXPRESS_ID
)
mTTAdNative
=
if
(
isFromMain
)
{
TTUnifiedNativeAd
(
MintsApplication
.
getContext
(),
CsjGroMoreManager
.
APP_IN_MAIN_AD_UNIT_EXPRESS_ID
)
}
else
{
TTUnifiedNativeAd
(
MintsApplication
.
getContext
(),
CsjGroMoreManager
.
APP_IN_COMMON_AD_UNIT_EXPRESS_ID
)
}
//视频声音控制设置
var
videoOption
:
TTVideoOption
=
VideoOptionUtil
.
getTTVideoOption
()
...
...
@@ -82,14 +97,16 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
//针对Admob Native的特殊配置项
val
admobNativeAdOptions
=
AdmobNativeAdOptions
()
admobNativeAdOptions
.
setAdChoicesPlacement
(
AdmobNativeAdOptions
.
ADCHOICES_TOP_RIGHT
)
//设置广告小标默认情况下,广告选择叠加层会显示在右上角。
.
setRequestMultipleImages
(
true
).
isReturnUrlsForImageAssets
=
true
//设置为true,SDK会仅提供Uri字段的值,允许自行决定是否下载实际图片,同时不会提供Drawable字段的值
.
setRequestMultipleImages
(
true
).
isReturnUrlsForImageAssets
=
true
//设置为true,SDK会仅提供Uri字段的值,允许自行决定是否下载实际图片,同时不会提供Drawable字段的值
// 针对Gdt Native自渲染广告,可以自定义gdt logo的布局参数。该参数可选,非必须。
val
gdtNativeAdLogUtiloParams
=
FrameLayout
.
LayoutParams
(
BubbleUtils
.
dp2px
(
40
),
BubbleUtils
.
dp2px
(
14
),
Gravity
.
END
or
Gravity
.
TOP
)
// 例如,放在右上角
BubbleUtils
.
dp2px
(
40
),
BubbleUtils
.
dp2px
(
14
),
Gravity
.
END
or
Gravity
.
TOP
)
// 例如,放在右上角
/**
* 创建feed广告请求类型参数AdSlot,具体参数含义参考文档
...
...
@@ -104,13 +121,13 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
* 2:如果是信息流模板广告,宽度设置为希望的宽度,高度设置为0(0为高度选择自适应参数)
*/
val
adSlot
=
AdSlot
.
Builder
()
.
setTTVideoOption
(
videoOption
)
//视频声音相关的配置
.
setAdmobNativeAdOptions
(
admobNativeAdOptions
)
.
setAdStyleType
(
mAdStyle
)
//必传,表示请求的模板广告还是原生广告,AdSlot.TYPE_EXPRESS_AD:模板广告 ; AdSlot.TYPE_NATIVE_AD:原生广告
.
setImageAdSize
(
340
,
0
)
// 必选参数 单位dp ,详情见上面备注解释
.
setAdCount
(
1
)
//请求广告数量为1到3条
.
setGdtNativeAdLogoParams
(
gdtNativeAdLogUtiloParams
)
// 设置gdt logo布局参数。
.
build
()
.
setTTVideoOption
(
videoOption
)
//视频声音相关的配置
.
setAdmobNativeAdOptions
(
admobNativeAdOptions
)
.
setAdStyleType
(
mAdStyle
)
//必传,表示请求的模板广告还是原生广告,AdSlot.TYPE_EXPRESS_AD:模板广告 ; AdSlot.TYPE_NATIVE_AD:原生广告
.
setImageAdSize
(
340
,
0
)
// 必选参数 单位dp ,详情见上面备注解释
.
setAdCount
(
1
)
//请求广告数量为1到3条
.
setGdtNativeAdLogoParams
(
gdtNativeAdLogUtiloParams
)
// 设置gdt logo布局参数。
.
build
()
//请求广告,调用feed广告异步请求接口,加载到广告后,拿到广告素材自定义渲染
/**
...
...
@@ -120,7 +137,7 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
mTTAdNative
?.
loadAd
(
adSlot
,
object
:
TTNativeAdLoadCallback
{
override
fun
onAdLoadedFial
(
adError
:
AdError
?)
{
LogUtil
.
e
(
TAG
,
"load feed ad error : "
+
adError
?.
code
+
", "
+
adError
?.
message
)
AppConfig
.
isPreExpressAwardActivity
=
false
AppConfig
.
isPreExpressAwardActivity
=
false
}
...
...
@@ -130,9 +147,14 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
return
}
AppConfig
.
isPreExpressAwardActivity
=
true
for
(
ttNativeAd
in
ads
)
{
LogUtil
.
e
(
TAG
,
" "
)
LogUtil
.
e
(
TAG
,
"adNetworkPlatformId: "
+
ttNativeAd
.
adNetworkPlatformId
+
" adNetworkRitId:"
+
ttNativeAd
.
adNetworkRitId
+
" preEcpm: "
+
ttNativeAd
.
preEcpm
)
LogUtil
.
e
(
TAG
,
"adNetworkPlatformId: "
+
ttNativeAd
.
adNetworkPlatformId
+
" adNetworkRitId:"
+
ttNativeAd
.
adNetworkRitId
+
" preEcpm: "
+
ttNativeAd
.
preEcpm
)
}
if
(
ads
.
size
>
0
)
{
...
...
@@ -144,7 +166,7 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
vo
[
"ecpm"
]
=
ttNativeAd
.
preEcpm
vo
[
"adSource"
]
=
ttNativeAd
.
adNetworkPlatformId
vo
[
"adType"
]
=
Constant
.
GRO_MORE_ADTYPE1
vo
[
"adid"
]
=
CsjGroMoreManager
.
AD_UNIT_EXPRESS_ID
vo
[
"adid"
]
=
CsjGroMoreManager
.
APP_IN_COMMON_
AD_UNIT_EXPRESS_ID
TrackManager
.
getInstance
().
cmtGroMoreInfo
(
vo
)
}
}
...
...
@@ -205,10 +227,12 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
//渲染模板广告
private
fun
getExpressAdView
(
ad
:
TTNativeAd
):
View
?
{
val
adViewHolder
:
ExpressAdViewHolder
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_native_express
,
null
,
false
)
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
.
inflate
(
R
.
layout
.
listitem_ad_native_express
,
null
,
false
)
try
{
adViewHolder
=
ExpressAdViewHolder
()
adViewHolder
.
mAdContainerView
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_express
)
as
FrameLayout
adViewHolder
.
mAdContainerView
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_express
)
as
FrameLayout
convertView
.
tag
=
adViewHolder
//判断是否存在dislike按钮
...
...
@@ -308,30 +332,36 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
* @return
*/
private
fun
getVerticalAdView
(
ad
:
TTNativeAd
):
View
?
{
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_vertical_pic
,
null
,
false
)
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
.
inflate
(
R
.
layout
.
listitem_ad_vertical_pic
,
null
,
false
)
val
adViewHolder
=
VerticalAdViewHolder
()
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
.
mDescription
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_desc
)
as
TextView
adViewHolder
.
mDescription
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_desc
)
as
TextView
adViewHolder
.
mVerticalImage
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_image
)
adViewHolder
.
mIcon
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_vertical_pic
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
build
()
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
if
(
ad
.
imageUrl
!=
null
)
{
adViewHolder
.
mVerticalImage
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
adViewHolder
.
mVerticalImage
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
}
return
convertView
}
...
...
@@ -340,28 +370,36 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
private
fun
getVideoView
(
ad
:
TTNativeAd
):
View
?
{
val
adViewHolder
:
VideoAdViewHolder
val
viewBinder
:
TTViewBinder
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_large_video
,
null
,
false
)
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
.
inflate
(
R
.
layout
.
listitem_ad_large_video
,
null
,
false
)
try
{
adViewHolder
=
VideoAdViewHolder
()
adViewHolder
.
mTitle
=
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
.
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
.
mTitle
=
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
.
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
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
adViewHolder
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
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
viewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_large_video
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
mediaViewIdId
(
R
.
id
.
iv_listitem_video
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
mediaViewIdId
(
R
.
id
.
iv_listitem_video
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
...
...
@@ -397,36 +435,46 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
}
private
fun
getLargeAdView
(
ad
:
TTNativeAd
):
View
?
{
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_large_pic
,
null
,
false
)
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
.
inflate
(
R
.
layout
.
listitem_ad_large_pic
,
null
,
false
)
val
adViewHolder
=
LargeAdViewHolder
()
adViewHolder
.
mTitle
=
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
.
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
.
mTitle
=
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
.
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
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_large_pic
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
if
(
ad
.
imageUrl
!=
null
)
{
adViewHolder
.
mLargeImage
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
adViewHolder
.
mLargeImage
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
}
return
convertView
}
private
fun
getGroupAdView
(
ad
:
TTNativeAd
):
View
?
{
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_group_pic
,
null
,
false
)
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
.
inflate
(
R
.
layout
.
listitem_ad_group_pic
,
null
,
false
)
val
adViewHolder
=
GroupAdViewHolder
()
adViewHolder
.
mTitle
=
convertView
!!
.
findViewById
(
R
.
id
.
tv_listitem_ad_title
)
as
TextView
adViewHolder
.
mSource
=
convertView
.
findViewById
(
R
.
id
.
tv_listitem_ad_source
)
as
TextView
...
...
@@ -436,17 +484,18 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
adViewHolder
.
mGroupImage3
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_image3
)
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
.
mCreativeButton
=
convertView
.
findViewById
(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_group_pic
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
//传第一张即可
.
mainImageId
(
R
.
id
.
iv_listitem_image1
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
//传第一张即可
.
mainImageId
(
R
.
id
.
iv_listitem_image1
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
...
...
@@ -455,48 +504,68 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
val
image2
=
ad
.
imageList
[
1
]
val
image3
=
ad
.
imageList
[
2
]
if
(
image1
!=
null
)
{
adViewHolder
.
mGroupImage1
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image1
).
into
(
it
)
}
adViewHolder
.
mGroupImage1
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image1
).
into
(
it
)
}
}
if
(
image2
!=
null
)
{
adViewHolder
.
mGroupImage2
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image2
).
into
(
it
)
}
adViewHolder
.
mGroupImage2
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image2
).
into
(
it
)
}
}
if
(
image3
!=
null
)
{
adViewHolder
.
mGroupImage3
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image3
).
into
(
it
)
}
adViewHolder
.
mGroupImage3
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image3
).
into
(
it
)
}
}
}
return
convertView
}
private
fun
getSmallAdView
(
ad
:
TTNativeAd
):
View
?
{
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_small_pic
,
null
,
false
)
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
.
inflate
(
R
.
layout
.
listitem_ad_small_pic
,
null
,
false
)
val
adViewHolder
=
SmallAdViewHolder
()
adViewHolder
.
mTitle
=
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
.
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
.
mTitle
=
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
.
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
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_small_pic
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议为GroupView 类型
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议为GroupView 类型
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
if
(
ad
.
imageUrl
!=
null
)
{
adViewHolder
.
mSmallImage
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
adViewHolder
.
mSmallImage
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
}
return
convertView
}
private
fun
bindData
(
convertView
:
View
,
adViewHolder
:
AdViewHolder
,
ad
:
TTNativeAd
,
viewBinder
:
TTViewBinder
)
{
private
fun
bindData
(
convertView
:
View
,
adViewHolder
:
AdViewHolder
,
ad
:
TTNativeAd
,
viewBinder
:
TTViewBinder
)
{
//设置dislike弹窗,如果有
// if (ad.hasDislike()) {
// val ttAdDislike = ad.getDislikeDialog( MintsApplication.getContext() as Activity?)
...
...
@@ -556,13 +625,16 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
adViewHolder
.
mSource
?.
text
=
if
(
TextUtils
.
isEmpty
(
ad
.
source
))
"广告来源"
else
ad
.
source
val
icon
=
ad
.
iconUrl
if
(
icon
!=
null
)
{
adViewHolder
.
mIcon
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
icon
).
into
(
it
)
}
adViewHolder
.
mIcon
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
icon
).
into
(
it
)
}
}
val
adCreativeButton
:
Button
?
=
adViewHolder
.
mCreativeButton
when
(
ad
.
interactionType
)
{
TTAdConstant
.
INTERACTION_TYPE_DOWNLOAD
->
{
adCreativeButton
?.
visibility
=
View
.
VISIBLE
adCreativeButton
?.
text
=
if
(
TextUtils
.
isEmpty
(
ad
.
actionText
))
"立即下载"
else
ad
.
actionText
adCreativeButton
?.
text
=
if
(
TextUtils
.
isEmpty
(
ad
.
actionText
))
"立即下载"
else
ad
.
actionText
}
TTAdConstant
.
INTERACTION_TYPE_DIAL
->
{
adCreativeButton
?.
visibility
=
View
.
VISIBLE
...
...
@@ -570,7 +642,8 @@ class GroMoreCarrierExpressManager : TTSettingConfigCallback {
}
TTAdConstant
.
INTERACTION_TYPE_LANDING_PAGE
,
TTAdConstant
.
INTERACTION_TYPE_BROWSER
->
{
adCreativeButton
?.
visibility
=
View
.
VISIBLE
adCreativeButton
?.
text
=
if
(
TextUtils
.
isEmpty
(
ad
.
actionText
))
"查看详情"
else
ad
.
actionText
adCreativeButton
?.
text
=
if
(
TextUtils
.
isEmpty
(
ad
.
actionText
))
"查看详情"
else
ad
.
actionText
}
else
->
{
adCreativeButton
?.
visibility
=
View
.
GONE
...
...
app/src/main/java/com/mints/flowbox/ad/express/GroMoreExpressManager.kt
View file @
030e7d21
...
...
@@ -63,7 +63,10 @@ class GroMoreExpressManager : TTSettingConfigCallback {
}
private
fun
loadAd
()
{
mTTAdNative
=
TTUnifiedNativeAd
(
MintsApplication
.
getContext
(),
CsjGroMoreManager
.
AD_UNIT_EXPRESS_ID
)
mTTAdNative
=
TTUnifiedNativeAd
(
MintsApplication
.
getContext
(),
CsjGroMoreManager
.
APP_IN_MAIN_AD_UNIT_EXPRESS_ID
)
//视频声音控制设置
var
videoOption
:
TTVideoOption
=
VideoOptionUtil
.
getTTVideoOption
()
...
...
@@ -77,14 +80,16 @@ class GroMoreExpressManager : TTSettingConfigCallback {
//针对Admob Native的特殊配置项
val
admobNativeAdOptions
=
AdmobNativeAdOptions
()
admobNativeAdOptions
.
setAdChoicesPlacement
(
AdmobNativeAdOptions
.
ADCHOICES_TOP_RIGHT
)
//设置广告小标默认情况下,广告选择叠加层会显示在右上角。
.
setRequestMultipleImages
(
true
).
isReturnUrlsForImageAssets
=
true
//设置为true,SDK会仅提供Uri字段的值,允许自行决定是否下载实际图片,同时不会提供Drawable字段的值
.
setRequestMultipleImages
(
true
).
isReturnUrlsForImageAssets
=
true
//设置为true,SDK会仅提供Uri字段的值,允许自行决定是否下载实际图片,同时不会提供Drawable字段的值
// 针对Gdt Native自渲染广告,可以自定义gdt logo的布局参数。该参数可选,非必须。
val
gdtNativeAdLogUtiloParams
=
FrameLayout
.
LayoutParams
(
BubbleUtils
.
dp2px
(
40
),
BubbleUtils
.
dp2px
(
14
),
Gravity
.
END
or
Gravity
.
TOP
)
// 例如,放在右上角
BubbleUtils
.
dp2px
(
40
),
BubbleUtils
.
dp2px
(
14
),
Gravity
.
END
or
Gravity
.
TOP
)
// 例如,放在右上角
/**
* 创建feed广告请求类型参数AdSlot,具体参数含义参考文档
...
...
@@ -99,13 +104,13 @@ class GroMoreExpressManager : TTSettingConfigCallback {
* 2:如果是信息流模板广告,宽度设置为希望的宽度,高度设置为0(0为高度选择自适应参数)
*/
val
adSlot
=
AdSlot
.
Builder
()
.
setTTVideoOption
(
videoOption
)
//视频声音相关的配置
.
setAdmobNativeAdOptions
(
admobNativeAdOptions
)
.
setAdStyleType
(
mAdStyle
)
//必传,表示请求的模板广告还是原生广告,AdSlot.TYPE_EXPRESS_AD:模板广告 ; AdSlot.TYPE_NATIVE_AD:原生广告
.
setImageAdSize
(
340
,
0
)
// 必选参数 单位dp ,详情见上面备注解释
.
setAdCount
(
1
)
//请求广告数量为1到3条
.
setGdtNativeAdLogoParams
(
gdtNativeAdLogUtiloParams
)
// 设置gdt logo布局参数。
.
build
()
.
setTTVideoOption
(
videoOption
)
//视频声音相关的配置
.
setAdmobNativeAdOptions
(
admobNativeAdOptions
)
.
setAdStyleType
(
mAdStyle
)
//必传,表示请求的模板广告还是原生广告,AdSlot.TYPE_EXPRESS_AD:模板广告 ; AdSlot.TYPE_NATIVE_AD:原生广告
.
setImageAdSize
(
340
,
0
)
// 必选参数 单位dp ,详情见上面备注解释
.
setAdCount
(
1
)
//请求广告数量为1到3条
.
setGdtNativeAdLogoParams
(
gdtNativeAdLogUtiloParams
)
// 设置gdt logo布局参数。
.
build
()
//请求广告,调用feed广告异步请求接口,加载到广告后,拿到广告素材自定义渲染
/**
...
...
@@ -115,7 +120,7 @@ class GroMoreExpressManager : TTSettingConfigCallback {
mTTAdNative
?.
loadAd
(
adSlot
,
object
:
TTNativeAdLoadCallback
{
override
fun
onAdLoadedFial
(
adError
:
AdError
?)
{
LogUtil
.
e
(
TAG
,
"load feed ad error : "
+
adError
?.
code
+
", "
+
adError
?.
message
)
AppConfig
.
isPreExpressAwardActivity
=
false
AppConfig
.
isPreExpressAwardActivity
=
false
}
...
...
@@ -127,7 +132,10 @@ class GroMoreExpressManager : TTSettingConfigCallback {
for
(
ttNativeAd
in
ads
)
{
LogUtil
.
e
(
TAG
,
" "
)
LogUtil
.
e
(
TAG
,
"adNetworkPlatformId: "
+
ttNativeAd
.
adNetworkPlatformId
+
" adNetworkRitId:"
+
ttNativeAd
.
adNetworkRitId
+
" preEcpm: "
+
ttNativeAd
.
preEcpm
)
LogUtil
.
e
(
TAG
,
"adNetworkPlatformId: "
+
ttNativeAd
.
adNetworkPlatformId
+
" adNetworkRitId:"
+
ttNativeAd
.
adNetworkRitId
+
" preEcpm: "
+
ttNativeAd
.
preEcpm
)
}
if
(
ads
.
size
>
0
)
{
...
...
@@ -140,7 +148,7 @@ class GroMoreExpressManager : TTSettingConfigCallback {
vo
[
"ecpm"
]
=
ttNativeAd
.
getPreEcpm
()
vo
[
"adSource"
]
=
ttNativeAd
.
getAdNetworkPlatformId
()
vo
[
"adType"
]
=
Constant
.
GRO_MORE_ADTYPE1
vo
[
"adid"
]
=
CsjGroMoreManager
.
AD_UNIT_EXPRESS_ID
vo
[
"adid"
]
=
CsjGroMoreManager
.
APP_IN_MAIN_
AD_UNIT_EXPRESS_ID
TrackManager
.
getInstance
().
cmtGroMoreInfo
(
vo
)
// sAdFrameLayout.addView(createAdView(ads[0]))
}
...
...
@@ -204,10 +212,12 @@ class GroMoreExpressManager : TTSettingConfigCallback {
//渲染模板广告
private
fun
getExpressAdView
(
ad
:
TTNativeAd
):
View
?
{
val
adViewHolder
:
ExpressAdViewHolder
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_native_express
,
null
,
false
)
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
.
inflate
(
R
.
layout
.
listitem_ad_native_express
,
null
,
false
)
try
{
adViewHolder
=
ExpressAdViewHolder
()
adViewHolder
.
mAdContainerView
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_express
)
as
FrameLayout
adViewHolder
.
mAdContainerView
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_express
)
as
FrameLayout
convertView
.
tag
=
adViewHolder
//判断是否存在dislike按钮
...
...
@@ -306,30 +316,36 @@ class GroMoreExpressManager : TTSettingConfigCallback {
* @return
*/
private
fun
getVerticalAdView
(
ad
:
TTNativeAd
):
View
?
{
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_vertical_pic
,
null
,
false
)
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
.
inflate
(
R
.
layout
.
listitem_ad_vertical_pic
,
null
,
false
)
val
adViewHolder
=
VerticalAdViewHolder
()
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
.
mDescription
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_desc
)
as
TextView
adViewHolder
.
mDescription
=
convertView
.
findViewById
<
View
>(
R
.
id
.
tv_listitem_ad_desc
)
as
TextView
adViewHolder
.
mVerticalImage
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_image
)
adViewHolder
.
mIcon
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_icon
)
as
ImageView
adViewHolder
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_vertical_pic
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
build
()
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
if
(
ad
.
imageUrl
!=
null
)
{
adViewHolder
.
mVerticalImage
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
adViewHolder
.
mVerticalImage
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
}
return
convertView
}
...
...
@@ -338,28 +354,36 @@ class GroMoreExpressManager : TTSettingConfigCallback {
private
fun
getVideoView
(
ad
:
TTNativeAd
):
View
?
{
val
adViewHolder
:
VideoAdViewHolder
val
viewBinder
:
TTViewBinder
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_large_video
,
null
,
false
)
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
.
inflate
(
R
.
layout
.
listitem_ad_large_video
,
null
,
false
)
try
{
adViewHolder
=
VideoAdViewHolder
()
adViewHolder
.
mTitle
=
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
.
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
.
mTitle
=
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
.
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
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
adViewHolder
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
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
viewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_large_video
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
mediaViewIdId
(
R
.
id
.
iv_listitem_video
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
mediaViewIdId
(
R
.
id
.
iv_listitem_video
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
...
...
@@ -395,36 +419,46 @@ class GroMoreExpressManager : TTSettingConfigCallback {
}
private
fun
getLargeAdView
(
ad
:
TTNativeAd
):
View
?
{
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_large_pic
,
null
,
false
)
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
.
inflate
(
R
.
layout
.
listitem_ad_large_pic
,
null
,
false
)
val
adViewHolder
=
LargeAdViewHolder
()
adViewHolder
.
mTitle
=
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
.
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
.
mTitle
=
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
.
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
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_large_pic
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
if
(
ad
.
imageUrl
!=
null
)
{
adViewHolder
.
mLargeImage
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
adViewHolder
.
mLargeImage
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
}
return
convertView
}
private
fun
getGroupAdView
(
ad
:
TTNativeAd
):
View
?
{
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_group_pic
,
null
,
false
)
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
.
inflate
(
R
.
layout
.
listitem_ad_group_pic
,
null
,
false
)
val
adViewHolder
=
GroupAdViewHolder
()
adViewHolder
.
mTitle
=
convertView
!!
.
findViewById
(
R
.
id
.
tv_listitem_ad_title
)
as
TextView
adViewHolder
.
mSource
=
convertView
.
findViewById
(
R
.
id
.
tv_listitem_ad_source
)
as
TextView
...
...
@@ -434,17 +468,18 @@ class GroMoreExpressManager : TTSettingConfigCallback {
adViewHolder
.
mGroupImage3
=
convertView
.
findViewById
(
R
.
id
.
iv_listitem_image3
)
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
.
mCreativeButton
=
convertView
.
findViewById
(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mLogo
=
convertView
.
findViewById
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_group_pic
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
//传第一张即可
.
mainImageId
(
R
.
id
.
iv_listitem_image1
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
//传第一张即可
.
mainImageId
(
R
.
id
.
iv_listitem_image1
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议传入GroupView类型
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
...
...
@@ -453,48 +488,68 @@ class GroMoreExpressManager : TTSettingConfigCallback {
val
image2
=
ad
.
imageList
[
1
]
val
image3
=
ad
.
imageList
[
2
]
if
(
image1
!=
null
)
{
adViewHolder
.
mGroupImage1
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image1
).
into
(
it
)
}
adViewHolder
.
mGroupImage1
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image1
).
into
(
it
)
}
}
if
(
image2
!=
null
)
{
adViewHolder
.
mGroupImage2
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image2
).
into
(
it
)
}
adViewHolder
.
mGroupImage2
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image2
).
into
(
it
)
}
}
if
(
image3
!=
null
)
{
adViewHolder
.
mGroupImage3
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image3
).
into
(
it
)
}
adViewHolder
.
mGroupImage3
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
image3
).
into
(
it
)
}
}
}
return
convertView
}
private
fun
getSmallAdView
(
ad
:
TTNativeAd
):
View
?
{
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
()).
inflate
(
R
.
layout
.
listitem_ad_small_pic
,
null
,
false
)
val
convertView
=
LayoutInflater
.
from
(
MintsApplication
.
getContext
())
.
inflate
(
R
.
layout
.
listitem_ad_small_pic
,
null
,
false
)
val
adViewHolder
=
SmallAdViewHolder
()
adViewHolder
.
mTitle
=
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
.
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
.
mTitle
=
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
.
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
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
adViewHolder
.
mDislike
=
convertView
.
findViewById
<
View
>(
R
.
id
.
iv_listitem_dislike
)
as
ImageView
adViewHolder
.
mCreativeButton
=
convertView
.
findViewById
<
View
>(
R
.
id
.
btn_listitem_creative
)
as
Button
val
viewBinder
:
TTViewBinder
=
TTViewBinder
.
Builder
(
R
.
layout
.
listitem_ad_small_pic
)
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议为GroupView 类型
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
.
titleId
(
R
.
id
.
tv_listitem_ad_title
)
.
sourceId
(
R
.
id
.
tv_listitem_ad_source
)
.
decriptionTextId
(
R
.
id
.
tv_listitem_ad_desc
)
.
mainImageId
(
R
.
id
.
iv_listitem_image
)
.
logoLayoutId
(
R
.
id
.
tt_ad_logo
)
//logoView 建议为GroupView 类型
.
callToActionId
(
R
.
id
.
btn_listitem_creative
)
.
iconImageId
(
R
.
id
.
iv_listitem_icon
)
.
build
()
adViewHolder
.
viewBinder
=
viewBinder
convertView
.
tag
=
adViewHolder
bindData
(
convertView
,
adViewHolder
,
ad
,
viewBinder
)
if
(
ad
.
imageUrl
!=
null
)
{
adViewHolder
.
mSmallImage
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
adViewHolder
.
mSmallImage
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
ad
.
imageUrl
).
into
(
it
)
}
}
return
convertView
}
private
fun
bindData
(
convertView
:
View
,
adViewHolder
:
AdViewHolder
,
ad
:
TTNativeAd
,
viewBinder
:
TTViewBinder
)
{
private
fun
bindData
(
convertView
:
View
,
adViewHolder
:
AdViewHolder
,
ad
:
TTNativeAd
,
viewBinder
:
TTViewBinder
)
{
//设置dislike弹窗,如果有
// if (ad.hasDislike()) {
// val ttAdDislike = ad.getDislikeDialog( MintsApplication.getContext() as Activity?)
...
...
@@ -554,13 +609,16 @@ class GroMoreExpressManager : TTSettingConfigCallback {
adViewHolder
.
mSource
?.
text
=
if
(
TextUtils
.
isEmpty
(
ad
.
source
))
"广告来源"
else
ad
.
source
val
icon
=
ad
.
iconUrl
if
(
icon
!=
null
)
{
adViewHolder
.
mIcon
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
icon
).
into
(
it
)
}
adViewHolder
.
mIcon
?.
let
{
Glide
.
with
(
MintsApplication
.
getContext
()).
load
(
icon
).
into
(
it
)
}
}
val
adCreativeButton
:
Button
?
=
adViewHolder
.
mCreativeButton
when
(
ad
.
interactionType
)
{
TTAdConstant
.
INTERACTION_TYPE_DOWNLOAD
->
{
adCreativeButton
?.
visibility
=
View
.
VISIBLE
adCreativeButton
?.
text
=
if
(
TextUtils
.
isEmpty
(
ad
.
actionText
))
"立即下载"
else
ad
.
actionText
adCreativeButton
?.
text
=
if
(
TextUtils
.
isEmpty
(
ad
.
actionText
))
"立即下载"
else
ad
.
actionText
}
TTAdConstant
.
INTERACTION_TYPE_DIAL
->
{
adCreativeButton
?.
visibility
=
View
.
VISIBLE
...
...
@@ -568,7 +626,8 @@ class GroMoreExpressManager : TTSettingConfigCallback {
}
TTAdConstant
.
INTERACTION_TYPE_LANDING_PAGE
,
TTAdConstant
.
INTERACTION_TYPE_BROWSER
->
{
adCreativeButton
?.
visibility
=
View
.
VISIBLE
adCreativeButton
?.
text
=
if
(
TextUtils
.
isEmpty
(
ad
.
actionText
))
"查看详情"
else
ad
.
actionText
adCreativeButton
?.
text
=
if
(
TextUtils
.
isEmpty
(
ad
.
actionText
))
"查看详情"
else
ad
.
actionText
}
else
->
{
adCreativeButton
?.
visibility
=
View
.
GONE
...
...
app/src/main/java/com/mints/flowbox/ad/express/PreLoadExpressManager.kt
View file @
030e7d21
...
...
@@ -15,7 +15,9 @@ import java.util.*
/**
* 预加载信息流管理类
*/
object
PreLoadExpressManager
:
TTADLoadSuccessListener
,
YLHADLoadSuccessListener
,
KSADLoadSuccessListener
,
GMADLoadSuccessListener
{
@SuppressLint
(
"StaticFieldLeak"
)
object
PreLoadExpressManager
:
TTADLoadSuccessListener
,
YLHADLoadSuccessListener
,
KSADLoadSuccessListener
,
GMADLoadSuccessListener
{
private
val
TAG
=
PreLoadExpressManager
::
class
.
java
.
simpleName
...
...
@@ -62,7 +64,8 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
// }
when
(
getRandomWeight
())
{
Constant
.
CSJ_EXPRESS_AD
->
TTPreLoadExpressManager
.
getInstance
().
loadTtFrameLayout
(
mAdFrameLayout
)
Constant
.
CSJ_EXPRESS_AD
->
TTPreLoadExpressManager
.
getInstance
()
.
loadTtFrameLayout
(
mAdFrameLayout
)
Constant
.
YLH_EXPRESS_AD
->
YlhPreLoadExpressManager
.
loadYlhFrameLayout
()
Constant
.
KS_EXPRESS_AD
->
KsPreLoadExpressManager
.
loadKsFrameLayout
(
mAdFrameLayout
as
ViewGroup
)
Constant
.
GM_EXPRESS_AD
->
GroMoreExpressManager
.
instance
.
loadADFrameLayout
()
...
...
@@ -135,8 +138,8 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
// if (currentIndex == 1) {
// mAdFrameLayout = adFrameLayout
// }
if
(
view
!=
null
)
{
AppConfig
.
isPreExpressAwardActivity
=
true
if
(
view
!=
null
)
{
AppConfig
.
isPreExpressAwardActivity
=
true
}
mAdFrameLayout
=
view
}
...
...
@@ -145,8 +148,8 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
// if (currentIndex == 2) {
// mAdFrameLayout?.addView(view)
// }
if
(
view
!=
null
)
{
AppConfig
.
isPreExpressAwardActivity
=
true
if
(
view
!=
null
)
{
AppConfig
.
isPreExpressAwardActivity
=
true
}
mAdFrameLayout
?.
addView
(
view
)
}
...
...
@@ -155,8 +158,8 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
// if (currentIndex == 3) {
// mAdFrameLayout?.addView(view)
// }
if
(
view
!=
null
)
{
AppConfig
.
isPreExpressAwardActivity
=
true
if
(
view
!=
null
)
{
AppConfig
.
isPreExpressAwardActivity
=
true
}
mAdFrameLayout
?.
addView
(
view
)
}
...
...
@@ -165,8 +168,8 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
// if (currentIndex == 3) {
// mAdFrameLayout?.addView(view)
// }
if
(
view
!=
null
)
{
AppConfig
.
isPreExpressAwardActivity
=
true
if
(
view
!=
null
)
{
AppConfig
.
isPreExpressAwardActivity
=
true
}
mAdFrameLayout
?.
addView
(
view
)
}
...
...
app/src/main/java/com/mints/flowbox/ad/express/TTPreLoadCarrierExpressManager.java
View file @
030e7d21
...
...
@@ -9,6 +9,7 @@ import android.widget.FrameLayout;
import
androidx.annotation.NonNull
;
import
com.mints.flowbox.MintsApplication
;
import
com.mints.flowbox.common.AppConfig
;
import
com.mints.flowbox.manager.TTNativeExpressManager
;
public
class
TTPreLoadCarrierExpressManager
{
...
...
@@ -86,6 +87,8 @@ public class TTPreLoadCarrierExpressManager {
ttFrameLayout
=
null
;
}
else
{
AppConfig
.
isPreExpressAwardActivity
=
true
;
try
{
ttFrameLayout
=
view
;
}
catch
(
Exception
e
)
{
...
...
app/src/main/java/com/mints/flowbox/ad/full/FullGroManager.java
View file @
030e7d21
...
...
@@ -81,7 +81,7 @@ public class FullGroManager {
* 注:每次加载全屏视频广告的时候需要新建一个TTFullVideoAd,否则可能会出现广告填充问题
* ( 例如:mTTFullVideoAd = new TTFullVideoAd(this, adUnitId);)
*/
mTTFullVideoAd
=
new
TTFullVideoAd
(
activity
,
CsjGroMoreManager
.
INSTANCE
.
getA
D_UNIT_FUL
L_ID
());
mTTFullVideoAd
=
new
TTFullVideoAd
(
activity
,
CsjGroMoreManager
.
INSTANCE
.
getA
PP_IN_COMMON_AD_UNIT_INTERSTITIA
L_ID
());
//声音控制 模板 2.0
TTVideoOption
videoOption
=
VideoOptionUtil
.
getTTVideoOption2
();
...
...
@@ -120,14 +120,14 @@ public class FullGroManager {
}
if
(
isLoadSuccess
&&
mTTFullVideoAd
!=
null
&&
mTTFullVideoAd
.
isReady
()
&&
activity
!=
null
)
{
//设置监听器
mTTFullVideoAd
.
showFullAd
(
activity
,
mTTFullVideoAdListener
);
mTTFullVideoAd
.
showFullAd
(
activity
,
mTTFullVideoAdListener
);
HashMap
<
String
,
Object
>
vo
=
new
HashMap
<>();
vo
.
put
(
"adcode"
,
mTTFullVideoAd
.
getAdNetworkRitId
());
vo
.
put
(
"ecpm"
,
mTTFullVideoAd
.
getPreEcpm
());
vo
.
put
(
"adSource"
,
mTTFullVideoAd
.
getAdNetworkPlatformId
());
vo
.
put
(
"adType"
,
Constant
.
GRO_MORE_ADTYPE4
);
vo
.
put
(
"adid"
,
CsjGroMoreManager
.
INSTANCE
.
getA
D_UNIT_FUL
L_ID
());
vo
.
put
(
"adid"
,
CsjGroMoreManager
.
INSTANCE
.
getA
PP_IN_COMMON_AD_UNIT_INTERSTITIA
L_ID
());
TrackManager
.
getInstance
().
cmtGroMoreInfo
(
vo
);
}
else
{
// 当加载到广告后 ,长时间未展示失效时 改变状态
...
...
@@ -152,7 +152,7 @@ public class FullGroManager {
@Override
public
void
onFullVideoAdClosed
()
{
if
(
wifiAdStatusListener
!=
null
)
{
if
(
wifiAdStatusListener
!=
null
)
{
wifiAdStatusListener
.
adClose
();
}
Log
.
d
(
TAG
,
"onFullVideoAdClosed"
);
...
...
app/src/main/java/com/mints/flowbox/ad/inscreen/InsertScreenAdManager.kt
View file @
030e7d21
...
...
@@ -24,24 +24,24 @@ class InsertScreenAdManager {
/**
* 预加载广告,必须传入activity
*/
fun
loadInterstitial
(
activity
:
Activity
)
{
fun
loadInterstitial
(
activity
:
Activity
,
isMain
:
Boolean
)
{
if
(
AppConfig
.
groMoreVideoAdCount
>
0
)
{
preLoadGroMore
(
activity
)
preLoadGroMore
(
activity
,
isMain
)
}
else
{
preLoadYlh
(
activity
)
}
}
private
fun
preLoadGroMore
(
activity
:
Activity
)
{
private
fun
preLoadGroMore
(
activity
:
Activity
,
isMain
:
Boolean
)
{
currentInterstitialType
=
Constant
.
GROMORE_INSERTSCREEN_AD
if
(
interstitialGroManager
!=
null
)
{
interstitialGroManager
?.
onDestroy
()
}
interstitialGroManager
=
InterstitialGroManager
()
interstitialGroManager
?.
loadInsertScreenAd
(
activity
)
interstitialGroManager
?.
loadInsertScreenAd
(
activity
,
isMain
)
interstitialGroManager
?.
setWifiAdStatusListener
(
object
:
WifiAdStatusListener
{
WifiAdStatusListener
{
override
fun
adSuccess
()
{
wifiAdStatusListener
?.
adSuccess
()
}
...
...
@@ -52,7 +52,7 @@ class InsertScreenAdManager {
}
override
fun
adClose
()
{
}
})
}
...
...
@@ -66,7 +66,7 @@ class InsertScreenAdManager {
interstitialYlhManager
=
InterstitialYlhManager
()
interstitialYlhManager
?.
loadYlhInteractionAd
(
activity
)
interstitialYlhManager
?.
setWifiAdStatusListener
(
object
:
WifiAdStatusListener
{
WifiAdStatusListener
{
override
fun
adSuccess
()
{
wifiAdStatusListener
?.
adSuccess
()
}
...
...
@@ -76,7 +76,7 @@ class InsertScreenAdManager {
}
override
fun
adClose
()
{
}
})
}
...
...
app/src/main/java/com/mints/flowbox/ad/inscreen/InterstitialGroManager.java
View file @
030e7d21
...
...
@@ -34,10 +34,13 @@ public class InterstitialGroManager {
private
Activity
activity
;
private
boolean
isLoadSuccess
=
false
;
public
void
loadInsertScreenAd
(
Activity
activity
)
{
private
boolean
isMain
=
false
;
public
void
loadInsertScreenAd
(
Activity
activity
,
boolean
isMain
)
{
// 加载到广告且未展示 则返回
if
(
isLoadSuccess
)
return
;
this
.
isMain
=
isMain
;
this
.
activity
=
activity
;
if
(
TTMediationAdSdk
.
configLoadSuccess
())
{
...
...
@@ -73,7 +76,11 @@ public class InterstitialGroManager {
* 注:每次加载插屏广告的时候需要新建一个TTInterstitialAd,否则可能会出现广告填充问题
* ( 例如:mInterstitialAd = new TTInterstitialAd(this, adUnitId);)
*/
mInterstitialAd
=
new
TTInterstitialAd
(
activity
,
CsjGroMoreManager
.
INSTANCE
.
getAD_UNIT_INTERSTITIAL_ID
());
if
(
isMain
)
{
mInterstitialAd
=
new
TTInterstitialAd
(
activity
,
CsjGroMoreManager
.
INSTANCE
.
getAPP_IN_MAIN_AD_UNIT_INTERSTITIAL_ID
());
}
else
{
mInterstitialAd
=
new
TTInterstitialAd
(
activity
,
CsjGroMoreManager
.
INSTANCE
.
getAPP_IN_COMMON_AD_UNIT_INTERSTITIAL_ID
());
}
//模板1.0
TTVideoOption
videoOption
=
VideoOptionUtil
.
getTTVideoOption
();
...
...
@@ -118,7 +125,11 @@ public class InterstitialGroManager {
vo
.
put
(
"ecpm"
,
mInterstitialAd
.
getPreEcpm
());
vo
.
put
(
"adSource"
,
mInterstitialAd
.
getAdNetworkPlatformId
());
vo
.
put
(
"adType"
,
Constant
.
GRO_MORE_ADTYPE3
);
vo
.
put
(
"adid"
,
CsjGroMoreManager
.
INSTANCE
.
getAD_UNIT_INTERSTITIAL_ID
());
if
(
isMain
)
{
vo
.
put
(
"adid"
,
CsjGroMoreManager
.
INSTANCE
.
getAPP_IN_MAIN_AD_UNIT_INTERSTITIAL_ID
());
}
else
{
vo
.
put
(
"adid"
,
CsjGroMoreManager
.
INSTANCE
.
getAPP_IN_COMMON_AD_UNIT_INTERSTITIAL_ID
());
}
TrackManager
.
getInstance
().
cmtGroMoreInfo
(
vo
);
}
else
{
// 当加载到广告后 ,长时间未展示失效时 改变状态
...
...
app/src/main/java/com/mints/flowbox/ad/video/CsjGroMoreVideoAdManager.java
View file @
030e7d21
...
...
@@ -68,7 +68,7 @@ public class CsjGroMoreVideoAdManager extends BaseVideoAd {
* 判断当前是否存在config 配置 ,如果存在直接加载广告 ,如果不存在则注册config加载回调
*/
if
(
TTMediationAdSdk
.
configLoadSuccess
())
{
loadAd
(
CsjGroMoreManager
.
INSTANCE
.
getAD_UNIT_VIDEO_ID
(),
TTAdConstant
.
VERTICAL
);
loadAd
(
CsjGroMoreManager
.
INSTANCE
.
getA
PP_IN_MAIN_A
D_UNIT_VIDEO_ID
(),
TTAdConstant
.
VERTICAL
);
}
else
{
TTMediationAdSdk
.
registerConfigCallback
(
mSettingConfigCallback
);
//不用使用内部类,否则在ondestory中无法移除该回调
}
...
...
@@ -80,7 +80,7 @@ public class CsjGroMoreVideoAdManager extends BaseVideoAd {
private
TTSettingConfigCallback
mSettingConfigCallback
=
new
TTSettingConfigCallback
()
{
@Override
public
void
configLoad
()
{
loadAd
(
CsjGroMoreManager
.
INSTANCE
.
getAD_UNIT_VIDEO_ID
(),
TTAdConstant
.
VERTICAL
);
loadAd
(
CsjGroMoreManager
.
INSTANCE
.
getA
PP_IN_MAIN_A
D_UNIT_VIDEO_ID
(),
TTAdConstant
.
VERTICAL
);
}
};
...
...
@@ -245,7 +245,7 @@ public class CsjGroMoreVideoAdManager extends BaseVideoAd {
vo
.
put
(
"adSource"
,
mttRewardAd
.
getAdNetworkPlatformId
());
vo
.
put
(
"adType"
,
Constant
.
GRO_MORE_ADTYPE2
);
vo
.
put
(
"ecpmId"
,
AppConfig
.
gromoreId
);
vo
.
put
(
"adid"
,
CsjGroMoreManager
.
INSTANCE
.
getAD_UNIT_VIDEO_ID
());
vo
.
put
(
"adid"
,
CsjGroMoreManager
.
INSTANCE
.
getA
PP_IN_MAIN_A
D_UNIT_VIDEO_ID
());
TrackManager
.
getInstance
().
cmtGroMoreInfo
(
vo
);
}
...
...
app/src/main/java/com/mints/flowbox/ad/wifi/WifiAdManager.kt
View file @
030e7d21
...
...
@@ -65,7 +65,7 @@ class WifiAdManager {
interstitialGroManager
?.
onDestroy
()
}
interstitialGroManager
=
InterstitialGroManager
()
interstitialGroManager
?.
loadInsertScreenAd
(
activity
)
interstitialGroManager
?.
loadInsertScreenAd
(
activity
,
false
)
}
/**
...
...
@@ -85,7 +85,7 @@ class WifiAdManager {
fun
showInterstitial
()
{
when
(
currentAdType
)
{
Constant
.
GROMORE_INSERTSCREEN_AD
->
{
interstitialGroManager
?.
setWifiAdStatusListener
(
object
:
WifiAdStatusListener
{
interstitialGroManager
?.
setWifiAdStatusListener
(
object
:
WifiAdStatusListener
{
override
fun
adSuccess
()
{
}
...
...
app/src/main/java/com/mints/flowbox/common/AppConfig.java
View file @
030e7d21
...
...
@@ -203,4 +203,9 @@ public class AppConfig {
public
static
boolean
isCanClean
=
true
;
/*是否可以 超强省电 */
public
static
boolean
isCanSaveBattery
=
true
;
// 是否展示第一次新人红包
public
static
boolean
isShowFirstGive
=
false
;
public
static
int
firstGiveCoin
=
1500
;
}
app/src/main/java/com/mints/flowbox/keepalive/AlarmManager.java
View file @
030e7d21
package
com
.
mints
.
flowbox
.
keepalive
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.os.Message
;
import
com.bytedance.msdk.adapter.util.WeakHandler
;
...
...
@@ -10,6 +11,7 @@ import com.mints.flowbox.common.AppConfig;
import
com.mints.flowbox.manager.TrackManager
;
import
com.mints.flowbox.ui.activitys.BoostActivity
;
import
com.mints.flowbox.utils.ForegroundOrBackground
;
import
com.mints.flowbox.utils.IntentUtils
;
/**
* 描述:应用外广告定时器
...
...
@@ -93,11 +95,14 @@ public class AlarmManager implements WeakHandler.IHandler {
}
// 预加载信息流
ExpressManager
.
INSTANCE
.
loadExpress
();
ExpressManager
.
INSTANCE
.
load
AppOut
Express
();
//用户关闭界面后10分钟调用
Intent
intent
=
new
Intent
(
MintsApplication
.
getContext
(),
BoostActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
MintsApplication
.
getContext
().
startActivity
(
intent
);
Bundle
bundle
=
new
Bundle
();
bundle
.
putBoolean
(
BoostActivity
.
IS_FROM_ALARM
,
true
);
intent
.
putExtras
(
bundle
);
IntentUtils
.
startActivity
(
ForegroundOrBackground
.
getMain_activity
(),
intent
);
}
}
...
...
app/src/main/java/com/mints/flowbox/manager/CsjGroMoreManager.kt
View file @
030e7d21
...
...
@@ -11,11 +11,35 @@ import com.mints.flowbox.mvp.model.GroAdcodeBean
*/
object
CsjGroMoreManager
{
var
AD_UNIT_EXPRESS_ID
=
"946265897"
// 信息流
var
AD_UNIT_SPLASH_ID
=
"887497104"
// 开屏
var
AD_UNIT_VIDEO_ID
=
"946265896"
// 激励视频
var
AD_UNIT_INTERSTITIAL_ID
=
"946265898"
// 插屏
var
AD_UNIT_FULL_ID
=
"946333578"
// 全屏
/**
* 老用户代码位-- ↓
* 应用内:
* 普通:
* 新插屏 -> 946333680
* 信息流 -> 946265897
* 网赚:
* 激励视频 -> 946265896
* 信息流 -> 946334121
* 插屏 -> 946334151
* 开屏 -> 887506685
* 应用外:
* 普通:
* 新插屏 -> 946333773
* 信息流 -> 94633992
* 锁屏:
* 信息流 -> 946334023
*/
var
APP_OUT_AD_UNIT_EXPRESS_ID
=
"94633992"
// 应用外普通信息流
var
APP_OUT_AD_UNIT_LOCK_EXPRESS_ID
=
"946334023"
// 应用外锁屏信息流
var
APP_OUT_AD_UNIT_INTERSTITIAL_ID
=
"946333773"
// 应用外插屏
var
APP_IN_COMMON_AD_UNIT_INTERSTITIAL_ID
=
"946333578"
// 应用内 普通 插屏
var
APP_IN_COMMON_AD_UNIT_EXPRESS_ID
=
"946265897"
// 应用内 普通 信息流
var
APP_IN_MAIN_AD_UNIT_VIDEO_ID
=
"946265896"
// 应用内 网赚 激励视频
var
APP_IN_MAIN_AD_UNIT_EXPRESS_ID
=
"946334121"
// 应用内 网赚 信息流
var
APP_IN_MAIN_AD_UNIT_INTERSTITIAL_ID
=
"946334151"
// 应用内 网赚 插屏
var
APP_IN_MAIN_AD_UNIT_SPLASH_ID
=
"887506685"
// 应用内 网赚 开屏
fun
init
(
application
:
MintsApplication
)
{
TTGroMoreAdManagerHolder
.
init
(
application
)
...
...
@@ -27,17 +51,27 @@ object CsjGroMoreManager {
fun
updataIdByChannel
(
idBean
:
GroAdcodeBean
?)
{
// 渠道对象不为空
if
(
idBean
!=
null
)
{
if
(!
TextUtils
.
isEmpty
(
idBean
.
groExpress
))
{
AD_UNIT_EXPRESS_ID
=
idBean
.
groExpress
if
(
idBean
.
gromoreAdcodes_main
!=
null
)
{
// 应用内网赚
APP_IN_MAIN_AD_UNIT_EXPRESS_ID
=
idBean
.
gromoreAdcodes_main
.
groExpress
APP_IN_MAIN_AD_UNIT_VIDEO_ID
=
idBean
.
gromoreAdcodes_main
.
groVideo
APP_IN_MAIN_AD_UNIT_INTERSTITIAL_ID
=
idBean
.
gromoreAdcodes_main
.
groInterstitial
APP_IN_MAIN_AD_UNIT_SPLASH_ID
=
idBean
.
gromoreAdcodes_main
.
groSplash
}
if
(!
TextUtils
.
isEmpty
(
idBean
.
groSplash
))
{
AD_UNIT_SPLASH_ID
=
idBean
.
groSplash
if
(
idBean
.
gromoreAdcodes_ordinary
!=
null
)
{
// 应用内普通
APP_IN_COMMON_AD_UNIT_EXPRESS_ID
=
idBean
.
gromoreAdcodes_ordinary
.
groExpress
APP_IN_COMMON_AD_UNIT_INTERSTITIAL_ID
=
idBean
.
gromoreAdcodes_ordinary
.
groNewInterstitial
}
if
(!
TextUtils
.
isEmpty
(
idBean
.
groVideo
))
{
AD_UNIT_VIDEO_ID
=
idBean
.
groVideo
if
(
idBean
.
gromoreAdcodes_outer_lock
!=
null
)
{
// 应用外锁屏
APP_OUT_AD_UNIT_LOCK_EXPRESS_ID
=
idBean
.
gromoreAdcodes_outer_lock
.
groExpress
}
if
(!
TextUtils
.
isEmpty
(
idBean
.
groInterstitial
))
{
AD_UNIT_INTERSTITIAL_ID
=
idBean
.
groInterstitial
if
(
idBean
.
gromoreAdcodes_outer_ordinary
!=
null
)
{
// 应用外普通
APP_OUT_AD_UNIT_EXPRESS_ID
=
idBean
.
gromoreAdcodes_main
.
groExpress
APP_OUT_AD_UNIT_INTERSTITIAL_ID
=
idBean
.
gromoreAdcodes_outer_ordinary
.
groNewInterstitial
}
}
}
...
...
app/src/main/java/com/mints/flowbox/mvp/model/GroAdcodeBean.java
View file @
030e7d21
...
...
@@ -7,25 +7,155 @@ import java.io.Serializable;
*/
public
class
GroAdcodeBean
implements
Serializable
{
private
String
groExpress
;
private
String
groSplash
;
private
String
groVideo
;
private
String
groInterstitial
;
public
String
getGroExpress
()
{
return
groExpress
;
/**
* groExpress : 946265897
* groNewInterstitial : 946333578
*/
private
GromoreAdcodesOrdinaryDTO
gromoreAdcodes_ordinary
;
/**
* groVideo : 946265896
* groInterstitial : 946334151
* groExpress : 946334121
* groSplash : 887506685
*/
private
GromoreAdcodesMainDTO
gromoreAdcodes_main
;
/**
* groExpress : 946334023
*/
private
GromoreAdcodesOuterLockDTO
gromoreAdcodes_outer_lock
;
/**
* groExpress : 946333992
* groNewInterstitial : 946333773
*/
private
GromoreAdcodesOuterOrdinaryDTO
gromoreAdcodes_outer_ordinary
;
public
GromoreAdcodesOrdinaryDTO
getGromoreAdcodes_ordinary
()
{
return
gromoreAdcodes_ordinary
;
}
public
void
setGromoreAdcodes_ordinary
(
GromoreAdcodesOrdinaryDTO
gromoreAdcodes_ordinary
)
{
this
.
gromoreAdcodes_ordinary
=
gromoreAdcodes_ordinary
;
}
public
GromoreAdcodesMainDTO
getGromoreAdcodes_main
()
{
return
gromoreAdcodes_main
;
}
public
void
setGromoreAdcodes_main
(
GromoreAdcodesMainDTO
gromoreAdcodes_main
)
{
this
.
gromoreAdcodes_main
=
gromoreAdcodes_main
;
}
public
GromoreAdcodesOuterLockDTO
getGromoreAdcodes_outer_lock
()
{
return
gromoreAdcodes_outer_lock
;
}
public
void
setGromoreAdcodes_outer_lock
(
GromoreAdcodesOuterLockDTO
gromoreAdcodes_outer_lock
)
{
this
.
gromoreAdcodes_outer_lock
=
gromoreAdcodes_outer_lock
;
}
public
GromoreAdcodesOuterOrdinaryDTO
getGromoreAdcodes_outer_ordinary
()
{
return
gromoreAdcodes_outer_ordinary
;
}
public
void
setGromoreAdcodes_outer_ordinary
(
GromoreAdcodesOuterOrdinaryDTO
gromoreAdcodes_outer_ordinary
)
{
this
.
gromoreAdcodes_outer_ordinary
=
gromoreAdcodes_outer_ordinary
;
}
public
String
getGroSplash
()
{
return
groSplash
;
public
static
class
GromoreAdcodesOrdinaryDTO
{
private
String
groExpress
;
private
String
groNewInterstitial
;
public
String
getGroExpress
()
{
return
groExpress
;
}
public
void
setGroExpress
(
String
groExpress
)
{
this
.
groExpress
=
groExpress
;
}
public
String
getGroNewInterstitial
()
{
return
groNewInterstitial
;
}
public
void
setGroNewInterstitial
(
String
groNewInterstitial
)
{
this
.
groNewInterstitial
=
groNewInterstitial
;
}
}
public
String
getGroVideo
()
{
return
groVideo
;
public
static
class
GromoreAdcodesMainDTO
{
private
String
groVideo
;
private
String
groInterstitial
;
private
String
groExpress
;
private
String
groSplash
;
public
String
getGroVideo
()
{
return
groVideo
;
}
public
void
setGroVideo
(
String
groVideo
)
{
this
.
groVideo
=
groVideo
;
}
public
String
getGroInterstitial
()
{
return
groInterstitial
;
}
public
void
setGroInterstitial
(
String
groInterstitial
)
{
this
.
groInterstitial
=
groInterstitial
;
}
public
String
getGroExpress
()
{
return
groExpress
;
}
public
void
setGroExpress
(
String
groExpress
)
{
this
.
groExpress
=
groExpress
;
}
public
String
getGroSplash
()
{
return
groSplash
;
}
public
void
setGroSplash
(
String
groSplash
)
{
this
.
groSplash
=
groSplash
;
}
}
public
String
getGroInterstitial
()
{
return
groInterstitial
;
public
static
class
GromoreAdcodesOuterLockDTO
{
private
String
groExpress
;
public
String
getGroExpress
()
{
return
groExpress
;
}
public
void
setGroExpress
(
String
groExpress
)
{
this
.
groExpress
=
groExpress
;
}
}
public
static
class
GromoreAdcodesOuterOrdinaryDTO
{
private
String
groExpress
;
private
String
groNewInterstitial
;
public
String
getGroExpress
()
{
return
groExpress
;
}
public
void
setGroExpress
(
String
groExpress
)
{
this
.
groExpress
=
groExpress
;
}
public
String
getGroNewInterstitial
()
{
return
groNewInterstitial
;
}
public
void
setGroNewInterstitial
(
String
groNewInterstitial
)
{
this
.
groNewInterstitial
=
groNewInterstitial
;
}
}
}
app/src/main/java/com/mints/flowbox/ui/activitys/ApkActivity.kt
View file @
030e7d21
...
...
@@ -83,7 +83,7 @@ class ApkActivity : BaseActivity() {
// 一键清理
val
bundle
=
Bundle
()
bundle
.
putInt
(
Constant
.
SCAN_TYPE
,
5
)
readyGo
(
CleanActivity
::
class
.
java
,
bundle
)
readyGo
ThenKill
(
CleanActivity
::
class
.
java
,
bundle
)
}
}
...
...
app/src/main/java/com/mints/flowbox/ui/activitys/AwardActivity.kt
View file @
030e7d21
...
...
@@ -12,7 +12,7 @@ import android.view.View
import
androidx.core.content.ContextCompat
import
com.bumptech.glide.Glide
import
com.mints.flowbox.R
import
com.mints.flowbox.ad.express.
PreLoad
ExpressManager
import
com.mints.flowbox.ad.express.ExpressManager
import
com.mints.flowbox.ad.video.VideoAdingManager
import
com.mints.flowbox.common.AppConfig
import
com.mints.flowbox.common.Constant
...
...
@@ -465,15 +465,9 @@ class AwardActivity : BaseActivity(), AwardView, View.OnClickListener {
AppConfig
.
gromoreId
=
""
try
{
PreLoadExpressManager
.
loadADFrameLayout
()
}
catch
(
e
:
java
.
lang
.
Exception
)
{
e
.
printStackTrace
()
}
ExpressManager
.
loadExpress
(
true
)
SoundPoolUtil
.
getInstance
().
onDestory
()
PreLoadExpressManager
.
onDestroy
()
flAwardAd
?.
removeAllViews
()
videoAdingManager
.
setVideoAdingListener
(
null
)
videoAdingManager
.
onDestroy
()
...
...
@@ -748,7 +742,7 @@ class AwardActivity : BaseActivity(), AwardView, View.OnClickListener {
try
{
if
(
flAwardAd
!=
null
)
{
flAwardAd
.
removeAllViews
()
flAwardAd
.
addView
(
PreLoadExpressManager
.
getAD
FrameLayout
())
flAwardAd
.
addView
(
ExpressManager
.
getExpress
FrameLayout
())
if
(
AppConfig
.
isPreExpressAwardActivity
)
{
flAwardAd
.
post
{
...
...
@@ -768,7 +762,7 @@ class AwardActivity : BaseActivity(), AwardView, View.OnClickListener {
if
(
flAwardAd
.
height
>
0
&&
flAwardAd
.
width
>
0
)
{
ivRootAwardAd
.
visibility
=
View
.
VISIBLE
if
(!
AwardActivity
@
this
.
isFinishing
)
{
if
(!
this
.
isFinishing
)
{
Glide
.
with
(
applicationContext
).
asGif
()
.
load
(
R
.
drawable
.
bg_award_effect
).
into
(
ivRootAwardAd
)
}
...
...
app/src/main/java/com/mints/flowbox/ui/activitys/BoostActivity.kt
View file @
030e7d21
package
com.mints.flowbox.ui.activitys
import
android.app.ActivityManager
import
android.app.KeyguardManager
import
android.content.Context
import
android.os.Build
import
android.os.Bundle
import
android.os.Handler
import
android.os.Looper
import
android.view.View
import
android.view.WindowManager
import
com.mints.flowbox.R
import
com.mints.flowbox.ad.express.ExpressManager
import
com.mints.flowbox.keepalive.AlarmManager
...
...
@@ -21,8 +18,22 @@ import kotlinx.android.synthetic.main.activity_boost.*
*/
class
BoostActivity
:
BaseActivity
()
{
companion
object
{
// 是否是定时器逻辑
const
val
IS_FROM_ALARM
=
"IS_FROM_ALARM"
}
private
var
mActivityManager
:
ActivityManager
?
=
null
private
var
mIsFromAlarm
=
false
override
fun
getBundleExtras
(
extras
:
Bundle
?)
{
super
.
getBundleExtras
(
extras
)
extras
?.
let
{
mIsFromAlarm
=
it
.
getBoolean
(
IS_FROM_ALARM
,
false
)
}
}
override
fun
getContentViewLayoutID
()
=
R
.
layout
.
activity_boost
override
fun
initViewsAndEvents
()
{
...
...
@@ -31,23 +42,20 @@ class BoostActivity : BaseActivity() {
finish
()
overridePendingTransition
(
0
,
0
)
}
}
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
window
.
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_SHOW_WHEN_LOCKED
or
WindowManager
.
LayoutParams
.
FLAG_DISMISS_KEYGUARD
or
WindowManager
.
LayoutParams
.
FLAG_KEEP_SCREEN_ON
or
WindowManager
.
LayoutParams
.
FLAG_TURN_SCREEN_ON
)
super
.
onCreate
(
savedInstanceState
)
Handler
(
Looper
.
getMainLooper
()).
postDelayed
({
finish
()
overridePendingTransition
(
0
,
0
)
},
5000
)
}
override
fun
isApplyKitKatTranslucency
()
=
true
override
fun
finish
()
{
super
.
finish
()
AlarmManager
.
getInstance
().
resetUserActionTime
()
if
(
mIsFromAlarm
)
{
AlarmManager
.
getInstance
().
resetUserActionTime
()
}
}
override
fun
onResume
()
{
...
...
@@ -70,14 +78,9 @@ class BoostActivity : BaseActivity() {
}
}
override
fun
onDestroy
()
{
// 预加载信息流
ExpressManager
.
loadExpress
()
super
.
onDestroy
()
}
private
fun
cleanMemory
()
{
ExpressManager
.
loadAppOutExpress
()
ccav_speed
.
startAnimation
()
Handler
(
Looper
.
getMainLooper
()).
postDelayed
(
{
...
...
app/src/main/java/com/mints/flowbox/ui/activitys/CleanActivity.kt
View file @
030e7d21
...
...
@@ -43,6 +43,11 @@ class CleanActivity : BaseActivity(), View.OnClickListener {
* Step5: 扫描安装包
*/
companion
object
{
// 定时器间隔时间
const
val
STEP_Interval
=
2000L
}
private
val
typeArr
=
arrayOf
(
"运行程序"
,
"系统缓存"
,
"临时文件"
,
"广告垃圾"
,
"安装包"
)
// 扫描类型
...
...
@@ -163,7 +168,7 @@ class CleanActivity : BaseActivity(), View.OnClickListener {
tvClean
.
text
=
SpanUtils
()
.
append
(
"检测到您的后台软件共运行\n
\n
"
)
.
append
(
"检测到您的后台软件共运行\n"
)
.
append
(
""
+
mCleanList
[
0
].
childList
.
size
)
.
setForegroundColor
(
ContextCompat
.
getColor
(
...
...
@@ -187,7 +192,7 @@ class CleanActivity : BaseActivity(), View.OnClickListener {
}).
execute
()
}
}
},
1000
,
(
1000
*
2
).
toLong
()
)
},
200
,
STEP_Interval
)
}
/** 开始清理 */
...
...
@@ -270,14 +275,14 @@ class CleanActivity : BaseActivity(), View.OnClickListener {
// }
}
}
},
1000
,
1000
.
toLong
()
)
},
200
,
STEP_Interval
)
}
private
fun
toResult
()
{
AppConfig
.
isCanClean
=
false
// 预加载信息流
ExpressManager
.
loadExpress
()
ExpressManager
.
loadExpress
(
false
)
val
bundle
=
Bundle
()
bundle
.
putString
(
...
...
@@ -380,13 +385,13 @@ class CleanActivity : BaseActivity(), View.OnClickListener {
iv_left_icon
.
setOnClickListener
(
this
)
btnClean
.
setOnClickListener
(
this
)
if
(
scanMax
==
1
)
{
ivClean
.
visibility
=
View
.
GONE
tvClean
.
visibility
=
View
.
VISIBLE
}
else
{
ivClean
.
visibility
=
View
.
VISIBLE
tvClean
.
visibility
=
View
.
GONE
}
//
if (scanMax == 1) {
//
ivClean.visibility = View.GONE
//
tvClean.visibility = View.VISIBLE
//
} else {
//
ivClean.visibility = View.VISIBLE
//
tvClean.visibility = View.GONE
//
}
}
private
fun
remove
(
groupPosition
:
Int
,
removeIndex
:
Int
,
removeChildInfo
:
ChildInfo
?)
{
...
...
app/src/main/java/com/mints/flowbox/ui/activitys/FoodSubsidyActivity.kt
View file @
030e7d21
...
...
@@ -89,7 +89,7 @@ class FoodSubsidyActivity : BaseActivity(), View.OnClickListener, FoodSubsidyVie
}
// 预加载信息流
ExpressManager
.
loadExpress
()
ExpressManager
.
loadExpress
(
true
)
}
...
...
app/src/main/java/com/mints/flowbox/ui/activitys/Increasespeed2Activity.kt
View file @
030e7d21
...
...
@@ -41,12 +41,15 @@ class Increasespeed2Activity : BaseActivity(), View.OnClickListener {
const
val
INCREASE2_TYPE
=
"INCREASE_TYPE"
// TYPE
const
val
INCREASE2_WIFI_BOOST
=
"WIFI_BOOST"
// wifi加速
const
val
INCREASE2_SAFE_CHECK
=
"SAFE_CHECK"
// 安全检测
// 定时器间隔时间
const
val
STEP_Interval
=
300L
}
private
val
mStringArr1
=
mutableListOf
(
"检测结果WiFi加密安全性"
,
"检查ARP网络攻击异常"
,
"提升DNS劫持安全性"
,
"提升DNS劫持安
STEP_Interval
全性"
,
"部署网页防篡改"
,
"加固链路,避免SSL中间人攻击"
,
"检测是否钓鱼WiFi"
...
...
@@ -100,10 +103,10 @@ class Increasespeed2Activity : BaseActivity(), View.OnClickListener {
containerAnim
.
setBackgroundColor
(
ContextCompat
.
getColor
(
this
,
R
.
color
.
color_main
))
GlideUtils
.
loadImageViewGif
(
this
,
R
.
drawable
.
wifi_speed
,
iv_gif
)
}
else
{
NumAnimUtil
.
startAnim
(
tv_progress
,
100f
)
containerAnim
.
setBackgroundColor
(
Color
.
parseColor
(
"#8278DC"
))
GlideUtils
.
loadImageViewGif
(
this
,
R
.
drawable
.
safe_check
,
iv_gif
)
mTimerMax
=
10
NumAnimUtil
.
startAnim
(
tv_progress
,
100f
,
((
mTimerMax
-
4
)
*
STEP_Interval
))
}
mTimer
=
Timer
()
...
...
@@ -134,7 +137,7 @@ class Increasespeed2Activity : BaseActivity(), View.OnClickListener {
}
}
}
},
100
,
300
)
},
200
,
STEP_Interval
)
}
private
fun
initView
()
{
...
...
@@ -211,8 +214,6 @@ class Increasespeed2Activity : BaseActivity(), View.OnClickListener {
mWifiAdManager
=
null
fl_ad
?.
removeAllViews
()
// 预加载信息流
ExpressManager
.
loadExpress
()
super
.
onDestroy
()
}
...
...
app/src/main/java/com/mints/flowbox/ui/activitys/IncreasespeedActivity.kt
View file @
030e7d21
...
...
@@ -5,20 +5,24 @@ import android.os.Bundle
import
android.os.Handler
import
android.os.Looper
import
android.text.Spannable
import
android.text.TextUtils
import
android.view.View
import
android.view.WindowManager
import
androidx.core.content.ContextCompat
import
com.daimajia.androidanimations.library.Techniques
import
com.daimajia.androidanimations.library.YoYo
import
com.mints.flowbox.MintsApplication
import
com.mints.flowbox.R
import
com.mints.flowbox.ad.express.ExpressManager
import
com.mints.flowbox.ad.wifi.WifiAdManager
import
com.mints.flowbox.ad.wifi.WifiAdStatusListener
import
com.mints.flowbox.common.AppConfig
import
com.mints.flowbox.common.Constant
import
com.mints.flowbox.manager.AppPreferencesManager
import
com.mints.flowbox.ui.activitys.base.BaseActivity
import
com.mints.flowbox.ui.widgets.seekbar.BubbleUtils
import
com.mints.flowbox.utils.SpanUtils
import
com.mints.library.utils.CommonUtils
import
com.mints.library.utils.GlideUtils
import
kotlinx.android.synthetic.main.activity_increasespeed.*
import
kotlinx.android.synthetic.main.activity_increasespeed.container
...
...
@@ -42,6 +46,9 @@ class IncreasespeedActivity : BaseActivity(), View.OnClickListener {
const
val
INCREASE_BOOST
=
"BOOST"
// 一键加速
const
val
INCREASE_CLEAN
=
"CLEAN"
// 一键清理
const
val
INCREASE_SAVE_ELECTRICITY
=
"SAVE_ELECTRICITY"
// 超强省电
// 定时器间隔时间
const
val
STEP_Interval
=
300L
}
private
var
mWifiAdManager
:
WifiAdManager
?
=
null
...
...
@@ -88,44 +95,80 @@ class IncreasespeedActivity : BaseActivity(), View.OnClickListener {
}
})
//
if (mIncreaseType == INCREASE_BOOST && AppConfig.isCanBoost) {
if
(
mIncreaseType
==
INCREASE_BOOST
)
{
if
(
mIncreaseType
==
INCREASE_BOOST
&&
AppConfig
.
isCanBoost
)
{
//
if (mIncreaseType == INCREASE_BOOST) {
startTimer
()
//
} else if (mIncreaseType == INCREASE_SAVE_ELECTRICITY && AppConfig.isCanSaveBattery) {
}
else
if
(
mIncreaseType
==
INCREASE_SAVE_ELECTRICITY
)
{
}
else
if
(
mIncreaseType
==
INCREASE_SAVE_ELECTRICITY
&&
AppConfig
.
isCanSaveBattery
)
{
//
} else if (mIncreaseType == INCREASE_SAVE_ELECTRICITY) {
startTimer
()
mTimerMax
=
11
//
} else if (mIncreaseType == INCREASE_CLEAN && AppConfig.isCanClean) {
}
else
if
(
mIncreaseType
==
INCREASE_CLEAN
)
{
}
else
if
(
mIncreaseType
==
INCREASE_CLEAN
&&
AppConfig
.
isCanClean
)
{
//
} else if (mIncreaseType == INCREASE_CLEAN) {
startTimer
()
mTimerMax
=
14
}
else
{
Handler
(
Looper
.
getMainLooper
()).
postDelayed
({
// 动画结束后 展示插屏广告
mWifiAdManager
?.
showInterstitial
()
showFirstGive
()
},
3000
)
}
initView
()
}
private
fun
showFirstGive
()
{
// 新人福利
if
(
AppConfig
.
isShowFirstGive
)
{
// 游客首次提示1500新人奖励 且 不是分享包
val
channel
=
CommonUtils
.
getAppMetaData
(
MintsApplication
.
getContext
(),
"CHANNEL_NAME"
)
if
(!
TextUtils
.
equals
(
channel
,
Constant
.
CHANNEL_SHARE
)
&&
AppPreferencesManager
.
get
().
getBoolean
(
Constant
.
FIRST_VISITOR_FLAG
,
true
)
)
{
AppPreferencesManager
.
get
().
put
(
Constant
.
FIRST_VISITOR_FLAG
,
false
)
val
bundle
=
Bundle
()
bundle
.
putInt
(
Constant
.
MAIN_CUR_COIN
,
AppConfig
.
firstGiveCoin
)
bundle
.
putString
(
Constant
.
MAIN_CARRIER_TYPE
,
Constant
.
CARRIER_NEW_VISITOR
)
readyGo
(
AwardActivity
::
class
.
java
,
bundle
)
}
}
}
private
fun
startTimer
()
{
container
.
visibility
=
View
.
GONE
containerAnim
.
visibility
=
View
.
VISIBLE
var
step
=
0
if
(
mIncreaseType
==
INCREASE_SAVE_ELECTRICITY
)
{
containerAnim
.
setBackgroundColor
(
ContextCompat
.
getColor
(
this
,
R
.
color
.
color_main
))
iv_gif
.
layoutParams
.
width
=
BubbleUtils
.
dp2px
(
200
)
GlideUtils
.
loadImageViewGif
(
this
,
R
.
drawable
.
battery
,
iv_gif
)
}
else
if
(
mIncreaseType
==
INCREASE_CLEAN
)
{
containerAnim
.
setBackgroundColor
(
Color
.
parseColor
(
"#906cf4"
))
GlideUtils
.
loadImageViewGif
(
this
,
R
.
drawable
.
rubbish
,
iv_gif
)
}
else
{
containerAnim
.
setBackgroundColor
(
Color
.
parseColor
(
"#906cf4"
))
GlideUtils
.
loadImageViewGif
(
this
,
R
.
drawable
.
rocket_anim
,
iv_gif
)
tv_progress
.
text
=
"正在检测后台常驻软件..."
when
(
mIncreaseType
)
{
INCREASE_SAVE_ELECTRICITY
->
{
containerAnim
.
setBackgroundColor
(
ContextCompat
.
getColor
(
this
,
R
.
color
.
color_main
))
iv_gif
.
layoutParams
.
width
=
BubbleUtils
.
dp2px
(
200
)
GlideUtils
.
loadImageViewGif
(
this
,
R
.
drawable
.
battery
,
iv_gif
)
}
INCREASE_CLEAN
->
{
containerAnim
.
setBackgroundColor
(
Color
.
parseColor
(
"#906cf4"
))
GlideUtils
.
loadImageViewGif
(
this
,
R
.
drawable
.
rubbish
,
iv_gif
)
}
else
->
{
containerAnim
.
setBackgroundColor
(
Color
.
parseColor
(
"#906cf4"
))
GlideUtils
.
loadImageViewGif
(
this
,
R
.
drawable
.
rocket_anim
,
iv_gif
)
tv_progress
.
text
=
"正在检测后台常驻软件..."
}
}
mTimer
=
Timer
()
...
...
@@ -154,6 +197,7 @@ class IncreasespeedActivity : BaseActivity(), View.OnClickListener {
Handler
(
Looper
.
getMainLooper
()).
postDelayed
({
// 动画结束后 展示插屏广告
mWifiAdManager
?.
showInterstitial
()
showFirstGive
()
},
3000
)
container
.
visibility
=
View
.
VISIBLE
}
else
if
(
step
==
mTimerMax
)
{
...
...
@@ -162,7 +206,7 @@ class IncreasespeedActivity : BaseActivity(), View.OnClickListener {
}
}
}
},
100
,
300
)
},
200
,
STEP_Interval
)
}
private
fun
initView
()
{
...
...
@@ -256,8 +300,6 @@ class IncreasespeedActivity : BaseActivity(), View.OnClickListener {
mWifiAdManager
=
null
fl_ad
?.
removeAllViews
()
// 预加载信息流
ExpressManager
.
loadExpress
()
super
.
onDestroy
()
}
...
...
app/src/main/java/com/mints/flowbox/ui/activitys/MainActivity.kt
View file @
030e7d21
...
...
@@ -28,6 +28,7 @@ import com.mints.flowbox.ui.fragment.*
import
com.mints.flowbox.ui.widgets.dialog.DialogListener
import
com.mints.flowbox.ui.widgets.dialog.PowerDialog
import
com.mints.flowbox.utils.WifiUtils
import
com.mints.library.utils.CommonUtils
import
com.mints.library.utils.GlideUtils
import
kotlinx.android.synthetic.main.activity_main.*
...
...
@@ -365,29 +366,6 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
// 数美初始化
ShumeiManager
.
getInstance
().
initShumei
()
// // 游客首次提示1500新人奖励 且 不是分享包
// val channel = CommonUtils.getAppMetaData(
// MintsApplication.getContext(),
// "CHANNEL_NAME"
// )
// if (!TextUtils.equals(channel, Constant.CHANNEL_SHARE) && AppPreferencesManager.get().getBoolean(
// Constant.FIRST_VISITOR_FLAG,
// true
// )
// ) {
// AppPreferencesManager.get().put(Constant.FIRST_VISITOR_FLAG, false)
// val bundle = Bundle()
// bundle.putInt(
// Constant.MAIN_CUR_COIN,
// if (userMsgBean != null && userMsgBean!!.userMsg.showCoin > 0) userMsgBean?.userMsg?.showCoin!! else 1500
// )
// bundle.putString(
// Constant.MAIN_CARRIER_TYPE,
// Constant.CARRIER_NEW_VISITOR
// )
// readyGo(AwardActivity::class.java, bundle)
// }
}
}
}
...
...
@@ -464,20 +442,17 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
// 是否上报点击广告
AppConfig
.
needReportClickAdEvent
=
data
.
isNeedReportClickAdEvent
// 新人福利
if
(
data
.
userMsg
.
firstGiveCoin
>
0
)
{
AppConfig
.
isShowFirstGive
=
true
AppConfig
.
firstGiveCoin
=
data
.
userMsg
.
firstGiveCoin
}
// 离线收益
if
(
data
.
offlineBean
.
offlineIncome
>
0
)
{
val
bundle
=
Bundle
()
bundle
.
putInt
(
Constant
.
MAIN_CUR_COIN
,
data
.
userMsg
.
firstGiveCoin
)
bundle
.
putString
(
Constant
.
MAIN_CARRIER_TYPE
,
Constant
.
CARRIER_
NEW_USER
)
bundle
.
putInt
(
Constant
.
MAIN_CUR_COIN
,
data
.
offlineBean
.
offlineIncome
)
bundle
.
putString
(
Constant
.
MAIN_CARRIER_TYPE
,
Constant
.
CARRIER_
OFFLINE_DOUBLE
)
readyGo
(
AwardActivity
::
class
.
java
,
bundle
)
}
else
{
// 离线收益
if
(
data
.
offlineBean
.
offlineIncome
>
0
)
{
val
bundle
=
Bundle
()
bundle
.
putInt
(
Constant
.
MAIN_CUR_COIN
,
data
.
offlineBean
.
offlineIncome
)
bundle
.
putString
(
Constant
.
MAIN_CARRIER_TYPE
,
Constant
.
CARRIER_OFFLINE_DOUBLE
)
readyGo
(
AwardActivity
::
class
.
java
,
bundle
)
}
}
}
...
...
app/src/main/java/com/mints/flowbox/ui/activitys/ScreenActivity.kt
View file @
030e7d21
...
...
@@ -40,6 +40,8 @@ class ScreenActivity : BaseSwipeBackCompatActivity(), View.OnClickListener {
}
override
fun
initViewsAndEvents
()
{
ExpressManager
.
loadAppOutExpress
()
Handler
(
Looper
.
getMainLooper
()).
postDelayed
({
mHelper
.
swipeBackLayout
.
setEdgeSize
(
ToolUtil
.
getScreenWidth
(
this
))
mHelper
.
swipeBackLayout
.
setTopEdgeSize
(
...
...
@@ -67,7 +69,7 @@ class ScreenActivity : BaseSwipeBackCompatActivity(), View.OnClickListener {
if
(
AntiShake
.
check
(
v
?.
id
))
return
// 预加载信息流
ExpressManager
.
loadExpress
()
ExpressManager
.
loadExpress
(
false
)
when
(
v
?.
id
)
{
R
.
id
.
tvBoost
->
{
...
...
@@ -111,13 +113,6 @@ class ScreenActivity : BaseSwipeBackCompatActivity(), View.OnClickListener {
}
}
override
fun
onDestroy
()
{
// 预加载信息流
ExpressManager
.
loadExpress
()
super
.
onDestroy
()
}
override
fun
onNetworkConnected
(
type
:
NetUtils
.
NetType
?)
{}
override
fun
onNetworkDisConnected
()
{}
...
...
app/src/main/java/com/mints/flowbox/ui/activitys/SpeedFastActivity.kt
View file @
030e7d21
...
...
@@ -164,7 +164,7 @@ class SpeedFastActivity : BaseActivity(), View.OnClickListener {
fl_ad
?.
removeAllViews
()
// 预加载信息流
ExpressManager
.
loadExpress
()
ExpressManager
.
loadExpress
(
false
)
super
.
onDestroy
()
}
}
app/src/main/java/com/mints/flowbox/ui/activitys/SpeedTestActivity.kt
View file @
030e7d21
...
...
@@ -6,6 +6,8 @@ import android.animation.ObjectAnimator
import
android.annotation.SuppressLint
import
android.app.Dialog
import
android.os.Bundle
import
android.os.Handler
import
android.os.Looper
import
android.view.KeyEvent
import
android.view.View
import
android.view.animation.LinearInterpolator
...
...
@@ -62,7 +64,9 @@ class SpeedTestActivity : BaseActivity(), View.OnClickListener {
if
(
step
==
5
)
{
DownloadApkManager
.
instance
.
destroy
()
endTest
()
Handler
(
Looper
.
getMainLooper
()).
postDelayed
({
endTest
()
},
500
)
}
}
},
0
,
1000
)
...
...
app/src/main/java/com/mints/flowbox/ui/activitys/SplashGroMoreActivity.java
View file @
030e7d21
...
...
@@ -17,7 +17,6 @@ import com.mints.flowbox.MintsApplication;
import
com.mints.flowbox.R
;
import
com.mints.flowbox.common.Constant
;
import
com.mints.flowbox.common.DeviceInfo
;
import
com.mints.flowbox.manager.AppPreferencesManager
;
import
com.mints.flowbox.manager.CsjGroMoreManager
;
import
com.mints.flowbox.manager.TrackManager
;
import
com.mints.flowbox.manager.TtCsjAdManager
;
...
...
@@ -79,7 +78,7 @@ public class SplashGroMoreActivity extends BaseActivity {
* 注:每次加载开屏广告的时候需要新建一个TTSplashAd,否则可能会出现广告填充问题
* ( 例如:mTTSplashAd = new TTSplashAd(this, mAdUnitId);)
*/
mTTSplashAd
=
new
TTSplashAd
(
this
,
CsjGroMoreManager
.
INSTANCE
.
getAD_UNIT_SPLASH_ID
());
mTTSplashAd
=
new
TTSplashAd
(
this
,
CsjGroMoreManager
.
INSTANCE
.
getA
PP_IN_MAIN_A
D_UNIT_SPLASH_ID
());
mTTSplashAd
.
setTTAdSplashListener
(
mSplashAdListener
);
//step3:创建开屏广告请求参数AdSlot,具体参数含义参考文档
...
...
@@ -126,7 +125,7 @@ public class SplashGroMoreActivity extends BaseActivity {
vo
.
put
(
"ecpm"
,
mTTSplashAd
.
getPreEcpm
());
vo
.
put
(
"adSource"
,
mTTSplashAd
.
getAdNetworkPlatformId
());
vo
.
put
(
"adType"
,
Constant
.
GRO_MORE_ADTYPE0
);
vo
.
put
(
"adid"
,
CsjGroMoreManager
.
INSTANCE
.
getAD_UNIT_SPLASH_ID
());
vo
.
put
(
"adid"
,
CsjGroMoreManager
.
INSTANCE
.
getA
PP_IN_MAIN_A
D_UNIT_SPLASH_ID
());
TrackManager
.
getInstance
().
cmtGroMoreInfo
(
vo
);
}
LogUtil
.
d
(
TAG
,
"load splash ad success "
);
...
...
app/src/main/java/com/mints/flowbox/ui/activitys/SplashGroMoreBackgroundActivity.java
View file @
030e7d21
...
...
@@ -69,7 +69,7 @@ public class SplashGroMoreBackgroundActivity extends BaseActivity {
* 注:每次加载开屏广告的时候需要新建一个TTSplashAd,否则可能会出现广告填充问题
* ( 例如:mTTSplashAd = new TTSplashAd(this, mAdUnitId);)
*/
mTTSplashAd
=
new
TTSplashAd
(
this
,
CsjGroMoreManager
.
INSTANCE
.
getAD_UNIT_SPLASH_ID
());
mTTSplashAd
=
new
TTSplashAd
(
this
,
CsjGroMoreManager
.
INSTANCE
.
getA
PP_IN_MAIN_A
D_UNIT_SPLASH_ID
());
mTTSplashAd
.
setTTAdSplashListener
(
mSplashAdListener
);
//step3:创建开屏广告请求参数AdSlot,具体参数含义参考文档
...
...
@@ -91,7 +91,7 @@ public class SplashGroMoreBackgroundActivity extends BaseActivity {
//step4:请求广告,调用开屏广告异步请求接口,对请求回调的广告作渲染处理
mTTSplashAd
.
loadAd
(
adSlot
,
ttNetworkRequestInfo
,
new
TTSplashAdLoadCallback
()
{
// mTTSplashAd.loadAd(adSlot, new TTSplashAdLoadCallback() {
// mTTSplashAd.loadAd(adSlot, new TTSplashAdLoadCallback() {
@Override
public
void
onSplashAdLoadFail
(
AdError
adError
)
{
LogUtil
.
d
(
TAG
,
adError
.
message
);
...
...
@@ -116,7 +116,7 @@ public class SplashGroMoreBackgroundActivity extends BaseActivity {
vo
.
put
(
"ecpm"
,
mTTSplashAd
.
getPreEcpm
());
vo
.
put
(
"adSource"
,
mTTSplashAd
.
getAdNetworkPlatformId
());
vo
.
put
(
"adType"
,
Constant
.
GRO_MORE_ADTYPE0
);
vo
.
put
(
"adid"
,
CsjGroMoreManager
.
INSTANCE
.
getAD_UNIT_SPLASH_ID
());
vo
.
put
(
"adid"
,
CsjGroMoreManager
.
INSTANCE
.
getA
PP_IN_MAIN_A
D_UNIT_SPLASH_ID
());
TrackManager
.
getInstance
().
cmtGroMoreInfo
(
vo
);
}
Log
.
e
(
TAG
,
"load splash ad success "
);
...
...
app/src/main/java/com/mints/flowbox/ui/activitys/WalkActivity.kt
View file @
030e7d21
...
...
@@ -100,7 +100,7 @@ class WalkActivity : BaseActivity(), View.OnClickListener, WalkView, StepView.St
}
// 预加载信息流
ExpressManager
.
loadExpress
()
ExpressManager
.
loadExpress
(
true
)
}
/**
...
...
app/src/main/java/com/mints/flowbox/ui/activitys/WaterActivity.kt
View file @
030e7d21
...
...
@@ -71,7 +71,7 @@ class WaterActivity : BaseActivity(), View.OnClickListener, WaterView.WaterViewL
}
// 预加载信息流
ExpressManager
.
loadExpress
()
ExpressManager
.
loadExpress
(
true
)
}
override
fun
clickForWaterSuc
(
waterCoin
:
Int
)
{
...
...
app/src/main/java/com/mints/flowbox/ui/fragment/BonusFragment.kt
View file @
030e7d21
...
...
@@ -56,7 +56,6 @@ class BonusFragment : BaseFragment(), OnItemChildClickListener, BonusView, View.
private
var
signData
=
mutableListOf
<
SignRedbagsBean
.
RedbagsDTO
>()
private
var
gvSignAdapter
:
GvSignAdapter
?
=
null
private
var
isButtonCanClick
=
false
private
var
todayMoney
=
0
private
var
allMoney
=
0
...
...
@@ -202,7 +201,7 @@ class BonusFragment : BaseFragment(), OnItemChildClickListener, BonusView, View.
}
// 当天是否可签到
isButtonCanClick
=
data
.
isButtonCanClick
btn_sign
.
isEnabled
=
data
.
isButtonCanClick
btn_sign
.
text
=
data
.
buttonText
...
...
app/src/main/java/com/mints/flowbox/ui/fragment/HomeFragment.kt
View file @
030e7d21
...
...
@@ -118,15 +118,22 @@ class HomeFragment : BaseFragment(), WifiStateManager.WifiStateCallback,
super
.
onResume
()
if
(
AppConfig
.
fragmentClickFlag
==
Constant
.
FRAGMENT_CLICK_ONE
)
{
refreshData
()
wifi_view
.
wifiOn
()
if
(
bubbleCount
==
0
)
{
wifi_view
.
wifiOnAndNoBonus
()
}
else
{
wifi_view
.
wifiOn
()
}
tvContent
.
text
=
"每天签到最高可得${AppConfig.HOME_BANNER_SIGN_GIVECASH}元红包"
}
}
override
fun
onPause
()
{
super
.
onPause
()
wifi_view
.
wifiOff
()
if
(
bubbleCount
==
0
)
{
wifi_view
.
wifiOnAndNoBonus
()
}
else
{
wifi_view
.
wifiOff
()
}
}
/** 刷新数据 **/
...
...
@@ -152,12 +159,20 @@ class HomeFragment : BaseFragment(), WifiStateManager.WifiStateCallback,
override
fun
getContentViewLayoutID
()
=
R
.
layout
.
fragment_home
override
fun
onWifiOpen
()
{
wifi_view
.
wifiOn
()
if
(
bubbleCount
==
0
)
{
wifi_view
.
wifiOnAndNoBonus
()
}
else
{
wifi_view
.
wifiOn
()
}
bg_view
.
setBackgroundResource
(
R
.
mipmap
.
bg_home_enable
)
}
override
fun
onWifiClose
()
{
wifi_view
.
wifiOff
()
if
(
bubbleCount
==
0
)
{
wifi_view
.
wifiOnAndNoBonus
()
}
else
{
wifi_view
.
wifiOff
()
}
bg_view
.
setBackgroundResource
(
R
.
mipmap
.
bg_home_unenable
)
}
...
...
@@ -210,7 +225,7 @@ class HomeFragment : BaseFragment(), WifiStateManager.WifiStateCallback,
// wifi提速
R
.
id
.
btn_speed_fast
->
{
// 预加载信息流
ExpressManager
.
loadExpress
()
ExpressManager
.
loadExpress
(
false
)
readyGo
(
SpeedFastActivity
::
class
.
java
)
}
...
...
@@ -311,22 +326,22 @@ class HomeFragment : BaseFragment(), WifiStateManager.WifiStateCallback,
// 自有界面
when
(
hotBean
.
toUrl
)
{
Constant
.
HOT_ACTIVITY_WATER
->
{
ExpressManager
.
loadExpress
()
ExpressManager
.
loadExpress
(
true
)
readyGo
(
WaterActivity
::
class
.
java
)
}
Constant
.
HOT_ACTIVITY_WALK
->
{
ExpressManager
.
loadExpress
()
ExpressManager
.
loadExpress
(
true
)
readyGo
(
WalkActivity
::
class
.
java
)
}
Constant
.
HOT_ACTIVITY_CARD
->
{
readyGo
(
EraseActivity
::
class
.
java
)
}
Constant
.
HOT_ACTIVITY_MORNINGCLOCK
->
{
ExpressManager
.
loadExpress
()
ExpressManager
.
loadExpress
(
true
)
readyGo
(
MorningClockActivity
::
class
.
java
)
}
Constant
.
HOT_ACTIVITY_EAT
->
{
ExpressManager
.
loadExpress
()
ExpressManager
.
loadExpress
(
true
)
readyGo
(
FoodSubsidyActivity
::
class
.
java
)
}
Constant
.
HOT_ACTIVITY_SHARE_NEWS
->
{
...
...
app/src/main/java/com/mints/flowbox/ui/fragment/MyFragment.kt
View file @
030e7d21
...
...
@@ -698,7 +698,6 @@ class MyFragment : BaseFragment(),
}
private
fun
initManager
()
{
BannerManager
.
instance
.
init
()
videoAdingManager
=
VideoAdingManager
.
getInstance
(
activity
)
}
...
...
app/src/main/java/com/mints/flowbox/ui/fragment/TurnTableFragment.kt
View file @
030e7d21
...
...
@@ -119,7 +119,7 @@ class TurnTableFragment : BaseFragment(), TurnTableView, AdapterView.OnItemClick
insertScreenAdManager
=
InsertScreenAdManager
()
insertScreenAdManager
?.
setInsertScreenAdStatusListener
(
object
:
WifiAdStatusListener
{
WifiAdStatusListener
{
override
fun
adSuccess
()
{
try
{
if
(
turnTableData
?.
surplus
!!
<=
0
)
{
...
...
@@ -349,7 +349,7 @@ class TurnTableFragment : BaseFragment(), TurnTableView, AdapterView.OnItemClick
MobclickAgent
.
onEvent
(
activity
!!
,
Constant
.
CARRIER_CHALLENGE_TURN
,
map
)
if
(
insertScreenAdManager
==
null
)
insertScreenAdManager
=
InsertScreenAdManager
()
insertScreenAdManager
?.
loadInterstitial
(
requireActivity
())
insertScreenAdManager
?.
loadInterstitial
(
requireActivity
()
,
true
)
turnTableView
.
startRotate
(
1
)
awardVedio
()
...
...
app/src/main/java/com/mints/flowbox/ui/fragment/WifiFragment.kt
View file @
030e7d21
...
...
@@ -5,6 +5,7 @@ import android.annotation.SuppressLint
import
android.app.Dialog
import
android.content.Intent
import
android.content.pm.PackageManager
import
android.net.wifi.WifiInfo
import
android.os.Build
import
android.os.Bundle
import
android.os.Handler
...
...
@@ -41,6 +42,7 @@ import com.mints.library.utils.nodoubleclick.AntiShake
import
com.tbruyelle.rxpermissions.RxPermissions
import
kotlinx.android.synthetic.main.fragment_wifi.*
import
rx.Observable
import
java.util.*
import
kotlin.random.Random
private
val
TAG
=
WifiFragment
::
class
.
java
.
simpleName
...
...
@@ -77,7 +79,11 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
override
fun
onResume
()
{
super
.
onResume
()
if
(
AppConfig
.
fragmentClickFlag
==
Constant
.
FRAGMENT_CLICK_THREE
)
{
loadWifiData
()
if
(
PermissionUtils
.
isOpenGps
(
requireContext
()))
{
loadWifiData
()
}
else
{
openGpsSettings
()
}
// 防止banner刷新太快
if
(
AntiShake
.
check
(
fl_wifi_banner
?.
id
))
return
...
...
@@ -92,12 +98,14 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
}
override
fun
initViewsAndEvents
()
{
BannerManager
.
instance
.
init
()
initRecy
()
initView
()
initListener
()
}
/** 重置wifi数据 */
@SuppressLint
(
"SetTextI18n"
)
private
fun
loadWifiData
()
{
btn_signal
.
postDelayed
({
...
...
@@ -144,30 +152,7 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
imageView2
.
setImageResource
(
R
.
mipmap
.
ic_main_wifi_none
)
}
val
ssid
=
connectionWifiInfo
.
ssid
.
replace
(
"\""
,
""
)
for
(
scanResult
in
wifiUtils
.
wifiList
)
{
if
(
TextUtils
.
isEmpty
(
scanResult
.
SSID
))
continue
if
(
TextUtils
.
equals
(
scanResult
.
SSID
,
ssid
))
{
mWifiList
.
add
(
WifiListBean
(
scanResult
.
SSID
,
wifiUtils
.
getWifiRssiStr
(
scanResult
.
level
),
wifiUtils
.
getCipherType
(
scanResult
),
true
)
)
}
else
{
mWifiList
.
add
(
WifiListBean
(
scanResult
.
SSID
,
wifiUtils
.
getWifiRssiStr
(
scanResult
.
level
),
wifiUtils
.
getCipherType
(
scanResult
),
false
)
)
}
}
mMainWifiAdapter
?.
notifyDataSetChanged
()
generateWifiListData
(
connectionWifiInfo
)
}
else
{
tv_wifi_ssid
.
text
=
"WIFI未开启"
tv_wifi_info
.
text
=
"请先开启无线网络"
...
...
@@ -176,6 +161,58 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
}
}
/** 生成wifi列表数据 */
private
fun
generateWifiListData
(
connectionWifiInfo
:
WifiInfo
)
{
val
ssid
=
connectionWifiInfo
.
ssid
.
replace
(
"\""
,
""
)
for
(
scanResult
in
wifiUtils
.
wifiList
)
{
if
(
TextUtils
.
isEmpty
(
scanResult
.
SSID
))
continue
if
(
TextUtils
.
equals
(
scanResult
.
SSID
,
ssid
))
{
mWifiList
.
add
(
WifiListBean
(
scanResult
.
SSID
,
wifiUtils
.
getWifiRssiStr
(
scanResult
.
level
),
wifiUtils
.
getCipherType
(
scanResult
),
true
)
)
}
else
{
mWifiList
.
add
(
WifiListBean
(
scanResult
.
SSID
,
wifiUtils
.
getWifiRssiStr
(
scanResult
.
level
),
wifiUtils
.
getCipherType
(
scanResult
),
false
)
)
}
}
var
isHasConnectWifi
=
false
var
connectIndex
=
0
for
(
i
in
0
until
mWifiList
.
size
)
{
if
(
mWifiList
[
i
].
wifiName
.
equals
(
ssid
))
{
isHasConnectWifi
=
true
connectIndex
=
i
}
}
if
(!
isHasConnectWifi
)
{
// 插入数组头
mWifiList
.
add
(
0
,
WifiListBean
(
ssid
,
wifiUtils
.
getWifiRssiStr
(
connectionWifiInfo
.
rssi
),
"unknown"
,
true
)
)
}
else
{
// 互换位置
Collections
.
swap
(
mWifiList
,
0
,
connectIndex
)
}
mMainWifiAdapter
?.
notifyDataSetChanged
()
}
/** 更新UI页面数据 */
private
fun
updateUiState
()
{
val
usedPercentValue
=
SystemUtils
.
getUsedPercentValue
(
mContext
)
...
...
@@ -246,7 +283,6 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
.
setFontSize
(
BubbleUtils
.
sp2px
(
10
))
.
create
()
}
}
override
fun
onPause
()
{
...
...
@@ -290,7 +326,7 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
}
// 预加载信息流
ExpressManager
.
loadExpress
()
ExpressManager
.
loadExpress
(
false
)
val
bundle
=
Bundle
()
bundle
.
putString
(
...
...
@@ -306,7 +342,7 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
}
// 预加载信息流
ExpressManager
.
loadExpress
()
ExpressManager
.
loadExpress
(
false
)
if
(
wifiUtils
.
isWifiConnected
(
mContext
))
{
readyGo
(
SpeedTestActivity
::
class
.
java
)
...
...
@@ -329,7 +365,7 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
}
R
.
id
.
tv_memory_clean
->
{
// 一键加速
// 预加载信息流
ExpressManager
.
loadExpress
()
ExpressManager
.
loadExpress
(
false
)
val
bundle
=
Bundle
()
bundle
.
putString
(
...
...
@@ -340,7 +376,7 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
}
R
.
id
.
tv_clean
->
{
// 一键清理
// 预加载信息流
ExpressManager
.
loadExpress
()
ExpressManager
.
loadExpress
(
false
)
val
bundle
=
Bundle
()
bundle
.
putString
(
...
...
@@ -351,7 +387,7 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
}
R
.
id
.
tv_save_battery
->
{
// 超强省电
// 预加载信息流
ExpressManager
.
loadExpress
()
ExpressManager
.
loadExpress
(
false
)
val
bundle
=
Bundle
()
bundle
.
putString
(
...
...
@@ -361,14 +397,21 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
readyGo
(
IncreasespeedActivity
::
class
.
java
,
bundle
)
}
R
.
id
.
btn_signal
->
{
// 信号增强
if
(
ActivityCompat
.
checkSelf
Permission
(
requireContext
()
,
if
(
PermissionUtils
.
check
Permission
(
mContext
,
Manifest
.
permission
.
ACCESS_COARSE_LOCATION
)
!=
PackageManager
.
PERMISSION_GRANTED
)
)
{
checkPermission
()
return
}
// 未打开定位开关
if
(!
PermissionUtils
.
isOpenGps
(
mContext
))
{
openGpsSettings
()
return
}
if
(!
wifiUtils
.
isWifiConnected
(
mContext
)
||
!
wifiUtils
.
isWifiEnable
)
{
wifiUtils
.
openWifi
()
startActivity
(
Intent
(
Settings
.
ACTION_WIFI_SETTINGS
))
...
...
@@ -376,7 +419,7 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
}
// 预加载信息流
ExpressManager
.
loadExpress
()
ExpressManager
.
loadExpress
(
false
)
readyGo
(
SpeedFastActivity
::
class
.
java
)
}
R
.
id
.
ivImg
->
{
// 点我赚钱
...
...
@@ -387,12 +430,14 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
}
}
/** 滚动到底部 */
private
fun
scrollToBottom
()
{
Handler
(
Looper
.
getMainLooper
()).
postDelayed
({
container
.
scrollTo
(
0
,
container
.
height
)
},
100
)
}
/** 检测权限 */
private
fun
checkPermission
()
{
val
request
:
Observable
<
Boolean
>
=
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
Q
)
{
...
...
@@ -411,7 +456,7 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
loadWifiData
()
// 预加载信息流
ExpressManager
.
loadExpress
()
ExpressManager
.
loadExpress
(
false
)
val
bundle
=
Bundle
()
bundle
.
putString
(
...
...
@@ -425,7 +470,27 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
showMissingPermissionDialog
(
"位置"
)
}
}
}
/** 打开GPS定位信息 */
private
fun
openGpsSettings
()
{
DialogUtils
.
showDialog
(
requireActivity
(),
"为了保护您的WIFI安全\n请打开系统定位权限"
,
"提示"
,
"去设置"
,
object
:
DialogListener
()
{
override
fun
onClick
(
dialog
:
Dialog
?,
v
:
View
?)
{
IntentUtils
.
openGPSSettings
(
mContext
)
dialog
?.
dismiss
()
}
},
"取消"
,
object
:
DialogListener
()
{
override
fun
onClick
(
dialog
:
Dialog
?,
v
:
View
?)
{
dialog
?.
dismiss
()
}
}
)
}
override
fun
onItemClick
(
view
:
View
?,
position
:
Int
)
{
...
...
@@ -436,6 +501,8 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
return
}
if
(
mWifiList
[
position
].
isConnected
)
return
val
wifiListBean
=
mWifiList
[
position
]
if
(
wifiDialog
==
null
)
wifiDialog
=
WifiConnectDialog
(
mContext
,
object
:
DialogListener
()
{
...
...
@@ -460,6 +527,7 @@ class WifiFragment : BaseFragment(), View.OnClickListener, OnItemClickListener,
}
}
/** wifi开启 */
override
fun
onWifiOpen
()
{
loadWifiData
()
}
...
...
app/src/main/java/com/mints/flowbox/ui/widgets/CircleCleanAnimationView.kt
View file @
030e7d21
...
...
@@ -33,8 +33,8 @@ class CircleCleanAnimationView @JvmOverloads constructor(
private
var
im_out
:
ImageView
?
=
null
//中心图片控件
private
var
rotateAnimation
:
RotateAnimation
?
=
null
//旋转动画
private
var
scaleAnimation
:
ScaleAnimation
?
=
null
//放大缩小动画
private
val
imageCenterWidth
=
4
00
//中心图片的宽度
private
val
imageCenterHeight
=
4
00
//中心图片的高度
private
val
imageCenterWidth
=
3
00
//中心图片的宽度
private
val
imageCenterHeight
=
3
00
//中心图片的高度
private
val
LineStrokeWidth
=
8
//线框的宽度
private
fun
init
(
...
...
app/src/main/java/com/mints/flowbox/ui/widgets/CycleProgress.java
View file @
030e7d21
...
...
@@ -112,6 +112,11 @@ public class CycleProgress extends View {
mProgressPaint
.
setXfermode
(
null
);
}
public
void
setComplete
()
{
mProgressWidth
=
mViewWidth
;
invalidate
();
}
/**
* 0--1
*/
...
...
app/src/main/java/com/mints/flowbox/ui/widgets/WifiView.java
View file @
030e7d21
...
...
@@ -144,6 +144,18 @@ public class WifiView extends FrameLayout implements View.OnClickListener {
tvPlaceholder
.
setVisibility
(
View
.
INVISIBLE
);
}
public
void
wifiOnAndNoBonus
()
{
progressBar
.
setVisibility
(
View
.
VISIBLE
);
tvTitle
.
setVisibility
(
View
.
VISIBLE
);
tvInfo
.
setVisibility
(
View
.
VISIBLE
);
tvPlaceholder
.
setVisibility
(
View
.
INVISIBLE
);
setTitle
(
"WIFI已连接"
);
tvInfo
.
setText
(
"今日流量补贴金额已达到上限"
);
progressBar
.
setComplete
();
}
public
void
wifiOff
()
{
progressBar
.
pauseAnim
();
setTitle
(
"WIFI已关闭"
);
...
...
app/src/main/java/com/mints/flowbox/utils/IntentUtils.java
View file @
030e7d21
...
...
@@ -8,6 +8,7 @@ import android.content.Intent;
import
android.database.Cursor
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.provider.Settings
;
import
android.util.Log
;
import
com.mints.flowbox.MintsApplication
;
...
...
@@ -70,12 +71,12 @@ public class IntentUtils {
}
/**
* 判断vivo后台弹出界面
1未开启 0
开启
* 判断vivo后台弹出界面
false未开启 true
开启
*
* @param context
* @return
*/
public
static
int
getvivoBgStartActivityPermissionStatus
(
Context
context
)
{
public
static
boolean
getvivoBgStartActivityPermissionStatus
(
Context
context
)
{
String
packageName
=
context
.
getPackageName
();
Uri
uri2
=
Uri
.
parse
(
"content://com.vivo.permissionmanager.provider.permission/start_bg_activity"
);
String
selection
=
"pkgname = ?"
;
...
...
@@ -88,16 +89,16 @@ public class IntentUtils {
if
(
cursor
.
moveToFirst
())
{
int
currentmode
=
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"currentstate"
));
cursor
.
close
();
return
currentmode
;
return
currentmode
==
0
;
}
else
{
cursor
.
close
();
return
1
;
return
false
;
}
}
}
catch
(
Throwable
throwable
)
{
throwable
.
printStackTrace
();
}
return
1
;
return
false
;
}
/**
...
...
@@ -132,13 +133,17 @@ public class IntentUtils {
}
public
static
void
startActivity
(
Activity
activity
,
Intent
intent
)
{
if
(!
isRunningForeground
(
activity
))
{
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
Q
)
{
moveToFront
(
activity
);
MintsApplication
.
getContext
().
startActivity
(
intent
);
activity
.
moveTaskToBack
(
true
);
if
(
isAllowedBackPopPermission
(
activity
)
|
getvivoBgStartActivityPermissionStatus
(
activity
))
{
if
(!
isRunningForeground
(
activity
))
{
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
Q
)
{
moveToFront
(
activity
);
MintsApplication
.
getContext
().
startActivity
(
intent
);
activity
.
moveTaskToBack
(
true
);
}
else
{
NotificationUtils
.
INSTANCE
.
sendNotificationFullScreen
(
activity
,
""
,
""
,
intent
);
}
}
else
{
NotificationUtils
.
INSTANCE
.
sendNotificationFullScreen
(
activity
,
""
,
""
,
intent
);
MintsApplication
.
getContext
().
startActivity
(
intent
);
}
}
else
{
MintsApplication
.
getContext
().
startActivity
(
intent
);
...
...
@@ -170,4 +175,12 @@ public class IntentUtils {
}
}
/**
* 跳转GPS设置
*/
public
static
void
openGPSSettings
(
Context
context
)
{
Intent
intent
=
new
Intent
(
Settings
.
ACTION_LOCATION_SOURCE_SETTINGS
);
context
.
startActivity
(
intent
);
}
}
app/src/main/java/com/mints/flowbox/utils/PermissionUtils.java
View file @
030e7d21
...
...
@@ -5,6 +5,7 @@ import android.content.Context;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.location.LocationManager
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.provider.Settings
;
...
...
@@ -165,7 +166,7 @@ public class PermissionUtils {
try
{
Class
localClass
=
Class
.
forName
(
"android.content.Context"
);
Method
localMethod
=
localClass
.
getMethod
(
"checkSelfPermission"
,
String
.
class
);
int
i
=
(
Integer
)
localMethod
.
invoke
(
paramContext
,
paramString
);
int
i
=
(
Integer
)
localMethod
.
invoke
(
paramContext
,
paramString
);
bool
=
i
==
0
;
}
catch
(
Throwable
var6
)
{
bool
=
false
;
...
...
@@ -180,4 +181,22 @@ public class PermissionUtils {
return
bool
;
}
}
/**
* 判断是否打开网络定位
*
* @param context 用于获取LocationManager
* @return true/false
*/
public
static
boolean
isOpenGps
(
Context
context
)
{
LocationManager
locationManager
=
(
LocationManager
)
context
.
getSystemService
(
Context
.
LOCATION_SERVICE
);
if
(
locationManager
!=
null
)
{
//这里只判断了是否开启网络定位
//还有GPS定位 LocationManager.GPS_PROVIDER
return
locationManager
.
isProviderEnabled
(
LocationManager
.
NETWORK_PROVIDER
);
}
else
{
return
false
;
}
}
}
app/src/main/java/com/mints/flowbox/utils/WifiUtils.java
View file @
030e7d21
...
...
@@ -2,6 +2,7 @@ package com.mints.flowbox.utils;
import
android.app.Activity
;
import
android.content.Context
;
import
android.location.LocationManager
;
import
android.net.ConnectivityManager
;
import
android.net.NetworkInfo
;
import
android.net.wifi.ScanResult
;
...
...
@@ -51,6 +52,10 @@ public class WifiUtils {
private
WifiManager
wifiManager
;
public
void
startScan
()
{
wifiManager
.
startScan
();
}
/**
* wifi是否打开
*
...
...
@@ -282,4 +287,20 @@ public class WifiUtils {
}
return
"UNKNOWN"
;
}
public
String
getCipherTypeByCapa
(
String
capabilities
)
{
if
(!
TextUtils
.
isEmpty
(
capabilities
))
{
if
(
capabilities
.
contains
(
"WPA"
)
||
capabilities
.
contains
(
"wpa"
))
{
if
(
capabilities
.
contains
(
"WPA2"
)
||
capabilities
.
contains
(
"wpa2"
))
{
return
"WPA2 PSK"
;
}
return
"WPA PSK"
;
}
else
if
(
capabilities
.
contains
(
"WEP"
)
||
capabilities
.
contains
(
"wep"
))
{
return
"WEP"
;
}
else
{
return
"UNKNOWN"
;
}
}
return
"UNKNOWN"
;
}
}
\ No newline at end of file
app/src/main/res/drawable/bg_gray_circle.xml
View file @
030e7d21
...
...
@@ -2,6 +2,7 @@
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<gradient
android:angle=
"270"
android:endColor=
"#C9C3FF"
android:startColor=
"#AFA6FF"
/>
...
...
app/src/main/res/layout/activity_award.xml
View file @
030e7d21
...
...
@@ -67,10 +67,10 @@
android:background=
"@drawable/shape_btn_gold_left"
android:drawablePadding=
"4dp"
android:gravity=
"center"
android:paddingLeft=
"1
0
dp"
android:paddingTop=
"
10
dp"
android:paddingRight=
"1
0
dp"
android:paddingBottom=
"
10
dp"
android:paddingLeft=
"1
2
dp"
android:paddingTop=
"
8
dp"
android:paddingRight=
"1
2
dp"
android:paddingBottom=
"
8
dp"
android:text=
"领取金币"
android:textColor=
"@color/white"
android:textSize=
"14sp"
...
...
@@ -103,6 +103,7 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"4dp"
android:textSize=
"12sp"
android:visibility=
"gone"
app:layout_constraintBottom_toBottomOf=
"parent"
...
...
@@ -115,6 +116,7 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"4dp"
android:textSize=
"12sp"
android:visibility=
"gone"
app:layout_constraintBottom_toBottomOf=
"parent"
...
...
@@ -177,8 +179,8 @@
android:id=
"@+id/flAwardAd"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:
background=
"@drawable/shape_bg_award_gray_bottom
"
android:
layout_gravity=
"center
"
/>
android:
layout_gravity=
"center
"
android:
background=
"@drawable/shape_bg_award_gray_bottom
"
/>
<ImageView
android:id=
"@+id/ivRootAwardAd"
...
...
@@ -186,7 +188,7 @@
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:scaleType=
"fitXY"
android:visibility=
"gone"
></ImageView
>
android:visibility=
"gone"
/
>
</FrameLayout>
</LinearLayout>
\ No newline at end of file
app/src/main/res/layout/activity_clean.xml
View file @
030e7d21
...
...
@@ -15,22 +15,23 @@
<ImageView
android:id=
"@+id/ivClean"
android:layout_width=
"
wrap_content
"
android:layout_height=
"
wrap_content
"
android:layout_width=
"
100dp
"
android:layout_height=
"
100dp
"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"30dp"
android:src=
"@mipmap/ic_clean"
/>
android:layout_marginTop=
"10dp"
android:src=
"@mipmap/ic_clean"
android:visibility=
"visible"
/>
<TextView
android:id=
"@+id/tvClean"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"
5
0dp"
android:layout_marginTop=
"
12
0dp"
android:gravity=
"center"
android:text=
"正在扫描您的手机..."
android:textColor=
"@color/white"
android:visibility=
"
gon
e"
/>
android:visibility=
"
visibl
e"
/>
<ExpandableListView
android:id=
"@+id/elv_clean"
...
...
app/src/main/res/layout/activity_increasespeed.xml
View file @
030e7d21
...
...
@@ -4,50 +4,50 @@
android:layout_height=
"match_parent"
android:background=
"@color/white"
>
<View
android:layout_width=
"match_parent"
android:layout_height=
"320dp"
android:background=
"@drawable/shape_bg_speed"
/>
<LinearLayout
<RelativeLayout
android:id=
"@+id/containerAnim"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
android:visibility=
"gone"
>
<ImageView
android:id=
"@+id/iv_gif"
android:layout_width=
"250dp"
android:layout_height=
"wrap_content"
android:layout_centerInParent=
"true"
/>
<TextView
android:id=
"@+id/tv_progress"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentBottom=
"true"
android:layout_centerHorizontal=
"true"
android:layout_marginBottom=
"80dp"
android:textColor=
"@color/white"
/>
</RelativeLayout>
<androidx.core.widget.NestedScrollView
android:id=
"@+id/container"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<RelativeLayout
android:id=
"@+id/containerAnim"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:visibility=
"gone"
>
<ImageView
android:id=
"@+id/iv_gif"
android:layout_width=
"250dp"
android:layout_height=
"wrap_content"
android:layout_centerInParent=
"true"
/>
<TextView
android:id=
"@+id/tv_progress"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentBottom=
"true"
android:layout_centerHorizontal=
"true"
android:layout_marginBottom=
"80dp"
android:textColor=
"@color/white"
/>
</RelativeLayout>
<androidx.core.widget.NestedScrollView
android:id=
"@+id/container"
<FrameLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<View
android:layout_width=
"match_parent"
android:layout_height=
"320dp"
android:background=
"@drawable/shape_bg_speed"
/>
<LinearLayout
android:id=
"@+id/llMyRoot"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<include
layout=
"@layout/header_layout"
/>
<RelativeLayout
...
...
@@ -98,8 +98,8 @@
</LinearLayout>
</
androidx.core.widget.NestedScrollView
>
</
FrameLayout
>
</
LinearLayout
>
</
androidx.core.widget.NestedScrollView
>
</FrameLayout>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment