From a84e3a8123b70fcaff511030756b400990e9511b Mon Sep 17 00:00:00 2001 From: fccaikai <714564390@qq.com> Date: Mon, 24 Oct 2016 22:14:06 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=94=AF=E6=8C=81=E5=BC=80=E5=A7=8B=E6=97=B6?= =?UTF-8?q?=E5=B7=A6=E6=BB=91=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/kcode/autoscrollviewpager/view/AutoViewPager.java | 8 +++----- .../autoscrollviewpager/view/BaseViewPagerAdapter.java | 4 +++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/autoScrollViewPager/src/main/java/com/kcode/autoscrollviewpager/view/AutoViewPager.java b/autoScrollViewPager/src/main/java/com/kcode/autoscrollviewpager/view/AutoViewPager.java index d7cceeb..557fbcb 100644 --- a/autoScrollViewPager/src/main/java/com/kcode/autoscrollviewpager/view/AutoViewPager.java +++ b/autoScrollViewPager/src/main/java/com/kcode/autoscrollviewpager/view/AutoViewPager.java @@ -36,6 +36,9 @@ public void init(AutoViewPager viewPager,BaseViewPagerAdapter adapter){ } public void start(){ + //先停止 + onStop(); + if (mTimer == null) { mTimer = new Timer(); } @@ -108,14 +111,9 @@ public void onResume(){ public boolean onTouchEvent(MotionEvent ev) { switch (ev.getAction()){ case MotionEvent.ACTION_DOWN: - Log.i(TAG,"down"); onStop(); break; - case MotionEvent.ACTION_MOVE: - Log.i(TAG,"move"); - break; case MotionEvent.ACTION_UP: - Log.i(TAG,"up"); onResume(); break; } diff --git a/autoScrollViewPager/src/main/java/com/kcode/autoscrollviewpager/view/BaseViewPagerAdapter.java b/autoScrollViewPager/src/main/java/com/kcode/autoscrollviewpager/view/BaseViewPagerAdapter.java index 9444616..2ea2aff 100644 --- a/autoScrollViewPager/src/main/java/com/kcode/autoscrollviewpager/view/BaseViewPagerAdapter.java +++ b/autoScrollViewPager/src/main/java/com/kcode/autoscrollviewpager/view/BaseViewPagerAdapter.java @@ -59,7 +59,9 @@ public void init(AutoViewPager viewPager,BaseViewPagerAdapter adapter){ if (data == null || data.size() == 0){ return; } - mView.setCurrentItem(0); + //设置初始为中间,这样一开始就能够往左滑动了 + int position = Integer.MAX_VALUE/2 - (Integer.MAX_VALUE/2) % getRealCount(); + mView.setCurrentItem(position); mView.start(); mView.updatePointView(getRealCount());