Commit 266fc864 authored by wanglei's avatar wanglei

...

parent 5a94377e
......@@ -6,6 +6,7 @@ import android.net.Uri
import android.text.SpannableString
import android.text.Spanned
import android.text.style.UnderlineSpan
import android.view.View
import com.base.browserwhite.MyApplication
import com.base.browserwhite.bean.ConstObject.ifAgreePrivacy
import com.base.browserwhite.databinding.ActivitySplash2Binding
......@@ -61,12 +62,12 @@ class PrivacyManager {
clicked = true
ifAgreePrivacy = true
(context.application as MyApplication).initApp()
listener.onAgreePrivacy()
listener.onAgreePrivacy(true)
}
}
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
import CloseNotificationReceiver
import android.Manifest
import android.R.attr.duration
import android.animation.Animator
import android.animation.AnimatorSet
import android.animation.ObjectAnimator
import android.animation.PropertyValuesHolder
import android.animation.ValueAnimator
import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.Color
import android.os.Build
import android.os.Handler
import android.util.Log
import android.view.KeyEvent
import android.view.animation.LinearInterpolator
import android.view.View
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.view.ViewCompat
import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope
import com.base.browserwhite.R
import com.base.browserwhite.ads.AdmobMaxHelper
......@@ -77,6 +77,7 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(),
onAgreePrivacy()
}
} else {
startAnimation(false) {
PrivacyManager(binding, this, this)
}
......@@ -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) {
lifecycleScope.launch(Dispatchers.IO) {
......@@ -105,24 +112,36 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(),
weather.tempMin + "℃" + " / " + weather.tempMax + "℃"
val icon = when (weather.iconDay) {
"Sunny day" -> R.mipmap.x_qing
"Cloudy day" -> R.mipmap.x_yin
"Rainy day" -> R.mipmap.x_dayu
"Snowy day" -> R.mipmap.x_xiaxue
"Greasy day" -> R.mipmap.x_wumaishachengbao
"Unknown" -> R.mipmap.x_qing
else -> R.mipmap.x_qing
"Sunny day" -> R.mipmap.d_qing
"Cloudy day" -> R.mipmap.d_yin
"Rainy day" -> R.mipmap.d_dayu
"Snowy day" -> R.mipmap.d_xiaxue
"Greasy day" -> R.mipmap.d_wumaishachengbao
"Unknown" -> R.mipmap.d_qing
else -> R.mipmap.d_qing
}
binding.ivWeather.setImageResource(icon)
AnimationHelper.startAlphaAnimation(binding.ivWeather, 800) {
AnimationHelper.startAlphaAnimation(binding.tvDate, 800) {
AnimationHelper.startAlphaAnimation(binding.tvTemperature, 800) {
AnimationHelper.startAlphaAnimation(binding.ivWeather, 800, null) {
AnimationHelper.startAlphaAnimation(binding.tvDate, 800, null) {
AnimationHelper.startAlphaAnimation(binding.tvTemperature, 800, null) {
if (isAgree) {
AnimationHelper.startAlphaAnimation(binding.pb, 800) {
AnimationHelper.startAlphaAnimation(binding.pb, 800, null) {
callback.invoke()
}
} 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()
}
}
......@@ -130,7 +149,6 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(),
}
}
}
}
} else {
callback.invoke()
......@@ -147,14 +165,26 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(),
})
}
override fun onAgreePrivacy() {
override fun onAgreePrivacy(isStart: Boolean) {
EventUtils.event("app_start")
if (jumpType == 0) {
startStayNotification()
}
AdmobMaxHelper.preloadAd(this)
mTaskManager?.startProgress()
loadAd()
binding.idTvStart.isVisible = false
binding.llStart.visibility = View.GONE
binding.llProgress.visibility = View.VISIBLE
if (isStart) {
startPbAnimation {
mTaskManager?.startProgress()
loadAd()
}
} else {
mTaskManager?.startProgress()
loadAd()
}
}
......
......@@ -34,9 +34,7 @@ class TaskManager {
}
fun startProgress() {
binding.idTvStart.isVisible = false
binding.llStart.visibility = View.GONE
binding.llProgress.visibility = View.VISIBLE
val mRunnable: Runnable = object : Runnable {
override fun run() {
if (!mIsPaused) {
......
......@@ -12,9 +12,12 @@ public class AnimationHelper {
*
* @param view 要应用动画的视图。
* @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
view.setAlpha(0f);
......@@ -24,12 +27,20 @@ public class AnimationHelper {
// 设置动画监听器,以便在动画结束时调用回调
alphaAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);
if (startCallback != null) {
startCallback.onAnimationStart();
}
}
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
// 调用回调接口的onAnimationEnd方法
if (callback != null) {
callback.onAnimationEnd();
if (endCallback != null) {
endCallback.onAnimationEnd();
}
}
});
......@@ -44,4 +55,11 @@ public class AnimationHelper {
public interface AnimationEndCallback {
void onAnimationEnd();
}
/**
* 动画结束时的回调接口。
*/
public interface AnimationStartCallback {
void onAnimationStart();
}
}
\ No newline at end of file
......@@ -98,6 +98,7 @@
app:layout_constraintBottom_toBottomOf="parent">
<TextView
android:layout_marginTop="5dp"
android:alpha="0"
android:id="@+id/id_tv_start"
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