Code review fixes.

This commit is contained in:
Onuray Sahin 2022-12-19 14:44:36 +03:00
parent bc9ca3fd12
commit 3f510087d0
1 changed files with 9 additions and 8 deletions

View File

@ -20,6 +20,7 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.ViewTreeObserver
import androidx.core.widget.doOnTextChanged import androidx.core.widget.doOnTextChanged
import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.fragmentViewModel
import com.airbnb.mvrx.withState import com.airbnb.mvrx.withState
@ -69,11 +70,15 @@ class RenameSessionFragment :
} }
private fun showKeyboard() { private fun showKeyboard() {
views.renameSessionEditText.viewTreeObserver.addOnWindowFocusChangeListener { hasFocus -> val focusChangeListener = object : ViewTreeObserver.OnWindowFocusChangeListener {
if (hasFocus) { override fun onWindowFocusChanged(hasFocus: Boolean) {
views.renameSessionEditText.showKeyboard(andRequestFocus = true) if (hasFocus) {
views.renameSessionEditText.showKeyboard(andRequestFocus = true)
}
views.renameSessionEditText.viewTreeObserver.removeOnWindowFocusChangeListener(this)
} }
} }
views.renameSessionEditText.viewTreeObserver.addOnWindowFocusChangeListener(focusChangeListener)
} }
private fun initSaveButton() { private fun initSaveButton() {
@ -99,11 +104,7 @@ class RenameSessionFragment :
) )
SessionLearnMoreBottomSheet SessionLearnMoreBottomSheet
.show(childFragmentManager, args) .show(childFragmentManager, args)
.apply { .onDismiss = { showKeyboard() }
onDismiss = {
showKeyboard()
}
}
} }
private fun observeViewEvents() { private fun observeViewEvents() {