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
ccabf673
Commit
ccabf673
authored
Aug 07, 2023
by
mengcuiguang2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化
parent
982a6c58
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
MainFragment.kt
...main/java/com/mints/helivideo/ui/fragment/MainFragment.kt
+17
-0
No files found.
video/app/src/main/java/com/mints/helivideo/ui/fragment/MainFragment.kt
View file @
ccabf673
...
...
@@ -8,6 +8,8 @@ import android.view.View
import
android.widget.TextView
import
androidx.core.content.ContextCompat
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
androidx.viewpager2.widget.ViewPager2
import
com.google.android.material.tabs.TabLayout
import
com.google.android.material.tabs.TabLayoutMediator
import
com.scwang.smartrefresh.layout.api.RefreshLayout
...
...
@@ -34,6 +36,7 @@ import com.mints.helivideo.utils.SpanUtils
import
com.mints.library.utils.GlideUtils
import
com.mints.library.utils.nodoubleclick.AntiShake
import
kotlinx.android.synthetic.main.fragment_main.*
import
java.lang.reflect.Field
import
java.util.*
import
kotlin.concurrent.schedule
...
...
@@ -186,6 +189,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
vpAdapter
=
HomeVideoPageAdapter
(
tabsData
,
this
)
vp2
.
adapter
=
vpAdapter
vp2
.
desensitization
()
TabLayoutMediator
(
tablayout
,
vp2
)
{
tab
,
position
->
// 初始化Tab
tab
.
id
=
position
...
...
@@ -349,4 +353,17 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
}
}
fun
ViewPager2
.
desensitization
(){
//动态设置ViewPager2 灵敏度
try
{
val
recyclerViewField
:
Field
=
ViewPager2
::
class
.
java
.
getDeclaredField
(
"mRecyclerView"
)
recyclerViewField
.
isAccessible
=
true
val
recyclerView
=
recyclerViewField
.
get
(
this
)
as
RecyclerView
val
touchSlopField
:
Field
=
RecyclerView
::
class
.
java
.
getDeclaredField
(
"mTouchSlop"
)
touchSlopField
.
isAccessible
=
true
val
touchSlop
=
touchSlopField
.
get
(
recyclerView
)
as
Int
touchSlopField
.
set
(
recyclerView
,
touchSlop
*
3
)
//6 is empirical value
}
catch
(
ignore
:
java
.
lang
.
Exception
)
{
}
}
}
\ 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