Skip to content

Commit

Permalink
로그인 바텀 시트 딜레이 클릭 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
dogdduddy committed Feb 4, 2024
1 parent afed6b9 commit 02fa876
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import kotlinx.coroutines.launch
import org.gdsc.domain.model.response.UserLoginAction
import org.gdsc.presentation.R
import org.gdsc.presentation.databinding.FragmentLoginBinding
import org.gdsc.presentation.utils.onDelayedClick
import org.gdsc.presentation.utils.repeatWhenUiStarted
import org.gdsc.presentation.view.LoginManager
import org.gdsc.presentation.view.MainActivity
Expand Down Expand Up @@ -56,7 +57,7 @@ class LoginFragment : Fragment() {
}

private fun setLoginButton() {
binding.googleLoginBtnTemplate.setOnClickListener {
binding.googleLoginBtnTemplate.onDelayedClick {

viewLifecycleOwner.lifecycleScope.launch {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import android.widget.Toast
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import kotlin.math.abs

fun EditText.addAfterTextChangedListener(block: (String) -> Unit) {
this.addTextChangedListener(object : TextWatcher {
Expand All @@ -35,6 +36,17 @@ fun EditText.addAfterTextChangedListener(block: (String) -> Unit) {
})
}

private var lastClickTime: Long = 0L
fun View.onDelayedClick(defaultTime: Int = 400, block: () -> Unit) {
this.setOnClickListener {
val timeStamp =System.currentTimeMillis()
if (abs(timeStamp - lastClickTime) > defaultTime) {
lastClickTime = timeStamp
block()
}
}
}

fun View.fadeIn() {
val self = this
val animation = AlphaAnimation(0f, 1f)
Expand Down

0 comments on commit 02fa876

Please sign in to comment.