CopyPastor

Detecting plagiarism made easy.

Score: 0.8509140769137612; Reported for: String similarity Open both answers

Possible Plagiarism

Reposted on 2018-09-19
by Shohel Rana

Original Post

Original - Posted on 2018-09-19
by Shohel Rana



            
Present in both answers; Present only in the new answer; Present only in the old answer;

I use below Process. It's Working For Me Perfectly. Add below function in your activity Class.
override fun dispatchTouchEvent(event: MotionEvent): Boolean { if (event.action == MotionEvent.ACTION_DOWN) { val v = currentFocus if (v is EditText) { val outRect = Rect() v.getGlobalVisibleRect(outRect) if (!outRect.contains(event.rawX.toInt(), event.rawY.toInt())) { Log.d("focus", "touchevent") v.clearFocus() val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager imm.hideSoftInputFromWindow(v.windowToken, 0) } } } return super.dispatchTouchEvent(event)}
You can check Focus status using Below Code. Both activity and Fragment
appCompatEditText.onFocusChangeListener = View.OnFocusChangeListener { view, hasFocus -> if (!hasFocus) { toast("Focus Off") }else { toast("Focus On") } }
I use below Process. It's Working For Me Perfectly. Add below function in your activity Class.
override fun dispatchTouchEvent(event: MotionEvent): Boolean { if (event.action == MotionEvent.ACTION_DOWN) { val v = currentFocus if (v is EditText) { val outRect = Rect() v.getGlobalVisibleRect(outRect) if (!outRect.contains(event.rawX.toInt(), event.rawY.toInt())) { Log.d("focus", "touchevent") v.clearFocus() val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager imm.hideSoftInputFromWindow(v.windowToken, 0) } } } return super.dispatchTouchEvent(event) }
Then I will Check Focus status in my fragment.
appCompatEditText.onFocusChangeListener = View.OnFocusChangeListener { view, hasFocus -> if (!hasFocus) { toast("Focus Off") }else { toast("Focus On") } }
I was Checked in Fragment. I needed Focus status for my task Requirement. Focus Out I needed some task.

        
Present in both answers; Present only in the new answer; Present only in the old answer;