Skip to content

Commit

Permalink
[fix] #221 댓글 입력창 바깥을 터치했을 때만 키보드가 내려가고 포커스 해제되도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
leeeha committed Nov 4, 2023
1 parent 1af2ee2 commit 63b5699
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.go.sopt.winey.presentation.main.feed.detail

import android.content.Intent
import android.graphics.Rect
import android.os.Bundle
import android.view.Gravity
import android.view.MotionEvent
import android.view.View
import android.widget.EditText
import androidx.activity.viewModels
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
Expand Down Expand Up @@ -89,9 +91,23 @@ class DetailActivity : BindingActivity<ActivityDetailBinding>(R.layout.activity_
}
}

override fun dispatchTouchEvent(event: MotionEvent?): Boolean {
hideKeyboard()
binding.etComment.clearFocus()
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
if (event.action == MotionEvent.ACTION_DOWN) {
currentFocus?.let { view ->
if (view is EditText) {
val focusView = Rect()
view.getGlobalVisibleRect(focusView)

val touchedX = event.x.toInt()
val touchedY = event.y.toInt()

if (!focusView.contains(touchedX, touchedY)) {
hideKeyboard()
binding.etComment.clearFocus()
}
}
}
}
return super.dispatchTouchEvent(event)
}

Expand Down

0 comments on commit 63b5699

Please sign in to comment.