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

The following examples show how to use android.widget.AbsListView#getPaddingTop() . 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: ResolverDrawerLayout.java    From android-bottomsheet with ISC License 6 votes vote down vote up
public boolean canChildScrollUp() {
    if (mScrollableChildView != null) {
        if (android.os.Build.VERSION.SDK_INT < 14) {
            if (mScrollableChildView instanceof AbsListView) {
                final AbsListView absListView = (AbsListView) mScrollableChildView;
                return absListView.getChildCount() > 0
                        && (absListView.getFirstVisiblePosition() > 0
                        || absListView.getChildAt(0)
                        .getTop() < absListView.getPaddingTop());
            } else if (
                    RECYCLERVIEW_CLASS_NAME.equals(mScrollableChildView.getClass().getName())) {
                final RecyclerView recyclerView = (RecyclerView) mScrollableChildView;
                View firstView = recyclerView.getChildAt(0);
                return recyclerView.getChildCount() > 0
                        && (recyclerView.getLayoutManager().getPosition(firstView) > 0
                        || recyclerView.getChildAt(0).getTop() < recyclerView.getPaddingTop());
            } else {
                return mScrollableChildView.getScrollY() > 0;
            }
        } else {
            return ViewCompat.canScrollVertically(mScrollableChildView, -1);
        }
    }
    return false;
}
 
Example 2
Source File: VRefreshLayout.java    From BaseProject with Apache License 2.0 6 votes vote down vote up
private boolean isTheViewCanScrollDown(View canScrolableView) {
    if (canScrolableView != null) {
        if (android.os.Build.VERSION.SDK_INT < 14) {//android 4.0以下
            if (canScrolableView instanceof AbsListView) {
                final AbsListView absListView = (AbsListView) canScrolableView;
                return absListView.getChildCount() > 0
                        && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                        .getTop() < absListView.getPaddingTop());
            }
            else {
                return ViewCompat.canScrollVertically(canScrolableView, -1) || canScrolableView.getScrollY() > 0;
            }
        } else {
            return ViewCompat.canScrollVertically(canScrolableView, -1);
        }
    }
    return false;
}
 
Example 3
Source File: CommonPtrLayout.java    From FamilyChat with Apache License 2.0 6 votes vote down vote up
private boolean canScrollUp(View view)
{
    if (android.os.Build.VERSION.SDK_INT < 14)
    {
        if (view instanceof AbsListView)
        {
            final AbsListView absListView = (AbsListView) view;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else
        {
            return ViewCompat.canScrollVertically(view, -1) || view.getScrollY() > 0;
        }
    } else
    {
        return ViewCompat.canScrollVertically(view, -1);
    }
}
 
Example 4
Source File: ScrollingUtil.java    From AgentWebX5 with Apache License 2.0 6 votes vote down vote up
/**
 * 用来判断是否可以下拉
 * 手指在屏幕上该方法才有效
 */
public static boolean canChildScrollUp(View mChildView) {
    if (mChildView == null) {
        return false;
    }
    if (Build.VERSION.SDK_INT < 14) {
        if (mChildView instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) mChildView;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else {
            return ViewCompat.canScrollVertically(mChildView, -1) || mChildView.getScrollY() > 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mChildView, -1);
    }
}
 
Example 5
Source File: MultiSwipeRefreshLayout.java    From Qiitanium with MIT License 6 votes vote down vote up
/**
 * 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 setVisible 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 6
Source File: MultiSwipeRefreshLayout.java    From views-widgets-samples with Apache License 2.0 6 votes vote down vote up
/**
 * 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 7
Source File: SwipeToLoadLayout.java    From StickyListHeadersWithRefreshAndLoadMore with Apache License 2.0 5 votes vote down vote up
/**
 * copy from {@link android.support.v4.widget.SwipeRefreshLayout#canChildScrollUp()}
 *
 * @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.
 */
protected boolean canChildScrollUp() {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        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 8
Source File: SlidingLayout.java    From CloudReader with Apache License 2.0 5 votes vote down vote up
/**
 * 判断View是否可以上拉
 *
 * @return canChildScrollUp
 */
public boolean canChildScrollUp() {
    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.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else {
            return ViewCompat.canScrollVertically(mTargetView, -1) || mTargetView.getScrollY() > 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mTargetView, -1);
    }
}
 
Example 9
Source File: SwipeRefresh.java    From Android-Application-ZJB with Apache License 2.0 5 votes vote down vote up
/**
 * @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: LingjuSwipeRefreshLayout.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
/**
 * @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 ViewCompat.canScrollVertically(mTarget, -1) || mTarget.getScrollY() > 0;
        }
    } else {
        return ViewCompat.canScrollVertically(mTarget, -1);
    }
}
 
Example 11
Source File: PtrDefaultHandler.java    From Swface with Apache License 2.0 5 votes vote down vote up
public static boolean canChildScrollUp(View view) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (view instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) view;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else {
            return view.getScrollY() > 0;
        }
    } else {
        return view.canScrollVertically(-1);
    }
}
 
Example 12
Source File: SwipyRefreshLayout.java    From AndroidStudyDemo with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @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 13
Source File: SlidingLayout.java    From stynico with MIT License 5 votes vote down vote up
/**
 * 判断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: PullRefreshLayout.java    From MaterialQQLite with Apache License 2.0 5 votes vote down vote up
private 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 15
Source File: BGAScrollingUtil.java    From AndroidStudyDemo with GNU General Public License v2.0 5 votes vote down vote up
public static boolean isAbsListViewToTop(AbsListView absListView) {
    if (absListView != null) {
        int firstChildTop = 0;
        if (absListView.getChildCount() > 0) {
            // 如果AdapterView的子控件数量不为0,获取第一个子控件的top
            firstChildTop = absListView.getChildAt(0).getTop() - absListView.getPaddingTop();
        }
        if (absListView.getFirstVisiblePosition() == 0 && firstChildTop == 0) {
            return true;
        }
    }
    return false;
}
 
Example 16
Source File: PullRefreshLayout.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private 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 17
Source File: PtrDefaultHandler.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
public static boolean canChildScrollUp(View view) {
    if (android.os.Build.VERSION.SDK_INT < 14) {
        if (view instanceof AbsListView) {
            final AbsListView absListView = (AbsListView) view;
            return absListView.getChildCount() > 0
                    && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                    .getTop() < absListView.getPaddingTop());
        } else {
            return view.getScrollY() > 0;
        }
    } else {
        return view.canScrollVertically(-1);
    }
}
 
Example 18
Source File: SimpleSwipeRefreshLayout.java    From MarkdownEditors with Apache License 2.0 5 votes vote down vote up
@Override
public boolean canChildScrollUp() {
    if (view != null && view instanceof AbsListView) {
        final AbsListView absListView = (AbsListView) view;
        return absListView.getChildCount() > 0
                && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                .getTop() < absListView.getPaddingTop());
    }
    return super.canChildScrollUp();
}
 
Example 19
Source File: PullRefreshLayout.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private boolean canChildScrollDown() {
    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 20
Source File: SuperSwipeRefreshLayout.java    From AutoRecycleView with Apache License 2.0 5 votes vote down vote up
/**
 * 判断目标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);
    }
}