25 lines
736 B
Kotlin
25 lines
736 B
Kotlin
package net.schueller.peertube.utils
|
|
|
|
import android.content.Context
|
|
import android.view.inputmethod.InputMethodManager
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
import androidx.fragment.app.Fragment
|
|
|
|
fun Fragment.hideKeyboard(): Boolean {
|
|
activity?.currentFocus?.let {
|
|
val imm = context?.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
|
imm.hideSoftInputFromWindow(it.windowToken, 0)
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
fun AppCompatActivity.hideKeyboard(): Boolean {
|
|
currentFocus?.let {
|
|
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
|
imm.hideSoftInputFromWindow(it.windowToken, 0)
|
|
return true
|
|
}
|
|
return false
|
|
}
|