File tree Expand file tree Collapse file tree 3 files changed +28
-3
lines changed
library/src/main/java/com/timehop/stickyheadersrecyclerview Expand file tree Collapse file tree 3 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ public interface OnHeaderClickListener {
1717 }
1818
1919 public StickyRecyclerHeadersTouchListener (final RecyclerView recyclerView ,
20- final StickyRecyclerHeadersDecoration decor ) {
20+ final StickyRecyclerHeadersDecoration decor ) {
2121 mTapDetector = new GestureDetector (recyclerView .getContext (), new SingleTapDetector ());
2222 mRecyclerView = recyclerView ;
2323 mDecor = decor ;
@@ -40,7 +40,18 @@ public void setOnHeaderClickListener(OnHeaderClickListener listener) {
4040
4141 @ Override
4242 public boolean onInterceptTouchEvent (RecyclerView view , MotionEvent e ) {
43- return mOnHeaderClickListener != null && mTapDetector .onTouchEvent (e );
43+ if (this .mOnHeaderClickListener != null ) {
44+ boolean tapDetectorResponse = this .mTapDetector .onTouchEvent (e );
45+ if (tapDetectorResponse ) {
46+ // Don't return false if a single tap is detected
47+ return true ;
48+ }
49+ if (e .getAction () == MotionEvent .ACTION_DOWN ) {
50+ int position = mDecor .findHeaderPositionUnder ((int )e .getX (), (int )e .getY ());
51+ return position != -1 ;
52+ }
53+ }
54+ return false ;
4455 }
4556
4657 @ Override
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" utf-8" ?>
2+ <selector xmlns : android =" http://schemas.android.com/apk/res/android" >
3+ <item android : state_pressed =" true" >
4+ <shape android : shape =" rectangle" >
5+ <solid android : color =" @android:color/holo_blue_light" />
6+ </shape >
7+ </item >
8+ <item >
9+ <shape android : shape =" rectangle" >
10+ <solid android : color =" @android:color/white" />
11+ </shape >
12+ </item >
13+ </selector >
Original file line number Diff line number Diff line change 44 xmlns : android =" http://schemas.android.com/apk/res/android"
55 xmlns : tools =" http://schemas.android.com/tools"
66 android : orientation =" horizontal"
7+ android : clickable =" true"
78 android : layout_width =" match_parent"
89 android : layout_height =" wrap_content"
910 android : padding =" @dimen/small"
1011 android : textSize =" 14sp"
1112 tools : text =" Aardvark"
12- android : background =" @android:color/white "
13+ android : background =" @drawable/white_touch "
1314 tools : context =" .MainActivity" />
You can’t perform that action at this time.
0 commit comments