Java Code Examples for android.widget.AbsListView#getPaddingBottom()

The following examples show how to use android.widget.AbsListView#getPaddingBottom() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DiySwipeRefreshLayout.java    From AndroidStudyDemo with GNU General Public License v2.0 6 votes vote down vote up
public boolean canChildScrollDown() {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (mTarget instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTarget;
    		View lastChild = absListView.getChildAt(absListView.getChildCount() - 1);
    		if (lastChild != null) {
    			return (absListView.getLastVisiblePosition() == (absListView.getCount() - 1))
    					&& lastChild.getBottom() > absListView.getPaddingBottom();
    		}
    		else
    		{
    			return false;
    		}
        } else {
            return mTarget.getHeight() - mTarget.getScrollY() > 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mTarget, 1);
    }
}
 
Example 2
Source File: ExpandedScreen.java    From Dashchan with Apache License 2.0 6 votes vote down vote up
@Override
public void onScroll(AbsListView view, int scrollY, int totalItemCount, boolean first, boolean last) {
	if (Math.abs(scrollY) > slopShiftSize) {
		scrollingDown = scrollY > 0;
	}
	boolean hide = false;
	if (scrollingDown) {
		if (totalItemCount > minItemsCount) {
			// List can be overscrolled when it shows first item including list top padding
			// top <= 0 means that list is not overscrolled
			if (!first || view.getChildAt(0).getTop() <= 0) {
				if (last) {
					View lastView = view.getChildAt(view.getChildCount() - 1);
					if (view.getHeight() - view.getPaddingBottom() - lastView.getBottom() + lastItemLimit < 0) {
						hide = true;
					}
				} else {
					hide = true;
				}
			}
		}
	}
	setShowActionBar(!hide, true);
}
 
Example 3
Source File: SwipeRefreshLayout.java    From Overchan-Android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Этот метод добавлен
 */
public boolean canChildScrollDown() { //изменено
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (mTarget instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTarget;
            return absListView.getCount() > 0 
                    && (absListView.getLastVisiblePosition() < absListView.getCount() - 1 || absListView
                            .getChildAt(absListView.getLastVisiblePosition() - absListView.getFirstVisiblePosition())
                            .getBottom() > absListView.getPaddingBottom() + getMeasuredHeight());
        } else if (mTarget instanceof ScrollView) { //если ScrollView
            return mTarget.getScrollY() + mTarget.getMeasuredHeight() < ((ScrollView)mTarget).getChildAt(0).getMeasuredHeight();
        } else {
            return true; //остальные случаи не обрабатываются
        }
    } else {
        return ViewCompat.canScrollVertically(mTarget, 1);
    }
}
 
Example 4
Source File: SwipyRefreshLayout.java    From SwipyRefreshLayout with MIT License 6 votes vote down vote up
public boolean canChildScrollDown() {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (mTarget instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTarget;
            try {
                if (absListView.getCount() > 0) {
                    if (absListView.getLastVisiblePosition() + 1 == absListView.getCount()) {
                        int lastIndex = absListView.getLastVisiblePosition() - absListView.getFirstVisiblePosition();
                        return absListView.getChildAt(lastIndex).getBottom() == absListView.getPaddingBottom();
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            return true;
        } else {
            return true;
        }
    } else {
        return ViewCompat.canScrollVertically(mTarget, 1);
    }
}
 
Example 5
Source File: CommonPtrLayout.java    From FamilyChat with Apache License 2.0 6 votes vote down vote up
private boolean canScrollDown(View view)
{
    if (android.os.Build.VERSION.SDK_INT < 14)
    {
        if (view instanceof AbsListView)
        {
            final AbsListView absListView = (AbsListView) view;
            return absListView.getChildCount() > 0
                    && (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
                    || absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom());
        } else
        {
            return ViewCompat.canScrollVertically(view, 1) || view.getScrollY() < 0;
        }
    } else
    {
        return ViewCompat.canScrollVertically(view, 1);
    }
}
 
Example 6
Source File: PtrDefaultHandler2.java    From android-Ultra-Pull-To-Refresh-With-Load-More-master with MIT License 6 votes vote down vote up
public static boolean canChildScrollDown(View view) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (view instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) view;
            return absListView.getChildCount() > 0
                    && (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
                    || absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom());
        } else if (view instanceof ScrollView) {
            ScrollView scrollView = (ScrollView) view;
            if (scrollView.getChildCount() == 0) {
                return false;
            } else {
                return scrollView.getScrollY() < scrollView.getChildAt(0).getHeight() - scrollView.getHeight();
            }
        } else {
            return false;
        }
    } else {
        return view.canScrollVertically(1);
    }
}
 
Example 7
Source File: ViewScrollChecker.java    From Android-Pull-To-Refresh with Apache License 2.0 6 votes vote down vote up
private static boolean performAbsListView(AbsListView view, int direction) {
    int childCount = view.getChildCount();
    if (childCount > 0) {
        switch (direction) {
            case DIRECTION_DOWN:
                ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
                int firstItemTop = view.getChildAt(0).getTop();
                int listViewTop = view.getTop() + view.getPaddingTop() - lp.topMargin;
                if (DEBUG_SCROLL_CHECK)
                    L.e(TAG, "firstItemTop=%s,listViewTop=%s", firstItemTop, listViewTop);
                return (view.getFirstVisiblePosition() > 0
                        || firstItemTop < listViewTop);
            case DIRECTION_UP:
                int lastItemBottom = view.getChildAt(childCount - 1).getBottom();
                int listViewBottom = view.getBottom() - view.getPaddingBottom();
                if (DEBUG_SCROLL_CHECK)
                    L.e(TAG, "lastItemBottom=%s,listViewBottom=%s", lastItemBottom, listViewBottom);
                return (view.getLastVisiblePosition() < childCount - 1
                        || lastItemBottom > listViewBottom);
        }
    }
    if (DEBUG_SCROLL_CHECK)
        L.e(TAG, "AbsListView cannot scroll vertically or childCount is 0!!");
    return false;
}
 
Example 8
Source File: SwipyRefreshLayout.java    From AndroidStudyDemo with GNU General Public License v2.0 6 votes vote down vote up
public boolean canChildScrollDown() {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (mTarget instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTarget;
            try {
                if (absListView.getCount() > 0) {
                    if (absListView.getLastVisiblePosition() + 1 == absListView.getCount()) {
                        int lastIndex = absListView.getLastVisiblePosition() - absListView.getFirstVisiblePosition();
                        return absListView.getChildAt(lastIndex).getBottom() == absListView.getPaddingBottom();
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            return true;
        } else {
            return true;
        }
    } else {
        return ViewCompat.canScrollVertically(mTarget, 1);
    }
}
 
Example 9
Source File: PtrDefaultHandler2.java    From Elephant with Apache License 2.0 6 votes vote down vote up
public static boolean canChildScrollDown(View view) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (view instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) view;
            return absListView.getChildCount() > 0
                    && (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
                    || absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom());
        } else if (view instanceof ScrollView) {
            ScrollView scrollView = (ScrollView) view;
            if (scrollView.getChildCount() == 0) {
                return false;
            } else {
                return scrollView.getScrollY() < scrollView.getChildAt(0).getHeight() - scrollView.getHeight();
            }
        } else {
            return false;
        }
    } else {
        return view.canScrollVertically(1);
    }
}
 
Example 10
Source File: ViewUtils.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
/**
 * get AbsListView height according to every children
 * 
 * @param view
 * @return
 */
public static int getAbsListViewHeightBasedOnChildren(AbsListView view) {
    ListAdapter adapter;
    if (view == null || (adapter = view.getAdapter()) == null) {
        return 0;
    }

    int height = 0;
    for (int i = 0; i < adapter.getCount(); i++) {
        View item = adapter.getView(i, null, view);
        if (item instanceof ViewGroup) {
            item.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        }
        item.measure(0, 0);
        height += item.getMeasuredHeight();
    }
    height += view.getPaddingTop() + view.getPaddingBottom();
    return height;
}
 
Example 11
Source File: SwipeToRefreshLayout.java    From SwipeToRefresh with MIT License 6 votes vote down vote up
public boolean canChildScrollDown() {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (mTarget instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTarget;
            try {
                if (absListView.getCount() > 0) {
                    if (absListView.getLastVisiblePosition() + 1 == absListView.getCount()) {
                        int lastIndex = absListView.getLastVisiblePosition() - absListView.getFirstVisiblePosition();
                        return absListView.getChildAt(lastIndex).getBottom() == absListView.getPaddingBottom();
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            return true;
        } else {
            return true;
        }
    } else {
        return ViewCompat.canScrollVertically(mTarget, 1);
    }
}
 
Example 12
Source File: ScrollBoundaryUtil.java    From CollapsingRefresh with Apache License 2.0 5 votes vote down vote up
public static boolean canScrollDown(View targetView) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (targetView instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) targetView;
            return absListView.getChildCount() > 0
                    && (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
                    || absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom());
        } else {
            return targetView.getScrollY() < 0;
        }
    } else {
        return targetView.canScrollVertically(1);
    }
}
 
Example 13
Source File: SlidingLayout.java    From LLApp with Apache License 2.0 5 votes vote down vote up
/**
 * 判断View是否可以下拉
 * @return canChildScrollDown
 */
public boolean canChildScrollDown() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        if (mTargetView instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTargetView;
            return absListView.getChildCount() > 0 && absListView.getAdapter() != null
                    && (absListView.getLastVisiblePosition() < absListView.getAdapter().getCount() - 1 || absListView.getChildAt(absListView.getChildCount() - 1)
                    .getBottom() < absListView.getPaddingBottom());
        } else {
            return ViewCompat.canScrollVertically(mTargetView, 1) || mTargetView.getScrollY() > 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mTargetView, 1);
    }
}
 
Example 14
Source File: CanRefreshLayout.java    From CanRefresh with Apache License 2.0 5 votes vote down vote up
private boolean canScrollDown(View view) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (view instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) view;
            return absListView.getChildCount() > 0
                    && (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
                    || absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom());
        } else {
            return ViewCompat.canScrollVertically(view, 1) || view.getScrollY() < 0;
        }
    } else {
        return ViewCompat.canScrollVertically(view, 1);
    }
}
 
Example 15
Source File: SwipeToLoadLayout.java    From StickyListHeadersWithRefreshAndLoadMore with Apache License 2.0 5 votes vote down vote up
/**
 * Whether it is possible for the child view of this layout to
 * scroll down. Override this if the child view is a custom view.
 *
 * @return
 */
protected boolean canChildScrollDown() {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (mTargetView instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTargetView;
            return absListView.getChildCount() > 0
                    && (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
                    || absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom());
        } else {
            return ViewCompat.canScrollVertically(mTargetView, 1) || mTargetView.getScrollY() < 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mTargetView, 1);
    }
}
 
Example 16
Source File: ViewUtils.java    From VideoMeeting with Apache License 2.0 5 votes vote down vote up
private static boolean canChildScrollDown(View mTarget) {
	if (Build.VERSION.SDK_INT < 14) {
		if (mTarget instanceof AbsListView) {
			final AbsListView absListView = (AbsListView) mTarget;
			return absListView.getChildCount() > 0
					&& (absListView.getChildAt(absListView.getChildCount()-1)
					.getBottom() < absListView.getPaddingBottom());
		} else {
			return mTarget.getScrollY() > 0;
		}
	} else {
		return ViewCompat.canScrollVertically(mTarget, 1);
	}
}
 
Example 17
Source File: ScrollingUtil.java    From TwinklingRefreshLayout with Apache License 2.0 5 votes vote down vote up
/**
 * Whether it is possible for the child view of this layout to scroll down. Override this if the child view is a custom view.
 * 判断是否可以上拉
 */
public static boolean canChildScrollDown(View mChildView) {
    if (Build.VERSION.SDK_INT < 14) {
        if (mChildView instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mChildView;
            return absListView.getChildCount() > 0
                    && (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
                    || absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom());
        } else {
            return ViewCompat.canScrollVertically(mChildView, 1) || mChildView.getScrollY() < 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mChildView, 1);
    }
}
 
Example 18
Source File: ScrollingUtil.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
/**
 * Whether it is possible for the child view of this layout to scroll down. Override this if the child view is a custom view.
 * 判断是否可以上拉
 */
public static boolean canChildScrollDown(View mChildView) {
    if (Build.VERSION.SDK_INT < 14) {
        if (mChildView instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mChildView;
            return absListView.getChildCount() > 0
                    && (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1
                    || absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom());
        } else {
            return ViewCompat.canScrollVertically(mChildView, 1) || mChildView.getScrollY() < 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mChildView, 1);
    }
}
 
Example 19
Source File: SlidingLayout.java    From stynico with MIT License 5 votes vote down vote up
/**
 * 判断View是否可以下拉
 * @return canChildScrollDown
 */
public boolean canChildScrollDown() {
    if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        if (mTargetView instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mTargetView;
            return absListView.getChildCount() > 0 && absListView.getAdapter() != null
                    && (absListView.getLastVisiblePosition() < absListView.getAdapter().getCount() - 1 || absListView.getChildAt(absListView.getChildCount() - 1)
                    .getBottom() < absListView.getPaddingBottom());
        } else {
            return ViewCompat.canScrollVertically(mTargetView, 1) || mTargetView.getScrollY() > 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mTargetView, 1);
    }
}
 
Example 20
Source File: EdgeScrollListener.java    From ProjectX with Apache License 2.0 4 votes vote down vote up
/**
 * 滚动更改
 *
 * @param view             AbsListView
 * @param firstVisibleItem 第一个可见子项
 * @param visibleItemCount 可见子项总数
 * @param totalItemCount   子项总数
 */
private void onScrollChanged(AbsListView view, int firstVisibleItem,
                             int visibleItemCount, int totalItemCount) {
    if (visibleItemCount != 0) {
        ScrollLocation mNewScrollLocation;
        final int gridTop = view.getPaddingTop();
        final int gridBottom = view.getHeight() - view.getPaddingBottom();
        if (totalItemCount == visibleItemCount) {
            // 头尾均显示,需判断是否可滚动
            final int childFristTop = view.getChildAt(0).getTop();
            final int childLastBottom = view.getChildAt(
                    visibleItemCount - 1).getBottom();
            if (childFristTop >= gridTop && childLastBottom <= gridBottom) {
                mNewScrollLocation = ScrollLocation.TB;
            } else if (childFristTop >= gridTop) {
                mNewScrollLocation = ScrollLocation.TOP;
            } else if (childLastBottom <= gridBottom) {
                mNewScrollLocation = ScrollLocation.BOTTOM;
            } else {
                mNewScrollLocation = ScrollLocation.CENTER;
            }

        } else {
            // 头尾不完全显示
            if (firstVisibleItem == 0) {
                // 头显示
                if (view.getChildAt(0).getTop() >= gridTop) {
                    mNewScrollLocation = ScrollLocation.TOP;
                } else {
                    mNewScrollLocation = ScrollLocation.CENTER;
                }

            } else if (firstVisibleItem + visibleItemCount == totalItemCount) {
                // 尾显示
                if (view.getChildAt(visibleItemCount - 1).getBottom() <= gridBottom) {
                    mNewScrollLocation = ScrollLocation.BOTTOM;
                } else {
                    mNewScrollLocation = ScrollLocation.CENTER;
                }
            } else {
                // 头尾均不显示
                mNewScrollLocation = ScrollLocation.CENTER;
            }
        }
        if (mScrollLocation != mNewScrollLocation) {
            if (mScrollLocation == ScrollLocation.NULL) {
                mScrollLocation = mNewScrollLocation;
                return;
            }
            onScrollLocationChanged(mNewScrollLocation, mScrollLocation);
            mScrollLocation = mNewScrollLocation;
        }
    }
}