Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_vedio
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_vedio
Commits
b8430428
Commit
b8430428
authored
Aug 04, 2023
by
jyx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加首页信息流广告
parent
0705b50c
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
984 additions
and
37 deletions
+984
-37
build.gradle
video/app/build.gradle
+2
-0
MainExpressManager.kt
...java/com/mints/helivideo/ad/express/MainExpressManager.kt
+833
-0
VideoMultiItemEntity.kt
...ava/com/mints/helivideo/mvp/model/VideoMultiItemEntity.kt
+7
-0
NewHotStyle2Adapter.kt
...ava/com/mints/helivideo/ui/adapter/NewHotStyle2Adapter.kt
+61
-0
MovieFragment.kt
...ain/java/com/mints/helivideo/ui/fragment/MovieFragment.kt
+63
-34
UIUtils.java
.../app/src/main/java/com/mints/helivideo/utils/UIUtils.java
+4
-0
item_express_ad.xml
video/app/src/main/res/layout/item_express_ad.xml
+12
-0
item_hot_style.xml
video/app/src/main/res/layout/item_hot_style.xml
+1
-3
gradle.properties
video/gradle.properties
+1
-0
No files found.
video/app/build.gradle
View file @
b8430428
...
@@ -66,6 +66,7 @@ android {
...
@@ -66,6 +66,7 @@ android {
buildConfigField
"String"
,
"GROMORE_VIDEO_CODE"
,
GROMORE_VIDEO_CODE
buildConfigField
"String"
,
"GROMORE_VIDEO_CODE"
,
GROMORE_VIDEO_CODE
buildConfigField
"String"
,
"GROMORE_DRAW_CODE"
,
GROMORE_DRAW_CODE
buildConfigField
"String"
,
"GROMORE_DRAW_CODE"
,
GROMORE_DRAW_CODE
buildConfigField
"String"
,
"GROMORE_EXPRESS_CODE"
,
GROMORE_EXPRESS_CODE
buildConfigField
"String"
,
"GROMORE_EXPRESS_CODE"
,
GROMORE_EXPRESS_CODE
buildConfigField
"String"
,
"GROMORE_MAIN_EXPRESS_CODE"
,
GROMORE_MAIN_EXPRESS_CODE
buildConfigField
"String"
,
"GROMORE_BANNER_CODE"
,
GROMORE_BANNER_CODE
buildConfigField
"String"
,
"GROMORE_BANNER_CODE"
,
GROMORE_BANNER_CODE
buildConfigField
"String"
,
"WEIXIN_APP_PAY_ID"
,
WEIXIN_APP_PAY_ID
buildConfigField
"String"
,
"WEIXIN_APP_PAY_ID"
,
WEIXIN_APP_PAY_ID
...
@@ -88,6 +89,7 @@ android {
...
@@ -88,6 +89,7 @@ android {
buildConfigField
"String"
,
"GROMORE_VIDEO_CODE"
,
GROMORE_VIDEO_CODE
buildConfigField
"String"
,
"GROMORE_VIDEO_CODE"
,
GROMORE_VIDEO_CODE
buildConfigField
"String"
,
"GROMORE_DRAW_CODE"
,
GROMORE_DRAW_CODE
buildConfigField
"String"
,
"GROMORE_DRAW_CODE"
,
GROMORE_DRAW_CODE
buildConfigField
"String"
,
"GROMORE_EXPRESS_CODE"
,
GROMORE_EXPRESS_CODE
buildConfigField
"String"
,
"GROMORE_EXPRESS_CODE"
,
GROMORE_EXPRESS_CODE
buildConfigField
"String"
,
"GROMORE_MAIN_EXPRESS_CODE"
,
GROMORE_MAIN_EXPRESS_CODE
buildConfigField
"String"
,
"GROMORE_BANNER_CODE"
,
GROMORE_BANNER_CODE
buildConfigField
"String"
,
"GROMORE_BANNER_CODE"
,
GROMORE_BANNER_CODE
buildConfigField
"String"
,
"WEIXIN_APP_PAY_ID"
,
WEIXIN_APP_PAY_ID
buildConfigField
"String"
,
"WEIXIN_APP_PAY_ID"
,
WEIXIN_APP_PAY_ID
...
...
video/app/src/main/java/com/mints/helivideo/ad/express/MainExpressManager.kt
0 → 100644
View file @
b8430428
package
com.mints.helivideo.ad.express
import
android.net.Uri
import
android.text.TextUtils
import
android.util.Log
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.*
import
com.bumptech.glide.Glide
import
com.bytedance.sdk.openadsdk.*
import
com.bytedance.sdk.openadsdk.mediation.ad.MediationExpressRenderListener
import
com.bytedance.sdk.openadsdk.mediation.ad.MediationViewBinder
import
com.mints.helivideo.BuildConfig
import
com.mints.helivideo.MintsApplication
import
com.mints.helivideo.R
import
com.mints.helivideo.utils.ForegroundOrBackground
import
com.mints.helivideo.utils.LogUtil
import
com.mints.helivideo.utils.UIUtils
import
java.lang.Exception
import
java.util.ArrayList
private
val
TAG
=
MainExpressManager
::
class
.
java
.
simpleName
/**
* 信息流
*/
class
MainExpressManager
{
companion
object
{
val
instance
:
MainExpressManager
by
lazy
(
mode
=
LazyThreadSafetyMode
.
SYNCHRONIZED
)
{
MainExpressManager
()
}
}
private
var
adcode
=
""
private
var
ecpm
=
""
private
var
adSource
=
""
private
var
mTTFeedAdList
=
arrayListOf
<
TTFeedAd
>()
fun
loadAd
(
expressAdCallback
:
ExpressAdCallback
)
{
val
activity
=
ForegroundOrBackground
.
getTopActivity
()
val
adNativeLoader
=
TTAdSdk
.
getAdManager
().
createAdNative
(
activity
)
val
adslot
=
AdSlot
.
Builder
()
.
setCodeId
(
BuildConfig
.
GROMORE_MAIN_EXPRESS_CODE
)
/**
* 注:
* 1:单位为px
* 2:如果是信息流自渲染广告,设置广告图片期望的图片宽高 ,不能为0
* 2:如果是信息流模板广告,宽度设置为希望的宽度,高度设置为0(0为高度选择自适应参数)
*/
.
setImageAcceptedSize
(
UIUtils
.
getAdWidth3
(
MintsApplication
.
getContext
()).
toInt
(),
UIUtils
.
dip2px
(
MintsApplication
.
getContext
(),
192f
)
)
.
setAdCount
(
3
)
//请求广告数量为1到3条 (优先采用平台配置的数量)
.
build
()
adNativeLoader
.
loadFeedAd
(
adslot
,
object
:
TTAdNative
.
FeedAdListener
{
override
fun
onError
(
p0
:
Int
,
p1
:
String
?)
{
LogUtil
.
e
(
TAG
,
"gromore首页信息流--> 3、load feed ad error : $p0, $p1"
)
}
override
fun
onFeedAdLoad
(
ads
:
MutableList
<
TTFeedAd
>?)
{
LogUtil
.
d
(
TAG
,
"gromore首页信息流--> 3、Gromore onAdLoaded"
)
ads
?.
let
{
if
(
it
.
isEmpty
())
{
return
}
for
(
ttFeedAd
in
it
)
{
mTTFeedAdList
.
add
(
ttFeedAd
)
showAd
(
ttFeedAd
,
expressAdCallback
)
}
}
}
})
}
private
fun
showAd
(
ttNativeAd
:
TTFeedAd
?,
expressAdCallback
:
ExpressAdCallback
)
{
ttNativeAd
?.
let
{
if
(
it
.
mediationManager
.
isExpress
)
{
//--------------信息流模板广告渲染----------------
showExpressView
(
it
,
expressAdCallback
)
}
else
{
//--------------信息流自渲染广告渲染----------------
// val view: View? = when (it.imageMode) {
// TTAdConstant.IMAGE_MODE_SMALL_IMG -> getSmallAdView(frameLayout)//信息流自渲染广告渲染 :小图广告
// TTAdConstant.IMAGE_MODE_LARGE_IMG -> getLargeAdView(frameLayout)//信息流自渲染广告渲染 :大图广告
// TTAdConstant.IMAGE_MODE_GROUP_IMG -> getGroupAdView(frameLayout)//信息流自渲染广告渲染 :组图广告
// TTAdConstant.IMAGE_MODE_VIDEO -> getVideoView(frameLayout)//信息流自渲染广告渲染 :视频广告
// TTAdConstant.IMAGE_MODE_VERTICAL_IMG -> getVerticalAdView(frameLayout)//信息流自渲染广告渲染 :竖图广告
// TTAdConstant.IMAGE_MODE_VIDEO_VERTICAL -> getVideoView(frameLayout)//信息流自渲染广告渲染 :竖版视频广告
// else -> {
// Log.i(TAG, "展示样式错误")
// null
// }
// }
// view?.let {
// it.layoutParams = ViewGroup.LayoutParams(
// ViewGroup.LayoutParams.MATCH_PARENT,
// ViewGroup.LayoutParams.MATCH_PARENT
// )
// frameLayout?.removeAllViews()
// frameLayout?.addView(it)
// }
}
}
}
private
fun
showExpressView
(
it
:
TTFeedAd
,
expressAdCallback
:
ExpressAdCallback
)
{
it
.
setExpressRenderListener
(
object
:
MediationExpressRenderListener
{
override
fun
onRenderSuccess
(
p0
:
View
?,
p1
:
Float
,
p2
:
Float
,
p3
:
Boolean
)
{
Log
.
i
(
TAG
,
"onRenderSuccess"
)
it
.
setDislikeCallback
(
ForegroundOrBackground
.
getTopActivity
(),
object
:
TTAdDislike
.
DislikeInteractionCallback
{
override
fun
onShow
()
{
Log
.
i
(
TAG
,
"express dislike 点击show"
)
}
override
fun
onSelected
(
position
:
Int
,
value
:
String
?,
enforce
:
Boolean
)
{
Log
.
i
(
TAG
,
"express 点击 $value"
)
}
override
fun
onCancel
()
{
Log
.
i
(
TAG
,
"express dislike 点击了取消"
)
}
})
it
.
adView
?.
let
{
view
->
if
(
view
.
parent
!=
null
)
{
(
view
.
parent
as
ViewGroup
).
removeView
(
view
)
}
val
frameLayout
=
FrameLayout
(
MintsApplication
.
getContext
())
frameLayout
.
addView
(
view
)
expressAdCallback
.
renderSuccess
(
frameLayout
)
}
}
override
fun
onRenderFail
(
p0
:
View
?,
p1
:
String
?,
p2
:
Int
)
{
LogUtil
.
e
(
TAG
,
"gromore首页信息流--> 5、展示广告时失败了,onRenderFail msg=${p1} code=${p2} "
)
}
override
fun
onAdClick
()
{
Log
.
i
(
TAG
,
"onAdClick"
)
}
override
fun
onAdShow
()
{
Log
.
i
(
TAG
,
"onAdShow"
)
Log
.
i
(
TAG
,
"ad mediaExtraInfo ${it.mediaExtraInfo}"
)
}
})
it
.
render
()
//必须要调用render方法进行渲染,在onRenderSuccess中处理模板的view
}
/**
* 销毁
*/
fun
destroy
()
{
// 数据重置
adcode
=
""
ecpm
=
""
adSource
=
""
for
(
ttFeedAd
in
mTTFeedAdList
)
{
ttFeedAd
.
destroy
()
}
}
// private fun getSmallAdView(parent: ViewGroup?): View? {
// val convertView =
// LayoutInflater.from(ForegroundOrBackground.getTopActivity())
// .inflate(
// R.layout.mediation_listitem_ad_small_pic,
// parent,
// 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
//
// adViewHolder.app_info =
// convertView.findViewById<LinearLayout>(R.id.app_info)
// adViewHolder.app_name =
// convertView.findViewById<TextView>(R.id.app_name)
// adViewHolder.author_name =
// convertView.findViewById<TextView>(R.id.author_name)
// adViewHolder.package_size =
// convertView.findViewById<TextView>(R.id.package_size)
// adViewHolder.permissions_url =
// convertView.findViewById<TextView>(R.id.permissions_url)
// adViewHolder.permissions_content =
// convertView.findViewById<TextView>(R.id.permissions_content)
// adViewHolder.privacy_agreement =
// convertView.findViewById<TextView>(R.id.privacy_agreement)
// adViewHolder.version_name =
// convertView.findViewById<TextView>(R.id.version_name)
//
// val viewBinder =
// MediationViewBinder.Builder(R.layout.mediation_listitem_ad_small_pic)
// .titleId(R.id.tv_listitem_ad_title)
// .sourceId(R.id.tv_listitem_ad_source).descriptionTextId(
// R.id.tv_listitem_ad_desc
// )
// .mainImageId(R.id.iv_listitem_image)
// .logoLayoutId(R.id.tt_ad_logo)
// .callToActionId(R.id.btn_listitem_creative)
// .iconImageId(R.id.iv_listitem_icon).build()
// adViewHolder.viewBinder = viewBinder
// bindData(convertView, adViewHolder)
// if (mTTFeedAd?.imageList?.size != 0) {
// mTTFeedAd?.let { ttfeedad ->
// ttfeedad.imageList[0]?.imageUrl?.let {
// Glide.with(ForegroundOrBackground.getTopActivity()).load(it)
// .into(adViewHolder.mSmallImage!!)
// }
// }
// }
// return convertView;
// }
// private fun getLargeAdView(parent: ViewGroup?): View {
// val adViewHolder = LargeAdViewHolder()
// var convertView: View =
// LayoutInflater.from(ForegroundOrBackground.getTopActivity())
// .inflate(
// R.layout.mediation_listitem_ad_large_pic,
// parent,
// false
// )
// 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<RelativeLayout>(R.id.tt_ad_logo) //logoView 建议传入GroupView类型
//
//
// adViewHolder.app_info =
// convertView.findViewById<LinearLayout>(R.id.app_info)
// adViewHolder.app_name =
// convertView.findViewById<TextView>(R.id.app_name)
// adViewHolder.author_name =
// convertView.findViewById<TextView>(R.id.author_name)
// adViewHolder.package_size =
// convertView.findViewById<TextView>(R.id.package_size)
// adViewHolder.permissions_url =
// convertView.findViewById<TextView>(R.id.permissions_url)
// adViewHolder.permissions_content =
// convertView.findViewById<TextView>(R.id.permissions_content)
// adViewHolder.privacy_agreement =
// convertView.findViewById<TextView>(R.id.privacy_agreement)
// adViewHolder.version_name =
// convertView.findViewById<TextView>(R.id.version_name)
//
// val viewBinder =
// MediationViewBinder.Builder(R.layout.mediation_listitem_ad_large_pic)
// .titleId(R.id.tv_listitem_ad_title)
// .descriptionTextId(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)
// .iconImageId(R.id.iv_listitem_icon).build()
// adViewHolder.viewBinder = viewBinder
// bindData(convertView, adViewHolder)
// if (mTTFeedAd?.imageList?.size != 0) {
// mTTFeedAd?.let { ttfeedad ->
// ttfeedad.imageList[0]?.imageUrl?.let {
// Glide.with(ForegroundOrBackground.getTopActivity()).load(it)
// .into(adViewHolder.mLargeImage!!)
// }
// }
// }
// return convertView
// }
// private fun getGroupAdView(parent: ViewGroup?): View? {
// val adViewHolder = GroupAdViewHolder()
// var convertView: View = LayoutInflater.from(ForegroundOrBackground.getTopActivity())
// .inflate(
// R.layout.mediation_listitem_ad_group_pic,
// parent,
// false
// )
// 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.mGroupImage1 =
// convertView.findViewById<View>(R.id.iv_listitem_image1) as ImageView
// adViewHolder.mGroupImage2 =
// convertView.findViewById<View>(R.id.iv_listitem_image2) as ImageView
// adViewHolder.mGroupImage3 =
// convertView.findViewById<View>(R.id.iv_listitem_image3) 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<RelativeLayout>(R.id.tt_ad_logo) //logoView 建议传入GroupView类型
//
//
// adViewHolder.app_info =
// convertView.findViewById<LinearLayout>(R.id.app_info)
// adViewHolder.app_name =
// convertView.findViewById<TextView>(R.id.app_name)
// adViewHolder.author_name =
// convertView.findViewById<TextView>(R.id.author_name)
// adViewHolder.package_size =
// convertView.findViewById<TextView>(R.id.package_size)
// adViewHolder.permissions_url =
// convertView.findViewById<TextView>(R.id.permissions_url)
// adViewHolder.permissions_content =
// convertView.findViewById<TextView>(R.id.permissions_content)
// adViewHolder.privacy_agreement =
// convertView.findViewById<TextView>(R.id.privacy_agreement)
// adViewHolder.version_name =
// convertView.findViewById<TextView>(R.id.version_name)
//
// val viewBinder =
// MediationViewBinder.Builder(R.layout.mediation_listitem_ad_group_pic)
// .titleId(R.id.tv_listitem_ad_title)
// .descriptionTextId(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).callToActionId(
// R.id.btn_listitem_creative
// ).iconImageId(R.id.iv_listitem_icon)
// .groupImage1Id(R.id.iv_listitem_image1).groupImage2Id(
// R.id.iv_listitem_image2
// )
// .groupImage3Id(R.id.iv_listitem_image3).build()
// adViewHolder.viewBinder = viewBinder
//
// bindData(convertView, adViewHolder)
// if (mTTFeedAd?.imageList?.size ?: 0 >= 3) {
// val image1: String? = mTTFeedAd?.imageList?.get(0)?.imageUrl
// val image2: String? = mTTFeedAd?.imageList?.get(1)?.imageUrl
// val image3: String? = mTTFeedAd?.imageList?.get(2)?.imageUrl
// if (image1 != null) {
// Glide.with(ForegroundOrBackground.getTopActivity()).load(image1)
// .into(adViewHolder.mGroupImage1!!)
// }
// if (image2 != null) {
// Glide.with(ForegroundOrBackground.getTopActivity()).load(image2)
// .into(adViewHolder.mGroupImage2!!)
// }
// if (image3 != null) {
// Glide.with(ForegroundOrBackground.getTopActivity()).load(image3)
// .into(adViewHolder.mGroupImage3!!)
// }
// }
// return convertView
// }
// private fun getVideoView(parent: ViewGroup?): View? {
// val adViewHolder = VideoAdViewHolder()
// var convertView: View? = null
// try {
// convertView = LayoutInflater.from(ForegroundOrBackground.getTopActivity())
// .inflate(
// R.layout.mediation_listitem_ad_large_video,
// parent,
// false
// )
// 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<RelativeLayout>(R.id.tt_ad_logo) //logoView 建议传入GroupView类型
// adViewHolder.app_info =
// convertView.findViewById<LinearLayout>(R.id.app_info)
// adViewHolder.app_name =
// convertView.findViewById<TextView>(R.id.app_name)
// adViewHolder.author_name =
// convertView.findViewById<TextView>(R.id.author_name)
// adViewHolder.package_size =
// convertView.findViewById<TextView>(R.id.package_size)
// adViewHolder.permissions_url =
// convertView.findViewById<TextView>(R.id.permissions_url)
// adViewHolder.permissions_content =
// convertView.findViewById<TextView>(R.id.permissions_content)
// adViewHolder.privacy_agreement =
// convertView.findViewById<TextView>(R.id.privacy_agreement)
// adViewHolder.version_name =
// convertView.findViewById<TextView>(R.id.version_name)
//
// val viewBinder =
// MediationViewBinder.Builder(R.layout.mediation_listitem_ad_large_video)
// .titleId(R.id.tv_listitem_ad_title)
// .sourceId(R.id.tv_listitem_ad_source)
// .descriptionTextId(R.id.tv_listitem_ad_desc)
// .mediaViewIdId(
// R.id.iv_listitem_video
// )
// .callToActionId(R.id.btn_listitem_creative)
// .logoLayoutId(R.id.tt_ad_logo)
// .iconImageId(R.id.iv_listitem_icon).build()
// adViewHolder.viewBinder = viewBinder
//
// // 如果自己有需求进行视频播放操作,则按如下步骤进行。注意:不是所有adn都支持,因此需要进行判空操作。
//// mTTFeedAd?.csjmAdInfo?.setUseCustomVideo(true) // 注意:要在registerView之前调用
// val videoUrl: String? = mTTFeedAd?.customVideo?.videoUrl // 注意:不是所有adn都支持,这里务必要进行判空操作
// if (!TextUtils.isEmpty(videoUrl)) {
// // 如果通过getVideoUrl返回的url不是空,则自己处理视频播放操作,并通过reporter上报视频状态
// playAdVideo(adViewHolder.videoView as FrameLayout, videoUrl ?: "")
// } else {
// // 注意:即使该adn支持返回url,但某次偶然原因返回的videoUrl为空,则仍然会用adn自己的视频播放作为兜底
// }
//
// //视频广告设置播放状态回调(可选)
// mTTFeedAd?.setVideoAdListener(object : TTFeedAd.VideoAdListener {
// override fun onVideoLoad(ad: TTFeedAd?) {
// Log.i(TAG, "onVideoLoad")
// }
//
// override fun onVideoError(errorCode: Int, extraCode: Int) {
// Log.i(TAG, "onVideoError")
// }
//
// override fun onVideoAdStartPlay(ad: TTFeedAd?) {
// Log.i(TAG, "onVideoAdStartPlay")
// }
//
// override fun onVideoAdPaused(ad: TTFeedAd?) {
// Log.i(TAG, "onVideoAdPaused")
// }
//
// override fun onVideoAdContinuePlay(ad: TTFeedAd?) {
// Log.i(TAG, "onVideoAdContinuePlay")
// }
//
// override fun onProgressUpdate(current: Long, duration: Long) {
// Log.i(TAG, "onProgressUpdate")
// }
//
// override fun onVideoAdComplete(ad: TTFeedAd?) {
// Log.i(TAG, "onVideoAdComplete")
// }
//
// })
// mTTFeedAd?.setDownloadListener(object : TTAppDownloadListener {
// override fun onIdle() {
// Log.i(TAG, "setDownloadListener")
// }
//
// override fun onDownloadActive(
// totalBytes: Long,
// currBytes: Long,
// fileName: String?,
// appName: String?
// ) {
// Log.i(TAG, "onDownloadActive")
// }
//
// override fun onDownloadPaused(
// totalBytes: Long,
// currBytes: Long,
// fileName: String?,
// appName: String?
// ) {
// Log.i(TAG, "onDownloadPaused")
// }
//
// override fun onDownloadFailed(
// totalBytes: Long,
// currBytes: Long,
// fileName: String?,
// appName: String?
// ) {
// Log.i(TAG, "onDownloadFailed")
// }
//
// override fun onDownloadFinished(
// totalBytes: Long,
// fileName: String?,
// appName: String?
// ) {
// Log.i(TAG, "onDownloadFinished")
// }
//
// override fun onInstalled(fileName: String?, appName: String?) {
// Log.i(TAG, "onInstalled")
// }
//
// })
// //绑定广告数据、设置交互回调
// bindData(convertView, adViewHolder)
// } catch (e: Exception) {
// e.printStackTrace()
// }
//
// return convertView
// }
// private var mVideoView: VideoView? = null
// private var customVideoReporter: TTFeedAd.CustomizeVideo? = null
// private fun playAdVideo(videoContainer: ViewGroup, videoUrl: String) {
// mVideoView = VideoView(MintsApplication.getContext())
// videoContainer.addView(mVideoView)
// customVideoReporter = mTTFeedAd?.customVideo
// // 开发者根据自己的需求,做相应的视频控制界面,播放暂停等
// mVideoView?.setVideoURI(Uri.parse(videoUrl))
// mVideoView?.setOnErrorListener { mp, what, extra ->
// if (customVideoReporter != null) {
// customVideoReporter?.reportVideoError(
// mVideoView!!.currentPosition.toLong(),
// what,
// extra
// )
// }
// false
// }
// mVideoView?.setOnCompletionListener {
// if (customVideoReporter != null) {
// customVideoReporter?.reportVideoFinish()
// }
// }
// mVideoView?.start()
// customVideoReporter?.reportVideoStart()
// }
// private fun getVerticalAdView(parent: ViewGroup?): View? {
// val adViewHolder = VerticalAdViewHolder()
// var convertView = LayoutInflater.from(ForegroundOrBackground.getTopActivity())
// .inflate(
// R.layout.mediation_listitem_ad_vertical_pic,
// parent,
// false
// )
// 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.mVerticalImage =
// convertView.findViewById<ImageView>(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<RelativeLayout>(R.id.tt_ad_logo) //logoView 建议传入GroupView类型
//
//
// adViewHolder.app_info =
// convertView.findViewById<LinearLayout>(R.id.app_info)
// adViewHolder.app_name =
// convertView.findViewById<TextView>(R.id.app_name)
// adViewHolder.author_name =
// convertView.findViewById<TextView>(R.id.author_name)
// adViewHolder.package_size =
// convertView.findViewById<TextView>(R.id.package_size)
// adViewHolder.permissions_url =
// convertView.findViewById<TextView>(R.id.permissions_url)
// adViewHolder.permissions_content =
// convertView.findViewById<TextView>(R.id.permissions_content)
// adViewHolder.privacy_agreement =
// convertView.findViewById<TextView>(R.id.privacy_agreement)
// adViewHolder.version_name =
// convertView.findViewById<TextView>(R.id.version_name)
//
// val viewBinder =
// MediationViewBinder.Builder(R.layout.mediation_listitem_ad_vertical_pic)
// .titleId(R.id.tv_listitem_ad_title)
// .descriptionTextId(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
// bindData(convertView, adViewHolder)
// if (mTTFeedAd?.imageList?.size != 0) {
// mTTFeedAd?.let { ttfeedad ->
// ttfeedad.imageList[0]?.imageUrl?.let {
// Glide.with(ForegroundOrBackground.getTopActivity()).load(it)
// .into(adViewHolder.mVerticalImage!!)
// }
// }
// }
// return convertView
// }
// private fun bindData(convertView: View, adViewHolder: AdViewHolder) {
// mTTFeedAd?.let {
// if (it.mediationManager?.hasDislike() == true) {
// val ttAdDislike: TTAdDislike =
// it.getDislikeDialog(ForegroundOrBackground.getTopActivity())
// adViewHolder.mDislike?.visibility = View.VISIBLE
// adViewHolder.mDislike?.setOnClickListener(View.OnClickListener {
// //使用接口来展示
// ttAdDislike.showDislikeDialog()
// ttAdDislike.setDislikeInteractionCallback(object :
// TTAdDislike.DislikeInteractionCallback {
// override fun onShow() {
// Log.i(TAG, "dislike 点击show")
// }
//
// override fun onSelected(position: Int, value: String?, enforce: Boolean) {
// Log.i(TAG, "点击 $value")
// //用户选择不喜欢原因后,移除广告展示
//// frameLayout?.removeAllViews()
// }
//
// override fun onCancel() {
// Log.i(TAG, "dislike 点击了取消")
// }
//
// })
// })
// } else {
// if (adViewHolder.mDislike != null) adViewHolder.mDislike?.visibility = View.GONE
// }
//
// setDownLoadAppInfo(it, adViewHolder)
//
// //可以被点击的view, 也可以把convertView放进来意味item可被点击
// val clickViewList: MutableList<View?> = ArrayList()
// clickViewList.add(convertView)
// clickViewList.add(adViewHolder.mSource)
// clickViewList.add(adViewHolder.mTitle)
// clickViewList.add(adViewHolder.mDescription)
// clickViewList.add(adViewHolder.mIcon)
//
// //添加点击区域
// if (adViewHolder is LargeAdViewHolder) {
// clickViewList.add(adViewHolder.mLargeImage)
// } else if (adViewHolder is SmallAdViewHolder) {
// clickViewList.add(adViewHolder.mSmallImage)
// } else if (adViewHolder is VerticalAdViewHolder) {
// clickViewList.add(adViewHolder.mVerticalImage)
// } else if (adViewHolder is VideoAdViewHolder) {
// clickViewList.add(adViewHolder.videoView)
// } else if (adViewHolder is GroupAdViewHolder) {
// clickViewList.add(adViewHolder.mGroupImage1)
// clickViewList.add(adViewHolder.mGroupImage2)
// clickViewList.add(adViewHolder.mGroupImage3)
// }
//
// //触发创意广告的view(点击下载或拨打电话)
// val creativeViewList: MutableList<View?> = ArrayList()
// creativeViewList.add(adViewHolder.mCreativeButton)
// //重要! 这个涉及到广告计费,必须正确调用。**** convertView必须是com.bytedance.msdk.api.format.TTNativeAdView ****
// it.registerViewForInteraction(
// ForegroundOrBackground.getTopActivity(),
// convertView as ViewGroup,
// clickViewList,
// creativeViewList,
// null,
// object : TTNativeAd.AdInteractionListener {
// override fun onAdClicked(view: View?, ad: TTNativeAd?) {
// Log.i(TAG, "onAdClicked")
// }
//
// override fun onAdCreativeClick(view: View?, ad: TTNativeAd?) {
// Log.i(TAG, "onAdCreativeClick")
// }
//
// override fun onAdShow(ad: TTNativeAd?) {
// Log.i(TAG, "onAdShow")
// ad?.let {
//// PrintUtil.printShowInfo(ad.mediationManager)
// }
// }
// },
// adViewHolder.viewBinder
// )
//
// adViewHolder.mTitle?.text = it.title //title为广告的简单信息提示
//
// adViewHolder.mDescription?.text = it.description //description为广告的较长的说明
//
// adViewHolder.mSource?.text =
// if (TextUtils.isEmpty(it.source)) "广告来源" else it.source
//
// val icon: TTImage? = it.icon
// if (icon != null) {
// Glide.with(ForegroundOrBackground.getTopActivity()).load(icon.imageUrl)
// .into(adViewHolder.mIcon!!)
// }
// val adCreativeButton = adViewHolder.mCreativeButton
// when (it.interactionType) {
// TTAdConstant.INTERACTION_TYPE_DOWNLOAD -> {
// adCreativeButton?.visibility = View.VISIBLE;
// adCreativeButton?.setText(it.buttonText ?: "立即下载")
// }
// TTAdConstant.INTERACTION_TYPE_DIAL -> {
// adCreativeButton?.visibility = View.VISIBLE;
// adCreativeButton?.setText("立即拨打");
// }
// TTAdConstant.INTERACTION_TYPE_LANDING_PAGE,
// TTAdConstant.INTERACTION_TYPE_BROWSER -> {
// adCreativeButton?.visibility = View.VISIBLE;
// adCreativeButton?.setText(it.buttonText ?: "查看详情")
// }
// else -> {
// adCreativeButton?.visibility = View.GONE
// Log.i(TAG, "交互类型异常")
// }
// }
// }
// }
// private fun setDownLoadAppInfo(ttNativeAd: TTFeedAd, adViewHolder: AdViewHolder) {
// if (ttNativeAd.complianceInfo == null) {
// adViewHolder.app_info?.visibility = View.GONE
// } else {
// adViewHolder.app_info?.visibility = View.VISIBLE
// val appInfo = ttNativeAd.complianceInfo
// adViewHolder.app_name?.text = "应用名称:" + appInfo.appName
// adViewHolder.author_name?.text = "开发者:" + appInfo.developerName
// adViewHolder.package_size?.text = "包大小:不支持"
// adViewHolder.permissions_url?.text = "权限url:不支持"
// adViewHolder.privacy_agreement?.text = "隐私url:" + appInfo.privacyUrl
// adViewHolder.version_name?.text = "版本号:" + appInfo.appVersion
// adViewHolder.permissions_content!!.text =
// "权限内容:" + getPermissionsContent(appInfo.permissionsMap)
// }
// }
//
// private fun getPermissionsContent(permissionsMap: Map<String, String>?): String {
// if (permissionsMap == null) {
// return ""
// }
// val stringBuffer = StringBuffer()
// val keyList = permissionsMap.keys
// for (s in keyList) {
// stringBuffer.append(
// """$s : ${permissionsMap[s]} """
// )
// }
// return stringBuffer.toString()
// }
//
// 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
// }
//
// open private class AdViewHolder {
// var viewBinder: MediationViewBinder? = 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
// var app_info: LinearLayout? = null
// var app_name: TextView? = null
// var author_name: TextView? = null
// var package_size: TextView? = null
// var permissions_url: TextView? = null
// var privacy_agreement: TextView? = null
// var version_name: TextView? = null
// var permissions_content: TextView? = null
// }
}
\ No newline at end of file
video/app/src/main/java/com/mints/helivideo/mvp/model/VideoMultiItemEntity.kt
View file @
b8430428
package
com.mints.helivideo.mvp.model
package
com.mints.helivideo.mvp.model
import
android.widget.FrameLayout
import
com.chad.library.adapter.base.entity.MultiItemEntity
import
com.chad.library.adapter.base.entity.MultiItemEntity
import
com.mints.helivideo.video.tx.VideoModel
import
com.mints.helivideo.video.tx.VideoModel
...
@@ -18,3 +19,9 @@ data class VideoMultiItemEntity2(
...
@@ -18,3 +19,9 @@ data class VideoMultiItemEntity2(
var
video
:
VedioBean
?,
var
video
:
VedioBean
?,
var
videoModel
:
VideoModel
?
var
videoModel
:
VideoModel
?
)
:
MultiItemEntity
,
java
.
io
.
Serializable
)
:
MultiItemEntity
,
java
.
io
.
Serializable
data class
VideoMultiItemEntity3
(
override
val
itemType
:
Int
,
var
video
:
VedioBean
?,
var
adView
:
FrameLayout
?
)
:
MultiItemEntity
,
java
.
io
.
Serializable
video/app/src/main/java/com/mints/helivideo/ui/adapter/NewHotStyleAdapter.kt
→
video/app/src/main/java/com/mints/helivideo/ui/adapter/NewHotStyle
2
Adapter.kt
View file @
b8430428
package
com.mints.helivideo.ui.adapter
package
com.mints.helivideo.ui.adapter
import
com.chad.library.adapter.base.BaseQuickAdapter
import
android.widget.FrameLayout
import
com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import
com.chad.library.adapter.base.viewholder.BaseViewHolder
import
com.chad.library.adapter.base.viewholder.BaseViewHolder
import
com.mints.library.utils.GlideUtils
import
com.mints.library.utils.GlideUtils
import
com.mints.helivideo.R
import
com.mints.helivideo.R
import
com.mints.helivideo.mvp.model.VedioBean
import
com.mints.helivideo.mvp.model.*
import
com.mints.helivideo.utils.UIUtils
class
NewHotStyleAdapter
:
BaseQuickAdapter
<
VedioBean
,
BaseViewHolder
>(
R
.
layout
.
item_hot_style
)
{
class
NewHotStyle2Adapter
:
override
fun
convert
(
holder
:
BaseViewHolder
,
item
:
VedioBean
)
{
BaseMultiItemQuickAdapter
<
VideoMultiItemEntity3
,
BaseViewHolder
>()
{
init
{
addItemType
(
MULTI_ITEM_1
,
R
.
layout
.
item_hot_style
)
addItemType
(
MULTI_ITEM_3
,
R
.
layout
.
item_express_ad
)
}
override
fun
convert
(
holder
:
BaseViewHolder
,
item
:
VideoMultiItemEntity3
)
{
when
(
holder
.
itemViewType
)
{
MULTI_ITEM_1
->
{
initHolder
(
holder
,
item
.
video
)
}
MULTI_ITEM_3
->
{
initAdHolder
(
holder
,
item
.
adView
)
}
}
}
private
fun
initAdHolder
(
holder
:
BaseViewHolder
,
adView
:
FrameLayout
?)
{
adView
?.
let
{
UIUtils
.
removeFromParent
(
it
)
val
fmAd
=
holder
.
getView
<
FrameLayout
>(
R
.
id
.
fl_ad
)
fmAd
.
removeAllViews
()
fmAd
.
addView
(
it
)
}
}
private
fun
initHolder
(
holder
:
BaseViewHolder
,
item
:
VedioBean
?)
{
item
?.
let
{
item
?.
let
{
holder
.
setText
(
holder
.
setText
(
R
.
id
.
tvVedioItemCount
,
R
.
id
.
tvVedioItemCount
,
...
@@ -27,7 +56,6 @@ class NewHotStyleAdapter : BaseQuickAdapter<VedioBean, BaseViewHolder>(R.layout.
...
@@ -27,7 +56,6 @@ class NewHotStyleAdapter : BaseQuickAdapter<VedioBean, BaseViewHolder>(R.layout.
holder
.
getView
(
R
.
id
.
ivVedioItem
)
holder
.
getView
(
R
.
id
.
ivVedioItem
)
)
)
}
}
}
}
}
}
\ No newline at end of file
video/app/src/main/java/com/mints/helivideo/ui/fragment/MovieFragment.kt
View file @
b8430428
...
@@ -2,24 +2,23 @@ package com.mints.helivideo.ui.fragment
...
@@ -2,24 +2,23 @@ package com.mints.helivideo.ui.fragment
import
android.os.Bundle
import
android.os.Bundle
import
android.view.LayoutInflater
import
android.view.LayoutInflater
import
android.
view.View
import
android.
widget.FrameLayout
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.Fragment
import
androidx.recyclerview.widget.GridLayoutManager
import
com.mints.wisdomclean.ui.adapter.HotStyleAdapter
import
com.mints.helivideo.R
import
com.mints.helivideo.R
import
com.mints.helivideo.ad.express.ExpressAdCallback
import
com.mints.helivideo.ad.express.MainExpressManager
import
com.mints.helivideo.common.Constant
import
com.mints.helivideo.common.Constant
import
com.mints.helivideo.manager.LocalVedioManager
import
com.mints.helivideo.manager.LocalVedioManager
import
com.mints.helivideo.mvp.model.*
import
com.mints.helivideo.mvp.model.*
import
com.mints.helivideo.mvp.presenters.PicContentPresenter
import
com.mints.helivideo.mvp.presenters.PicContentPresenter
import
com.mints.helivideo.mvp.views.PicContentView
import
com.mints.helivideo.mvp.views.PicContentView
import
com.mints.helivideo.ui.adapter.NewHotStyleAdapter
import
com.mints.helivideo.ui.fragment.base.LazyLoadBaseFragment
import
com.mints.helivideo.ui.fragment.base.LazyLoadBaseFragment
import
com.scwang.smartrefresh.layout.api.RefreshLayout
import
com.scwang.smartrefresh.layout.api.RefreshLayout
import
com.scwang.smartrefresh.layout.listener.OnLoadMoreListener
import
com.scwang.smartrefresh.layout.listener.OnLoadMoreListener
import
com.mints.helivideo.common.AppConfig
import
com.mints.helivideo.common.AppConfig
import
com.mints.helivideo.ui.adapter.NewHotStyle2Adapter
import
com.mints.helivideo.ui.widgets.MyGridLayoutManager
import
com.mints.helivideo.ui.widgets.MyGridLayoutManager
import
kotlinx.android.synthetic.main.fragment_movie.*
import
kotlinx.android.synthetic.main.fragment_movie.*
import
java.util.*
class
MovieFragment
:
LazyLoadBaseFragment
(),
PicContentView
,
OnLoadMoreListener
{
class
MovieFragment
:
LazyLoadBaseFragment
(),
PicContentView
,
OnLoadMoreListener
{
...
@@ -43,9 +42,8 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
...
@@ -43,9 +42,8 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
private
val
picContentPresenter
by
lazy
{
PicContentPresenter
()
}
private
val
picContentPresenter
by
lazy
{
PicContentPresenter
()
}
private
var
hotPage
=
1
// 分页
private
var
hotPage
=
1
// 分页
private
val
hotList
:
ArrayList
<
VedioBean
>
=
arrayListOf
()
private
lateinit
var
hotStyleAdapter
:
NewHotStyleAdapter
private
lateinit
var
hotStyleAdapter
:
NewHotStyle2Adapter
// private lateinit var hotStyleAdapter: HotStyleAdapter
override
fun
getContentViewLayoutID
()
=
R
.
layout
.
fragment_movie
override
fun
getContentViewLayoutID
()
=
R
.
layout
.
fragment_movie
...
@@ -75,8 +73,10 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
...
@@ -75,8 +73,10 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
if
(
AppConfig
.
fragmentClickFlag
==
Constant
.
FRAGMENT_CLICK_ONE
)
{
if
(
AppConfig
.
fragmentClickFlag
==
Constant
.
FRAGMENT_CLICK_ONE
)
{
println
(
"mcg _______"
)
println
(
"mcg _______"
)
hotPage
=
1
hotPage
=
1
// hotList.clear()
srlMainPage
.
resetNoMoreData
()
srlMainPage
.
resetNoMoreData
()
MainExpressManager
.
instance
.
destroy
()
loadAd
()
picContentPresenter
.
getHomePageImageList
(
mType
,
hotPage
,
Constant
.
PAGE_SIZE
)
picContentPresenter
.
getHomePageImageList
(
mType
,
hotPage
,
Constant
.
PAGE_SIZE
)
}
}
...
@@ -84,6 +84,7 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
...
@@ -84,6 +84,7 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
override
fun
onLoadMore
(
refreshLayout
:
RefreshLayout
)
{
override
fun
onLoadMore
(
refreshLayout
:
RefreshLayout
)
{
hotPage
=
++
hotPage
hotPage
=
++
hotPage
loadAd
()
picContentPresenter
.
getHomePageImageList
(
mType
,
hotPage
,
Constant
.
PAGE_SIZE
)
picContentPresenter
.
getHomePageImageList
(
mType
,
hotPage
,
Constant
.
PAGE_SIZE
)
}
}
...
@@ -94,19 +95,16 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
...
@@ -94,19 +95,16 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
}
}
if
(
::
hotStyleAdapter
.
isInitialized
)
{
if
(
::
hotStyleAdapter
.
isInitialized
)
{
// hotList.addAll(data.list)
if
(
hotPage
==
1
)
{
if
(
hotPage
==
1
)
{
srlMainPage
.
finishRefresh
(
true
)
srlMainPage
.
finishRefresh
(
true
)
hotStyleAdapter
.
setNewInstance
(
data
.
list
)
hotStyleAdapter
.
setNewInstance
(
getAdapterData
(
data
.
list
))
// hotStyleAdapter.notifyDataSetChanged()
}
else
{
}
else
{
if
(
data
.
list
.
size
<
Constant
.
PAGE_SIZE
)
{
if
(
data
.
list
.
size
<
Constant
.
PAGE_SIZE
)
{
srlMainPage
.
finishLoadMoreWithNoMoreData
()
srlMainPage
.
finishLoadMoreWithNoMoreData
()
}
else
{
}
else
{
srlMainPage
.
finishLoadMore
()
srlMainPage
.
finishLoadMore
()
}
}
// hotStyleAdapter.notifyItemChanged(data.list.size)
hotStyleAdapter
.
addData
(
getAdapterData
(
data
.
list
))
hotStyleAdapter
.
addData
(
data
.
list
)
}
}
}
}
}
}
...
@@ -117,35 +115,19 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
...
@@ -117,35 +115,19 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
private
fun
initView
()
{
private
fun
initView
()
{
val
gridLayoutManager
=
MyGridLayoutManager
(
context
,
3
)
val
gridLayoutManager
=
MyGridLayoutManager
(
context
,
3
)
rv_pic_list
.
layoutManager
=
gridLayoutManager
rv_pic_list
.
layoutManager
=
gridLayoutManager
hotStyleAdapter
=
NewHotStyleAdapter
()
hotStyleAdapter
=
NewHotStyle
2
Adapter
()
rv_pic_list
.
adapter
=
hotStyleAdapter
rv_pic_list
.
adapter
=
hotStyleAdapter
val
emptyView
=
val
emptyView
=
LayoutInflater
.
from
(
requireContext
()).
inflate
(
R
.
layout
.
item_empty_data
,
null
)
LayoutInflater
.
from
(
requireContext
()).
inflate
(
R
.
layout
.
item_empty_data
,
null
)
hotStyleAdapter
.
setEmptyView
(
emptyView
)
hotStyleAdapter
.
setEmptyView
(
emptyView
)
// hotStyleAdapter.setNewInstance(hotList)
hotStyleAdapter
.
setOnItemClickListener
{
adapter
,
view
,
position
->
hotStyleAdapter
.
setOnItemClickListener
{
adapter
,
view
,
position
->
// if (hotList.size > 0
) {
if
(
hotStyleAdapter
.
data
[
position
].
itemType
==
MULTI_ITEM_1
)
{
LocalVedioManager
.
startVedioDetailActivityForType
(
LocalVedioManager
.
startVedioDetailActivityForType
(
requireActivity
(),
requireActivity
(),
hotStyleAdapter
.
data
.
get
(
position
)
hotStyleAdapter
.
data
[
position
].
video
)
)
//
}
}
}
}
// val gridLayoutManager = GridLayoutManager(context, 3)
// rv_pic_list.layoutManager = gridLayoutManager
// hotStyleAdapter = HotStyleAdapter(requireContext(), hotList)
// rv_pic_list.adapter = hotStyleAdapter
// hotStyleAdapter.setOnItemClickListener(object : HotStyleAdapter.OnItemClickListener {
// override fun onItemClick(position: Int) {
// if (hotList!=null&&hotList!!.size > 0) {
// LocalVedioManager.startVedioDetailActivityForType(
// requireActivity(),
// hotList!!.get(position)
// )
// }
// }
// })
}
}
private
fun
initListener
()
{
private
fun
initListener
()
{
...
@@ -153,4 +135,51 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
...
@@ -153,4 +135,51 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
srlMainPage
.
setOnLoadMoreListener
(
this
)
srlMainPage
.
setOnLoadMoreListener
(
this
)
}
}
private
fun
getAdapterData
(
list
:
List
<
VedioBean
>):
MutableList
<
VideoMultiItemEntity3
>
{
val
data
=
mutableListOf
<
VideoMultiItemEntity3
>()
for
(
item
in
list
)
{
data
.
add
(
VideoMultiItemEntity3
(
MULTI_ITEM_1
,
item
,
null
))
}
return
data
}
private
fun
loadAd
()
{
MainExpressManager
.
instance
.
loadAd
(
object
:
ExpressAdCallback
{
override
fun
loadSuccess
(
adView
:
FrameLayout
?)
{
}
override
fun
renderSuccess
(
adView
:
FrameLayout
?):
Boolean
{
adView
?.
let
{
addAdView
(
it
)
}
return
false
}
override
fun
loadFail
()
{
}
})
}
private
fun
addAdView
(
adView
:
FrameLayout
)
{
// 默认每各4个加1个
var
insertIndex
=
3
val
itemEntity3s
=
hotStyleAdapter
.
data
for
(
i
in
0
until
itemEntity3s
.
size
)
{
if
(
itemEntity3s
[
i
].
itemType
==
MULTI_ITEM_3
)
{
insertIndex
+=
4
}
}
if
(
insertIndex
>=
itemEntity3s
.
size
-
1
)
{
insertIndex
=
itemEntity3s
.
size
-
1
}
val
data
=
VideoMultiItemEntity3
(
MULTI_ITEM_3
,
null
,
adView
)
hotStyleAdapter
.
addData
(
insertIndex
,
data
)
}
override
fun
onDestroyView
()
{
super
.
onDestroyView
()
MainExpressManager
.
instance
.
destroy
()
}
}
}
\ No newline at end of file
video/app/src/main/java/com/mints/helivideo/utils/UIUtils.java
View file @
b8430428
...
@@ -291,6 +291,10 @@ public class UIUtils {
...
@@ -291,6 +291,10 @@ public class UIUtils {
return
getScreenWidth
(
context
)
-
dp2px
(
60
);
return
getScreenWidth
(
context
)
-
dp2px
(
60
);
}
}
public
static
float
getAdWidth3
(
Context
context
)
{
return
(
getScreenWidth
(
context
)
-
dp2px
(
50
))
/
3
f
;
}
public
static
float
getAdWidth2
(
Context
context
)
{
public
static
float
getAdWidth2
(
Context
context
)
{
return
getScreenWidth
(
context
)
-
dp2px
(
30
);
return
getScreenWidth
(
context
)
-
dp2px
(
30
);
}
}
...
...
video/app/src/main/res/layout/item_express_ad.xml
0 → 100644
View file @
b8430428
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/draw_view"
android:layout_width=
"match_parent"
android:layout_height=
"192dp"
>
<com.mints.helivideo.ui.widgets.RoundRectLayout
android:id=
"@+id/fl_ad"
android:layout_width=
"match_parent"
android:layout_height=
"192dp"
/>
</FrameLayout>
video/app/src/main/res/layout/item_hot_style.xml
View file @
b8430428
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/rlVedioItemRoot"
android:id=
"@+id/rlVedioItemRoot"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"
wrap_content
"
android:layout_height=
"
192dp
"
android:layout_marginTop=
"4dp"
android:layout_marginTop=
"4dp"
android:layout_marginBottom=
"6dp"
android:layout_marginBottom=
"6dp"
android:orientation=
"vertical"
android:orientation=
"vertical"
...
...
video/gradle.properties
View file @
b8430428
...
@@ -47,5 +47,6 @@ GROMORE_APP_ID="5412556"
...
@@ -47,5 +47,6 @@ GROMORE_APP_ID="5412556"
GROMORE_SPLASH_CODE="102398740"
GROMORE_SPLASH_CODE="102398740"
GROMORE_VIDEO_CODE
=
"102398300"
GROMORE_VIDEO_CODE
=
"102398300"
GROMORE_EXPRESS_CODE="102405261"
GROMORE_EXPRESS_CODE="102405261"
GROMORE_MAIN_EXPRESS_CODE
=
"102413160"
GROMORE_DRAW_CODE="102405069"
GROMORE_DRAW_CODE="102405069"
GROMORE_BANNER_CODE
=
"102405532"
GROMORE_BANNER_CODE
=
"102405532"
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