Skip to content

Commit

Permalink
[refactor] : #159 버튼 중복 클릭
Browse files Browse the repository at this point in the history
  • Loading branch information
lsakee committed Mar 3, 2024
1 parent 7c1751e commit 9413636
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {

defaultConfig {
applicationId = "org.sopt.linkmind"
versionCode = 7
versionCode = 8
versionName = "1.0.1"
}
viewBinding.enable = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class LinkMindAuthenticator @Inject constructor(
@LOGIN private val intentProvider: IntentProvider,
) : Authenticator {
override fun authenticate(route: Route?, response: Response): Request? {

if (response.code == CODE_TOKEN_EXPIRED) {
val newTokens = runCatching {
runBlocking {
Expand Down
2 changes: 2 additions & 0 deletions core/ui/src/main/java/org/sopt/ui/base/BindingFragment.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.sopt.ui.base

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand All @@ -13,6 +14,7 @@ abstract class BindingFragment<T : ViewBinding>(
private var _binding: T? = null
protected val binding
get() = requireNotNull(_binding) {
Log.d("error","$_binding")
}

override fun onCreateView(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ class WebViewFragment : BindingFragment<FragmentWebviewBinding>({ FragmentWebvie
wbClip.webViewClient = object : WebViewClient() {
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)

runCatching { updateColors() }
}
}
Expand Down
2 changes: 2 additions & 0 deletions feature/home/src/main/java/org/sopt/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>({ FragmentHomeBinding.
is HomeSideEffect.NavigateWebView -> navigateToDestination(
"featureSaveLink://webViewFragment?site=${viewModel.container.stateFlow.value.url},,,${0},,,false",
)

else -> {}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ package org.sopt.savelink.ui.savelinksetclip
import android.os.Bundle
import android.view.View
import androidx.fragment.app.viewModels
import androidx.lifecycle.viewModelScope
import androidx.navigation.fragment.findNavController
import dagger.hilt.android.AndroidEntryPoint
import designsystem.components.bottomsheet.LinkMindBottomSheet
import designsystem.components.button.state.LinkMindButtonState
import designsystem.components.dialog.LinkMindDialog
import designsystem.components.toast.linkMindSnackBar
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import org.orbitmvi.orbit.viewmodel.observe
import org.sopt.mainfeature.R
import org.sopt.savelink.databinding.FragmentSaveLinkSetClipBinding
Expand Down Expand Up @@ -106,12 +110,19 @@ class SaveLinkSetClipFragment : BindingFragment<FragmentSaveLinkSetClipBinding>(
viewModel.showDialog()
}
}

private val mutex = Mutex()
private fun onClickCompleteBtn() {
binding.btnSaveLinkComplete.apply {
btnClick {
if (state == LinkMindButtonState.DISABLE) return@btnClick
viewModel.saveLink(viewModel.container.stateFlow.value.url, viewModel.container.stateFlow.value.categoryId)

if (!mutex.isLocked) {
viewModel.viewModelScope.launch {
mutex.withLock {
viewModel.saveLink(viewModel.container.stateFlow.value.url, viewModel.container.stateFlow.value.categoryId)
}
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ class TimerFragment : BindingFragment<FragmentTimerBinding>({ FragmentTimerBindi
is UiState.Failure -> {}
is UiState.Empty -> {}
is UiState.Loading -> {}
else -> {}
}
}.launchIn(viewLifeCycleScope)
}
Expand Down

0 comments on commit 9413636

Please sign in to comment.