Skip to content

Commit

Permalink
refactor: 만들어놓은 Lifecycle 관련 유틸 함수 사용
Browse files Browse the repository at this point in the history
  • Loading branch information
Taewan-P committed Nov 20, 2023
1 parent a153d0f commit 0f7c5af
Showing 1 changed file with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,20 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.widget.NestedScrollView
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import app.priceguard.R
import app.priceguard.data.dto.SignUpState
import app.priceguard.databinding.ActivitySignupBinding
import app.priceguard.ui.main.MainActivity
import app.priceguard.ui.signup.SignupViewModel.SignupEvent
import app.priceguard.ui.signup.SignupViewModel.SignupUIState
import app.priceguard.ui.util.lifecycle.repeatOnStarted
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.appbar.AppBarLayout.Behavior.DragCallback
import com.google.android.material.button.MaterialButton
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.progressindicator.CircularProgressIndicatorSpec
import com.google.android.material.progressindicator.IndeterminateDrawable
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch

@AndroidEntryPoint
class SignupActivity : AppCompatActivity() {
Expand Down Expand Up @@ -140,22 +137,18 @@ class SignupActivity : AppCompatActivity() {
}

private fun observeState() {
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
signupViewModel.state.collect { state ->
updateNameTextFieldUI(state)
updateEmailTextFieldUI(state)
updatePasswordTextFieldUI(state)
updateRetypePasswordTextFieldUI(state)
}
repeatOnStarted {
signupViewModel.state.collect { state ->
updateNameTextFieldUI(state)
updateEmailTextFieldUI(state)
updatePasswordTextFieldUI(state)
updateRetypePasswordTextFieldUI(state)
}
}

lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
signupViewModel.eventFlow.collect { event ->
handleSignupEvent(event)
}
repeatOnStarted {
signupViewModel.eventFlow.collect { event ->
handleSignupEvent(event)
}
}
}
Expand Down

0 comments on commit 0f7c5af

Please sign in to comment.