Java Code Examples for android.widget.AbsListView#getChildCount()
The following examples show how to use
android.widget.AbsListView#getChildCount() .
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: MultiSwipeRefreshLayout.java From ZfsoftCampusAssit with Apache License 2.0 | 6 votes |
/** * Utility method to check whether a {@link View} can scroll up from it's current position. * Handles platform version differences, providing backwards compatible functionality where * needed. */ private static boolean canViewScrollUp(View view) { if (android.os.Build.VERSION.SDK_INT >= 14) { // For ICS and above we can call canScrollVertically() to determine this return ViewCompat.canScrollVertically(view, -1); } else { if (view instanceof AbsListView) { // Pre-ICS we need to manually check the first visible item and the child view's top // value final AbsListView listView = (AbsListView) view; return listView.getChildCount() > 0 && (listView.getFirstVisiblePosition() > 0 || listView.getChildAt(0).getTop() < listView.getPaddingTop()); } else { // For all other view types we just check the getScrollY() value return view.getScrollY() > 0; } } }
Example 2
Source File: FireworkyPullToRefreshLayout.java From FireworkyPullToRefresh with MIT License | 6 votes |
/** * @return Whether it is possible for the child view of this layout to * scroll up. Override this if the child view is a custom view. */ public boolean canChildScrollUp() { if (mOnChildScrollUpCallback != null) { return mOnChildScrollUpCallback.canChildScrollUp(this, mTarget); } if (android.os.Build.VERSION.SDK_INT < 14) { if (mTarget instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTarget; return absListView.getChildCount() > 0 && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0).getTop() < absListView.getPaddingTop()); } else { return ViewCompat.canScrollVertically(mTarget, -1) || mTarget.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(mTarget, -1); } }
Example 3
Source File: PtrDefaultHandler2.java From Elephant with Apache License 2.0 | 6 votes |
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 4
Source File: CommonPtrLayout.java From FamilyChat with Apache License 2.0 | 6 votes |
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 5
Source File: ViewScrollChecker.java From Android-Pull-To-Refresh with Apache License 2.0 | 6 votes |
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 6
Source File: WXSwipeLayout.java From weex-uikit with MIT License | 6 votes |
/** * Whether child view can scroll down * @return */ public boolean canChildScrollDown() { if (mTargetView == null) { return false; } if (Build.VERSION.SDK_INT < 14) { if (mTargetView instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTargetView; if (absListView.getChildCount() > 0) { int lastChildBottom = absListView.getChildAt(absListView.getChildCount() - 1) .getBottom(); return absListView.getLastVisiblePosition() == absListView.getAdapter().getCount() - 1 && lastChildBottom <= absListView.getMeasuredHeight(); } else { return false; } } else { return ViewCompat.canScrollVertically(mTargetView, 1) || mTargetView.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(mTargetView, 1); } }
Example 7
Source File: CustomSwipeRefreshLayout.java From NewFastFrame with Apache License 2.0 | 6 votes |
/** * @return Whether it is possible for the child view of this layout to * scroll up. Override this if the child view is a custom view. */ public boolean canChildScrollUp() { if (mChildScrollUpCallback != null) { return mChildScrollUpCallback.canChildScrollUp(this, mTarget); } if (android.os.Build.VERSION.SDK_INT < 14) { if (mTarget instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTarget; return absListView.getChildCount() > 0 && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0) .getTop() < absListView.getPaddingTop()); } else { return ViewCompat.canScrollVertically(mTarget, -1) || mTarget.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(mTarget, -1); } }
Example 8
Source File: SwipeRefreshLayout.java From android-recipes-app with Apache License 2.0 | 5 votes |
/** * @return Whether it is possible for the child view of this layout to * scroll up. Override this if the child view is a custom view. */ public boolean canChildScrollUp() { if (android.os.Build.VERSION.SDK_INT < 14) { if (mTarget instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTarget; return absListView.getChildCount() > 0 && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0) .getTop() < absListView.getPaddingTop()); } else { return mTarget.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(mTarget, -1); } }
Example 9
Source File: SwipeRefreshLayout.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
/** * @return Whether it is possible for the child view of this layout to * scroll up. Override this if the child view is a custom view. */ public boolean canChildScrollUp() { if (android.os.Build.VERSION.SDK_INT < 14) { if (mTarget instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTarget; return absListView.getChildCount() > 0 && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0) .getTop() < absListView.getPaddingTop()); } else { return mTarget.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(mTarget, -1); } }
Example 10
Source File: SlidingLayout.java From LLApp with Apache License 2.0 | 5 votes |
/** * 判断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 11
Source File: BGARefreshLayout.java From AndroidStudyDemo with GNU General Public License v2.0 | 5 votes |
public boolean shouldHandleAbsListViewLoadingMore(AbsListView absListView) { if (mIsLoadingMore || mCurrentRefreshStatus == RefreshStatus.REFRESHING || mLoadMoreFooterView == null || mDelegate == null || absListView == null || absListView.getAdapter() == null || absListView.getAdapter().getCount() == 0) { return false; } int lastChildBottom = 0; if (absListView.getChildCount() > 0) { // 如果AdapterView的子控件数量不为0,获取最后一个子控件的bottom lastChildBottom = absListView.getChildAt(absListView.getChildCount() - 1).getBottom(); } return absListView.getLastVisiblePosition() == absListView.getAdapter().getCount() - 1 && lastChildBottom <= absListView.getMeasuredHeight(); }
Example 12
Source File: SlidingLayout.java From stynico with MIT License | 5 votes |
/** * 判断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 13
Source File: SlidingLayout.java From stynico with MIT License | 5 votes |
/** * 判断View是否可以上拉 * @return canChildScrollUp */ public boolean canChildScrollUp() { 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.getFirstVisiblePosition() > 0 || absListView.getChildAt(0) .getTop() < absListView.getPaddingTop()); } else { return ViewCompat.canScrollVertically(mTargetView, -1) || mTargetView.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(mTargetView, -1); } }
Example 14
Source File: ScrollStateUtil.java From SimpleProject with MIT License | 5 votes |
/** * AbsListView类型的View是否已滑动到底部 * @param listView * @return */ public static boolean absListViewReachBottom(AbsListView listView) { if (listView.getChildCount() > 0) { int lastItemBottom = listView.getChildAt(listView.getChildCount() - 1).getBottom(); int listHeight = listView.getBottom() - listView.getTop(); return listView.getLastVisiblePosition() == listView.getAdapter().getCount() - 1 && lastItemBottom <= listHeight; } return false; }
Example 15
Source File: StartView.java From anvil-examples with MIT License | 5 votes |
public void onScroll(AbsListView v, int first, int count, int total) { int top = 0; if (v.getChildCount() > 0) { top = -v.getChildAt(0).getTop() + first * v.getChildAt(0).getHeight(); if (top >= 0) { mTopViewHeight = Math.max((int) (Style.MAX_TOP_HEIGHT - top/(getResources().getDisplayMetrics().density)/1.5f), Style.MIN_TOP_HEIGHT); } } }
Example 16
Source File: SuperSwipeRefreshLayout.java From AutoRecycleView with Apache License 2.0 | 5 votes |
/** * 判断目标View是否滑动到顶部-还能否继续滑动 * * @return */ public boolean isChildScrollToTop() { if (android.os.Build.VERSION.SDK_INT < 14) { if (mTarget instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTarget; return !(absListView.getChildCount() > 0 && (absListView .getFirstVisiblePosition() > 0 || absListView .getChildAt(0).getTop() < absListView.getPaddingTop())); } else { return !(mTarget.getScrollY() > 0); } } else { return !ViewCompat.canScrollVertically(mTarget, -1); } }
Example 17
Source File: ScrollingUtil.java From AgentWebX5 with Apache License 2.0 | 5 votes |
/** * 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: SwipeRefresh.java From mooc_hyman with Apache License 2.0 | 5 votes |
/** * @return Whether it is possible for the child view of this layout to * scroll up. Override this if the child view is a custom view. */ public boolean canChildScrollUp() { if (android.os.Build.VERSION.SDK_INT < 14) { if (mTarget instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTarget; return absListView.getChildCount() > 0 && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0) .getTop() < absListView.getPaddingTop()); } else { return mTarget.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(mTarget, -1); } }
Example 19
Source File: Util.java From dynamiclistview with MIT License | 5 votes |
public static boolean reachedListBottom(AbsListView listView) { boolean flag = true; if (listView.getChildCount() != 0) { int i = listView.getLastVisiblePosition(); int j = listView.getCount(); int k = listView.getHeight(); int l = listView.getChildAt(-1 + listView.getChildCount()).getBottom(); if (i != j - 1 || l > k) { flag = false; } } return flag; }
Example 20
Source File: DSListView.java From direct-select-android with MIT License | 4 votes |
@Override public void onScroll(AbsListView listView, int firstVisible, int visibleItemCount, int totalItemCount) { if (!pickerInitialized || !selectorAnimationsEnabled) return; int selectorPosY = cellHeight * cellsBeforeSelector; int applyingRangeY = cellHeight; for (int i = 0; i < listView.getChildCount(); i++) { // Exclude elements that does not need to edit if (!(listView.getChildAt(i) instanceof FrameLayout)) continue; ViewGroup itemRoot = (ViewGroup) listView.getChildAt(i); float deviation = 2f; if (itemRoot.getTop() > selectorPosY + applyingRangeY * deviation || itemRoot.getTop() < selectorPosY - applyingRangeY * deviation) continue; View cellContent = itemRoot.getChildAt(0); // Edit elements regarding to their position from selector float dy = Math.abs(itemRoot.getTop() - selectorPosY); if (!selectorAnimationCenterPivot) { cellContent.setPivotX(0); cellContent.setPivotY(cellContent.getHeight() / 2); } // Scale and "3d effect" for big scale factors on API>=LOLLIPOP if (dy <= applyingRangeY) { float k1 = 1 - (dy / applyingRangeY); float scale = 1 + scaleFactorDelta * k1; cellContent.setScaleX(scale); cellContent.setScaleY(scale); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) itemRoot.setZ((dy <= applyingRangeY / 2) ? 2 : 1); } else { cellContent.setScaleX(1f); cellContent.setScaleY(1f); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) itemRoot.setZ(0); } } }