Skip to content

Commit

Permalink
fix the horizontal slide event distribution issue
Browse files Browse the repository at this point in the history
  • Loading branch information
lucklygaj committed Oct 28, 2016
1 parent b9f7968 commit 942f3f4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion library/src/main/java/com/ajguan/library/EasyRefreshLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public class EasyRefreshLayout extends ViewGroup {
private boolean isEnableLoadMore = true;




private Runnable delayToScrollTopRunnable = new Runnable() {
@Override
public void run() {
Expand Down Expand Up @@ -248,9 +250,11 @@ protected void onLayout(boolean b, int i, int i1, int i2, int i3) {
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {


if (!isEnablePullToRefresh || isLoading || contentView == null) {
return super.dispatchTouchEvent(ev);
}

//获取支持多点触控的action
final int actionMasked = ev.getActionMasked();
switch (actionMasked) {
Expand All @@ -273,7 +277,7 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
removeCallbacks(delayToScrollTopRunnable);
removeCallbacks(autoRefreshRunnable);
super.dispatchTouchEvent(ev);
//表示消耗了该事件,便面子view都没有消耗而导致后面接收不到该事件的事件序列
//表示消耗了该事件,以便子view都没有消耗而导致后面接收不到该事件的事件序列
return true;
}

Expand All @@ -293,6 +297,10 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
float offsetY = yDiff * DRAG_RATE;
lastMotionX = x;
lastMotionY = y;
if (Math.abs(xDiff) > touchSlop /*&& isInterceptMoveEvent*/) {
/*左右滑动了*/
break;
}

if (!isBeginDragged && Math.abs(y - initDownY) > touchSlop) {
isBeginDragged = true;
Expand Down Expand Up @@ -969,4 +977,5 @@ public long getHideLoadViewAnimatorDuration() {
public void setHideLoadViewAnimatorDuration(long showCompletedTime) {
SHOW_COMPLETED_TIME = showCompletedTime;
}

}

0 comments on commit 942f3f4

Please sign in to comment.