mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
refactor: Split off the function even more
This commit is contained in:
parent
c4ed991c79
commit
00baed7058
3 changed files with 13 additions and 11 deletions
|
@ -49,17 +49,19 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
|
|||
appState.isSplashShown = true
|
||||
}
|
||||
|
||||
val splashScreen = installSplashScreen()
|
||||
return installSplashScreen()
|
||||
}
|
||||
|
||||
fun SplashScreen.configure() {
|
||||
val startTime = System.currentTimeMillis()
|
||||
splashScreen.setKeepOnScreenCondition {
|
||||
this.setKeepOnScreenCondition {
|
||||
val elapsed = System.currentTimeMillis() - startTime
|
||||
elapsed <= SPLASH_MIN_DURATION || (!appState.ready && elapsed <= SPLASH_MAX_DURATION)
|
||||
}
|
||||
|
||||
return splashScreen
|
||||
this.setSplashScreenExitAnimation()
|
||||
}
|
||||
|
||||
fun SplashScreen.setSplashScreenExitAnimation() {
|
||||
private fun SplashScreen.setSplashScreenExitAnimation() {
|
||||
val root = findViewById<View>(android.R.id.content)
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
|
||||
|
|
|
@ -242,6 +242,8 @@ open class MainActivity : BaseActivity<MainActivityBinding>() {
|
|||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
val splashScreen = maybeInstallSplashScreen(savedInstanceState)
|
||||
|
||||
// Set up shared element transition and disable overlay so views don't show above system bars
|
||||
window.requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)
|
||||
setExitSharedElementCallback(
|
||||
|
@ -266,8 +268,6 @@ open class MainActivity : BaseActivity<MainActivityBinding>() {
|
|||
)
|
||||
window.sharedElementsUseOverlay = false
|
||||
|
||||
val splashScreen = maybeInstallSplashScreen(savedInstanceState)
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
backPressedCallback = object : OnBackPressedCallback(enabled = true) {
|
||||
|
@ -652,7 +652,7 @@ open class MainActivity : BaseActivity<MainActivityBinding>() {
|
|||
(router.backstack.lastOrNull()?.controller as? BaseLegacyController<*>)?.setTitle()
|
||||
(router.backstack.lastOrNull()?.controller as? SettingsController)?.setTitle()
|
||||
|
||||
splashScreen?.setSplashScreenExitAnimation()
|
||||
splashScreen?.configure()
|
||||
|
||||
getExtensionUpdates(true)
|
||||
|
||||
|
|
|
@ -275,6 +275,8 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
|
|||
* Called when the activity is created. Initializes the view model and configuration.
|
||||
*/
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
val splashScreen = maybeInstallSplashScreen(savedInstanceState)
|
||||
|
||||
// Setup shared element transitions
|
||||
if (intent.extras?.getString(TRANSITION_NAME) != null) {
|
||||
window.requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)
|
||||
|
@ -291,8 +293,6 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
|
|||
}
|
||||
}
|
||||
|
||||
val splashScreen = maybeInstallSplashScreen(savedInstanceState)
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ReaderActivityBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
@ -301,7 +301,7 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
|
|||
a.recycle()
|
||||
setCutoutMode()
|
||||
|
||||
splashScreen?.setSplashScreenExitAnimation()
|
||||
splashScreen?.configure()
|
||||
|
||||
wic.isAppearanceLightStatusBars = lightStatusBar
|
||||
wic.isAppearanceLightNavigationBars = lightStatusBar
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue