Skip to content

Instantly share code, notes, and snippets.

View BhavyaRattan's full-sized avatar

Bhavya Mishra BhavyaRattan

View GitHub Profile
@BhavyaRattan
BhavyaRattan / ScaleItemOnTouchListener.kt
Created September 26, 2020 14:21
Magic Touch Recycler
class ScaleItemOnTouchListener : RecyclerView.OnItemTouchListener {
private var previousX = 0f
private var previousY = 0f
private var previousMotionX = 0f
private var previousMotionY = 0f
private object Constants {
const val SCALE_DEFAULT = 1f
@BhavyaRattan
BhavyaRattan / onInterceptTouchEvent.kt
Last active January 21, 2021 12:10
Magic Touch Recycler
class ScaleItemOnTouchListener : RecyclerView.OnItemTouchListener {
.......
override fun onInterceptTouchEvent(rv: RecyclerView, event: MotionEvent): Boolean {
var interceptTouch = false
when (event.actionMasked) {
MotionEvent.ACTION_DOWN -> {
previousMotionX = event.x
previousMotionY = event.y
@BhavyaRattan
BhavyaRattan / onTouchEvent.kt
Created January 21, 2021 12:13
Magic Touch Recycler
class ScaleItemOnTouchListener : RecyclerView.OnItemTouchListener {
.......
override fun onTouchEvent(rv: RecyclerView, event: MotionEvent) {
val childView = rv.findChildViewUnder(event.x, event.y)
val previousChild = rv.findChildViewUnder(previousX, previousY)
if (childView != null) {
when (event.action) {