Skip to content

Commit

Permalink
Fixed an issue where the app crashes on API 30 due to splash screen a…
Browse files Browse the repository at this point in the history
…nimation
  • Loading branch information
Anthonyy232 committed May 12, 2024
1 parent 047d519 commit 3f412f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ android {
applicationId = "com.anthonyla.paperize"
minSdk = 26
targetSdk = 34
versionCode = 7
versionCode = 8
versionName = "1.1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.animation.ObjectAnimator
import android.app.Activity
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle
import android.view.View
import android.view.animation.AccelerateInterpolator
Expand Down Expand Up @@ -41,13 +42,17 @@ class MainActivity : ComponentActivity() {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
val splashScreen = installSplashScreen()
splashScreen.setOnExitAnimationListener { splashScreenViewProvider ->
val fadeOut = ObjectAnimator.ofFloat(splashScreenViewProvider.view, View.ALPHA, 1f, 0f)
fadeOut.interpolator = AccelerateInterpolator()
fadeOut.duration = 300L
fadeOut.doOnEnd { splashScreenViewProvider.remove() }
fadeOut.start()

if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) {
splashScreen.setOnExitAnimationListener { splashScreenViewProvider ->
val fadeOut = ObjectAnimator.ofFloat(splashScreenViewProvider.view, View.ALPHA, 1f, 0f)
fadeOut.interpolator = AccelerateInterpolator()
fadeOut.duration = 300L
fadeOut.doOnEnd { splashScreenViewProvider.remove() }
fadeOut.start()
}
}

setContent {
val settingsState = settingsViewModel.state.collectAsStateWithLifecycle()
val selectedState = wallpaperScreenViewModel.state.collectAsStateWithLifecycle()
Expand Down

0 comments on commit 3f412f4

Please sign in to comment.