Skip to content

Commit 06afc45

Browse files
committed
ViewExtensions: Update
Signed-off-by: Fung <fython@163.com>
1 parent b6e4c80 commit 06afc45

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

kotlinyan-common/src/main/kotlin/moe/feng/kotlinyan/common/ViewExtensions.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import android.view.inputmethod.InputMethodManager
1010
import android.widget.ImageView
1111
import kotlin.concurrent.thread
1212

13-
interface ViewExtensions {
13+
interface ViewExtensions: ServiceExtensions {
1414

1515
// Find views
1616

@@ -24,16 +24,14 @@ interface ViewExtensions {
2424
*/
2525
fun View.showKeyboard() {
2626
this.requestFocus()
27-
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
28-
imm.showSoftInput(this, InputMethodManager.SHOW_IMPLICIT)
27+
context.inputMethodManager.showSoftInput(this, InputMethodManager.SHOW_IMPLICIT)
2928
}
3029

3130
/**
3231
* Hide keyboard when the view is focused.
3332
*/
3433
fun View.hideKeyboard() {
35-
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
36-
imm.hideSoftInputFromWindow(windowToken, 0)
34+
context.inputMethodManager.hideSoftInputFromWindow(windowToken, 0)
3735
}
3836

3937
// Visibility Methods

0 commit comments

Comments
 (0)