1.通过布局的根目录,判断虚拟键盘的弹出与否:
ViewTreeObserver viewTreeObserver = rootView.getViewTreeObserver();
viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int heightDiff = rootView.getRootView().getHeight() - rootView.getHeight();
if (heightDiff > 100) {
//大小超过100时,一般为显示虚拟键盘事件
isShow = true;
} else {
//大小小于100时,为不显示虚拟键盘或虚拟键盘隐藏
isShow = false;
}
}
});
2.我们在使用第三方的RecyclerView:
UltimateRecyclerView
recyclerView.setOnLoadMoreListener(new UltimateRecyclerView.OnLoadMoreListener() {
@Override
public void loadMore(int itemsCount, final int maxLastVisiblePosition) {
XDLog.e("loadMore", "loadMore data---------");
isReply = false;
if (itemsCount > Constant.MAX_PAGE_COUNT && !isShow)
loadRecommentData(Constant.LoadDataMode.LoadMore);
}
});