Browse Source

Removing unused class

master
anthony restaino 8 years ago
parent
commit
d7e5a5fbe2
  1. 67
      app/src/main/java/acr/browser/lightning/utils/KeyboardHelper.java

67
app/src/main/java/acr/browser/lightning/utils/KeyboardHelper.java

@ -1,67 +0,0 @@ @@ -1,67 +0,0 @@
package acr.browser.lightning.utils;
import android.graphics.Rect;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.ViewTreeObserver;
class KeyboardHelper {
interface KeyboardListener {
/**
* Called when the visibility of the keyboard changes.
* Parameter tells whether the keyboard has been shown
* or hidden.
*
* @param visible true if the keyboard has been shown,
* false otherwise.
*/
void keyboardVisibilityChanged(boolean visible);
}
@NonNull private final View mView;
private int mLastRight = -1;
private int mLastBottom = -1;
/**
* Constructor
*
* @param view the view to listen on, should be
* the {@link android.R.id#content} view.
*/
public KeyboardHelper(@NonNull View view) {
mView = view;
}
/**
* Registers a {@link KeyboardListener} to receive
* callbacks when the keyboard is shown for the specific
* view. The view used should be the content view as it
* will receive resize events from the system.
*
* @param listener the listener to register to receive events.
*/
public void registerKeyboardListener(@NonNull final KeyboardListener listener) {
mView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Rect rect = new Rect();
if (mLastBottom == -1) {
mLastBottom = rect.bottom;
}
if (mLastRight == -1) {
mLastRight = rect.right;
}
mView.getWindowVisibleDisplayFrame(rect);
if (mLastRight == rect.right && rect.bottom < mLastBottom) {
listener.keyboardVisibilityChanged(true);
} else if (mLastRight == rect.right && rect.bottom > mLastBottom) {
listener.keyboardVisibilityChanged(false);
}
mLastBottom = rect.bottom;
mLastRight = rect.right;
}
});
}
}
Loading…
Cancel
Save