Commit 266fc864 authored by wanglei's avatar wanglei

...

parent 5a94377e
...@@ -6,6 +6,7 @@ import android.net.Uri ...@@ -6,6 +6,7 @@ import android.net.Uri
import android.text.SpannableString import android.text.SpannableString
import android.text.Spanned import android.text.Spanned
import android.text.style.UnderlineSpan import android.text.style.UnderlineSpan
import android.view.View
import com.base.browserwhite.MyApplication import com.base.browserwhite.MyApplication
import com.base.browserwhite.bean.ConstObject.ifAgreePrivacy import com.base.browserwhite.bean.ConstObject.ifAgreePrivacy
import com.base.browserwhite.databinding.ActivitySplash2Binding import com.base.browserwhite.databinding.ActivitySplash2Binding
...@@ -61,12 +62,12 @@ class PrivacyManager { ...@@ -61,12 +62,12 @@ class PrivacyManager {
clicked = true clicked = true
ifAgreePrivacy = true ifAgreePrivacy = true
(context.application as MyApplication).initApp() (context.application as MyApplication).initApp()
listener.onAgreePrivacy() listener.onAgreePrivacy(true)
} }
} }
interface onUserPrivacyAggreementListener { interface onUserPrivacyAggreementListener {
fun onAgreePrivacy() fun onAgreePrivacy(isStart: Boolean=false)
} }
} }
\ No newline at end of file
...@@ -2,19 +2,19 @@ package com.base.browserwhite.ui.activity.splash ...@@ -2,19 +2,19 @@ package com.base.browserwhite.ui.activity.splash
import CloseNotificationReceiver import CloseNotificationReceiver
import android.Manifest import android.Manifest
import android.R.attr.duration import android.animation.AnimatorSet
import android.animation.Animator
import android.animation.ObjectAnimator import android.animation.ObjectAnimator
import android.animation.PropertyValuesHolder import android.animation.ValueAnimator
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Intent import android.content.Intent
import android.graphics.Color import android.graphics.Color
import android.os.Build import android.os.Build
import android.os.Handler import android.os.Handler
import android.util.Log
import android.view.KeyEvent import android.view.KeyEvent
import android.view.animation.LinearInterpolator import android.view.View
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.view.ViewCompat
import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.base.browserwhite.R import com.base.browserwhite.R
import com.base.browserwhite.ads.AdmobMaxHelper import com.base.browserwhite.ads.AdmobMaxHelper
...@@ -77,6 +77,7 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(), ...@@ -77,6 +77,7 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(),
onAgreePrivacy() onAgreePrivacy()
} }
} else { } else {
startAnimation(false) { startAnimation(false) {
PrivacyManager(binding, this, this) PrivacyManager(binding, this, this)
} }
...@@ -85,7 +86,13 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(), ...@@ -85,7 +86,13 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(),
} }
@SuppressLint("SetTextI18n") fun startPbAnimation(callback: () -> Unit) {
AnimationHelper.startAlphaAnimation(binding.pb, 800, null) {
callback.invoke()
}
}
@SuppressLint("SetTextI18n", "Recycle")
fun startAnimation(isAgree: Boolean, callback: () -> Unit) { fun startAnimation(isAgree: Boolean, callback: () -> Unit) {
lifecycleScope.launch(Dispatchers.IO) { lifecycleScope.launch(Dispatchers.IO) {
...@@ -105,24 +112,36 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(), ...@@ -105,24 +112,36 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(),
weather.tempMin + "℃" + " / " + weather.tempMax + "℃" weather.tempMin + "℃" + " / " + weather.tempMax + "℃"
val icon = when (weather.iconDay) { val icon = when (weather.iconDay) {
"Sunny day" -> R.mipmap.x_qing "Sunny day" -> R.mipmap.d_qing
"Cloudy day" -> R.mipmap.x_yin "Cloudy day" -> R.mipmap.d_yin
"Rainy day" -> R.mipmap.x_dayu "Rainy day" -> R.mipmap.d_dayu
"Snowy day" -> R.mipmap.x_xiaxue "Snowy day" -> R.mipmap.d_xiaxue
"Greasy day" -> R.mipmap.x_wumaishachengbao "Greasy day" -> R.mipmap.d_wumaishachengbao
"Unknown" -> R.mipmap.x_qing "Unknown" -> R.mipmap.d_qing
else -> R.mipmap.x_qing else -> R.mipmap.d_qing
} }
binding.ivWeather.setImageResource(icon) binding.ivWeather.setImageResource(icon)
AnimationHelper.startAlphaAnimation(binding.ivWeather, 800) { AnimationHelper.startAlphaAnimation(binding.ivWeather, 800, null) {
AnimationHelper.startAlphaAnimation(binding.tvDate, 800) { AnimationHelper.startAlphaAnimation(binding.tvDate, 800, null) {
AnimationHelper.startAlphaAnimation(binding.tvTemperature, 800) { AnimationHelper.startAlphaAnimation(binding.tvTemperature, 800, null) {
if (isAgree) { if (isAgree) {
AnimationHelper.startAlphaAnimation(binding.pb, 800) { AnimationHelper.startAlphaAnimation(binding.pb, 800, null) {
callback.invoke() callback.invoke()
} }
} else { } else {
AnimationHelper.startAlphaAnimation(binding.idTvStart, 800) { AnimationHelper.startAlphaAnimation(binding.idTvStart, 1200, {
val set1 = AnimatorSet()
// 创建缩放动画的ObjectAnimator
val scaleUpAnimator1 = ObjectAnimator.ofFloat(binding.idTvStart, "scaleX", 1f, 0.95f, 1.05f)
val scaleUpAnimator2 = ObjectAnimator.ofFloat(binding.idTvStart, "scaleY", 1f, 0.95f, 1.05f)
scaleUpAnimator1.duration = 1200 // 动画持续500毫秒
scaleUpAnimator1.repeatCount = 1 // 重复次数
scaleUpAnimator1.repeatMode = ValueAnimator.REVERSE // 反向重复,实现缩小效果
scaleUpAnimator2.duration = 1200 // 动画持续500毫秒
scaleUpAnimator2.repeatCount = 1 // 重复次数
set1.playTogether(scaleUpAnimator1, scaleUpAnimator2)
set1.start()
}) {
callback.invoke() callback.invoke()
} }
} }
...@@ -130,7 +149,6 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(), ...@@ -130,7 +149,6 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(),
} }
} }
} }
} }
} else { } else {
callback.invoke() callback.invoke()
...@@ -147,15 +165,27 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(), ...@@ -147,15 +165,27 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(),
}) })
} }
override fun onAgreePrivacy() { override fun onAgreePrivacy(isStart: Boolean) {
EventUtils.event("app_start") EventUtils.event("app_start")
if (jumpType == 0) { if (jumpType == 0) {
startStayNotification() startStayNotification()
} }
AdmobMaxHelper.preloadAd(this) AdmobMaxHelper.preloadAd(this)
binding.idTvStart.isVisible = false
binding.llStart.visibility = View.GONE
binding.llProgress.visibility = View.VISIBLE
if (isStart) {
startPbAnimation {
mTaskManager?.startProgress() mTaskManager?.startProgress()
loadAd() loadAd()
} }
} else {
mTaskManager?.startProgress()
loadAd()
}
}
override fun onProgressMax() { override fun onProgressMax() {
......
...@@ -34,9 +34,7 @@ class TaskManager { ...@@ -34,9 +34,7 @@ class TaskManager {
} }
fun startProgress() { fun startProgress() {
binding.idTvStart.isVisible = false
binding.llStart.visibility = View.GONE
binding.llProgress.visibility = View.VISIBLE
val mRunnable: Runnable = object : Runnable { val mRunnable: Runnable = object : Runnable {
override fun run() { override fun run() {
if (!mIsPaused) { if (!mIsPaused) {
......
...@@ -12,9 +12,12 @@ public class AnimationHelper { ...@@ -12,9 +12,12 @@ public class AnimationHelper {
* *
* @param view 要应用动画的视图。 * @param view 要应用动画的视图。
* @param duration 动画持续时间(毫秒)。 * @param duration 动画持续时间(毫秒)。
* @param callback 动画结束时调用的回调接口。 * @param endCallback 动画结束时调用的回调接口。
*/ */
public static void startAlphaAnimation(final View view, long duration, final AnimationEndCallback callback) { public static void startAlphaAnimation(final View view,
long duration,
final AnimationStartCallback startCallback,
final AnimationEndCallback endCallback) {
// 确保视图初始透明度为0 // 确保视图初始透明度为0
view.setAlpha(0f); view.setAlpha(0f);
...@@ -24,12 +27,20 @@ public class AnimationHelper { ...@@ -24,12 +27,20 @@ public class AnimationHelper {
// 设置动画监听器,以便在动画结束时调用回调 // 设置动画监听器,以便在动画结束时调用回调
alphaAnimator.addListener(new AnimatorListenerAdapter() { alphaAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);
if (startCallback != null) {
startCallback.onAnimationStart();
}
}
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation); super.onAnimationEnd(animation);
// 调用回调接口的onAnimationEnd方法 // 调用回调接口的onAnimationEnd方法
if (callback != null) { if (endCallback != null) {
callback.onAnimationEnd(); endCallback.onAnimationEnd();
} }
} }
}); });
...@@ -44,4 +55,11 @@ public class AnimationHelper { ...@@ -44,4 +55,11 @@ public class AnimationHelper {
public interface AnimationEndCallback { public interface AnimationEndCallback {
void onAnimationEnd(); void onAnimationEnd();
} }
/**
* 动画结束时的回调接口。
*/
public interface AnimationStartCallback {
void onAnimationStart();
}
} }
\ No newline at end of file
...@@ -98,6 +98,7 @@ ...@@ -98,6 +98,7 @@
app:layout_constraintBottom_toBottomOf="parent"> app:layout_constraintBottom_toBottomOf="parent">
<TextView <TextView
android:layout_marginTop="5dp"
android:alpha="0" android:alpha="0"
android:id="@+id/id_tv_start" android:id="@+id/id_tv_start"
android:layout_width="match_parent" android:layout_width="match_parent"
......
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