Created
March 13, 2015 09:29
-
-
Save Krishan14sharma/9d7706820b27b77dae4a to your computer and use it in GitHub Desktop.
Fixed issue with View pager and listview.
This file contains hidden or 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
| package com.zap.catchthecup.view; | |
| import android.content.Context; | |
| import android.support.v4.widget.SwipeRefreshLayout; | |
| import android.util.AttributeSet; | |
| import android.view.MotionEvent; | |
| import android.view.ViewConfiguration; | |
| public class CustomSwipeToRefresh extends SwipeRefreshLayout { | |
| private int mTouchSlop; | |
| private float mPrevX; | |
| public CustomSwipeToRefresh(Context context, AttributeSet attrs) { | |
| super(context, attrs); | |
| mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); | |
| } | |
| @Override | |
| public boolean onInterceptTouchEvent(MotionEvent event) { | |
| switch (event.getAction()) { | |
| case MotionEvent.ACTION_DOWN: | |
| mPrevX = MotionEvent.obtain(event).getX(); | |
| break; | |
| case MotionEvent.ACTION_MOVE: | |
| final float eventX = event.getX(); | |
| float xDiff = Math.abs(eventX - mPrevX); | |
| if (xDiff > mTouchSlop) { | |
| return false; | |
| } | |
| } | |
| return super.onInterceptTouchEvent(event); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment