11 | * To use it you must pass an instance of a class that implements this 12 | * interface as a second argment StickyRecyclerHeadersDecoration's constructor. 13 | */ 14 | public interface ItemVisibilityAdapter { 15 | 16 | /** 17 | * Return true the specified adapter position is visible, false otherwise 18 | *
19 | * The implementation of this method will typically return true if
20 | * the position is between the layout manager's findFirstVisibleItemPosition
21 | * and findLastVisibleItemPosition (inclusive).
22 | *
23 | * @param position the adapter position
24 | */
25 | boolean isPositionVisible(final int position);
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wujf/stickyheaderfooter/headerfooterutil/util/LinearLayoutOrientationProvider.java:
--------------------------------------------------------------------------------
1 | package com.wujf.stickyheaderfooter.headerfooterutil.util;
2 |
3 | import android.support.v7.widget.LinearLayoutManager;
4 | import android.support.v7.widget.RecyclerView;
5 |
6 | /**
7 | * OrientationProvider for ReyclerViews who use a LinearLayoutManager
8 | */
9 | public class LinearLayoutOrientationProvider implements OrientationProvider {
10 |
11 | @Override
12 | public int getOrientation(RecyclerView recyclerView) {
13 | RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
14 | throwIfNotLinearLayoutManager(layoutManager);
15 | return ((LinearLayoutManager) layoutManager).getOrientation();
16 | }
17 |
18 | @Override
19 | public boolean isReverseLayout(RecyclerView recyclerView) {
20 | RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
21 | throwIfNotLinearLayoutManager(layoutManager);
22 | return ((LinearLayoutManager) layoutManager).getReverseLayout();
23 | }
24 |
25 | private void throwIfNotLinearLayoutManager(RecyclerView.LayoutManager layoutManager) {
26 | if (!(layoutManager instanceof LinearLayoutManager)) {
27 | throw new IllegalStateException("StickyListHeadersDecoration can only be used with a " +
28 | "LinearLayoutManager.");
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/wujf/stickyheaderfooter/headerfooterutil/StickyRecyclerFootersAdapter.java:
--------------------------------------------------------------------------------
1 | package com.wujf.stickyheaderfooter.headerfooterutil;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.ViewGroup;
5 |
6 | public interface StickyRecyclerFootersAdapter