Search in sources :

Example 1 with BGAStickyNavLayout

use of cn.bingoogolapple.refreshlayout.BGAStickyNavLayout in project BGARefreshLayout-Android by bingoogolapple.

the class BGARefreshScrollingUtil method isAbsListViewToBottom.

public static boolean isAbsListViewToBottom(AbsListView absListView) {
    if (absListView != null && absListView.getAdapter() != null && absListView.getChildCount() > 0 && absListView.getLastVisiblePosition() == absListView.getAdapter().getCount() - 1) {
        View lastChild = absListView.getChildAt(absListView.getChildCount() - 1);
        BGAStickyNavLayout stickyNavLayout = getStickyNavLayout(absListView);
        if (stickyNavLayout != null) {
            // 处理BGAStickyNavLayout中lastChild.getBottom() <= absListView.getMeasuredHeight()失效问题
            // 0表示x,1表示y
            int[] location = new int[2];
            lastChild.getLocationOnScreen(location);
            int lastChildBottomOnScreen = location[1] + lastChild.getMeasuredHeight();
            stickyNavLayout.getLocationOnScreen(location);
            int stickyNavLayoutBottomOnScreen = location[1] + stickyNavLayout.getMeasuredHeight();
            return lastChildBottomOnScreen + absListView.getPaddingBottom() <= stickyNavLayoutBottomOnScreen;
        } else {
            return lastChild.getBottom() <= absListView.getMeasuredHeight();
        }
    }
    return false;
}
Also used : BGAStickyNavLayout(cn.bingoogolapple.refreshlayout.BGAStickyNavLayout) AbsListView(android.widget.AbsListView) ScrollView(android.widget.ScrollView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) WebView(android.webkit.WebView)

Example 2 with BGAStickyNavLayout

use of cn.bingoogolapple.refreshlayout.BGAStickyNavLayout in project BGARefreshLayout-Android by bingoogolapple.

the class BGARefreshScrollingUtil method isRecyclerViewToBottom.

public static boolean isRecyclerViewToBottom(RecyclerView recyclerView) {
    if (recyclerView != null) {
        RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
        if (manager == null || manager.getItemCount() == 0) {
            return false;
        }
        if (manager instanceof LinearLayoutManager) {
            // 处理item高度超过一屏幕时的情况
            View lastVisibleChild = recyclerView.getChildAt(recyclerView.getChildCount() - 1);
            if (lastVisibleChild != null && lastVisibleChild.getMeasuredHeight() >= recyclerView.getMeasuredHeight()) {
                if (android.os.Build.VERSION.SDK_INT < 14) {
                    return !(ViewCompat.canScrollVertically(recyclerView, 1) || recyclerView.getScrollY() < 0);
                } else {
                    return !ViewCompat.canScrollVertically(recyclerView, 1);
                }
            }
            LinearLayoutManager layoutManager = (LinearLayoutManager) manager;
            if (layoutManager.findLastCompletelyVisibleItemPosition() == layoutManager.getItemCount() - 1) {
                BGAStickyNavLayout stickyNavLayout = getStickyNavLayout(recyclerView);
                if (stickyNavLayout != null) {
                    // 处理BGAStickyNavLayout中findLastCompletelyVisibleItemPosition失效问题
                    View lastCompletelyVisibleChild = layoutManager.getChildAt(layoutManager.findLastCompletelyVisibleItemPosition());
                    if (lastCompletelyVisibleChild == null) {
                        return true;
                    } else {
                        // 0表示x,1表示y
                        int[] location = new int[2];
                        lastCompletelyVisibleChild.getLocationOnScreen(location);
                        int lastChildBottomOnScreen = location[1] + lastCompletelyVisibleChild.getMeasuredHeight();
                        stickyNavLayout.getLocationOnScreen(location);
                        int stickyNavLayoutBottomOnScreen = location[1] + stickyNavLayout.getMeasuredHeight();
                        return lastChildBottomOnScreen <= stickyNavLayoutBottomOnScreen;
                    }
                } else {
                    return true;
                }
            }
        } else if (manager instanceof StaggeredGridLayoutManager) {
            StaggeredGridLayoutManager layoutManager = (StaggeredGridLayoutManager) manager;
            int[] out = layoutManager.findLastCompletelyVisibleItemPositions(null);
            int lastPosition = layoutManager.getItemCount() - 1;
            for (int position : out) {
                if (position == lastPosition) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : BGAStickyNavLayout(cn.bingoogolapple.refreshlayout.BGAStickyNavLayout) RecyclerView(androidx.recyclerview.widget.RecyclerView) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) AbsListView(android.widget.AbsListView) ScrollView(android.widget.ScrollView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) WebView(android.webkit.WebView)

Aggregations

View (android.view.View)2 WebView (android.webkit.WebView)2 AbsListView (android.widget.AbsListView)2 ScrollView (android.widget.ScrollView)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 BGAStickyNavLayout (cn.bingoogolapple.refreshlayout.BGAStickyNavLayout)2 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 StaggeredGridLayoutManager (androidx.recyclerview.widget.StaggeredGridLayoutManager)1