Skip to content

Commit 652414b

Browse files
author
jacob-tabak
committed
Merge branch 'alexcohn-master'
2 parents 126d271 + 3019977 commit 652414b

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

library/src/main/java/com/timehop/stickyheadersrecyclerview/StickyRecyclerHeadersTouchListener.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff 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
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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>

sample/src/main/res/layout/view_item.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
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"/>

0 commit comments

Comments
 (0)