Skip to content

Commit

Permalink
Merge pull request #70 from IceWaterGuo/master
Browse files Browse the repository at this point in the history
手指触摸轮播图时停止looping
  • Loading branch information
zhpanvip authored Dec 20, 2019
2 parents 4f5b5f6 + fa82e28 commit 0fdb48d
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,22 @@ protected void onAttachedToWindow() {
startLoop();
}

//触碰控件的时候,翻页应该停止,离开的时候如果之前是开启了翻页的话则重新启动翻页
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
int action = ev.getAction();
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_OUTSIDE) {
// 开始翻页
setLooping(false);
startLoop();
} else if (action == MotionEvent.ACTION_DOWN) {
// 停止翻页
setLooping(true);
stopLoop();
}
return super.dispatchTouchEvent(ev);
}

@SuppressLint("ClickableViewAccessibility")
private void setTouchListener() {
mViewPager.setOnTouchListener(new OnTouchListener() {
Expand Down Expand Up @@ -285,7 +301,7 @@ private void setupViewPager(List<T> list) {
addView(mIndicatorLayout);
initPageStyle();
startLoop();
setTouchListener();
// setTouchListener();
} else {
throw new NullPointerException("You must set HolderCreator for BannerViewPager");
}
Expand Down

0 comments on commit 0fdb48d

Please sign in to comment.