
PullToRefresh就不用说了,非常的好用,原作者已经不更新了,所以不支持RecyclerView
不多说了,直接上代码。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
public class extends PullToRefreshBase<RecyclerView>{ public (Context context) { super(context); }
public (Context context, AttributeSet attrs) { super(context, attrs); }
public (Context context, Mode mode) { super(context, mode); }
public (Context context, Mode mode, AnimationStyle style) { super(context, mode, style); }
public final Orientation getPullToRefreshScrollDirection() { return Orientation.VERTICAL; }
protected RecyclerView createRefreshableView(Context context, AttributeSet attrs) { return new RecyclerView(context, attrs); }
protected boolean isReadyForPullStart() { if (mRefreshableView.getChildCount() <= 0) { return true; } int firstVisiblePosition = mRefreshableView.getChildPosition(mRefreshableView.getChildAt(0)); if (firstVisiblePosition == 0) { return mRefreshableView.getChildAt(0).getTop() == mRefreshableView.getPaddingTop(); } return false; }
protected boolean isReadyForPullEnd() { int lastItemPosition = mRefreshableView.getChildCount() - 1; View lastItemView = mRefreshableView.getChildAt(lastItemPosition); int lastVisiblePosition = mRefreshableView.getChildPosition(lastItemView); if (lastVisiblePosition >= mRefreshableView.getAdapter().getItemCount() - 1) { return mRefreshableView.getChildAt(lastItemPosition).getBottom() <= mRefreshableView.getBottom(); } return false; } }
|
近期评论