Commit 78893c71 authored by Christophe Henry's avatar Christophe Henry

Correctly hide keyboard

parent 04391fb5
......@@ -5,7 +5,6 @@ import android.animation.AnimatorListenerAdapter
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.os.ResultReceiver
import android.view.View
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
......@@ -17,17 +16,16 @@ import fr.chenry.android.freshrss.R
import fr.chenry.android.freshrss.store.Store
import fr.chenry.android.freshrss.utils.*
import kotlinx.android.synthetic.main.activity_login.*
import nl.komponents.kovenant.deferred
import nl.komponents.kovenant.resolve
import nl.komponents.kovenant.ui.failUi
import nl.komponents.kovenant.ui.successUi
import java.util.Properties
/**
* A login screen that offers login via email/password.
*/
class LoginActivity : AppCompatActivity() {
private lateinit var instanceUrl: InstanceUrl
private val inputManager by lazy {
getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
......@@ -133,15 +131,8 @@ class LoginActivity : AppCompatActivity() {
}
private fun hideKeyboard() {
val deferred = deferred<Unit, Exception>()
val view = this.currentFocus
view?.let {
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(it.windowToken, 0, object : ResultReceiver(null) {
override fun onReceiveResult(resultCode: Int, resultData: Bundle?) = deferred.resolve()
})
}.whenNull { deferred.resolve() }
deferred.promise.get()
val token = (this.currentFocus ?: findViewById<View>(android.R.id.content).rootView).windowToken
token?.let {inputManager.hideSoftInputFromWindow(it, 0)}
}
private fun showProgress(show: Boolean) {
......
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