Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,12 @@ public PullToRefreshView(Context context, AttributeSet attrs) {

public void setRefreshStyle(int type) {
setRefreshing(false);
switch (type) {
case STYLE_SUN:
mBaseRefreshView = new SunRefreshView(getContext(), this);
break;
default:
throw new InvalidParameterException("Type does not exist");
if (type != STYLE_SUN) {
throw new InvalidParameterException("Type does not exist");
} else {
mBaseRefreshView = new SunRefreshView(getContext(), this);
}

mRefreshView.setImageDrawable(mBaseRefreshView);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,8 @@ public PullToRefreshLayout(Context context, AttributeSet attrs) {

public void setRefreshStyle(int type) {
setRefreshing(false);
switch (type) {
case STYLE_SUN:
break;
default:
throw new InvalidParameterException("Type does not exist");
if (type != STYLE_SUN) {
throw new InvalidParameterException("Type does not exist");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,16 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
if (mIsRefreshing) {
return true;
}
switch (ev.getAction()) {
//记下按下的Y坐标
case MotionEvent.ACTION_DOWN:
mTouchStartY = ev.getY();
mTouchCurY = mTouchStartY;
break;
case MotionEvent.ACTION_MOVE:
float curY = ev.getY();
float dy = curY - mTouchStartY;
//如果是向下滑动并且已经滑动顶部,拦截点击事件
if (dy > 0 && !canChildScrollUp()) {
return true;
}
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
mTouchStartY = ev.getY();
mTouchCurY = mTouchStartY;
} else if (ev.getAction() == MotionEvent.ACTION_MOVE ) {
float curY = ev.getY();
float dy = curY - mTouchStartY;
//如果是向下滑动并且已经滑动顶部,拦截点击事件
if (dy > 0 && !canChildScrollUp()) {
return true;
}
}
return super.onInterceptTouchEvent(ev);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,18 +205,15 @@ public boolean onInterceptTouchEvent(MotionEvent e) {
if (isRefreshing) {
return true;
}
switch (e.getAction()) {
case MotionEvent.ACTION_DOWN:
mTouchStartY = e.getY();
mCurrentY = mTouchStartY;
break;
case MotionEvent.ACTION_MOVE:
float currentY = e.getY();
float dy = currentY - mTouchStartY;
if (dy > 0 && !canChildScrollUp()) {
return true;
}
break;
if (e.getAction() == MotionEvent.ACTION_DOWN) {
mTouchStartY = e.getY();
mCurrentY = mTouchStartY;
} else if (e.getAction() == MotionEvent.ACTION_MOVE) {
float currentY = e.getY();
float dy = currentY - mTouchStartY;
if (dy > 0 && !canChildScrollUp()) {
return true;
}
}
return super.onInterceptTouchEvent(e);
}
Expand Down