From 5811202f48db1cc911b7d7313233487ff65aa767 Mon Sep 17 00:00:00 2001 From: bngsh Date: Thu, 17 Nov 2022 21:07:15 +0900 Subject: [PATCH] =?UTF-8?q?:sparkles:=20RunningStart=20=EB=B7=B0=20?= =?UTF-8?q?=EB=AA=A8=EB=8D=B8=20=EA=B5=AC=ED=98=84=20(=ED=98=84=EC=9E=AC?= =?UTF-8?q?=20=EB=9F=AC=EB=84=88=20=EC=B9=B4=EC=9A=B4=ED=8A=B8=20=EB=B0=9B?= =?UTF-8?q?=EC=95=84=EC=98=A4=EA=B8=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: yonghanJu --- .../runningstart/RunningStartFragment.kt | 33 +++++++++++++++++++ .../runningstart/RunningStartViewModel.kt | 14 ++++++++ 2 files changed, 47 insertions(+) create mode 100644 presentation/src/main/java/com/whyranoid/presentation/runningstart/RunningStartFragment.kt create mode 100644 presentation/src/main/java/com/whyranoid/presentation/runningstart/RunningStartViewModel.kt diff --git a/presentation/src/main/java/com/whyranoid/presentation/runningstart/RunningStartFragment.kt b/presentation/src/main/java/com/whyranoid/presentation/runningstart/RunningStartFragment.kt new file mode 100644 index 00000000..e833d5d4 --- /dev/null +++ b/presentation/src/main/java/com/whyranoid/presentation/runningstart/RunningStartFragment.kt @@ -0,0 +1,33 @@ +package com.whyranoid.presentation.runningstart + +import android.os.Bundle +import android.view.View +import androidx.fragment.app.viewModels +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.lifecycleScope +import androidx.lifecycle.repeatOnLifecycle +import com.whyranoid.presentation.R +import com.whyranoid.presentation.base.BaseFragment +import com.whyranoid.presentation.databinding.FragmentRunningStartBinding +import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.launch + +@AndroidEntryPoint +internal class RunningStartFragment : + BaseFragment(R.layout.fragment_running_start) { + + private val viewModel by viewModels() + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + binding.vm = viewModel + + lifecycleScope.launch { + viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) { + viewModel.runnerCount.collect { runnerCount -> + binding.tvRunnerCountNumber.text = runnerCount.toString() + } + } + } + } +} diff --git a/presentation/src/main/java/com/whyranoid/presentation/runningstart/RunningStartViewModel.kt b/presentation/src/main/java/com/whyranoid/presentation/runningstart/RunningStartViewModel.kt new file mode 100644 index 00000000..1e1c354f --- /dev/null +++ b/presentation/src/main/java/com/whyranoid/presentation/runningstart/RunningStartViewModel.kt @@ -0,0 +1,14 @@ +package com.whyranoid.presentation.runningstart + +import androidx.lifecycle.ViewModel +import com.whyranoid.domain.usecase.GetRunnerCountUseCase +import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject + +@HiltViewModel +class RunningStartViewModel @Inject constructor( + getRunnerCountUseCase: GetRunnerCountUseCase +) : ViewModel() { + + val runnerCount = getRunnerCountUseCase() +}