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
4a940003
Commit
4a940003
authored
Jun 29, 2023
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化
parent
52722928
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
160 additions
and
11 deletions
+160
-11
HomeVideoPageAdapter.kt
.../com/mints/wisdomclean/ui/adapter/HomeVideoPageAdapter.kt
+6
-3
HotStyleAdapter.kt
.../java/com/mints/wisdomclean/ui/adapter/HotStyleAdapter.kt
+86
-0
MainFragment.kt
...in/java/com/mints/wisdomclean/ui/fragment/MainFragment.kt
+2
-1
MovieFragment.kt
...n/java/com/mints/wisdomclean/ui/fragment/MovieFragment.kt
+8
-6
fragment_movie.xml
video/app/src/main/res/layout/fragment_movie.xml
+0
-1
item_hot_style.xml
video/app/src/main/res/layout/item_hot_style.xml
+58
-0
No files found.
video/app/src/main/java/com/mints/wisdomclean/ui/adapter/HomeVideoPageAdapter.kt
View file @
4a940003
...
@@ -19,16 +19,19 @@ class HomeVideoPageAdapter(
...
@@ -19,16 +19,19 @@ class HomeVideoPageAdapter(
private
val
fragments
=
mutableMapOf
<
Int
,
Fragment
>()
private
val
fragments
=
mutableMapOf
<
Int
,
Fragment
>()
override
fun
getItemId
(
position
:
Int
):
Long
{
override
fun
getItemId
(
position
:
Int
):
Long
{
return
data
[
position
].
id
.
toLong
()
// return data[position].id.toLong()
return
0
}
}
override
fun
getItemCount
()
=
data
.
size
// override fun getItemCount() = data.size
override
fun
getItemCount
()
=
10
override
fun
createFragment
(
position
:
Int
):
Fragment
{
override
fun
createFragment
(
position
:
Int
):
Fragment
{
val
fragment
=
fragments
[
position
]
val
fragment
=
fragments
[
position
]
if
(
fragment
!=
null
)
return
fragment
if
(
fragment
!=
null
)
return
fragment
val
newFragment
=
MovieFragment
.
newInstance
(
data
[
position
].
id
,
position
)
// val newFragment = MovieFragment.newInstance(data[position].id,position)
val
newFragment
=
MovieFragment
.
newInstance
(
1
,
position
)
fragments
[
position
]
=
newFragment
fragments
[
position
]
=
newFragment
return
newFragment
return
newFragment
}
}
...
...
video/app/src/main/java/com/mints/wisdomclean/ui/adapter/HotStyleAdapter.kt
0 → 100644
View file @
4a940003
package
com.mints.wisdomclean.ui.adapter
import
android.content.Context
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.ImageView
import
android.widget.TextView
import
androidx.recyclerview.widget.RecyclerView
import
com.airbnb.lottie.*
import
com.daimajia.androidanimations.library.Techniques
import
com.daimajia.androidanimations.library.YoYo
import
com.itheima.roundedimageview.RoundedImageView
import
com.mints.wisdomclean.R
import
com.mints.wisdomclean.mvp.model.HotStyleBean
import
com.mints.wisdomclean.ui.adapter.base.OnItemClickListener
class
HotStyleAdapter
(
val
context
:
Context
,
val
dataList
:
ArrayList
<
HotStyleBean
>)
:
RecyclerView
.
Adapter
<
RecyclerView
.
ViewHolder
>()
{
lateinit
var
mOnItemClickListener
:
OnItemClickListener
private
var
showAnim
=
true
inner
class
ViewHolder
(
view
:
View
)
:
RecyclerView
.
ViewHolder
(
view
)
{
val
rivXmlyPage
:
RoundedImageView
=
view
.
findViewById
(
R
.
id
.
riv_img
)
val
ivXmlyPage
:
ImageView
=
view
.
findViewById
(
R
.
id
.
iv_img
)
val
tvTitle
:
TextView
=
view
.
findViewById
(
R
.
id
.
tv_title
)
val
tvHotBtn
:
TextView
=
view
.
findViewById
(
R
.
id
.
tv_hot_btn
)
}
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
RecyclerView
.
ViewHolder
{
val
view
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
item_hot_style
,
parent
,
false
)
return
ViewHolder
(
view
)
}
override
fun
onBindViewHolder
(
holder
:
RecyclerView
.
ViewHolder
,
position
:
Int
)
{
val
viewHolder
=
holder
as
ViewHolder
if
(
dataList
.
size
>
0
)
{
val
data
=
dataList
[
position
]
if
(
position
==
0
&&
showAnim
)
{
val
lottieDrawable
=
LottieDrawable
()
LottieCompositionFactory
.
fromAsset
(
context
,
"guide_template_category.json"
)
.
addListener
{
result
:
LottieComposition
?
->
lottieDrawable
.
setImagesAssetsFolder
(
"guild_template_category/"
)
lottieDrawable
.
composition
=
result
lottieDrawable
.
loop
(
true
)
lottieDrawable
.
playAnimation
()
}
holder
.
ivXmlyPage
.
setImageDrawable
(
lottieDrawable
)
holder
.
ivXmlyPage
.
visibility
=
View
.
VISIBLE
holder
.
tvHotBtn
.
visibility
=
View
.
VISIBLE
holder
.
rivXmlyPage
.
visibility
=
View
.
GONE
holder
.
tvHotBtn
.
postDelayed
({
YoYo
.
with
(
Techniques
.
Pulse
).
duration
(
500
).
repeat
(-
1
).
playOn
(
holder
.
tvHotBtn
)
},
300
)
}
else
{
// GlideUtils.loadRoundImageViewGif(
// holder.itemView.context,
// data.imageUrl!!,
// holder.rivXmlyPage
// )
holder
.
ivXmlyPage
.
visibility
=
View
.
GONE
holder
.
tvHotBtn
.
visibility
=
View
.
GONE
holder
.
rivXmlyPage
.
visibility
=
View
.
VISIBLE
}
viewHolder
.
tvTitle
.
text
=
data
.
name
viewHolder
.
itemView
.
setOnClickListener
{
if
(
::
mOnItemClickListener
.
isInitialized
)
{
mOnItemClickListener
.
onItemClick
(
holder
.
itemView
,
position
)
}
}
}
}
override
fun
getItemCount
():
Int
=
30
fun
setOnItemClickListener
(
listener
:
OnItemClickListener
)
{
mOnItemClickListener
=
listener
}
fun
setShowAnim
(
showAnim
:
Boolean
)
{
this
.
showAnim
=
showAnim
}
}
\ No newline at end of file
video/app/src/main/java/com/mints/wisdomclean/ui/fragment/MainFragment.kt
View file @
4a940003
...
@@ -162,7 +162,8 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener, OnRefreshLi
...
@@ -162,7 +162,8 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener, OnRefreshLi
TabLayoutMediator
(
tablayout
,
vp2
)
{
tab
,
position
->
TabLayoutMediator
(
tablayout
,
vp2
)
{
tab
,
position
->
// 初始化Tab
// 初始化Tab
tab
.
id
=
position
tab
.
id
=
position
tab
.
customView
=
getTabView
(
tabsData
[
position
].
title
)
tab
.
customView
=
getTabView
(
"123"
)
// tab.customView = getTabView(tabsData[position].title)
}.
attach
()
}.
attach
()
tablayout
.
addOnTabSelectedListener
(
object
:
TabLayout
.
OnTabSelectedListener
{
tablayout
.
addOnTabSelectedListener
(
object
:
TabLayout
.
OnTabSelectedListener
{
override
fun
onTabSelected
(
tab
:
TabLayout
.
Tab
?)
{
override
fun
onTabSelected
(
tab
:
TabLayout
.
Tab
?)
{
...
...
video/app/src/main/java/com/mints/wisdomclean/ui/fragment/MovieFragment.kt
View file @
4a940003
...
@@ -3,8 +3,10 @@ package com.mints.wisdomclean.ui.fragment
...
@@ -3,8 +3,10 @@ package com.mints.wisdomclean.ui.fragment
import
android.os.Bundle
import
android.os.Bundle
import
android.view.View
import
android.view.View
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.Fragment
import
androidx.recyclerview.widget.GridLayoutManager
import
com.mints.wisdomclean.R
import
com.mints.wisdomclean.R
import
com.mints.wisdomclean.mvp.model.*
import
com.mints.wisdomclean.mvp.model.*
import
com.mints.wisdomclean.ui.adapter.HotStyleAdapter
import
com.mints.wisdomclean.ui.fragment.base.LazyLoadBaseFragment
import
com.mints.wisdomclean.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
...
@@ -35,7 +37,7 @@ class MovieFragment : LazyLoadBaseFragment(), OnLoadMoreListener {
...
@@ -35,7 +37,7 @@ class MovieFragment : LazyLoadBaseFragment(), OnLoadMoreListener {
private
var
hotPage
=
1
// 分页
private
var
hotPage
=
1
// 分页
private
val
hotList
:
ArrayList
<
HotStyleBean
>
=
arrayListOf
()
private
val
hotList
:
ArrayList
<
HotStyleBean
>
=
arrayListOf
()
//
private lateinit var hotStyleAdapter: HotStyleAdapter
private
lateinit
var
hotStyleAdapter
:
HotStyleAdapter
private
var
mCurrentPosition
=
0
private
var
mCurrentPosition
=
0
override
fun
getContentViewLayoutID
()
=
R
.
layout
.
fragment_movie
override
fun
getContentViewLayoutID
()
=
R
.
layout
.
fragment_movie
...
@@ -109,11 +111,11 @@ class MovieFragment : LazyLoadBaseFragment(), OnLoadMoreListener {
...
@@ -109,11 +111,11 @@ class MovieFragment : LazyLoadBaseFragment(), OnLoadMoreListener {
// }
// }
private
fun
initView
()
{
private
fun
initView
()
{
// val gridLayoutManager = GridLayoutManager(context, 2
)
val
gridLayoutManager
=
GridLayoutManager
(
context
,
3
)
//
rv_pic_list.layoutManager = gridLayoutManager
rv_pic_list
.
layoutManager
=
gridLayoutManager
//
hotStyleAdapter = HotStyleAdapter(requireContext(), hotList)
hotStyleAdapter
=
HotStyleAdapter
(
requireContext
(),
hotList
)
//
hotStyleAdapter.setShowAnim(mPosition == 0)
hotStyleAdapter
.
setShowAnim
(
mPosition
==
0
)
//
rv_pic_list.adapter = hotStyleAdapter
rv_pic_list
.
adapter
=
hotStyleAdapter
// hotStyleAdapter.setOnItemClickListener(object : OnItemClickListener {
// hotStyleAdapter.setOnItemClickListener(object : OnItemClickListener {
// override fun onItemClick(view: View?, position: Int) {
// override fun onItemClick(view: View?, position: Int) {
// if (hotList.size > 0) {
// if (hotList.size > 0) {
...
...
video/app/src/main/res/layout/fragment_movie.xml
View file @
4a940003
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:minHeight=
"600dp"
android:minHeight=
"600dp"
android:background=
"#f00"
android:overScrollMode=
"never"
/>
android:overScrollMode=
"never"
/>
<com.scwang.smartrefresh.layout.footer.ClassicsFooter
<com.scwang.smartrefresh.layout.footer.ClassicsFooter
...
...
video/app/src/main/res/layout/item_hot_style.xml
0 → 100644
View file @
4a940003
<?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"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_margin=
"4dp"
android:background=
"@color/red"
android:orientation=
"vertical"
>
<FrameLayout
android:layout_width=
"match_parent"
android:layout_height=
"235dp"
android:layout_marginLeft=
"6dp"
android:layout_marginRight=
"6dp"
>
<ImageView
android:id=
"@+id/iv_img"
android:scaleType=
"centerCrop"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
<TextView
android:id=
"@+id/tv_hot_btn"
android:layout_width=
"134dp"
android:layout_height=
"28dp"
android:textSize=
"14sp"
android:visibility=
"gone"
android:layout_gravity=
"center_horizontal|bottom"
android:layout_marginBottom=
"24dp"
android:gravity=
"center"
android:textStyle=
"bold"
android:textColor=
"@color/white"
android:text=
"点击做同款"
></TextView>
<com.itheima.roundedimageview.RoundedImageView
android:id=
"@+id/riv_img"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:scaleType=
"centerCrop"
app:riv_corner_radius=
"5dp"
/>
</FrameLayout>
<TextView
android:id=
"@+id/tv_title"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"2dp"
android:layout_marginBottom=
"2dp"
android:ellipsize=
"end"
android:lines=
"1"
android:singleLine=
"true"
android:textColor=
"#A7A8AA"
android:textSize=
"14sp"
android:textStyle=
"bold"
/>
</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