Skip to content

Commit

Permalink
FIX: Fixed error touch listener
Browse files Browse the repository at this point in the history
  • Loading branch information
leonel Mendez authored and leonel Mendez committed Dec 14, 2016
1 parent 7cb50b0 commit 334cf7e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ open class RecyclerViewHeaderClickListener(context: Context, var headerClick:OnH

val child:View? = rv?.findChildViewUnder(e!!.x,e.y)
if(gestureDetector.onTouchEvent(e)) {
if(rv?.getChildAdapterPosition(child) == 0)
headerClick.onHeaderClick()
else
recyclerViewItem.onItemClick(child, (rv?.getChildAdapterPosition(child)?.minus(1)))
if(rv?.getChildAdapterPosition(child)!! >= 0) {
if (rv?.getChildAdapterPosition(child) == 0) {
headerClick.onHeaderClick()
return true
} else {
recyclerViewItem.onItemClick(child, (rv?.getChildAdapterPosition(child)?.minus(1)))
return true
}
}else {
return false
}
}
return false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ open class RecyclerViewItemClickListener(context: Context, var recyclerViewItem:
}

override fun onInterceptTouchEvent(rv: RecyclerView?, e: MotionEvent?): Boolean {
val child:View? = rv?.findChildViewUnder(e!!.x,e.y)
if(gestureDetector.onTouchEvent(e)) {
recyclerViewItem.onItemClick(child, rv?.getChildAdapterPosition(child))
val child: View? = rv?.findChildViewUnder(e!!.x, e.y)
if (gestureDetector.onTouchEvent(e)) {
if (rv?.getChildAdapterPosition(child)!! >= 0) {
recyclerViewItem.onItemClick(child, rv?.getChildAdapterPosition(child))
return true
} else {
return false
}
}
return false
}
Expand Down

0 comments on commit 334cf7e

Please sign in to comment.