Java Code Examples for android.widget.AdapterView.getLastVisiblePosition()

The following are Jave code examples for showing how to use getLastVisiblePosition() of the android.widget.AdapterView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: GitHub   File: MDRootLayout.java   View Source Code Vote up 6 votes
private static boolean canAdapterViewScroll(AdapterView lv) {
    /* Force it to layout it's children */
    if (lv.getLastVisiblePosition() == -1)
        return false;

    /* We can scroll if the first or last item is not visible */
    boolean firstItemVisible = lv.getFirstVisiblePosition() == 0;
    boolean lastItemVisible = lv.getLastVisiblePosition() == lv.getCount() - 1;

    if (firstItemVisible && lastItemVisible && lv.getChildCount() > 0) {
        /* Or the first item's top is above or own top */
        if (lv.getChildAt(0).getTop() < lv.getPaddingTop())
            return true;
        /* or the last item's bottom is beyond our own bottom */
        return lv.getChildAt(lv.getChildCount() - 1).getBottom() >
                lv.getHeight() - lv.getPaddingBottom();
    }

    return true;
}
 
Example 2
Project: Tribe   File: InterceptLayout.java   View Source Code Vote up 5 votes
public boolean avPullUpIntercept(View child) {
    boolean intercept = false;
    AdapterView adapterChild = (AdapterView) child;

    // 判断AbsListView是否已经到达内容最底部
    if (adapterChild.getLastVisiblePosition() == adapterChild.getCount() - 1
            && (adapterChild.getChildAt(adapterChild.getChildCount() - 1).getBottom() == getMeasuredHeight())) {
        // 如果到达底部,则拦截事件
        intercept = true;
    }
    return intercept;
}