隐藏键盘
This commit is contained in:
parent
597b3935fa
commit
774d4a4379
|
|
@ -13,6 +13,7 @@ import androidx.core.view.updatePadding
|
|||
import androidx.fragment.app.viewModels
|
||||
import com.ama.core.architecture.appBase.AppViewsFragment
|
||||
import com.ama.core.architecture.appBase.OnFragmentBackgroundListener
|
||||
import com.ama.core.architecture.util.AndroidUtil
|
||||
import com.ama.core.architecture.util.setOnClickBatch
|
||||
import com.ama.core.architecture.util.setStatusBarDarkFont
|
||||
import com.ama.core.common.util.dp
|
||||
|
|
@ -67,6 +68,7 @@ class MineFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(),
|
|||
|
||||
ivSaveName -> {
|
||||
switchNameEditState(false)
|
||||
AndroidUtil.hideKeyboard(ivSaveName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.ama.core.architecture.util
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
import android.content.pm.PackageManager
|
||||
|
|
@ -16,6 +17,7 @@ import android.view.LayoutInflater
|
|||
import android.view.PixelCopy
|
||||
import android.view.View
|
||||
import android.view.Window
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.webkit.WebView
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
|
|
@ -108,6 +110,20 @@ class AndroidUtil private constructor() {
|
|||
}
|
||||
}
|
||||
|
||||
fun hideKeyboard(view: View?) {
|
||||
view?.let { v ->
|
||||
val imm = v.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
imm.hideSoftInputFromWindow(v.windowToken, InputMethodManager.HIDE_NOT_ALWAYS)
|
||||
v.clearFocus()
|
||||
}
|
||||
}
|
||||
|
||||
fun showKeyboard(view: View) {
|
||||
view.requestFocus()
|
||||
val imm = view.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT)
|
||||
}
|
||||
|
||||
fun openUrl(url: String) {
|
||||
val appContext = BaseApp.appContext()
|
||||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
||||
|
|
|
|||
Loading…
Reference in New Issue