Skip to content

Commit

Permalink
[refactor] #92 스플래쉬, 로딩 화면에서 코루틴 delay 함수 사용하도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
leeeha committed Aug 6, 2023
1 parent e674ce2 commit 7f2b9ba
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 41 deletions.
15 changes: 6 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
android:screenOrientation="portrait"
android:theme="@style/Theme.Winey.SplashScreen">

<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity>

Expand All @@ -34,15 +39,7 @@
android:name=".presentation.main.feed.upload.UploadActivity"
android:exported="true"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" >

<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity>
android:windowSoftInputMode="adjustResize" />

<activity
android:name=".presentation.main.feed.upload.loading.LoadingActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package com.android.go.sopt.winey.presentation.main.feed.upload.loading

import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import androidx.lifecycle.lifecycleScope
import com.android.go.sopt.winey.R
import com.android.go.sopt.winey.databinding.ActivityLoadingBinding
import com.android.go.sopt.winey.presentation.main.MainActivity
import com.android.go.sopt.winey.util.binding.BindingActivity
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

class LoadingActivity : BindingActivity<ActivityLoadingBinding>(R.layout.activity_loading) {
override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -20,7 +21,6 @@ class LoadingActivity : BindingActivity<ActivityLoadingBinding>(R.layout.activit
private fun classifySaveItemCategory() {
val amountString = intent.extras?.getString(EXTRA_AMOUNT_KEY, "") ?: return
val amount = amountString.toLong()

val amountRange = resources.getIntArray(R.array.save_amount_range)
val itemCategories = resources.getStringArray(R.array.save_item_categories)

Expand All @@ -38,12 +38,13 @@ class LoadingActivity : BindingActivity<ActivityLoadingBinding>(R.layout.activit
}

private fun delayMillis() {
Handler(Looper.getMainLooper()).postDelayed({
navigateMainScreen()
}, DELAY_TIME)
lifecycleScope.launch {
delay(DELAY_TIME)
navigateToMainScreen()
}
}

private fun navigateMainScreen() {
private fun navigateToMainScreen() {
Intent(this, MainActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@ package com.android.go.sopt.winey.presentation.splash

import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import com.android.go.sopt.winey.R
import com.android.go.sopt.winey.databinding.ActivitySplashBinding
import com.android.go.sopt.winey.presentation.main.MainActivity
import com.android.go.sopt.winey.util.binding.BindingActivity
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

@AndroidEntryPoint
class SplashActivity : AppCompatActivity() {
class SplashActivity : BindingActivity<ActivitySplashBinding>(R.layout.activity_splash) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash)

Handler(Looper.getMainLooper()).postDelayed({
lifecycleScope.launch {
delay(DELAY_TIME)
navigateToMainScreen()
}, DELAY_TIME)
}
}

private fun navigateToMainScreen() {
Expand Down
39 changes: 23 additions & 16 deletions app/src/main/res/layout/activity_splash.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black">
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<com.airbnb.lottie.LottieAnimationView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginBottom="50dp"
app:lottie_autoPlay="true"
app:lottie_rawRes="@raw/lottie_splash" />
<data>

</androidx.constraintlayout.widget.ConstraintLayout>
</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black">

<com.airbnb.lottie.LottieAnimationView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginBottom="50dp"
app:lottie_autoPlay="true"
app:lottie_rawRes="@raw/lottie_splash" />

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
3 changes: 1 addition & 2 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
@android:color/transparent
</item>
<item name="postSplashScreenTheme">@style/Theme.Winey</item>

<item name="android:statusBarColor">@color/black</item>
<item name="android:windowLightStatusBar">false</item>
</style>
</resources>
</resources>

0 comments on commit 7f2b9ba

Please sign in to comment.