Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ravindu committed Jul 20, 2017
2 parents af8be5d + e153a04 commit 3214739
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions KeyboardUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class KeyboardUtils implements ViewTreeObserver.OnGlobalLayoutListener

private SoftKeyboardToggleListener mCallback;
private View mRootView;
private Boolean prevValue = null;
private float mScreenDensity = 1;
private static HashMap<SoftKeyboardToggleListener, KeyboardUtils> sListenerMap = new HashMap<>();

Expand All @@ -36,9 +37,12 @@ public void onGlobalLayout()

int heightDiff = mRootView.getRootView().getHeight() - (r.bottom - r.top);
float dp = heightDiff/ mScreenDensity;
boolean isVisible = dp > MAGIC_NUMBER;

if(mCallback != null)
mCallback.onToggleSoftKeyboard(dp > MAGIC_NUMBER);
if (mCallback != null && (prevValue == null || isVisible != prevValue)) {
prevValue = isVisible;
mCallback.onToggleSoftKeyboard(isVisible);
}
}


Expand Down

0 comments on commit 3214739

Please sign in to comment.