Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
A
appzxhy
Project
Project
Details
Activity
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
appzxhy
Commits
aaf58ba6
Commit
aaf58ba6
authored
Jun 25, 2025
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[拆包]首页水波纹
parent
5c3305f7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
47 deletions
+101
-47
HomeFragment.kt
app/src/main/java/com/base/appzxhy/ui/main/HomeFragment.kt
+82
-32
fragment_home1.xml
app/src/main/res/layout/fragment_home1.xml
+19
-15
No files found.
app/src/main/java/com/base/appzxhy/ui/main/HomeFragment.kt
View file @
aaf58ba6
...
@@ -33,10 +33,14 @@ import com.base.appzxhy.ui.dialog.permissionStorageJump
...
@@ -33,10 +33,14 @@ import com.base.appzxhy.ui.dialog.permissionStorageJump
import
com.base.appzxhy.ui.set.SettingActivity
import
com.base.appzxhy.ui.set.SettingActivity
import
com.base.appzxhy.utils.BarUtils
import
com.base.appzxhy.utils.BarUtils
import
com.base.appzxhy.utils.KotlinExt.toFormatSize
import
com.base.appzxhy.utils.KotlinExt.toFormatSize
import
com.base.appzxhy.utils.LogEx
import
com.base.appzxhy.utils.Utils
import
com.base.appzxhy.utils.Utils
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.async
import
kotlinx.coroutines.async
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.isActive
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.launch
import
kotlin.random.Random
class
HomeFragment
:
BaseFragment
<
FragmentHome1Binding
>(
FragmentHome1Binding
::
inflate
)
{
class
HomeFragment
:
BaseFragment
<
FragmentHome1Binding
>(
FragmentHome1Binding
::
inflate
)
{
...
@@ -125,8 +129,85 @@ class HomeFragment : BaseFragment<FragmentHome1Binding>(FragmentHome1Binding::in
...
@@ -125,8 +129,85 @@ class HomeFragment : BaseFragment<FragmentHome1Binding>(FragmentHome1Binding::in
adapter
.
submitList
(
featureList
)
adapter
.
submitList
(
featureList
)
initWave
()
}
}
private
fun
initWave
()
{
binding
.
wave1
.
setWaves
(
getRandomWave2
())
binding
.
wave1
.
progress
=
0.15f
binding
.
wave1
.
colorAlpha
=
0.8f
binding
.
wave1
.
startColor
=
"#AACBEC"
.
toColorInt
()
binding
.
wave1
.
closeColor
=
"#AACBEC"
.
toColorInt
()
binding
.
wave1
.
waveHeight
=
Random
.
nextInt
(
15
,
30
)
binding
.
wave1
.
velocity
=
Random
.
nextInt
(
30
,
60
)
*
0.1f
binding
.
wave1
.
start
()
binding
.
wave1
.
visibility
=
View
.
VISIBLE
binding
.
wave2
.
setWaves
(
getRandomWave1
())
binding
.
wave2
.
colorAlpha
=
0.9f
binding
.
wave2
.
progress
=
0.15f
binding
.
wave2
.
startColor
=
"#A9CAEB"
.
toColorInt
()
binding
.
wave2
.
closeColor
=
"#A9CAEB"
.
toColorInt
()
binding
.
wave2
.
waveHeight
=
Random
.
nextInt
(
15
,
30
)
binding
.
wave2
.
velocity
=
Random
.
nextInt
(
30
,
60
)
*
0.1f
binding
.
wave2
.
start
()
binding
.
wave2
.
visibility
=
View
.
VISIBLE
val
randomWave
=
getRandomWave1
()
LogEx
.
logDebug
(
TAG
,
"randomWave=$randomWave"
)
binding
.
wave3
.
setWaves
(
randomWave
)
binding
.
wave3
.
colorAlpha
=
1f
binding
.
wave3
.
progress
=
0.15f
binding
.
wave3
.
startColor
=
ContextCompat
.
getColor
(
requireContext
(),
R
.
color
.
colorPrimary
)
binding
.
wave3
.
closeColor
=
ContextCompat
.
getColor
(
requireContext
(),
R
.
color
.
colorPrimary
)
binding
.
wave3
.
waveHeight
=
Random
.
nextInt
(
15
,
30
)
binding
.
wave3
.
velocity
=
Random
.
nextInt
(
30
,
60
)
*
0.1f
binding
.
wave3
.
start
()
binding
.
wave3
.
visibility
=
View
.
VISIBLE
lifecycleScope
.
launch
(
Dispatchers
.
IO
)
{
while
(
isActive
)
{
delay
(
5000
)
launch
(
Dispatchers
.
Main
)
{
binding
.
wave1
.
velocity
=
Random
.
nextInt
(
80
,
100
)
*
0.1f
binding
.
wave2
.
velocity
=
Random
.
nextInt
(
80
,
100
)
*
0.1f
binding
.
wave3
.
velocity
=
Random
.
nextInt
(
80
,
100
)
*
0.1f
}
delay
(
3000
)
launch
(
Dispatchers
.
Main
)
{
binding
.
wave1
.
velocity
=
Random
.
nextInt
(
30
,
60
)
*
0.1f
binding
.
wave2
.
velocity
=
Random
.
nextInt
(
30
,
60
)
*
0.1f
binding
.
wave3
.
velocity
=
Random
.
nextInt
(
30
,
60
)
*
0.1f
}
}
}
}
// "70,25,1.4,1.4,-26\n"
fun
getRandomWave1
():
String
{
val
offsetX
=
Random
.
nextInt
(
70
,
90
)
val
offsetY
=
Random
.
nextInt
(
20
,
30
)
val
scaleX
=
Random
.
nextInt
(
10
,
16
)
/
10f
val
scaleY
=
Random
.
nextInt
(
10
,
15
)
/
10f
val
velocity
=
Random
.
nextInt
(-
30
,
-
20
)
return
"$offsetX,$offsetY,$scaleX,$scaleY,$velocity\n"
}
// "100,5,1.4,1.2,15\n"
fun
getRandomWave2
():
String
{
val
offsetX
=
Random
.
nextInt
(
90
,
120
)
val
offsetY
=
Random
.
nextInt
(
3
,
8
)
val
scaleX
=
Random
.
nextInt
(
10
,
16
)
/
10f
val
scaleY
=
Random
.
nextInt
(
9
,
13
)
/
10f
val
velocity
=
Random
.
nextInt
(
8
,
18
)
return
"$offsetX,$offsetY,$scaleX,$scaleY,$velocity\n"
}
override
fun
initListener
()
{
override
fun
initListener
()
{
super
.
initListener
()
super
.
initListener
()
...
@@ -160,38 +241,7 @@ class HomeFragment : BaseFragment<FragmentHome1Binding>(FragmentHome1Binding::in
...
@@ -160,38 +241,7 @@ class HomeFragment : BaseFragment<FragmentHome1Binding>(FragmentHome1Binding::in
}
}
}
}
// Wave(/*Context context, */int offsetX, int offsetY, int velocity, float scaleX, float scaleY, int wave) {
// super(context);
// this.wave = wave; //波幅(波宽)
// this.scaleX = scaleX; //水平拉伸量
// this.scaleY = scaleY; //竖直拉伸量
// this.offsetX = offsetX; //水平偏移量
// this.offsetY = offsetY; //竖直偏移量
// this.velocity = velocity; //移动速度(像素/秒)
// this.path = new Path();
// }
// "70,25,1.4,1.4,-26\n" +
// "100,5,1.4,1.2,15\n" +
// "420,0,1.15,1,-10\n" +
// "520,10,1.7,1.5,20\n" +
// "220,0,1,1,-15"
binding
.
WaveHeader1
.
setStartColor
(
R
.
color
.
colorPrimary
)
binding
.
WaveHeader1
.
setCloseColorId
(
R
.
color
.
colorPrimary
)
binding
.
WaveHeader1
.
setWaves
(
"70,25,1.4,1.4,-26"
)
binding
.
WaveHeader1
.
colorAlpha
=
0.5f
binding
.
WaveHeader1
.
visibility
=
View
.
GONE
binding
.
WaveHeader2
.
setStartColor
(
R
.
color
.
color_aacbec
)
binding
.
WaveHeader2
.
setCloseColorId
(
R
.
color
.
color_aacbec
)
binding
.
WaveHeader2
.
setWaves
(
"220,0,1,1,-15"
)
binding
.
WaveHeader2
.
colorAlpha
=
0.8f
binding
.
WaveHeader2
.
visibility
=
View
.
GONE
binding
.
WaveHeader3
.
colorAlpha
=
1f
binding
.
WaveHeader3
.
setWaves
(
"25,5,1.15,1.2,25"
)
binding
.
WaveHeader3
.
velocity
=
2f
binding
.
WaveHeader3
.
visibility
=
View
.
VISIBLE
}
}
...
...
app/src/main/res/layout/fragment_home1.xml
View file @
aaf58ba6
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
android:id=
"@+id/iv"
android:id=
"@+id/iv"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/dp_450"
android:layout_height=
"@dimen/dp_450"
android:background=
"
#82FF60
"
android:background=
"
@color/colorPrimary
"
app:layout_constraintTop_toTopOf=
"parent"
/>
app:layout_constraintTop_toTopOf=
"parent"
/>
...
@@ -165,36 +165,40 @@
...
@@ -165,36 +165,40 @@
android:background=
"@color/white"
android:background=
"@color/white"
android:overScrollMode=
"never"
android:overScrollMode=
"never"
android:paddingHorizontal=
"@dimen/dp_8"
android:paddingHorizontal=
"@dimen/dp_8"
android:paddingTop=
"@dimen/dp_
2
0"
android:paddingTop=
"@dimen/dp_
4
0"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/tvClean"
/>
app:layout_constraintTop_toBottomOf=
"@id/tvClean"
/>
<FrameLayout
<FrameLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"0dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintTop_toTopOf=
"@id/rv"
>
app:layout_constraintTop_toTopOf=
"@id/rv"
>
<com.scwang.wave.MultiWaveHeader
<com.scwang.wave.MultiWaveHeader
android:id=
"@+id/
WaveHeader
1"
android:id=
"@+id/
wave
1"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/dp_60"
android:layout_height=
"match_parent"
android:visibility=
"gone"
/>
android:visibility=
"gone"
app:mwhProgress=
"0.15"
tools:mwhEnableFullScreen=
"true"
/>
<com.scwang.wave.MultiWaveHeader
<com.scwang.wave.MultiWaveHeader
android:id=
"@+id/
WaveHeader
2"
android:id=
"@+id/
wave
2"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/dp_60"
android:layout_height=
"match_parent"
android:visibility=
"gone"
/>
android:visibility=
"gone"
app:mwhProgress=
"0.15"
tools:mwhEnableFullScreen=
"true"
/>
<com.scwang.wave.MultiWaveHeader
<com.scwang.wave.MultiWaveHeader
android:id=
"@+id/
WaveHeader
3"
android:id=
"@+id/
wave
3"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/dp_60"
android:layout_height=
"match_parent"
android:visibility=
"visible"
android:visibility=
"gone"
app:mwhCloseColor=
"@color/colorPrimary"
app:mwhProgress=
"0.15"
app:mwhColorAlpha=
"1"
tools:mwhEnableFullScreen=
"true"
/>
app:mwhStartColor=
"@color/colorPrimary"
/>
</FrameLayout>
</FrameLayout>
...
...
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