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
338b1c8e
Commit
338b1c8e
authored
Aug 04, 2023
by
jyx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化
parent
b50a7c37
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
248 additions
and
96 deletions
+248
-96
MainExpressManager.kt
...java/com/mints/helivideo/ad/express/MainExpressManager.kt
+4
-2
VideoMultiItemEntity.kt
...ava/com/mints/helivideo/mvp/model/VideoMultiItemEntity.kt
+1
-1
NewHotStyle2Adapter.kt
...ava/com/mints/helivideo/ui/adapter/NewHotStyle2Adapter.kt
+0
-61
NewHotStyleAdapter.kt
...java/com/mints/helivideo/ui/adapter/NewHotStyleAdapter.kt
+177
-0
MovieFragment.kt
...ain/java/com/mints/helivideo/ui/fragment/MovieFragment.kt
+29
-26
item_express_ad.xml
video/app/src/main/res/layout/item_express_ad.xml
+2
-2
item_hot_style.xml
video/app/src/main/res/layout/item_hot_style.xml
+1
-4
item_hot_style_root.xml
video/app/src/main/res/layout/item_hot_style_root.xml
+34
-0
No files found.
video/app/src/main/java/com/mints/helivideo/ad/express/MainExpressManager.kt
View file @
338b1c8e
...
...
@@ -52,8 +52,9 @@ class MainExpressManager {
* 2:如果是信息流模板广告,宽度设置为希望的宽度,高度设置为0(0为高度选择自适应参数)
*/
.
setImageAcceptedSize
(
UIUtils
.
getAdWidth3
(
MintsApplication
.
getContext
()).
toInt
(),
UIUtils
.
dip2px
(
MintsApplication
.
getContext
(),
192f
)
UIUtils
.
getAdWidth2
(
MintsApplication
.
getContext
()).
toInt
(),
// UIUtils.dip2px(MintsApplication.getContext(), 192f)
0
)
.
setAdCount
(
2
)
//请求广告数量为1到3条 (优先采用平台配置的数量)
.
build
()
...
...
@@ -173,6 +174,7 @@ class MainExpressManager {
for
(
ttFeedAd
in
mTTFeedAdList
)
{
ttFeedAd
.
destroy
()
}
mTTFeedAdList
.
clear
()
}
// private fun getSmallAdView(parent: ViewGroup?): View? {
...
...
video/app/src/main/java/com/mints/helivideo/mvp/model/VideoMultiItemEntity.kt
View file @
338b1c8e
...
...
@@ -22,6 +22,6 @@ data class VideoMultiItemEntity2(
data class
VideoMultiItemEntity3
(
override
val
itemType
:
Int
,
var
video
:
VedioBean
?,
var
video
s
:
List
<
VedioBean
>
?,
var
adView
:
FrameLayout
?
)
:
MultiItemEntity
,
java
.
io
.
Serializable
video/app/src/main/java/com/mints/helivideo/ui/adapter/NewHotStyle2Adapter.kt
deleted
100644 → 0
View file @
b50a7c37
package
com.mints.helivideo.ui.adapter
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.*
import
com.mints.helivideo.utils.UIUtils
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
,
"${if (it.completeStatus == 0) "
已完结
" else "
更新至$
{
it
.
vedioTotal
}
集
"}"
)
holder
.
setText
(
R
.
id
.
tvVedioItemTitle
,
"${it.title}"
)
holder
.
setText
(
R
.
id
.
tvVedioItemText
,
"${it.vedioDesc}"
)
GlideUtils
.
loadImageViewGifForCenterCrop
(
context
,
it
.
coverImage
,
holder
.
getView
(
R
.
id
.
ivVedioItem
)
)
}
}
}
\ No newline at end of file
video/app/src/main/java/com/mints/helivideo/ui/adapter/NewHotStyleAdapter.kt
0 → 100644
View file @
338b1c8e
package
com.mints.helivideo.ui.adapter
import
android.view.View
import
android.widget.FrameLayout
import
android.widget.TextView
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.*
import
com.mints.helivideo.utils.UIUtils
class
NewHotStyleAdapter
:
BaseMultiItemQuickAdapter
<
VideoMultiItemEntity3
,
BaseViewHolder
>()
{
init
{
addItemType
(
MULTI_ITEM_1
,
R
.
layout
.
item_hot_style_root
)
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
.
videos
)
}
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
:
List
<
VedioBean
>?)
{
item
?.
let
{
if
(
it
.
isEmpty
())
{
holder
.
getView
<
View
>(
R
.
id
.
item1
).
visibility
=
View
.
INVISIBLE
holder
.
getView
<
View
>(
R
.
id
.
item2
).
visibility
=
View
.
INVISIBLE
holder
.
getView
<
View
>(
R
.
id
.
item3
).
visibility
=
View
.
INVISIBLE
return
}
holder
.
getView
<
View
>(
R
.
id
.
item1
).
visibility
=
View
.
VISIBLE
holder
.
getView
<
View
>(
R
.
id
.
item1
)
.
findViewById
<
TextView
>(
R
.
id
.
tvVedioItemCount
)
.
text
=
"${if (it[0].completeStatus == 0) "
已完结
" else "
更新至$
{
it
[
0
].
vedioTotal
}
集
"}"
holder
.
getView
<
View
>(
R
.
id
.
item1
)
.
findViewById
<
TextView
>(
R
.
id
.
tvVedioItemTitle
)
.
text
=
"${it[0].title}"
holder
.
getView
<
View
>(
R
.
id
.
item1
)
.
findViewById
<
TextView
>(
R
.
id
.
tvVedioItemText
)
.
text
=
"${it[0].vedioDesc}"
GlideUtils
.
loadImageViewGifForCenterCrop
(
context
,
it
[
0
].
coverImage
,
holder
.
getView
<
View
>(
R
.
id
.
item1
)
.
findViewById
(
R
.
id
.
ivVedioItem
)
)
holder
.
getView
<
View
>(
R
.
id
.
item1
).
setOnClickListener
{
it1
->
mOnCustomChildClickListener
?.
onCustomChildClick
(
it1
,
it
[
0
])
}
if
(
it
.
size
<
2
)
{
holder
.
getView
<
View
>(
R
.
id
.
item2
).
visibility
=
View
.
INVISIBLE
holder
.
getView
<
View
>(
R
.
id
.
item3
).
visibility
=
View
.
INVISIBLE
return
}
holder
.
getView
<
View
>(
R
.
id
.
item2
).
visibility
=
View
.
VISIBLE
holder
.
getView
<
View
>(
R
.
id
.
item2
)
.
findViewById
<
TextView
>(
R
.
id
.
tvVedioItemCount
)
.
text
=
"${if (it[1].completeStatus == 0) "
已完结
" else "
更新至$
{
it
[
1
].
vedioTotal
}
集
"}"
holder
.
getView
<
View
>(
R
.
id
.
item2
)
.
findViewById
<
TextView
>(
R
.
id
.
tvVedioItemTitle
)
.
text
=
"${it[1].title}"
holder
.
getView
<
View
>(
R
.
id
.
item2
)
.
findViewById
<
TextView
>(
R
.
id
.
tvVedioItemText
)
.
text
=
"${it[1].vedioDesc}"
GlideUtils
.
loadImageViewGifForCenterCrop
(
context
,
it
[
1
].
coverImage
,
holder
.
getView
<
View
>(
R
.
id
.
item2
)
.
findViewById
(
R
.
id
.
ivVedioItem
)
)
holder
.
getView
<
View
>(
R
.
id
.
item2
).
setOnClickListener
{
it1
->
mOnCustomChildClickListener
?.
onCustomChildClick
(
it1
,
it
[
1
])
}
if
(
it
.
size
<
3
)
{
holder
.
getView
<
View
>(
R
.
id
.
item3
).
visibility
=
View
.
INVISIBLE
return
}
holder
.
getView
<
View
>(
R
.
id
.
item3
).
visibility
=
View
.
VISIBLE
holder
.
getView
<
View
>(
R
.
id
.
item3
)
.
findViewById
<
TextView
>(
R
.
id
.
tvVedioItemCount
)
.
text
=
"${if (it[2].completeStatus == 0) "
已完结
" else "
更新至$
{
it
[
2
].
vedioTotal
}
集
"}"
holder
.
getView
<
View
>(
R
.
id
.
item3
)
.
findViewById
<
TextView
>(
R
.
id
.
tvVedioItemTitle
)
.
text
=
"${it[2].title}"
holder
.
getView
<
View
>(
R
.
id
.
item3
)
.
findViewById
<
TextView
>(
R
.
id
.
tvVedioItemText
)
.
text
=
"${it[2].vedioDesc}"
GlideUtils
.
loadImageViewGifForCenterCrop
(
context
,
it
[
2
].
coverImage
,
holder
.
getView
<
View
>(
R
.
id
.
item3
)
.
findViewById
(
R
.
id
.
ivVedioItem
)
)
holder
.
getView
<
View
>(
R
.
id
.
item3
).
setOnClickListener
{
it1
->
mOnCustomChildClickListener
?.
onCustomChildClick
(
it1
,
it
[
2
])
}
// for (vedio in it) {
// val itemView =
// LayoutInflater.from(context).inflate(R.layout.item_hot_style, null)
//
// itemView.findViewById<TextView>(R.id.tvVedioItemCount).text =
// "${if (vedio.completeStatus == 0) "已完结" else "更新至${vedio.vedioTotal}集"}"
// itemView.findViewById<TextView>(R.id.tvVedioItemTitle).text = "${vedio.title}"
// itemView.findViewById<TextView>(R.id.tvVedioItemText).text =
// "${vedio.vedioDesc}"
// GlideUtils.loadImageViewGifForCenterCrop(
// context,
// vedio.coverImage,
// itemView.findViewById(R.id.ivVedioItem)
// )
// mOnCustomChildClickListener?.onCustomChildClick(itemView, vedio)
// val layoutParams = LinearLayout.LayoutParams(
// LinearLayout.LayoutParams.MATCH_PARENT,
// LinearLayout.LayoutParams.MATCH_PARENT
// )
// layoutParams.weight = 1f
// itemView.layoutParams = layoutParams
// rootView.addView(itemView)
// }
}
// item?.let {
// holder.setText(
// R.id.tvVedioItemCount,
// "${if (it.completeStatus == 0) "已完结" else "更新至${it.vedioTotal}集"}"
// )
// holder.setText(
// R.id.tvVedioItemTitle,
// "${it.title}"
// )
// holder.setText(
// R.id.tvVedioItemText,
// "${it.vedioDesc}"
// )
// GlideUtils.loadImageViewGifForCenterCrop(
// context,
// it.coverImage,
// holder.getView(R.id.ivVedioItem)
// )
// }
}
private
var
mOnCustomChildClickListener
:
OnCustomChildClickListener
?
=
null
fun
setOnCustomChildClickListener
(
onCustomChildClickListener
:
OnCustomChildClickListener
)
{
this
.
mOnCustomChildClickListener
=
onCustomChildClickListener
}
interface
OnCustomChildClickListener
{
fun
onCustomChildClick
(
view
:
View
,
vedioBean
:
VedioBean
)
}
}
\ No newline at end of file
video/app/src/main/java/com/mints/helivideo/ui/fragment/MovieFragment.kt
View file @
338b1c8e
...
...
@@ -2,8 +2,10 @@ 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.LinearLayoutManager
import
com.mints.helivideo.R
import
com.mints.helivideo.ad.express.ExpressAdCallback
import
com.mints.helivideo.ad.express.MainExpressManager
...
...
@@ -17,9 +19,8 @@ import com.scwang.smartrefresh.layout.api.RefreshLayout
import
com.scwang.smartrefresh.layout.listener.OnLoadMoreListener
import
com.mints.helivideo.common.AppConfig
import
com.mints.helivideo.manager.UserManager
import
com.mints.helivideo.ui.adapter.NewHotStyle2Adapter
import
com.mints.helivideo.ui.widgets.MyGridLayoutManager
import
com.mints.helivideo.utils.LogUtil
import
com.mints.helivideo.ui.adapter.NewHotStyleAdapter
import
com.mints.helivideo.utils.CommonUtils
import
kotlinx.android.synthetic.main.fragment_movie.*
class
MovieFragment
:
LazyLoadBaseFragment
(),
PicContentView
,
OnLoadMoreListener
{
...
...
@@ -45,7 +46,7 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
private
var
hotPage
=
1
// 分页
private
lateinit
var
hotStyleAdapter
:
NewHotStyle
2
Adapter
private
lateinit
var
hotStyleAdapter
:
NewHotStyleAdapter
override
fun
getContentViewLayoutID
()
=
R
.
layout
.
fragment_movie
...
...
@@ -77,8 +78,7 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
hotPage
=
1
srlMainPage
.
resetNoMoreData
()
MainExpressManager
.
instance
.
destroy
()
// loadAd()
loadAd
()
picContentPresenter
.
getHomePageImageList
(
mType
,
hotPage
,
Constant
.
PAGE_SIZE
)
}
...
...
@@ -103,7 +103,7 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
if
(
data
.
list
.
size
<
Constant
.
PAGE_SIZE
)
{
srlMainPage
.
finishLoadMoreWithNoMoreData
()
}
else
{
//
loadAd()
loadAd
()
srlMainPage
.
finishLoadMore
()
}
hotStyleAdapter
.
addData
(
getAdapterData
(
data
.
list
))
...
...
@@ -111,25 +111,25 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
}
}
override
fun
getHomePageImageListFail
()
{
}
override
fun
getHomePageImageListFail
()
{}
private
fun
initView
()
{
val
gridLayoutManager
=
MyGridLayoutManager
(
context
,
3
)
rv_pic_list
.
layoutManager
=
gridLayoutManager
hotStyleAdapter
=
NewHotStyle2Adapter
()
rv_pic_list
.
layoutManager
=
LinearLayoutManager
(
context
)
hotStyleAdapter
=
NewHotStyleAdapter
()
hotStyleAdapter
.
animationEnable
=
false
rv_pic_list
.
adapter
=
hotStyleAdapter
val
emptyView
=
LayoutInflater
.
from
(
requireContext
()).
inflate
(
R
.
layout
.
item_empty_data
,
null
)
hotStyleAdapter
.
setEmptyView
(
emptyView
)
hotStyleAdapter
.
setOnItemClickListener
{
adapter
,
view
,
position
->
if
(
hotStyleAdapter
.
data
[
position
].
itemType
==
MULTI_ITEM_1
)
{
hotStyleAdapter
.
setOnCustomChildClickListener
(
object
:
NewHotStyleAdapter
.
OnCustomChildClickListener
{
override
fun
onCustomChildClick
(
view
:
View
,
vedioBean
:
VedioBean
)
{
LocalVedioManager
.
startVedioDetailActivityForType
(
requireActivity
(),
hotStyleAdapter
.
data
[
position
].
video
vedioBean
)
}
}
}
)
}
private
fun
initListener
()
{
...
...
@@ -139,8 +139,9 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
private
fun
getAdapterData
(
list
:
List
<
VedioBean
>):
MutableList
<
VideoMultiItemEntity3
>
{
val
data
=
mutableListOf
<
VideoMultiItemEntity3
>()
for
(
item
in
list
)
{
data
.
add
(
VideoMultiItemEntity3
(
MULTI_ITEM_1
,
item
,
null
))
val
subList
=
CommonUtils
.
getSubList
(
3
,
list
)
for
(
itemEntity3s
in
subList
)
{
data
.
add
(
VideoMultiItemEntity3
(
MULTI_ITEM_1
,
itemEntity3s
,
null
))
}
return
data
}
...
...
@@ -164,19 +165,21 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
}
private
fun
addAdView
(
adView
:
FrameLayout
)
{
// 默认每各
4
个加1个
var
insertIndex
=
3
// 默认每各
6
个加1个
var
insertIndex
=
2
val
itemEntity3s
=
hotStyleAdapter
.
data
for
(
i
in
itemEntity3s
.
size
-
1
downTo
0
)
{
if
(
itemEntity3s
[
i
].
itemType
==
MULTI_ITEM_3
)
{
insertIndex
+=
4
val
allData
=
hotStyleAdapter
.
data
for
(
i
in
allData
.
size
-
1
downTo
0
)
{
if
(
allData
[
i
].
itemType
==
MULTI_ITEM_3
)
{
insertIndex
+=
3
}
}
if
(
insertIndex
>=
itemEntity3s
.
size
)
{
insertIndex
=
itemEntity3s
.
size
if
(
insertIndex
>=
allData
.
size
)
{
insertIndex
=
allData
.
size
}
if
(
allData
[
allData
.
lastIndex
].
itemType
==
MULTI_ITEM_3
)
return
val
data
=
VideoMultiItemEntity3
(
MULTI_ITEM_3
,
null
,
adView
)
hotStyleAdapter
.
addData
(
insertIndex
,
data
)
}
...
...
video/app/src/main/res/layout/item_express_ad.xml
View file @
338b1c8e
...
...
@@ -2,11 +2,11 @@
<FrameLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/draw_view"
android:layout_width=
"match_parent"
android:layout_height=
"
192dp
"
>
android:layout_height=
"
wrap_content
"
>
<com.mints.helivideo.ui.widgets.RoundRectLayout
android:id=
"@+id/fl_ad"
android:layout_width=
"match_parent"
android:layout_height=
"
192dp
"
/>
android:layout_height=
"
wrap_content
"
/>
</FrameLayout>
video/app/src/main/res/layout/item_hot_style.xml
View file @
338b1c8e
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/rlVedioItemRoot"
android:layout_width=
"match_parent"
android:layout_height=
"192dp"
android:layout_marginTop=
"4dp"
android:layout_marginBottom=
"6dp"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:paddingLeft=
"5dp"
android:paddingRight=
"5dp"
>
...
...
video/app/src/main/res/layout/item_hot_style_root.xml
0 → 100644
View file @
338b1c8e
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/root_view"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"4dp"
android:layout_marginBottom=
"6dp"
android:orientation=
"horizontal"
>
<include
android:id=
"@+id/item1"
layout=
"@layout/item_hot_style"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:visibility=
"invisible"
/>
<include
android:id=
"@+id/item2"
layout=
"@layout/item_hot_style"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:visibility=
"invisible"
/>
<include
android:id=
"@+id/item3"
layout=
"@layout/item_hot_style"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
android:visibility=
"invisible"
/>
</LinearLayout>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment