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
Expand all
Show 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 {
buildConfigField
"String"
,
"GROMORE_VIDEO_CODE"
,
GROMORE_VIDEO_CODE
buildConfigField
"String"
,
"GROMORE_DRAW_CODE"
,
GROMORE_DRAW_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"
,
"WEIXIN_APP_PAY_ID"
,
WEIXIN_APP_PAY_ID
...
...
@@ -88,6 +89,7 @@ android {
buildConfigField
"String"
,
"GROMORE_VIDEO_CODE"
,
GROMORE_VIDEO_CODE
buildConfigField
"String"
,
"GROMORE_DRAW_CODE"
,
GROMORE_DRAW_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"
,
"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
This diff is collapsed.
Click to expand it.
video/app/src/main/java/com/mints/helivideo/mvp/model/VideoMultiItemEntity.kt
View file @
b8430428
package
com.mints.helivideo.mvp.model
import
android.widget.FrameLayout
import
com.chad.library.adapter.base.entity.MultiItemEntity
import
com.mints.helivideo.video.tx.VideoModel
...
...
@@ -18,3 +19,9 @@ data class VideoMultiItemEntity2(
var
video
:
VedioBean
?,
var
videoModel
:
VideoModel
?
)
:
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
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.mints.library.utils.GlideUtils
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
)
{
override
fun
convert
(
holder
:
BaseViewHolder
,
item
:
VedioBean
)
{
class
NewHotStyle2Adapter
:
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
{
holder
.
setText
(
R
.
id
.
tvVedioItemCount
,
...
...
@@ -27,7 +56,6 @@ class NewHotStyleAdapter : BaseQuickAdapter<VedioBean, BaseViewHolder>(R.layout.
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
import
android.os.Bundle
import
android.view.LayoutInflater
import
android.
view.View
import
android.
widget.FrameLayout
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.ad.express.ExpressAdCallback
import
com.mints.helivideo.ad.express.MainExpressManager
import
com.mints.helivideo.common.Constant
import
com.mints.helivideo.manager.LocalVedioManager
import
com.mints.helivideo.mvp.model.*
import
com.mints.helivideo.mvp.presenters.PicContentPresenter
import
com.mints.helivideo.mvp.views.PicContentView
import
com.mints.helivideo.ui.adapter.NewHotStyleAdapter
import
com.mints.helivideo.ui.fragment.base.LazyLoadBaseFragment
import
com.scwang.smartrefresh.layout.api.RefreshLayout
import
com.scwang.smartrefresh.layout.listener.OnLoadMoreListener
import
com.mints.helivideo.common.AppConfig
import
com.mints.helivideo.ui.adapter.NewHotStyle2Adapter
import
com.mints.helivideo.ui.widgets.MyGridLayoutManager
import
kotlinx.android.synthetic.main.fragment_movie.*
import
java.util.*
class
MovieFragment
:
LazyLoadBaseFragment
(),
PicContentView
,
OnLoadMoreListener
{
...
...
@@ -43,9 +42,8 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
private
val
picContentPresenter
by
lazy
{
PicContentPresenter
()
}
private
var
hotPage
=
1
// 分页
private
val
hotList
:
ArrayList
<
VedioBean
>
=
arrayListOf
()
private
lateinit
var
hotStyleAdapter
:
NewHotStyleAdapter
// private lateinit var hotStyleAdapter: HotStyleAdapter
private
lateinit
var
hotStyleAdapter
:
NewHotStyle2Adapter
override
fun
getContentViewLayoutID
()
=
R
.
layout
.
fragment_movie
...
...
@@ -75,8 +73,10 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
if
(
AppConfig
.
fragmentClickFlag
==
Constant
.
FRAGMENT_CLICK_ONE
)
{
println
(
"mcg _______"
)
hotPage
=
1
// hotList.clear()
srlMainPage
.
resetNoMoreData
()
MainExpressManager
.
instance
.
destroy
()
loadAd
()
picContentPresenter
.
getHomePageImageList
(
mType
,
hotPage
,
Constant
.
PAGE_SIZE
)
}
...
...
@@ -84,6 +84,7 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
override
fun
onLoadMore
(
refreshLayout
:
RefreshLayout
)
{
hotPage
=
++
hotPage
loadAd
()
picContentPresenter
.
getHomePageImageList
(
mType
,
hotPage
,
Constant
.
PAGE_SIZE
)
}
...
...
@@ -94,19 +95,16 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
}
if
(
::
hotStyleAdapter
.
isInitialized
)
{
// hotList.addAll(data.list)
if
(
hotPage
==
1
)
{
srlMainPage
.
finishRefresh
(
true
)
hotStyleAdapter
.
setNewInstance
(
data
.
list
)
// hotStyleAdapter.notifyDataSetChanged()
hotStyleAdapter
.
setNewInstance
(
getAdapterData
(
data
.
list
))
}
else
{
if
(
data
.
list
.
size
<
Constant
.
PAGE_SIZE
)
{
srlMainPage
.
finishLoadMoreWithNoMoreData
()
}
else
{
srlMainPage
.
finishLoadMore
()
}
// hotStyleAdapter.notifyItemChanged(data.list.size)
hotStyleAdapter
.
addData
(
data
.
list
)
hotStyleAdapter
.
addData
(
getAdapterData
(
data
.
list
))
}
}
}
...
...
@@ -117,35 +115,19 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
private
fun
initView
()
{
val
gridLayoutManager
=
MyGridLayoutManager
(
context
,
3
)
rv_pic_list
.
layoutManager
=
gridLayoutManager
hotStyleAdapter
=
NewHotStyleAdapter
()
hotStyleAdapter
=
NewHotStyle
2
Adapter
()
rv_pic_list
.
adapter
=
hotStyleAdapter
val
emptyView
=
LayoutInflater
.
from
(
requireContext
()).
inflate
(
R
.
layout
.
item_empty_data
,
null
)
hotStyleAdapter
.
setEmptyView
(
emptyView
)
// hotStyleAdapter.setNewInstance(hotList)
hotStyleAdapter
.
setOnItemClickListener
{
adapter
,
view
,
position
->
// if (hotList.size > 0
) {
if
(
hotStyleAdapter
.
data
[
position
].
itemType
==
MULTI_ITEM_1
)
{
LocalVedioManager
.
startVedioDetailActivityForType
(
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
()
{
...
...
@@ -153,4 +135,51 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
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 {
return
getScreenWidth
(
context
)
-
dp2px
(
60
);
}
public
static
float
getAdWidth3
(
Context
context
)
{
return
(
getScreenWidth
(
context
)
-
dp2px
(
50
))
/
3
f
;
}
public
static
float
getAdWidth2
(
Context
context
)
{
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"?>
<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:layout_width=
"match_parent"
android:layout_height=
"
wrap_content
"
android:layout_height=
"
192dp
"
android:layout_marginTop=
"4dp"
android:layout_marginBottom=
"6dp"
android:orientation=
"vertical"
...
...
video/gradle.properties
View file @
b8430428
...
...
@@ -47,5 +47,6 @@ GROMORE_APP_ID="5412556"
GROMORE_SPLASH_CODE="102398740"
GROMORE_VIDEO_CODE
=
"102398300"
GROMORE_EXPRESS_CODE="102405261"
GROMORE_MAIN_EXPRESS_CODE
=
"102413160"
GROMORE_DRAW_CODE="102405069"
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