forked from upstream-mirrors/quik
Dismiss keyboard when drawer is opened
This commit is contained in:
@@ -18,9 +18,11 @@
|
||||
*/
|
||||
package common.util.extensions
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.support.annotation.StringRes
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.Toast
|
||||
|
||||
fun Context.getColorCompat(colorRes: Int): Int {
|
||||
@@ -33,4 +35,13 @@ fun Context.makeToast(@StringRes res: Int, duration: Int = Toast.LENGTH_SHORT) {
|
||||
|
||||
fun Context.makeToast(text: String, duration: Int = Toast.LENGTH_SHORT) {
|
||||
Toast.makeText(this, text, duration).show()
|
||||
}
|
||||
|
||||
fun Activity.dismissKeyboard() {
|
||||
window.currentFocus?.let { focus ->
|
||||
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
imm.hideSoftInputFromWindow(focus.windowToken, 0)
|
||||
|
||||
focus.clearFocus()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user