Commit 88f0dbc2 authored by leichao.gao's avatar leichao.gao

收起软键盘

parent bde02d1b
...@@ -58,8 +58,14 @@ class SearchActivity : BaseActivity<ActivitySearchBinding>() { ...@@ -58,8 +58,14 @@ class SearchActivity : BaseActivity<ActivitySearchBinding>() {
override val binding: ActivitySearchBinding by lazy { override val binding: ActivitySearchBinding by lazy {
ActivitySearchBinding.inflate(layoutInflater) ActivitySearchBinding.inflate(layoutInflater)
} }
fun closeIm() {
val imm = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
if (imm != null && currentFocus != null) {
imm.hideSoftInputFromWindow(currentFocus!!.windowToken, 0)
}
}
private fun searchJump(content: String) { private fun searchJump(content: String) {
closeIm()
var link = "" var link = ""
LinkSearchUtils.handleInput(content, loadUrl = { LinkSearchUtils.handleInput(content, loadUrl = {
link = it link = it
......
...@@ -4,6 +4,7 @@ package com.base.browserwhite.ui.activity.webbrowser ...@@ -4,6 +4,7 @@ package com.base.browserwhite.ui.activity.webbrowser
import android.animation.AnimatorSet import android.animation.AnimatorSet
import android.animation.ObjectAnimator import android.animation.ObjectAnimator
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent import android.content.Intent
import android.graphics.Color import android.graphics.Color
import android.text.Editable import android.text.Editable
...@@ -375,9 +376,10 @@ class WebBrowserActivity : BaseActivity<ActivityWebBrowserBinding>() { ...@@ -375,9 +376,10 @@ class WebBrowserActivity : BaseActivity<ActivityWebBrowserBinding>() {
binding.ivPageSearchClose.setOnClickListener { binding.ivPageSearchClose.setOnClickListener {
binding.editPageSearch.setText("") binding.editPageSearch.setText("")
binding.editPageSearch.clearFocus()
binding.llPageSearch.visibility = View.GONE binding.llPageSearch.visibility = View.GONE
binding.clBottom.visibility = View.VISIBLE binding.clBottom.visibility = View.VISIBLE
closeIm() hideKeyboard(this,binding.editPageSearch)
} }
...@@ -410,11 +412,9 @@ class WebBrowserActivity : BaseActivity<ActivityWebBrowserBinding>() { ...@@ -410,11 +412,9 @@ class WebBrowserActivity : BaseActivity<ActivityWebBrowserBinding>() {
} }
} }
} }
fun closeIm() { fun hideKeyboard(context: Context, view: View) {
val imm = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager val imm = context.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
if (imm != null && currentFocus != null) { imm?.hideSoftInputFromWindow(view.windowToken, 0)
imm.hideSoftInputFromWindow(currentFocus!!.windowToken, 0)
}
} }
fun setSearchNum(int: Int, max: Int) { fun setSearchNum(int: Int, max: Int) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment