Commit f4929c61 authored by jyx's avatar jyx

添加GroMore信息流及AppLog

parent 65372e0a
......@@ -6,6 +6,7 @@ apply plugin: 'dagger.hilt.android.plugin'
apply plugin: 'androidx.navigation.safeargs.kotlin'
apply plugin: 'android-aspectjx'
apply plugin: 'com.sensorsdata.analytics.android'
apply plugin: 'com.bytedance.std.tracker'
android {
compileSdkVersion rootProject.ext.androidCompileSdkVersion
......@@ -38,7 +39,8 @@ android {
UMENG_KEY : RELEASE_UMENG_KEY,
SHARE_KEY : RELEASE_SHARESDK_KEY,
SHARE_SECRET : RELEASE_SHARESDK_SECRET,
APPLICATION_ID : applicationId]
APPLICATION_ID : applicationId,
APPLOG_SCHEME : "rangersapplog.98d71e505549780b".toLowerCase()]
}
......@@ -371,4 +373,6 @@ dependencies {
// 快手
implementation(name: 'kssdk-ad-3.3.9', ext: 'aar')
// implementation(name: 'kssdk-all--3.3.16-publishRelease-9ffe2b94e', ext: 'aar')
// applog
implementation 'com.bytedance.applog:RangersAppLog-All-cn:5.2.6'
}
......@@ -141,6 +141,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.activitys.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
......@@ -251,10 +252,13 @@
<activity
android:name=".call.detail.DetailApplyActivity"
android:screenOrientation="portrait" />
<activity android:name=".ui.activitys.XiaomanActivity"
android:screenOrientation="portrait"/>
<activity android:name=".ui.activitys.ShaiziActivity"
android:screenOrientation="portrait"/>
<activity
android:name=".ui.activitys.XiaomanActivity"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activitys.ShaiziActivity"
android:screenOrientation="portrait" />
<service
android:name=".service.UpdateService"
android:exported="true" />
......
......@@ -12,6 +12,7 @@ import androidx.multidex.MultiDexApplication;
import com.hjq.toast.ToastUtils;
import com.mints.goodmoney.common.Constant;
import com.mints.goodmoney.manager.CsjAppLogManager;
import com.mints.goodmoney.manager.CsjGroMoreManager;
import com.mints.goodmoney.manager.KsManager;
import com.mints.goodmoney.manager.LiebaoManager;
......@@ -129,7 +130,10 @@ public class MintsApplication extends MultiDexApplication {
TtCsjAdManager.init(this);
// GroMore
CsjGroMoreManager.INSTANCE.init();
CsjGroMoreManager.INSTANCE.init(this);
// AppLog
CsjAppLogManager.INSTANCE.init(this);
// 快手
KsManager.INSTANCE.initKs(this);
......
package com.mints.goodmoney.ad.express
import android.text.TextUtils
import android.view.Gravity
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.*
import com.bumptech.glide.Glide
import com.bytedance.msdk.api.*
import com.bytedance.msdk.api.nativeAd.*
import com.mints.goodmoney.MintsApplication
import com.mints.goodmoney.R
import com.mints.goodmoney.manager.CsjGroMoreManager
import com.mints.goodmoney.ui.widgets.seekbar.BubbleUtils
import com.mints.goodmoney.utils.LogUtil
import com.mints.goodmoney.utils.ToastUtil
import com.mints.goodmoney.utils.UIUtils
import com.mints.goodmoney.utils.VideoOptionUtil
import java.util.*
import android.view.View
private val TAG = GroMoreExpressManager::class.java.simpleName
class GroMoreExpressManager : TTSettingConfigCallback {
companion object {
val instance: GroMoreExpressManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
GroMoreExpressManager()
}
}
private var mADLoadSuccessListener: GMADLoadSuccessListener? = null
fun setListener(adLoadSuccessListener: GMADLoadSuccessListener?) {
mADLoadSuccessListener = adLoadSuccessListener
}
@Volatile
private var sAdFrameLayout: FrameLayout = FrameLayout(MintsApplication.getContext())
private var mTTAdNative: TTUnifiedNativeAd? = null
private var mAdStyle = 0
private var mExpressType = 0
init {
mAdStyle = AdSlot.TYPE_EXPRESS_AD
}
fun loadADFrameLayout() {
// 销毁及移除事件
destroy()
sAdFrameLayout.removeAllViews()
if (TTMediationAdSdk.configLoadSuccess()) {
loadAd()
} else {
TTMediationAdSdk.registerConfigCallback(this)
}
}
private fun loadAd() {
mTTAdNative = TTUnifiedNativeAd(MintsApplication.getContext(), CsjGroMoreManager.AD_UNIT_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(UIUtils.getScreenWidthDp(MintsApplication.getContext()).toInt(), 320) // 必选参数 单位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)
}
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) {
mADLoadSuccessListener?.onGMAdLoadSuc(ads[0])
// sAdFrameLayout.addView(createAdView(ads[0]))
}
}
})
}
fun getADFrameLayout(): FrameLayout? {
return sAdFrameLayout
}
/**
* config成功,加载信息流
*/
override fun configLoad() {
loadAd()
}
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 -> {
ToastUtil.show(MintsApplication.getContext(), "图片展示样式错误")
return null
}
}
}
/**
* 销毁
*/
private fun destroy() {
TTMediationAdSdk.unregisterConfigCallback(this)
}
//渲染模板广告
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) {
// 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
}
/**
* @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() {
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")
}
})
//绑定广告数据、设置交互回调
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
ToastUtil.show(MintsApplication.getContext(), "交互类型异常")
}
}
}
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")
ToastUtil.show(MintsApplication.getContext(), "自渲染广告被点击")
}
override fun onAdShow() {
LogUtil.d(TAG, "onAdShow")
ToastUtil.show(MintsApplication.getContext(), "广告展示")
}
}
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ package com.mints.goodmoney.ad.express
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import com.bytedance.msdk.api.nativeAd.TTNativeAd
import com.mints.goodmoney.MintsApplication
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.mvp.model.WeightBean
......@@ -14,7 +15,7 @@ import java.util.*
/**
* 预加载信息流管理类
*/
object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener, KSADLoadSuccessListener {
object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener, KSADLoadSuccessListener, GMADLoadSuccessListener {
private val TAG = PreLoadExpressManager::class.java.simpleName
......@@ -28,18 +29,21 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
private var csjWeight = 0
private var ylhWeight = 0
private var ksWeight = 0
private var gmWeight = 0
init {
mAdFrameLayout = FrameLayout(MintsApplication.getContext())
YlhPreLoadExpressManager.setListener(this)
TTPreLoadExpressManager.getInstance().setListener(this)
KsPreLoadExpressManager.setListener(this)
GroMoreExpressManager.instance.setListener(this)
}
fun init(csjWeight: Int, ylhWeight: Int, ksWeight: Int) {
fun init(csjWeight: Int, ylhWeight: Int, ksWeight: Int, gmWeight: Int) {
this.csjWeight = csjWeight
this.ylhWeight = ylhWeight
this.ksWeight = ksWeight
this.gmWeight = gmWeight
}
fun loadADFrameLayout() {
......@@ -61,6 +65,7 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
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()
else -> {
TTPreLoadExpressManager.getInstance().loadTtFrameLayout(mAdFrameLayout)
}
......@@ -76,19 +81,24 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
// 若没有视频完成数,不加入权重计算范围内
if (csjWeight > 0) {
weightList.add(WeightBean(csjWeight, Constant.CSJ_EXPRESS_AD))
weight = weight + csjWeight
weight += csjWeight
LogUtil.d(TAG, "EXPRESS权重值:csjWeight:$csjWeight")
}
if (ylhWeight > 0) {
weightList.add(WeightBean(ylhWeight, Constant.YLH_EXPRESS_AD))
weight = weight + ylhWeight
weight += ylhWeight
LogUtil.d(TAG, "EXPRESS权重值:ylhWeight:$ylhWeight")
}
if (ksWeight > 0) {
weightList.add(WeightBean(ksWeight, Constant.KS_EXPRESS_AD))
weight = weight + ksWeight
weight += ksWeight
LogUtil.d(TAG, "EXPRESS权重值:ksWeight:$ksWeight")
}
if (gmWeight > 0) {
weightList.add(WeightBean(gmWeight, Constant.GM_EXPRESS_AD))
weight += gmWeight
LogUtil.d(TAG, "EXPRESS权重值:gmWeight:$gmWeight")
}
// 权重随机
if (weightList.size > 0 && weight > 0) {
......@@ -142,6 +152,13 @@ object PreLoadExpressManager : TTADLoadSuccessListener, YLHADLoadSuccessListener
mAdFrameLayout?.addView(view)
}
override fun onGMAdLoadSuc(ttNativeAd: TTNativeAd?) {
// if (currentIndex == 3) {
// mAdFrameLayout?.addView(view)
// }
mAdFrameLayout?.addView(ttNativeAd?.expressView)
}
}
interface TTADLoadSuccessListener {
......@@ -154,4 +171,8 @@ interface YLHADLoadSuccessListener {
interface KSADLoadSuccessListener {
fun onKSAdLoadSuc(ksNativeAd: View?)
}
interface GMADLoadSuccessListener {
fun onGMAdLoadSuc(ttNativeAd: TTNativeAd?)
}
\ No newline at end of file
......@@ -188,6 +188,7 @@ object Constant {
const val CSJ_EXPRESS_AD = "CSJ_EXPRESS_AD"
const val YLH_EXPRESS_AD = "YLH_EXPRESS_AD"
const val KS_EXPRESS_AD = "KS_EXPRESS_AD"
const val GM_EXPRESS_AD = "GM_EXPRESS_AD"
// 游戏类型
const val EVENT_TYPE_CLICK = "CLICK"
......
package com.mints.goodmoney.manager
import android.app.Application
import com.bytedance.applog.AppLog
import com.bytedance.applog.InitConfig
import com.bytedance.applog.util.UriConstants
import com.mints.goodmoney.utils.LogUtil
private val TAG = CsjAppLogManager::class.java.simpleName
object CsjAppLogManager {
fun init(application: Application) {
/* 初始化开始 */
val config = InitConfig("your_appid", "your_channel") // appid和渠道,appid如不清楚请联系对接同学
//上报域名只支持中国
config.setUriConfig(UriConstants.DEFAULT)
// 是否在控制台输出日志,可用于观察用户行为日志上报情况
config.setLogger { msg, t -> LogUtil.d(TAG, "$msg -> $t") }
config.setAutoStart(true)
AppLog.init(application, config)
/* 初始化结束 */
/* 自定义 “用户公共属性”(可选,初始化后调用, key相同会覆盖)
关于自定义 “用户公共属性” 请注意:1. 上报机制是随着每一次日志发送进行提交,默认的日志发送频率是1分钟,所以如果在一分钟内连续修改自定义用户公共属性,,按照日志发送前的最后一次修改为准, 2. 不推荐高频次修改,如每秒修改一次 */
//Map<String,Object> headerMap = new HashMap<String, Object>();
//headerMap.put("your_custom_key","your_custom_value");
//AppLog.setHeaderInfo((HashMap<String, Object>)headerMap);
//移除公共属性
//AppLog.removeHeaderInfo("your_custom_key");
}
}
\ No newline at end of file
......@@ -5,8 +5,10 @@ import com.mints.goodmoney.MintsApplication
object CsjGroMoreManager {
fun init(){
TTGroMoreAdManagerHolder.init(MintsApplication.getContext())
const val AD_UNIT_ID = "946167770"
fun init(application: MintsApplication) {
TTGroMoreAdManagerHolder.init(application)
}
}
\ No newline at end of file
......@@ -10,6 +10,7 @@ public class FlowAdRulesBean implements Serializable {
private int YLH;
private int KS;
private int CSJ;
private int GROMORE;
public int getYLH() {
return YLH;
......@@ -22,4 +23,8 @@ public class FlowAdRulesBean implements Serializable {
public int getCSJ() {
return CSJ;
}
public int getGROMORE() {
return GROMORE;
}
}
......@@ -11,6 +11,7 @@ import android.view.KeyEvent
import android.view.View
import androidx.core.content.ContextCompat
import com.mints.goodmoney.R
import com.mints.goodmoney.ad.express.GroMoreExpressManager
import com.mints.goodmoney.ad.express.PreLoadExpressManager
import com.mints.goodmoney.ad.video.VideoAdingManager
import com.mints.goodmoney.common.AppConfig
......@@ -391,6 +392,7 @@ class AwardActivity : BaseActivity(), AwardView, View.OnClickListener {
try {
PreLoadExpressManager.loadADFrameLayout()
// GroMoreExpressManager.instance.loadADFrameLayout()
} catch (e: java.lang.Exception) {
e.printStackTrace()
}
......
......@@ -3,6 +3,7 @@ package com.mints.goodmoney.ui.activitys
import android.os.Bundle
import android.view.View
import com.mints.goodmoney.R
import com.mints.goodmoney.ad.express.GroMoreExpressManager
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.ad.express.TTPreLoadCarrierExpressManager
import com.mints.goodmoney.manager.TtCsjAdManager
......@@ -50,6 +51,9 @@ class FoodSubsidyActivity : BaseActivity(), View.OnClickListener, FoodSubsidyVie
svWalk?.destoryAnim()
flSubsidykAd?.removeAllViews()
GroMoreExpressManager.instance.loadADFrameLayout()
foodSubsidyPresenter.detachView()
}
......@@ -100,7 +104,8 @@ class FoodSubsidyActivity : BaseActivity(), View.OnClickListener, FoodSubsidyVie
if (TTPreLoadCarrierExpressManager.getInstance().ttFrameLayout != null) {
if (flSubsidykAd != null) {
flSubsidykAd.removeAllViews()
flSubsidykAd.addView(TTPreLoadCarrierExpressManager.getInstance().ttFrameLayout)
// flSubsidykAd.addView(TTPreLoadCarrierExpressManager.getInstance().ttFrameLayout)
flSubsidykAd.addView(GroMoreExpressManager.instance.getADFrameLayout())
}
}
} catch (e: Exception) {
......
......@@ -5,6 +5,7 @@ import android.view.View
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.GridLayoutManager
import com.mints.goodmoney.R
import com.mints.goodmoney.ad.express.GroMoreExpressManager
import com.mints.goodmoney.ad.video.VideoAdingManager
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.ad.express.TTPreLoadCarrierExpressManager
......@@ -53,6 +54,9 @@ class MorningClockActivity : BaseActivity(), View.OnClickListener, MorningClockV
override fun onDestroy() {
super.onDestroy()
GroMoreExpressManager.instance.loadADFrameLayout()
flMorningClockAd?.removeAllViews()
morningClockPresenter.detachView()
}
......@@ -182,11 +186,10 @@ class MorningClockActivity : BaseActivity(), View.OnClickListener, MorningClockV
*/
private fun initExpress() {
try {
if (TTPreLoadCarrierExpressManager.getInstance().ttFrameLayout != null) {
if (flMorningClockAd != null) {
flMorningClockAd.removeAllViews()
flMorningClockAd.addView(TTPreLoadCarrierExpressManager.getInstance().ttFrameLayout)
}
if (flMorningClockAd != null) {
flMorningClockAd.removeAllViews()
// flMorningClockAd.addView(TTPreLoadCarrierExpressManager.getInstance().ttFrameLayout)
flMorningClockAd.addView(GroMoreExpressManager.instance.getADFrameLayout())
}
} catch (e: Exception) {
e.printStackTrace()
......
......@@ -3,6 +3,7 @@ package com.mints.goodmoney.ui.activitys
import android.os.Bundle
import android.view.View
import com.mints.goodmoney.R
import com.mints.goodmoney.ad.express.GroMoreExpressManager
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.ad.express.TTPreLoadCarrierExpressManager
import com.mints.goodmoney.manager.TtCsjAdManager
......@@ -44,6 +45,8 @@ class WalkActivity : BaseActivity(), View.OnClickListener, WalkView, StepView.St
override fun onDestroy() {
super.onDestroy()
GroMoreExpressManager.instance.loadADFrameLayout()
svWalk?.destoryAnim()
flWalkAd?.removeAllViews()
walkPresenter.detachView()
......@@ -110,7 +113,8 @@ class WalkActivity : BaseActivity(), View.OnClickListener, WalkView, StepView.St
if (TTPreLoadCarrierExpressManager.getInstance().ttFrameLayout != null) {
if (flWalkAd != null) {
flWalkAd.removeAllViews()
flWalkAd.addView(TTPreLoadCarrierExpressManager.getInstance().ttFrameLayout)
// flWalkAd.addView(TTPreLoadCarrierExpressManager.getInstance().ttFrameLayout)
flWalkAd.addView(GroMoreExpressManager.instance.getADFrameLayout())
}
}
} catch (e: Exception) {
......
......@@ -3,6 +3,7 @@ package com.mints.goodmoney.ui.activitys
import android.os.Bundle
import android.view.View
import com.mints.goodmoney.R
import com.mints.goodmoney.ad.express.GroMoreExpressManager
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.ad.express.TTPreLoadCarrierExpressManager
import com.mints.goodmoney.manager.TtCsjAdManager
......@@ -47,6 +48,8 @@ class WaterActivity : BaseActivity(), View.OnClickListener, WaterView.WaterViewL
override fun onDestroy() {
super.onDestroy()
GroMoreExpressManager.instance.loadADFrameLayout()
// 取消水滴动画
wvWater?.destoryAnim()
wvWater?.closeWaterViewTime()
......@@ -111,11 +114,10 @@ class WaterActivity : BaseActivity(), View.OnClickListener, WaterView.WaterViewL
*/
private fun initExpress() {
try {
if (TTPreLoadCarrierExpressManager.getInstance().ttFrameLayout != null) {
if (flWaterAd != null) {
flWaterAd.removeAllViews()
flWaterAd.addView(TTPreLoadCarrierExpressManager.getInstance().ttFrameLayout)
}
if (flWaterAd != null) {
flWaterAd.removeAllViews()
// flWaterAd.addView(TTPreLoadCarrierExpressManager.getInstance().ttFrameLayout)
flWaterAd.addView(GroMoreExpressManager.instance.getADFrameLayout())
}
} catch (e: Exception) {
e.printStackTrace()
......
......@@ -16,6 +16,7 @@ import com.daimajia.androidanimations.library.YoYo
import com.daimajia.androidanimations.library.YoYo.YoYoString
import com.mints.goodmoney.MintsApplication
import com.mints.goodmoney.R
import com.mints.goodmoney.ad.express.GroMoreExpressManager
import com.mints.goodmoney.ad.express.PreLoadExpressManager
import com.mints.goodmoney.ad.express.TTPreLoadExpressXmlyManager
import com.mints.goodmoney.ad.video.VideoAdingManager
......@@ -64,7 +65,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
private var bindWxDialog: BindWxDialog? = null
private var userMsgBean: UserTaskMsgBean? = null
private lateinit var baseResponse: BaseResponse<UserTaskMsgBean>
// private lateinit var baseResponse: BaseResponse<UserTaskMsgBean>
// 视频相关
private var rewardDoubleCoin = 0 // 大金币
......@@ -98,6 +99,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
videoAdingManager = VideoAdingManager.getInstance(activity)
// 奖励页预加载 信息流广告
PreLoadExpressManager.loadADFrameLayout()
// GroMoreExpressManager.instance.loadADFrameLayout()
// 刷新喜马拉雅信息流
TTPreLoadExpressXmlyManager.getInstance().loadTtFrameLayout()
......@@ -647,7 +649,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
}
private fun initExpress(flowAdRules: FlowAdRulesBean) {
PreLoadExpressManager.init(flowAdRules.csj, flowAdRules.ylh, flowAdRules.ks)
PreLoadExpressManager.init(flowAdRules.csj, flowAdRules.ylh, flowAdRules.ks, flowAdRules.gromore)
}
/**
......
......@@ -381,7 +381,7 @@ class MyFragment : BaseFragment(),
* 跳转到微信搜索页面
*/
private fun getWechatApi() {
LogUtil.d("getWeChatApi","点击事件响应了。。。。。。。。。。。。。。。。。。。")
LogUtil.d("getWeChatApi", "点击事件响应了。。。。。。。。。。。。。。。。。。。")
try {
val intent = Intent(Intent.ACTION_MAIN)
val cmp = ComponentName("com.tencent.mm", "com.tencent.mm.ui.LauncherUI")
......@@ -1330,7 +1330,7 @@ class MyFragment : BaseFragment(),
}
private fun initExpress(flowAdRules: FlowAdRulesBean) {
PreLoadExpressManager.init(flowAdRules.csj, flowAdRules.ylh, flowAdRules.ks)
PreLoadExpressManager.init(flowAdRules.csj, flowAdRules.ylh, flowAdRules.ks, flowAdRules.gromore)
}
/**
......
package com.mints.goodmoney.utils;
import com.bytedance.msdk.api.BaiduExtraOptions;
import com.bytedance.msdk.api.GDTExtraOption;
import com.bytedance.msdk.api.TTVideoOption;
public class VideoOptionUtil {
public static TTVideoOption getTTVideoOption() {
//广点通(GDT)单独使用配置
GDTExtraOption gdtExtraOption = new GDTExtraOption.Builder()
.setGDTAutoPlayMuted(true)//自动播放是否静音,默认true
.setGDTDetailPageMuted(false)//详情页是否静音,默认值为false,即有声播放;
.setGDTEnableDetailPage(true)//是否能跳转详情页,默认true
.setGDTEnableUserControl(false)//是否能控制是否暂停与播放,默认false
.setGDTMaxVideoDuration(0)//视频最大长度,单位:秒 此设置会影响广告填充,请谨慎设置
.setGDTMinVideoDuration(0)//视频最小长度,单位:秒 此设置会影响广告填充,请谨慎设置
// VideoOption.AutoPlayPolicy.WIFI表示只在WiFi下自动播放;
// VideoOption.AutoPlayPolicy.ALWAYS表示始终自动播放,不区分当前网络;
// VideoOption.AutoPlayPolicy.NEVER表示始终都不自动播放,不区分当前网络,但在WiFi时会预下载视频资源;
// 默认为始终自动播放;模板渲染视频、插屏2.0视频、自渲染2.0视频都可使用
.setAutoPlayPolicy(GDTExtraOption.AutoPlayPolicy.WIFI)//自动播放策略--
.setDownAPPConfirmPolicy(GDTExtraOption.DownAPPConfirmPolicy.TYPE_DEFAULT)//指定点击 APP 广告后是否展示二次确认,可选项包括 Default(wifi 不展示,非wifi 展示),NoConfirm(所有情况不展示)
.setBrowserType(GDTExtraOption.BrowserType.TYPE_DEFAULT)//指定普链广告点击后用于展示落地页的浏览器类型,可选项包括:InnerBrowser(APP 内置浏览器),Sys(系统浏览器),Default(默认),SDK 按照默认逻辑选择
.build();
//针对百度SDK信息流设置
BaiduExtraOptions baiduExtraOptions = new BaiduExtraOptions.Builder()
.setGDTExtraOption(BaiduExtraOptions.DOWNLOAD_APP_CONFIRM_ALWAYS)
.setCacheVideoOnlyWifi(true).build();
//视频声音控制
TTVideoOption videoOption = new TTVideoOption.Builder()
.setMuted(false) //所有类型生效,GDT除外
.setAdmobAppVolume(1f)//admob 声音配置,与setMuted配合使用
.setGDTExtraOption(gdtExtraOption)//GDT 单独
.setBaiduExtraOption(baiduExtraOptions)//百度SDK配置
.build();
return videoOption;
}
public static TTVideoOption getTTVideoOption2() {
//广点通(GDT)单独使用配置
GDTExtraOption gdtExtraOption = new GDTExtraOption.Builder()
.setGDTAutoPlayMuted(true)//自动播放是否静音,默认true
.setGDTDetailPageMuted(false)//详情页是否静音,默认值为false,即有声播放;
.setGDTEnableDetailPage(true)//是否能跳转详情页,默认true
.setGDTEnableUserControl(false)//是否能控制是否暂停与播放,默认false
.setGDTMaxVideoDuration(0)//视频最大长度,单位:秒 此设置会影响广告填充,请谨慎设置
.setGDTMinVideoDuration(0)//视频最小长度,单位:秒 此设置会影响广告填充,请谨慎设置
.setFeedExpressType(GDTExtraOption.FeedExpressType.FEED_EXPRESS_TYPE_2)//确定使用GDT FEED 模板渲染2.0功能;需要向广点通商务申请2.0权限
// VideoOption.AutoPlayPolicy.WIFI表示只在WiFi下自动播放;
// VideoOption.AutoPlayPolicy.ALWAYS表示始终自动播放,不区分当前网络;
// VideoOption.AutoPlayPolicy.NEVER表示始终都不自动播放,不区分当前网络,但在WiFi时会预下载视频资源;
// 默认为始终自动播放;模板渲染视频、插屏2.0视频、自渲染2.0视频都可使用
.setAutoPlayPolicy(GDTExtraOption.AutoPlayPolicy.WIFI)//自动播放策略--
.setDownAPPConfirmPolicy(GDTExtraOption.DownAPPConfirmPolicy.TYPE_DEFAULT)//指定点击 APP 广告后是否展示二次确认,可选项包括 Default(wifi 不展示,非wifi 展示),NoConfirm(所有情况不展示)
.setBrowserType(GDTExtraOption.BrowserType.TYPE_DEFAULT).build();//指定普链广告点击后用于展示落地页的浏览器类型,可选项包括:InnerBrowser(APP 内置浏览器),Sys(系统浏览器),Default(默认),SDK 按照默认逻辑选择
//针对百度SDK信息流设置
BaiduExtraOptions baiduExtraOptions = new BaiduExtraOptions.Builder()
.setGDTExtraOption(BaiduExtraOptions.DOWNLOAD_APP_CONFIRM_ALWAYS)
.setCacheVideoOnlyWifi(true).build();
//视频声音控制
TTVideoOption videoOption = new TTVideoOption.Builder()
.setMuted(false) //所有类型生效,GDT除外
.setAdmobAppVolume(1f)//admob 声音配置,与setMuted配合使用
.setGDTExtraOption(gdtExtraOption)//GDT 单独
.setBaiduExtraOption(baiduExtraOptions)//百度SDK配置
.build();
return videoOption;
}
}
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<corners android:radius="6dp" />
<stroke android:color="#3C93CD" android:width="1dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<corners android:radius="6dp" />
<stroke android:color="#f85959" android:width="1dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" >
<shape >
<stroke android:color="#7f2a90d7" />
<solid android:color="#2a90d7" />
<corners android:radius="6dp"/>
</shape>
</item>
<item >
<shape >
<stroke android:color="#2a90d7" />
<solid android:color="#2a90d7" />
<corners android:radius="6dp"/>
</shape>
</item>
</selector>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/ad_title_creative_btn_layout"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:gravity="center"
android:visibility="gone"
android:orientation="horizontal">
<Button
android:id="@+id/btn_listitem_stop"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_marginEnd="20dp"
android:layout_marginRight="20dp"
android:background="@drawable/btn_bg_blue"
android:textColor="#3C93CD"
android:text="暂停下载"
android:visibility="gone" />
<Button
android:id="@+id/btn_listitem_remove"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:background="@drawable/btn_bg_red"
android:textColor="#f85959"
android:text="删除下载"
android:visibility="gone" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<com.bytedance.msdk.api.format.TTNativeAdView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="HardcodedText">
<!-- icon+广告源+关闭按钮 layout -->
<include
android:id="@+id/icon_source_layout"
layout="@layout/listitem_ad_icon_source_layout"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:paddingEnd="10dp"
android:paddingRight="10dp" />
<TextView
android:id="@+id/tv_listitem_ad_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/icon_source_layout"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:ellipsize="end"
android:lineSpacingMultiplier="1"
android:maxLines="2"
android:singleLine="false"
android:text="劳力士服务中心,清洗保养,更换配件,9秒费用查询"
android:textColor="@android:color/black"
android:textSize="18sp" />
<!-- -->
<LinearLayout
android:id="@+id/layout_image_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tv_listitem_ad_desc"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_listitem_image1"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:scaleType="centerCrop" />
<ImageView
android:id="@+id/iv_listitem_image2"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:scaleType="centerCrop" />
<ImageView
android:id="@+id/iv_listitem_image3"
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="1"
android:scaleType="centerCrop" />
</LinearLayout>
<!-- title+creativeBtn layout -->
<include
android:id="@+id/ad_title_creative_btn_layout"
layout="@layout/listitem_ad_title_creative_btn_layout"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_below="@+id/layout_image_group"
android:layout_marginLeft="10dp"
android:layout_marginTop="4dp"
android:layout_marginRight="10dp" />
<!--==== 测试下载状态控制功能 begin ========-->
<include
layout="@layout/listitem_ad_download_btn_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/ad_title_creative_btn_layout"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:gravity="center"
android:orientation="horizontal" />
<!--==== 测试下载状态控制功能 end ========-->
</RelativeLayout>
</com.bytedance.msdk.api.format.TTNativeAdView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<com.bytedance.msdk.api.format.TTNativeAdView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="HardcodedText">
<include
android:id="@+id/icon_source_layout"
layout="@layout/listitem_ad_icon_source_layout" />
<TextView
android:id="@+id/tv_listitem_ad_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/icon_source_layout"
android:layout_marginLeft="10dp"
android:layout_marginTop="3dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="3dp"
android:ellipsize="end"
android:lineSpacingMultiplier="1"
android:maxLines="2"
android:singleLine="false"
android:text="劳力士服务中心,清洗保养,更换配件,9秒费用查询"
android:textColor="@android:color/black"
android:textSize="18sp" />
<ImageView
android:id="@+id/iv_listitem_image"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_below="@id/tv_listitem_ad_desc"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/tt_ad_cover_btn_begin_bg"
android:scaleType="centerCrop" />
<!-- title+creativeBtn layout -->
<include
android:id="@+id/ad_title_creative_btn_layout"
layout="@layout/listitem_ad_title_creative_btn_layout"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_below="@+id/iv_listitem_image"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" />
</RelativeLayout>
</com.bytedance.msdk.api.format.TTNativeAdView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<com.bytedance.msdk.api.format.TTNativeAdView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="HardcodedText">
<include
android:id="@+id/icon_source_layout"
layout="@layout/listitem_ad_icon_source_layout" />
<TextView
android:id="@+id/tv_listitem_ad_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/icon_source_layout"
android:layout_marginLeft="10dp"
android:layout_marginTop="3dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="3dp"
android:ellipsize="end"
android:lineSpacingMultiplier="1"
android:maxLines="2"
android:singleLine="false"
android:text="劳力士服务中心,清洗保养,更换配件,9秒费用查询"
android:textColor="@android:color/black"
android:textSize="18sp" />
<com.bytedance.msdk.api.format.TTMediaView
android:id="@+id/iv_listitem_video"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_below="@id/tv_listitem_ad_desc"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@android:color/background_dark"
android:scaleType="centerCrop" />
<!-- title+creativeBtn layout -->
<include
android:id="@+id/ad_title_creative_btn_layout"
layout="@layout/listitem_ad_title_creative_btn_layout"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_below="@+id/iv_listitem_video"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" />
</RelativeLayout>
</com.bytedance.msdk.api.format.TTNativeAdView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<com.bytedance.msdk.api.format.TTNativeAdView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/iv_listitem_express"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" />
</com.bytedance.msdk.api.format.TTNativeAdView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<com.bytedance.msdk.api.format.TTNativeAdView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="HardcodedText">
<RelativeLayout
android:id="@+id/ad_contentPanel"
android:layout_width="match_parent"
android:layout_height="85dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp">
<ImageView
android:id="@+id/iv_listitem_image"
android:layout_width="100dp"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:background="@drawable/tt_ad_cover_btn_begin_bg"
android:scaleType="centerCrop" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_toStartOf="@+id/iv_listitem_image"
android:layout_toLeftOf="@+id/iv_listitem_image"
android:orientation="vertical">
<TextView
android:id="@+id/tv_listitem_ad_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lineSpacingMultiplier="1.1"
android:maxLines="2"
android:text="80后的回忆!经典三国完美复刻,安卓用户的福利"
android:textColor="@android:color/black"
android:textSize="18sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginTop="3dp"
android:paddingEnd="10dp"
android:paddingRight="10dp">
<ImageView
android:id="@+id/iv_listitem_icon"
android:layout_width="30dp"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:src="@drawable/tt_mute" />
<TextView
android:id="@+id/tv_listitem_ad_source"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_toStartOf="@+id/iv_listitem_dislike"
android:layout_toLeftOf="@+id/iv_listitem_dislike"
android:layout_toEndOf="@+id/iv_listitem_icon"
android:layout_toRightOf="@+id/iv_listitem_icon"
android:ellipsize="end"
android:gravity="center_vertical"
android:singleLine="true"
android:text="着陆无双"
android:textColor="#70000000"
android:textSize="16sp" />
<ImageView
android:id="@+id/iv_listitem_dislike"
android:layout_width="20dp"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="center_vertical"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:clickable="true"
android:focusable="true" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<!-- title+creativeBtn layout -->
<include
android:id="@+id/ad_title_creative_btn_layout"
layout="@layout/listitem_ad_title_creative_btn_layout"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_below="@+id/ad_contentPanel"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" />
</RelativeLayout>
</com.bytedance.msdk.api.format.TTNativeAdView>
\ No newline at end of file
......@@ -7,6 +7,14 @@
android:layout_marginBottom="2dp"
android:background="#F4F5F7">
<RelativeLayout
android:id="@+id/tt_ad_logo"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:visibility="gone" />
<TextView
android:id="@+id/tv_listitem_ad_title"
android:layout_width="match_parent"
......
<?xml version="1.0" encoding="utf-8"?>
<com.bytedance.msdk.api.format.TTNativeAdView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:ignore="HardcodedText">
<ImageView
android:id="@+id/iv_listitem_image"
android:layout_width="135dp"
android:layout_height="240dp"
android:layout_centerHorizontal="true"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:scaleType="centerCrop" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/iv_listitem_image"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="@+id/tv_listitem_ad_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:gravity="center"
android:singleLine="false"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<ImageView
android:id="@+id/iv_listitem_icon"
android:layout_width="30dp"
android:layout_height="40dp"
android:layout_centerVertical="true"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp" />
<LinearLayout
android:id="@+id/tv_source_desc_layout"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_below="@id/layout_image_group"
android:layout_centerVertical="true"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_toEndOf="@id/iv_listitem_icon"
android:layout_toRightOf="@id/iv_listitem_icon"
android:orientation="vertical"
tools:ignore="NotSibling">
<TextView
android:id="@+id/tv_listitem_ad_desc"
android:layout_width="80dp"
android:layout_height="20dp"
android:ellipsize="end"
android:singleLine="true"
android:textSize="10sp" />
<TextView
android:id="@+id/tv_listitem_ad_source"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="10dp"
android:ellipsize="end"
android:singleLine="true"
android:textSize="8sp" />
</LinearLayout>
</RelativeLayout>
<Button
android:id="@+id/btn_listitem_creative"
android:layout_width="135dp"
android:layout_height="40dp"
android:textSize="9sp" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/iv_listitem_dislike"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:clickable="true"
android:src="@mipmap/dislike_icon" />
</RelativeLayout>
</com.bytedance.msdk.api.format.TTNativeAdView>
\ No newline at end of file
......@@ -67,6 +67,9 @@ buildscript {
classpath "com.google.dagger:hilt-android-gradle-plugin:2.28.3-alpha"
classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:2.0.10'
classpath 'com.sensorsdata.analytics.android:android-gradle-plugin2:3.3.1'
// 穿山甲APPlog
classpath 'com.bytedance.applog:RangersAppLog-All-plugin:5.2.6'
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment