diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/service/TicketEntryService.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/service/TicketEntryService.kt index b2d1e0ac6..14abf21a4 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/service/TicketEntryService.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/service/TicketEntryService.kt @@ -9,7 +9,7 @@ class TicketEntryService : FirebaseMessagingService() { override fun onMessageReceived(remoteMessage: RemoteMessage) { runBlocking { // TODO: 입장완료 로직인지 확인하는 로직 추가 필요 - ticketStateChangeEvent.emit(true) + ticketStateChangeEvent.emit(Unit) } } @@ -18,6 +18,6 @@ class TicketEntryService : FirebaseMessagingService() { } companion object { - val ticketStateChangeEvent: MutableSharedFlow = MutableSharedFlow() + val ticketStateChangeEvent: MutableSharedFlow = MutableSharedFlow() } } diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketentry/TicketEntryActivity.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketentry/TicketEntryActivity.kt index 9e61406a2..542aa8132 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketentry/TicketEntryActivity.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketentry/TicketEntryActivity.kt @@ -15,6 +15,7 @@ import com.google.zxing.BarcodeFormat import com.journeyapps.barcodescanner.BarcodeEncoder import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.collectLatest +import kotlinx.coroutines.flow.first @AndroidEntryPoint class TicketEntryActivity : AppCompatActivity() { @@ -65,13 +66,11 @@ class TicketEntryActivity : AppCompatActivity() { } } repeatOnStarted(this) { - TicketEntryService.ticketStateChangeEvent.collect { event -> - if (event) { - // TODO 티켓 스캔 화면 처리 - Toast.makeText(this, "티켓이 스캔되었습니다.", Toast.LENGTH_SHORT).show() - setResult(RESULT_OK, intent) - finish() - } + TicketEntryService.ticketStateChangeEvent.first { + Toast.makeText(this, "티켓이 스캔되었습니다.", Toast.LENGTH_SHORT).show() + setResult(RESULT_OK, intent) + finish() + true } } } diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketentry/TicketEntryViewModel.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketentry/TicketEntryViewModel.kt index b2edea862..ae14081a2 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketentry/TicketEntryViewModel.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/ticketentry/TicketEntryViewModel.kt @@ -66,9 +66,11 @@ class TicketEntryViewModel @Inject constructor( } } - private suspend fun setTimer(ticketId: Long, ticketCode: TicketCode) { - timer.timerListener = createTimerListener(ticketId) - timer.start(ticketCode.period) + private fun setTimer(ticketId: Long, ticketCode: TicketCode) { + viewModelScope.launch { + timer.timerListener = createTimerListener(ticketId) + timer.start(ticketCode.period) + } } private fun createTimerListener(ticketId: Long): TimerListener = object : TimerListener {