Created
July 30, 2015 12:01
-
-
Save damianpetla/e72fd505415e0fc10c78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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