Skip to content

Instantly share code, notes, and snippets.

@fpillet
Created February 9, 2012 12:12

Revisions

  1. fpillet created this gist Feb 9, 2012.
    20 changes: 20 additions & 0 deletions gistfile1.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    containerView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener()
    {
    public void onGlobalLayout()
    {
    final Activity app = getActivity();
    if (app == null)
    return;
    Rect r = new Rect();
    containerView.getWindowVisibleDisplayFrame(r);
    boolean visible = (Math.abs(r.height() - containerView.getHeight()) > 128);
    if (visible != keyboardVisible)
    {
    keyboardVisible = visible;
    NotificationCenter.postNotification(
    Constants.KEYBOARD_VISIBILITY_CHANGED,
    this,
    CFDictionary.withObjectsAndKeys(visible, "visible"));
    }
    }
    });