Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX/#370] Notice / 구독 연장 여부 서버 통신 재호출 수정 #371

Merged
merged 2 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import com.el.yello.presentation.util.dp
import com.el.yello.util.amplitude.AmplitudeUtils
import com.el.yello.util.context.yelloSnackbar
import com.example.domain.enum.SubscribeType.CANCELED
import com.example.domain.enum.SubscribeType.NORMAL
import com.example.ui.base.BindingActivity
import com.example.ui.context.toast
import com.example.ui.intent.stringExtra
Expand All @@ -35,6 +34,7 @@ import com.example.ui.view.UiState.Failure
import com.example.ui.view.UiState.Loading
import com.example.ui.view.UiState.Success
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import java.text.SimpleDateFormat
Expand All @@ -49,6 +49,7 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
private val type by stringExtra()

private var backPressedTime: Long = 0
private var userSubsStateJob: Job? = null

private val onBackPressedCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
Expand Down Expand Up @@ -189,7 +190,7 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
}

private fun setupGetUserSubsState() {
viewModel.getUserSubsState.flowWithLifecycle(lifecycle)
userSubsStateJob = viewModel.getUserSubsState.flowWithLifecycle(lifecycle)
.onEach { state ->
when (state) {
is Empty -> return@onEach
Expand Down Expand Up @@ -275,6 +276,10 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
badgeDrawable.isVisible = count != 0
}

fun resetUserSubsStateFlow() {
userSubsStateJob?.cancel()
}
Comment on lines +279 to +281
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

음~좋네용


companion object {
private const val EXTRA_TYPE = "type"
private const val EXTRA_PATH = "path"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ import android.view.ViewGroup
import android.view.WindowManager
import com.el.yello.R
import com.el.yello.databinding.FragmentNoticeResubscribeBinding
import com.el.yello.presentation.main.MainActivity
import com.example.ui.base.BindingDialogFragment
import com.example.ui.view.setOnSingleClickListener

class PayReSubsNoticeDialog :
BindingDialogFragment<FragmentNoticeResubscribeBinding>(R.layout.fragment_notice_resubscribe) {

private val mainActivity: MainActivity by lazy {
requireActivity() as MainActivity
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setNoticeBtnClickListener()
Expand All @@ -36,12 +40,16 @@ class PayReSubsNoticeDialog :
}

private fun setNoticeBtnClickListener() {
binding.btnNoticeQuit.setOnSingleClickListener { dismiss() }
binding.btnYelloplusSubscribe.setOnSingleClickListener {
binding.btnNoticeQuit.setOnSingleClickListener {
dismiss()
mainActivity.resetUserSubsStateFlow()
}
binding.btnYelloplusSubscribe.setOnSingleClickListener {
Intent(requireContext(), PayActivity::class.java).apply {
startActivity(this)
}
dismiss()
mainActivity.resetUserSubsStateFlow()
}
}

Expand Down
Loading