Skip to content

Commit

Permalink
修复4.2低版本适配
Browse files Browse the repository at this point in the history
  • Loading branch information
lic committed Feb 13, 2020
1 parent 5a5d60a commit 7c6166f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions keyboard/src/main/java/com/lllic/keyboard/KeyBoardStateHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class KeyBoardStateHelper(activity: FragmentActivity) {

private val popupWindow: PopupWindow = PopupWindow()
private val layoutListener: ViewTreeObserver.OnGlobalLayoutListener
private val windowFocusChangeListener: ViewTreeObserver.OnWindowFocusChangeListener
private var windowFocusChangeListener: ViewTreeObserver.OnWindowFocusChangeListener? = null
private val screenRealHeight: Int
private var keybordShow = false
private var displayHeight: Int = 0
Expand Down Expand Up @@ -52,9 +52,11 @@ class KeyBoardStateHelper(activity: FragmentActivity) {
screenRealHeight = activity.screenRealHeight
layoutListener = ViewTreeObserver.OnGlobalLayoutListener { onStateChange() }
popupWindow.contentView.viewTreeObserver.addOnGlobalLayoutListener(layoutListener)
windowFocusChangeListener = ViewTreeObserver.OnWindowFocusChangeListener {focus ->
if (!focus){
keyBoardPanelSwitchHelper?.hideKeyBoardPanel()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
windowFocusChangeListener = ViewTreeObserver.OnWindowFocusChangeListener {focus ->
if (!focus){
keyBoardPanelSwitchHelper?.hideKeyBoardPanel()
}
}
}
val decorView = activity.window?.decorView
Expand Down

0 comments on commit 7c6166f

Please sign in to comment.