Commit 9b213b7b authored by leichao.gao's avatar leichao.gao

update

parent 7ac8a05e
......@@ -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, 800A) {
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() {
......
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(0f);
// 创建透明度从0到1的动画
ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
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
......@@ -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"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment