Skip to content

Instantly share code, notes, and snippets.

@damianpetla
Created July 30, 2015 12:01
Show Gist options
  • Save damianpetla/e72fd505415e0fc10c78 to your computer and use it in GitHub Desktop.
Save damianpetla/e72fd505415e0fc10c78 to your computer and use it in GitHub Desktop.
public class MySwipeLayout : SwipeRefreshLayout {
public constructor(context: Context) : super(context)
public constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
var appBarLayout: AppBarLayout? = null
override fun onAttachedToWindow() {
super<SwipeRefreshLayout>.onAttachedToWindow()
val context = getContext()
if (context is Activity) {
appBarLayout = context.findViewById(R.id.appBarLayout) as AppBarLayout?
}
}
override fun onDetachedFromWindow() {
appBarLayout = null
super<SwipeRefreshLayout>.onDetachedFromWindow()
}
override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
if (appBarLayout?.getTop() != 0) {
return false
}
return super<SwipeRefreshLayout>.onInterceptTouchEvent(ev)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment