Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
B
Browser White
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
Browser White
Commits
9b213b7b
Commit
9b213b7b
authored
Aug 28, 2024
by
leichao.gao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
7ac8a05e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
28 deletions
+58
-28
Splash2Activity.kt
...m/base/browserwhite/ui/activity/splash/Splash2Activity.kt
+8
-27
AnimationHelper.java
...ain/java/com/base/browserwhite/utils/AnimationHelper.java
+47
-0
activity_splash_2.xml
app/src/main/res/layout/activity_splash_2.xml
+3
-1
No files found.
app/src/main/java/com/base/browserwhite/ui/activity/splash/Splash2Activity.kt
View file @
9b213b7b
...
...
@@ -25,6 +25,7 @@ import com.base.browserwhite.help.EventUtils
import
com.base.browserwhite.help.WeatherUtils
import
com.base.browserwhite.service.StayNotificationService.Companion.startStayNotification
import
com.base.browserwhite.ui.activity.BaseActivity
import
com.base.browserwhite.utils.AnimationHelper
import
com.base.browserwhite.utils.BarUtils
import
com.base.browserwhite.utils.LogEx
import
kotlinx.coroutines.Dispatchers
...
...
@@ -93,7 +94,8 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(),
LogEx
.
logDebug
(
TAG
,
"weather 开始 ${weather.fxDate}"
)
binding
.
tvDate
.
text
=
weather
.
fxDate
binding
.
tvTemperature
.
text
=
weather
.
tempMin
+
"℃"
+
" / "
+
weather
.
tempMax
+
"℃"
binding
.
tvTemperature
.
text
=
weather
.
tempMin
+
"℃"
+
" / "
+
weather
.
tempMax
+
"℃"
val
icon
=
when
(
weather
.
iconDay
)
{
"Sunny day"
->
R
.
mipmap
.
x_qing
...
...
@@ -105,33 +107,13 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(),
else
->
R
.
mipmap
.
x_qing
}
binding
.
ivWeather
.
setImageResource
(
icon
)
AnimationHelper
.
startAlphaAnimation
(
binding
.
ivWeather
,
800
)
{
AnimationHelper
.
startAlphaAnimation
(
binding
.
tvDate
,
800
)
{
AnimationHelper
.
startAlphaAnimation
(
binding
.
tvTemperature
,
800
A
)
{
val
alphaHolder
=
PropertyValuesHolder
.
ofFloat
(
"alpha"
,
0f
,
1f
)
// 创建ObjectAnimator对象,设置动画持续时间和插值器
val
animator
:
ObjectAnimator
=
ObjectAnimator
.
ofPropertyValuesHolder
(
binding
.
llWeather
,
alphaHolder
)
animator
.
setDuration
(
duration
.
toLong
())
animator
.
interpolator
=
LinearInterpolator
()
animator
.
addListener
(
object
:
Animator
.
AnimatorListener
{
override
fun
onAnimationStart
(
animation
:
Animator
)
{
LogEx
.
logDebug
(
TAG
,
"onAnimationStart"
)
}
override
fun
onAnimationEnd
(
animation
:
Animator
)
{
}
override
fun
onAnimationCancel
(
animation
:
Animator
)
{
}
}
override
fun
onAnimationRepeat
(
animation
:
Animator
)
{
}
})
// 开始动画
animator
.
start
()
}
}
}
...
...
@@ -140,7 +122,6 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(),
}.
start
()
}
private
fun
closeNotification
()
{
...
...
app/src/main/java/com/base/browserwhite/utils/AnimationHelper.java
0 → 100644
View file @
9b213b7b
package
com
.
base
.
browserwhite
.
utils
;
import
android.animation.Animator
;
import
android.animation.AnimatorListenerAdapter
;
import
android.animation.ObjectAnimator
;
import
android.view.View
;
public
class
AnimationHelper
{
/**
* 开始透明度渐变动画,并设置动画结束时的回调。
*
* @param view 要应用动画的视图。
* @param duration 动画持续时间(毫秒)。
* @param callback 动画结束时调用的回调接口。
*/
public
static
void
startAlphaAnimation
(
final
View
view
,
long
duration
,
final
AnimationEndCallback
callback
)
{
// 确保视图初始透明度为0
view
.
setAlpha
(
0
f
);
// 创建透明度从0到1的动画
ObjectAnimator
alphaAnimator
=
ObjectAnimator
.
ofFloat
(
view
,
"alpha"
,
0
f
,
1
f
);
alphaAnimator
.
setDuration
(
duration
);
// 设置动画监听器,以便在动画结束时调用回调
alphaAnimator
.
addListener
(
new
AnimatorListenerAdapter
()
{
@Override
public
void
onAnimationEnd
(
Animator
animation
)
{
super
.
onAnimationEnd
(
animation
);
// 调用回调接口的onAnimationEnd方法
if
(
callback
!=
null
)
{
callback
.
onAnimationEnd
();
}
}
});
// 启动动画
alphaAnimator
.
start
();
}
/**
* 动画结束时的回调接口。
*/
public
interface
AnimationEndCallback
{
void
onAnimationEnd
();
}
}
\ No newline at end of file
app/src/main/res/layout/activity_splash_2.xml
View file @
9b213b7b
...
...
@@ -10,7 +10,6 @@
<LinearLayout
android:visibility=
"invisible"
android:id=
"@+id/ll_weather"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
...
...
@@ -23,6 +22,7 @@
tools:ignore=
"UseCompoundDrawables"
>
<ImageView
android:alpha=
"0"
android:id=
"@+id/iv_weather"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
...
...
@@ -31,6 +31,7 @@
tools:src=
"@mipmap/duoyun_splash"
/>
<TextView
android:alpha=
"0"
android:id=
"@+id/tv_date"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
...
...
@@ -42,6 +43,7 @@
<TextView
android:id=
"@+id/tv_temperature"
android:alpha=
"0"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
...
...
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