From b83ebe61569ca261b7f746b0f5ab11659e23ddb5 Mon Sep 17 00:00:00 2001 From: MikeAfc Date: Thu, 13 Apr 2017 13:20:20 +0800 Subject: [PATCH 01/54] Update readme --- README-ch.md | 4 ++-- README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README-ch.md b/README-ch.md index d049520..ff0bab7 100644 --- a/README-ch.md +++ b/README-ch.md @@ -32,7 +32,7 @@ UltraViewPager继承自RelativeLayout,将ViewPager和indicator置于其中, ``` //gradle -compile ('com.alibaba.android:ultraviewpager:1.0.0@aar') { +compile ('com.alibaba.android:ultraviewpager:1.0.1@aar') { transitive = true } @@ -45,7 +45,7 @@ compile ('com.alibaba.android:ultraviewpager:1.0.0@aar') { com.alibaba.android ultraviewpager - 1.0.0 + 1.0.1 aar diff --git a/README.md b/README.md index ec2eefc..5d0c89a 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Using Gradle: ``` //gradle -compile ('com.alibaba.android:ultraviewpager:1.0.0@aar') { +compile ('com.alibaba.android:ultraviewpager:1.0.1@aar') { transitive = true } ``` @@ -48,7 +48,7 @@ or grab via Maven: com.alibaba.android ultraviewpager - 1.0.0 + 1.0.1 aar From d2cf81a194ab080f93eaab37e2b3b3a7ea3c555e Mon Sep 17 00:00:00 2001 From: longerian Date: Thu, 13 Apr 2017 13:20:41 +0800 Subject: [PATCH 02/54] update version --- README-ch.md | 2 +- README.md | 2 +- gradle.properties | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README-ch.md b/README-ch.md index ff0bab7..b341558 100644 --- a/README-ch.md +++ b/README-ch.md @@ -28,7 +28,7 @@ UltraViewPager继承自RelativeLayout,将ViewPager和indicator置于其中, 竖向滑动是通过在ViewPager的onInterceptTouchEvent和onTouchEvent中交换横竖向的event location,同时设置特殊PageTransformer实现,详见源码. #### 使用方法 -版本请参考mvn repository上的最新版本(目前最新版本是1.0.0),最新的 aar 都会发布到 jcenter 和 MavenCentral 上,确保配置了这两个仓库源,然后引入aar依赖: +版本请参考mvn repository上的最新版本(目前最新版本是1.0.1),最新的 aar 都会发布到 jcenter 和 MavenCentral 上,确保配置了这两个仓库源,然后引入aar依赖: ``` //gradle diff --git a/README.md b/README.md index 5d0c89a..6d86c9e 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ In order to achieve vertical scroll, through exchanging MotionEvent in onInterce #### Usage -Please find the latest version(1.0.0 so far) in maven repository. The newest version has been upload to jcenter and MavenCantral, make sure you have added at least one of these repositories. +Please find the latest version(1.0.1 so far) in maven repository. The newest version has been upload to jcenter and MavenCantral, make sure you have added at least one of these repositories. Using Gradle: diff --git a/gradle.properties b/gradle.properties index c90f9ab..23e457e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -46,7 +46,7 @@ GROUP=com.alibaba.android ARTIFACT=ultraviewpager VERSION=1 -VERSION_NAME=1.0.0 +VERSION_NAME=1.0.1 PACKAGING_TYPE=aar systemProp.compileSdkVersion=23 systemProp.targetSdkVersion=23 From accd4a0b267982c296cc9fda91a3f8501ad9177d Mon Sep 17 00:00:00 2001 From: Richard Yee Date: Thu, 13 Apr 2017 16:30:34 -0700 Subject: [PATCH 03/54] Fixed page change listener not calling The deprecated setOnPageChangeListener wasn't callling on page changes. Updating to the new addOnPageChangeListener method fixed the issue. --- .../src/main/java/com/tmall/ultraviewpager/UltraViewPager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java index bfb23a5..5068e34 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java @@ -395,7 +395,7 @@ public PagerAdapter getAdapter() { public void setOnPageChangeListener(ViewPager.OnPageChangeListener listener) { if (pagerIndicator == null) { - viewPager.setOnPageChangeListener(listener); + viewPager.addOnPageChangeListener(listener); } else { pagerIndicator.setPageChangeListener(listener); } From 83c93959fbee013e6b023494b25820c5b6397479 Mon Sep 17 00:00:00 2001 From: nex3z Date: Sat, 15 Apr 2017 10:13:59 +0800 Subject: [PATCH 04/54] fix #9, set an id for the inner UltraViewPagerView to work with FragmentPagerAdapter. --- .../main/java/com/tmall/ultraviewpager/UltraViewPager.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java index 5068e34..ef033a2 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java @@ -30,6 +30,7 @@ import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Point; +import android.os.Build; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.util.AttributeSet; @@ -126,6 +127,12 @@ public UltraViewPager(Context context, AttributeSet attrs, int defStyleAttr) { private void initView() { viewPager = new UltraViewPagerView(getContext()); + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { + viewPager.setId(viewPager.hashCode()); + } else { + viewPager.setId(View.generateViewId()); + } + addView(viewPager, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); } From 4f73f8094aa2544aa091c35c7d83ed6af6ad70c8 Mon Sep 17 00:00:00 2001 From: MikeAfc Date: Sun, 16 Apr 2017 10:54:42 +0800 Subject: [PATCH 05/54] Update infinite ratio to 400 --- .../java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java index 1f8436d..db4cefb 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java @@ -49,7 +49,7 @@ interface UltraViewPagerCenterListener { void resetPosition(); } - private static final int INFINITE_RATIO = 4; + private static final int INFINITE_RATIO = 400; public static final String MULTISCR_TAG = "multi_scr_tag_"; private PagerAdapter adapter; From 768eb7b62d38bd660500e17dad110816023ad17f Mon Sep 17 00:00:00 2001 From: MikeAfc Date: Wed, 26 Apr 2017 11:44:14 +0800 Subject: [PATCH 06/54] Opt experience when touch happened. --- .../java/com/tmall/ultraviewpager/TimerHandler.java | 4 ++-- .../java/com/tmall/ultraviewpager/UltraViewPager.java | 10 ++++++---- .../tmall/ultraviewpager/UltraViewPagerAdapter.java | 1 - 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/TimerHandler.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/TimerHandler.java index 4ad90e4..d78de03 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/TimerHandler.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/TimerHandler.java @@ -38,7 +38,7 @@ interface TimerHandlerListener { } long interval; - boolean isInTouchMode; + boolean isStopped = true; TimerHandlerListener listener; static final int MSG_TIMER_ID = 87108; @@ -51,7 +51,7 @@ interface TimerHandlerListener { @Override public void handleMessage(Message msg) { if (MSG_TIMER_ID == msg.what) { - if (listener != null && !isInTouchMode) + if (listener != null) listener.callBack(); sendEmptyMessageDelayed(MSG_TIMER_ID, interval); } diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java index 0fd5846..c0f2c43 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java @@ -210,9 +210,9 @@ public boolean dispatchTouchEvent(MotionEvent ev) { if (timer != null) { final int action = ev.getAction(); if (action == MotionEvent.ACTION_DOWN) - timer.isInTouchMode = true; + stopTimer(); if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) - timer.isInTouchMode = false; + startTimer(); } return super.dispatchTouchEvent(ev); } @@ -435,18 +435,20 @@ private void constrainTo(Point size, Point maxSize) { } private void startTimer() { - if (timer == null) + if (timer == null || !timer.isStopped) return; timer.listener = mTimerHandlerListener; timer.removeCallbacksAndMessages(null); timer.sendEmptyMessageDelayed(TimerHandler.MSG_TIMER_ID, timer.interval); + timer.isStopped = false; } private void stopTimer() { - if (timer == null) + if (timer == null || timer.isStopped) return; timer.removeCallbacksAndMessages(null); timer.listener = null; + timer.isStopped = true; } @Override diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java index db4cefb..2f03d73 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java @@ -50,7 +50,6 @@ interface UltraViewPagerCenterListener { } private static final int INFINITE_RATIO = 400; - public static final String MULTISCR_TAG = "multi_scr_tag_"; private PagerAdapter adapter; private boolean enableLoop; From 2a6bbf8b39d67d5d1f15aa261979eb0ec2c3dca5 Mon Sep 17 00:00:00 2001 From: longerian Date: Wed, 26 Apr 2017 12:16:17 +0800 Subject: [PATCH 07/54] release 1.0.2 --- README-ch.md | 6 +++--- README.md | 6 +++--- gradle.properties | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README-ch.md b/README-ch.md index b341558..6acc1d5 100644 --- a/README-ch.md +++ b/README-ch.md @@ -28,11 +28,11 @@ UltraViewPager继承自RelativeLayout,将ViewPager和indicator置于其中, 竖向滑动是通过在ViewPager的onInterceptTouchEvent和onTouchEvent中交换横竖向的event location,同时设置特殊PageTransformer实现,详见源码. #### 使用方法 -版本请参考mvn repository上的最新版本(目前最新版本是1.0.1),最新的 aar 都会发布到 jcenter 和 MavenCentral 上,确保配置了这两个仓库源,然后引入aar依赖: +版本请参考mvn repository上的最新版本(目前最新版本是1.0.2),最新的 aar 都会发布到 jcenter 和 MavenCentral 上,确保配置了这两个仓库源,然后引入aar依赖: ``` //gradle -compile ('com.alibaba.android:ultraviewpager:1.0.1@aar') { +compile ('com.alibaba.android:ultraviewpager:1.0.2@aar') { transitive = true } @@ -45,7 +45,7 @@ compile ('com.alibaba.android:ultraviewpager:1.0.1@aar') { com.alibaba.android ultraviewpager - 1.0.1 + 1.0.2 aar diff --git a/README.md b/README.md index 6d86c9e..9819a00 100644 --- a/README.md +++ b/README.md @@ -31,13 +31,13 @@ In order to achieve vertical scroll, through exchanging MotionEvent in onInterce #### Usage -Please find the latest version(1.0.1 so far) in maven repository. The newest version has been upload to jcenter and MavenCantral, make sure you have added at least one of these repositories. +Please find the latest version(1.0.2 so far) in maven repository. The newest version has been upload to jcenter and MavenCantral, make sure you have added at least one of these repositories. Using Gradle: ``` //gradle -compile ('com.alibaba.android:ultraviewpager:1.0.1@aar') { +compile ('com.alibaba.android:ultraviewpager:1.0.2@aar') { transitive = true } ``` @@ -48,7 +48,7 @@ or grab via Maven: com.alibaba.android ultraviewpager - 1.0.1 + 1.0.2 aar diff --git a/gradle.properties b/gradle.properties index 23e457e..8e6b3d1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -46,7 +46,7 @@ GROUP=com.alibaba.android ARTIFACT=ultraviewpager VERSION=1 -VERSION_NAME=1.0.1 +VERSION_NAME=1.0.2 PACKAGING_TYPE=aar systemProp.compileSdkVersion=23 systemProp.targetSdkVersion=23 From 5900447af4b94af3b35353c8b6148f3aff092c38 Mon Sep 17 00:00:00 2001 From: MikeAfc Date: Thu, 27 Apr 2017 20:57:20 +0800 Subject: [PATCH 08/54] Fix #4, indicator not centered in horizontal mode --- .../UltraViewPagerIndicator.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerIndicator.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerIndicator.java index ee0f0ed..cff89d2 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerIndicator.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerIndicator.java @@ -36,6 +36,7 @@ import android.util.TypedValue; import android.view.Gravity; import android.view.View; + /** * Created by mikeafc on 15/11/25. */ @@ -127,16 +128,16 @@ protected void onDraw(Canvas canvas) { if (orientation == UltraViewPager.Orientation.HORIZONTAL) { longSize = viewPager.getWidth(); shortSize = viewPager.getHeight(); - longPaddingBefore = (int) (getItemWidth() + getPaddingLeft() + marginLeft); + longPaddingBefore = getPaddingLeft() + marginLeft; longPaddingAfter = getPaddingRight() + marginRight; - shortPaddingBefore = (int) (getItemWidth() + getPaddingTop() + marginTop); + shortPaddingBefore = getPaddingTop() + marginTop; shortPaddingAfter = (int) paintStroke.getStrokeWidth() + getPaddingBottom() + marginBottom; } else { longSize = viewPager.getHeight(); shortSize = viewPager.getWidth(); - longPaddingBefore = (int) (getItemWidth() + getPaddingTop() + marginTop); + longPaddingBefore = getPaddingTop() + marginTop; longPaddingAfter = (int) paintStroke.getStrokeWidth() + getPaddingBottom() + marginBottom; - shortPaddingBefore = (int) (getItemWidth() + getPaddingLeft() + marginLeft); + shortPaddingBefore = getPaddingLeft() + marginLeft; shortPaddingAfter = getPaddingRight() + marginRight; } @@ -149,7 +150,7 @@ protected void onDraw(Canvas canvas) { float shortOffset = shortPaddingBefore; float longOffset = longPaddingBefore; - final float indicatorLength = count * itemWidth * widthRatio + (count - 1) * indicatorPadding; + final float indicatorLength = (count - 1) * (itemWidth * widthRatio + indicatorPadding); final int horizontalGravityMask = gravity & Gravity.HORIZONTAL_GRAVITY_MASK; final int verticalGravityMask = gravity & Gravity.VERTICAL_GRAVITY_MASK; @@ -159,13 +160,14 @@ protected void onDraw(Canvas canvas) { break; case Gravity.RIGHT: if (orientation == UltraViewPager.Orientation.HORIZONTAL) { - longOffset = longSize - longPaddingAfter - indicatorLength; + longOffset = longSize - longPaddingAfter - indicatorLength - itemWidth; } if (orientation == UltraViewPager.Orientation.VERTICAL) { shortOffset = shortSize - shortPaddingAfter - itemWidth; } break; case Gravity.LEFT: + longOffset += itemWidth; default: break; } @@ -183,6 +185,7 @@ protected void onDraw(Canvas canvas) { } break; case Gravity.TOP: + shortOffset += itemWidth; default: break; } @@ -202,6 +205,7 @@ protected void onDraw(Canvas canvas) { //Draw stroked circles for (int iLoop = 0; iLoop < count; iLoop++) { float drawLong = longOffset + (iLoop * (itemWidth * widthRatio + indicatorPadding)); + if (orientation == UltraViewPager.Orientation.HORIZONTAL) { dX = drawLong; dY = shortOffset; @@ -387,7 +391,7 @@ public IUltraIndicatorBuilder setMargin(int left, int top, int right, int bottom @Override public void build() { - if(indicatorBuildListener != null){ + if (indicatorBuildListener != null) { indicatorBuildListener.build(); } } From f36ff3a1c8a6cc1f9dcd687884a97033cad5a69f Mon Sep 17 00:00:00 2001 From: MikeAfc Date: Thu, 27 Apr 2017 21:01:14 +0800 Subject: [PATCH 09/54] Update version --- README-ch.md | 6 +++--- README.md | 6 +++--- gradle.properties | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README-ch.md b/README-ch.md index 6acc1d5..18b976d 100644 --- a/README-ch.md +++ b/README-ch.md @@ -28,11 +28,11 @@ UltraViewPager继承自RelativeLayout,将ViewPager和indicator置于其中, 竖向滑动是通过在ViewPager的onInterceptTouchEvent和onTouchEvent中交换横竖向的event location,同时设置特殊PageTransformer实现,详见源码. #### 使用方法 -版本请参考mvn repository上的最新版本(目前最新版本是1.0.2),最新的 aar 都会发布到 jcenter 和 MavenCentral 上,确保配置了这两个仓库源,然后引入aar依赖: +版本请参考mvn repository上的最新版本(目前最新版本是1.0.3),最新的 aar 都会发布到 jcenter 和 MavenCentral 上,确保配置了这两个仓库源,然后引入aar依赖: ``` //gradle -compile ('com.alibaba.android:ultraviewpager:1.0.2@aar') { +compile ('com.alibaba.android:ultraviewpager:1.0.3@aar') { transitive = true } @@ -45,7 +45,7 @@ compile ('com.alibaba.android:ultraviewpager:1.0.2@aar') { com.alibaba.android ultraviewpager - 1.0.2 + 1.0.3 aar diff --git a/README.md b/README.md index 9819a00..7f11083 100644 --- a/README.md +++ b/README.md @@ -31,13 +31,13 @@ In order to achieve vertical scroll, through exchanging MotionEvent in onInterce #### Usage -Please find the latest version(1.0.2 so far) in maven repository. The newest version has been upload to jcenter and MavenCantral, make sure you have added at least one of these repositories. +Please find the latest version(1.0.3 so far) in maven repository. The newest version has been upload to jcenter and MavenCantral, make sure you have added at least one of these repositories. Using Gradle: ``` //gradle -compile ('com.alibaba.android:ultraviewpager:1.0.2@aar') { +compile ('com.alibaba.android:ultraviewpager:1.0.3@aar') { transitive = true } ``` @@ -48,7 +48,7 @@ or grab via Maven: com.alibaba.android ultraviewpager - 1.0.2 + 1.0.3 aar diff --git a/gradle.properties b/gradle.properties index 8e6b3d1..f069d9c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -46,7 +46,7 @@ GROUP=com.alibaba.android ARTIFACT=ultraviewpager VERSION=1 -VERSION_NAME=1.0.2 +VERSION_NAME=1.0.3 PACKAGING_TYPE=aar systemProp.compileSdkVersion=23 systemProp.targetSdkVersion=23 From c241c629ff2263c6446c7e2a27cd0bd22ad99e10 Mon Sep 17 00:00:00 2001 From: MikeAfc Date: Fri, 19 May 2017 11:49:15 +0800 Subject: [PATCH 10/54] Add interface to setHGap between two pages --- README-ch.md | 6 +++--- README.md | 6 +++--- gradle.properties | 2 +- .../com/tmall/ultraviewpager/IUltraViewPagerFeature.java | 7 +++++++ .../main/java/com/tmall/ultraviewpager/UltraViewPager.java | 7 +++++++ 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/README-ch.md b/README-ch.md index 18b976d..f05251e 100644 --- a/README-ch.md +++ b/README-ch.md @@ -28,11 +28,11 @@ UltraViewPager继承自RelativeLayout,将ViewPager和indicator置于其中, 竖向滑动是通过在ViewPager的onInterceptTouchEvent和onTouchEvent中交换横竖向的event location,同时设置特殊PageTransformer实现,详见源码. #### 使用方法 -版本请参考mvn repository上的最新版本(目前最新版本是1.0.3),最新的 aar 都会发布到 jcenter 和 MavenCentral 上,确保配置了这两个仓库源,然后引入aar依赖: +版本请参考mvn repository上的最新版本(目前最新版本是1.0.4),最新的 aar 都会发布到 jcenter 和 MavenCentral 上,确保配置了这两个仓库源,然后引入aar依赖: ``` //gradle -compile ('com.alibaba.android:ultraviewpager:1.0.3@aar') { +compile ('com.alibaba.android:ultraviewpager:1.0.4@aar') { transitive = true } @@ -45,7 +45,7 @@ compile ('com.alibaba.android:ultraviewpager:1.0.3@aar') { com.alibaba.android ultraviewpager - 1.0.3 + 1.0.4 aar diff --git a/README.md b/README.md index 7f11083..3520dc2 100644 --- a/README.md +++ b/README.md @@ -31,13 +31,13 @@ In order to achieve vertical scroll, through exchanging MotionEvent in onInterce #### Usage -Please find the latest version(1.0.3 so far) in maven repository. The newest version has been upload to jcenter and MavenCantral, make sure you have added at least one of these repositories. +Please find the latest version(1.0.4 so far) in maven repository. The newest version has been upload to jcenter and MavenCantral, make sure you have added at least one of these repositories. Using Gradle: ``` //gradle -compile ('com.alibaba.android:ultraviewpager:1.0.3@aar') { +compile ('com.alibaba.android:ultraviewpager:1.0.4@aar') { transitive = true } ``` @@ -48,7 +48,7 @@ or grab via Maven: com.alibaba.android ultraviewpager - 1.0.3 + 1.0.4 aar diff --git a/gradle.properties b/gradle.properties index f069d9c..6272884 100644 --- a/gradle.properties +++ b/gradle.properties @@ -46,7 +46,7 @@ GROUP=com.alibaba.android ARTIFACT=ultraviewpager VERSION=1 -VERSION_NAME=1.0.3 +VERSION_NAME=1.0.4 PACKAGING_TYPE=aar systemProp.compileSdkVersion=23 systemProp.targetSdkVersion=23 diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/IUltraViewPagerFeature.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/IUltraViewPagerFeature.java index f75485b..4f048fe 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/IUltraViewPagerFeature.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/IUltraViewPagerFeature.java @@ -158,6 +158,13 @@ interface IUltraViewPagerFeature { */ void setItemRatio(double ratio); + /** + * Set the gap between two pages in pixel + * + * @param pixel + */ + void setHGap(int pixel); + /** * Set item margin * diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java index 0e0f75d..dae9ea4 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java @@ -332,6 +332,13 @@ public void setRatio(float ratio) { viewPager.setRatio(ratio); } + @Override + public void setHGap(int pixel) { + int screenWidth = getContext().getResources().getDisplayMetrics().widthPixels; + viewPager.setMultiScreen((screenWidth - pixel) / (float) screenWidth); + viewPager.setPageMargin(pixel); + } + @Override public void setMaxHeight(int height) { maxHeight = height; From fc38be0b977b96830e9f781fa26ac156c2b3fd96 Mon Sep 17 00:00:00 2001 From: longerian Date: Tue, 8 Aug 2017 15:04:19 +0800 Subject: [PATCH 11/54] fix #41 delete log --- .../java/com/tmall/ultraviewpager/UltraViewPagerView.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java index 621bb54..91ab488 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java @@ -26,17 +26,15 @@ package com.tmall.ultraviewpager; -import com.tmall.ultraviewpager.transformer.UltraVerticalTransformer; - import android.content.Context; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.util.AttributeSet; -import android.util.Log; import android.util.TypedValue; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import com.tmall.ultraviewpager.transformer.UltraVerticalTransformer; /** * Created by mikeafc on 15/11/25. @@ -85,7 +83,6 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { } protected void onMeasurePage(int widthMeasureSpec, int heightMeasureSpec) { - Log.d("TEST","onMeasurePage"+getCurrentItem()); View child = pagerAdapter.getViewAtPosition(getCurrentItem()); if (child == null) { child = getChildAt(0); From f11b237e9f851c49554f45d665433ad67642869c Mon Sep 17 00:00:00 2001 From: longerian Date: Tue, 8 Aug 2017 16:25:16 +0800 Subject: [PATCH 12/54] enable scroll interval for each frame --- .../ultraviewpager/sample/PagerActivity.java | 9 +++- .../IUltraViewPagerFeature.java | 8 ++++ .../tmall/ultraviewpager/TimerHandler.java | 45 +++++++++++++++++-- .../tmall/ultraviewpager/UltraViewPager.java | 35 ++++++++++++--- 4 files changed, 84 insertions(+), 13 deletions(-) diff --git a/sample/src/main/java/com/tmall/ultraviewpager/sample/PagerActivity.java b/sample/src/main/java/com/tmall/ultraviewpager/sample/PagerActivity.java index 0405410..dda9309 100644 --- a/sample/src/main/java/com/tmall/ultraviewpager/sample/PagerActivity.java +++ b/sample/src/main/java/com/tmall/ultraviewpager/sample/PagerActivity.java @@ -30,6 +30,7 @@ import android.graphics.Color; import android.os.Bundle; import android.support.v4.view.PagerAdapter; +import android.util.SparseIntArray; import android.util.TypedValue; import android.view.Gravity; import android.view.View; @@ -252,8 +253,12 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { ultraViewPager.setInfiniteLoop(isChecked); } if (buttonView == autoScrollCheckBox) { - if (isChecked) - ultraViewPager.setAutoScroll(2000); + if (isChecked) { + SparseIntArray special = new SparseIntArray(); + special.put(0, 5000); + special.put(1, 1500); + ultraViewPager.setAutoScroll(2000, special); + } else ultraViewPager.disableAutoScroll(); } diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/IUltraViewPagerFeature.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/IUltraViewPagerFeature.java index da86233..dcc09ea 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/IUltraViewPagerFeature.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/IUltraViewPagerFeature.java @@ -27,6 +27,7 @@ package com.tmall.ultraviewpager; import android.graphics.Bitmap; +import android.util.SparseIntArray; /** * Created by mikeafc on 15/11/30. @@ -90,6 +91,13 @@ interface IUltraViewPagerFeature { */ void setAutoScroll(int intervalInMillis); + /** + * Enable auto-scroll mode with special interval times + * @param intervalInMillis The default time to scroll + * @param intervalArray The special interval to scroll, in responding to each frame + */ + void setAutoScroll(int intervalInMillis, SparseIntArray intervalArray); + /** * Disable auto-scroll mode */ diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/TimerHandler.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/TimerHandler.java index 4ad90e4..578bb79 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/TimerHandler.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/TimerHandler.java @@ -28,22 +28,29 @@ import android.os.Handler; import android.os.Message; +import android.support.v4.view.ViewPager; +import android.util.SparseIntArray; /** * Created by mikeafc on 15/11/25. */ -class TimerHandler extends Handler { +class TimerHandler extends Handler implements ViewPager.OnPageChangeListener { + interface TimerHandlerListener { void callBack(); } + SparseIntArray specialInterval; long interval; boolean isInTouchMode; TimerHandlerListener listener; + UltraViewPager mUltraViewPager; + private int currentPosition = 0; static final int MSG_TIMER_ID = 87108; - TimerHandler(TimerHandlerListener listener, long interval) { + TimerHandler(UltraViewPager ultraViewPager, TimerHandlerListener listener, long interval) { + this.mUltraViewPager = ultraViewPager; this.listener = listener; this.interval = interval; } @@ -51,9 +58,39 @@ interface TimerHandlerListener { @Override public void handleMessage(Message msg) { if (MSG_TIMER_ID == msg.what) { - if (listener != null && !isInTouchMode) + if (listener != null && !isInTouchMode) { listener.callBack(); - sendEmptyMessageDelayed(MSG_TIMER_ID, interval); + } + } + } + + public void startTimer() { + sendEmptyMessageDelayed(TimerHandler.MSG_TIMER_ID, getNextInterval()); + } + + private long getNextInterval() { + long next = interval; + if (specialInterval != null) { + long has = specialInterval.get(currentPosition, -1); + if (has > 0) { + next = has; + } } + return next; + } + + @Override + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + + } + + @Override + public void onPageSelected(int position) { + currentPosition = mUltraViewPager.getCurrentItem(); + sendEmptyMessageDelayed(MSG_TIMER_ID, getNextInterval()); + } + + @Override + public void onPageScrollStateChanged(int state) { } } diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java index ef033a2..67eb5fc 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java @@ -34,6 +34,7 @@ import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.util.AttributeSet; +import android.util.SparseIntArray; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; @@ -216,10 +217,12 @@ public void onFinishTemporaryDetach() { public boolean dispatchTouchEvent(MotionEvent ev) { if (timer != null) { final int action = ev.getAction(); - if (action == MotionEvent.ACTION_DOWN) + if (action == MotionEvent.ACTION_DOWN) { timer.isInTouchMode = true; - if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) + } + if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) { timer.isInTouchMode = false; + } } return super.dispatchTouchEvent(ev); } @@ -296,12 +299,26 @@ public void callBack() { @Override public void setAutoScroll(int intervalInMillis) { - if (0 == intervalInMillis) + if (0 == intervalInMillis) { + return; + } + if (timer != null) { + disableAutoScroll(); + } + timer = new TimerHandler(this, mTimerHandlerListener, intervalInMillis); + startTimer(); + } + + @Override + public void setAutoScroll(int intervalInMillis, SparseIntArray intervalArray) { + if (0 == intervalInMillis) { return; + } if (timer != null) { disableAutoScroll(); } - timer = new TimerHandler(mTimerHandlerListener, intervalInMillis); + timer = new TimerHandler(this, mTimerHandlerListener, intervalInMillis); + timer.specialInterval = intervalArray; startTimer(); } @@ -442,16 +459,20 @@ private void constrainTo(Point size, Point maxSize) { } private void startTimer() { - if (timer == null) + if (timer == null || viewPager == null) { return; + } + viewPager.addOnPageChangeListener(timer); timer.listener = mTimerHandlerListener; timer.removeCallbacksAndMessages(null); - timer.sendEmptyMessageDelayed(TimerHandler.MSG_TIMER_ID, timer.interval); + timer.startTimer(); } private void stopTimer() { - if (timer == null) + if (timer == null || viewPager == null) { return; + } + viewPager.removeOnPageChangeListener(timer); timer.removeCallbacksAndMessages(null); timer.listener = null; } From e322e98496f7c2dedf621611ac0ae34ac2e3b8fe Mon Sep 17 00:00:00 2001 From: longerian Date: Tue, 8 Aug 2017 16:46:05 +0800 Subject: [PATCH 13/54] fix code error --- .../main/java/com/tmall/ultraviewpager/UltraViewPager.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java index f290f66..931a989 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java @@ -222,6 +222,7 @@ public boolean dispatchTouchEvent(MotionEvent ev) { } if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) { startTimer(); + } } return super.dispatchTouchEvent(ev); } @@ -465,7 +466,7 @@ private void constrainTo(Point size, Point maxSize) { } private void startTimer() { - if (timer == null || viewPager == null || !timer.isStopped) + if (timer == null || viewPager == null || !timer.isStopped) { return; } viewPager.addOnPageChangeListener(timer); @@ -476,7 +477,7 @@ private void startTimer() { } private void stopTimer() { - if (timer == null || viewPager == null || timer.isStopped) {s + if (timer == null || viewPager == null || timer.isStopped) { return; } viewPager.removeOnPageChangeListener(timer); From 40b510287353e5a251784fbe1fdf883bf4880b66 Mon Sep 17 00:00:00 2001 From: longerian Date: Tue, 8 Aug 2017 16:50:21 +0800 Subject: [PATCH 14/54] update version --- README-ch.md | 6 +++--- README.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README-ch.md b/README-ch.md index f05251e..9e679ea 100644 --- a/README-ch.md +++ b/README-ch.md @@ -28,11 +28,11 @@ UltraViewPager继承自RelativeLayout,将ViewPager和indicator置于其中, 竖向滑动是通过在ViewPager的onInterceptTouchEvent和onTouchEvent中交换横竖向的event location,同时设置特殊PageTransformer实现,详见源码. #### 使用方法 -版本请参考mvn repository上的最新版本(目前最新版本是1.0.4),最新的 aar 都会发布到 jcenter 和 MavenCentral 上,确保配置了这两个仓库源,然后引入aar依赖: +版本请参考mvn repository上的最新版本(目前最新版本是1.0.5),最新的 aar 都会发布到 jcenter 和 MavenCentral 上,确保配置了这两个仓库源,然后引入aar依赖: ``` //gradle -compile ('com.alibaba.android:ultraviewpager:1.0.4@aar') { +compile ('com.alibaba.android:ultraviewpager:1.0.5@aar') { transitive = true } @@ -45,7 +45,7 @@ compile ('com.alibaba.android:ultraviewpager:1.0.4@aar') { com.alibaba.android ultraviewpager - 1.0.4 + 1.0.5 aar diff --git a/README.md b/README.md index 3520dc2..cf30019 100644 --- a/README.md +++ b/README.md @@ -31,13 +31,13 @@ In order to achieve vertical scroll, through exchanging MotionEvent in onInterce #### Usage -Please find the latest version(1.0.4 so far) in maven repository. The newest version has been upload to jcenter and MavenCantral, make sure you have added at least one of these repositories. +Please find the latest version(1.0.5 so far) in maven repository. The newest version has been upload to jcenter and MavenCantral, make sure you have added at least one of these repositories. Using Gradle: ``` //gradle -compile ('com.alibaba.android:ultraviewpager:1.0.4@aar') { +compile ('com.alibaba.android:ultraviewpager:1.0.5@aar') { transitive = true } ``` @@ -48,7 +48,7 @@ or grab via Maven: com.alibaba.android ultraviewpager - 1.0.4 + 1.0.5 aar From da5cd207eba551e8ab3ca1ceff91a003c75dc623 Mon Sep 17 00:00:00 2001 From: longerian Date: Tue, 8 Aug 2017 16:52:01 +0800 Subject: [PATCH 15/54] update version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 6272884..13a3000 100644 --- a/gradle.properties +++ b/gradle.properties @@ -46,7 +46,7 @@ GROUP=com.alibaba.android ARTIFACT=ultraviewpager VERSION=1 -VERSION_NAME=1.0.4 +VERSION_NAME=1.0.5 PACKAGING_TYPE=aar systemProp.compileSdkVersion=23 systemProp.targetSdkVersion=23 From 77c71b6393ccbd9bb3585a50cb3c18d9cc7a24b1 Mon Sep 17 00:00:00 2001 From: longerian Date: Tue, 8 Aug 2017 20:47:20 +0800 Subject: [PATCH 16/54] fix the bug of setting interval for each frame --- README-ch.md | 6 ++-- README.md | 6 ++-- build.gradle | 3 ++ gradle.properties | 2 +- .../tmall/ultraviewpager/TimerHandler.java | 28 +++++-------------- .../tmall/ultraviewpager/UltraViewPager.java | 10 +++++-- .../ultraviewpager/UltraViewPagerView.java | 7 +++++ 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/README-ch.md b/README-ch.md index 9e679ea..2eef611 100644 --- a/README-ch.md +++ b/README-ch.md @@ -28,11 +28,11 @@ UltraViewPager继承自RelativeLayout,将ViewPager和indicator置于其中, 竖向滑动是通过在ViewPager的onInterceptTouchEvent和onTouchEvent中交换横竖向的event location,同时设置特殊PageTransformer实现,详见源码. #### 使用方法 -版本请参考mvn repository上的最新版本(目前最新版本是1.0.5),最新的 aar 都会发布到 jcenter 和 MavenCentral 上,确保配置了这两个仓库源,然后引入aar依赖: +版本请参考mvn repository上的最新版本(目前最新版本是1.0.6),最新的 aar 都会发布到 jcenter 和 MavenCentral 上,确保配置了这两个仓库源,然后引入aar依赖: ``` //gradle -compile ('com.alibaba.android:ultraviewpager:1.0.5@aar') { +compile ('com.alibaba.android:ultraviewpager:1.0.6@aar') { transitive = true } @@ -45,7 +45,7 @@ compile ('com.alibaba.android:ultraviewpager:1.0.5@aar') { com.alibaba.android ultraviewpager - 1.0.5 + 1.0.6 aar diff --git a/README.md b/README.md index cf30019..b1e5406 100644 --- a/README.md +++ b/README.md @@ -31,13 +31,13 @@ In order to achieve vertical scroll, through exchanging MotionEvent in onInterce #### Usage -Please find the latest version(1.0.5 so far) in maven repository. The newest version has been upload to jcenter and MavenCantral, make sure you have added at least one of these repositories. +Please find the latest version(1.0.6 so far) in maven repository. The newest version has been upload to jcenter and MavenCantral, make sure you have added at least one of these repositories. Using Gradle: ``` //gradle -compile ('com.alibaba.android:ultraviewpager:1.0.5@aar') { +compile ('com.alibaba.android:ultraviewpager:1.0.6@aar') { transitive = true } ``` @@ -48,7 +48,7 @@ or grab via Maven: com.alibaba.android ultraviewpager - 1.0.5 + 1.0.6 aar diff --git a/build.gradle b/build.gradle index 9b5ce84..3c06530 100644 --- a/build.gradle +++ b/build.gradle @@ -29,6 +29,7 @@ buildscript { repositories { maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } + maven { url "http://oss.jfrog.org/oss-snapshot-local/" } mavenCentral() jcenter() } @@ -36,6 +37,7 @@ buildscript { classpath 'com.android.tools.build:gradle:2.2.2' classpath 'com.github.xfumihiro.view-inspector:view-inspector-plugin:0.1.1' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4' + classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.0.0' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -45,6 +47,7 @@ buildscript { allprojects { repositories { maven{url'https://oss.sonatype.org/content/repositories/snapshots/'} + maven { url "http://oss.jfrog.org/oss-snapshot-local/" } mavenCentral() jcenter() } diff --git a/gradle.properties b/gradle.properties index 13a3000..026d8d2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -46,7 +46,7 @@ GROUP=com.alibaba.android ARTIFACT=ultraviewpager VERSION=1 -VERSION_NAME=1.0.5 +VERSION_NAME=1.0.6 PACKAGING_TYPE=aar systemProp.compileSdkVersion=23 systemProp.targetSdkVersion=23 diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/TimerHandler.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/TimerHandler.java index fd033c6..307a182 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/TimerHandler.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/TimerHandler.java @@ -28,13 +28,12 @@ import android.os.Handler; import android.os.Message; -import android.support.v4.view.ViewPager; import android.util.SparseIntArray; /** * Created by mikeafc on 15/11/25. */ -class TimerHandler extends Handler implements ViewPager.OnPageChangeListener { +class TimerHandler extends Handler { interface TimerHandlerListener { void callBack(); @@ -45,7 +44,6 @@ interface TimerHandlerListener { boolean isStopped = true; TimerHandlerListener listener; UltraViewPager mUltraViewPager; - private int currentPosition = 0; static final int MSG_TIMER_ID = 87108; @@ -58,20 +56,22 @@ interface TimerHandlerListener { @Override public void handleMessage(Message msg) { if (MSG_TIMER_ID == msg.what) { + int nextIndex = mUltraViewPager.getNextItem(); if (listener != null) { listener.callBack(); } + tick(nextIndex); } } - public void startTimer() { - sendEmptyMessageDelayed(TimerHandler.MSG_TIMER_ID, getNextInterval()); + public void tick(int index) { + sendEmptyMessageDelayed(TimerHandler.MSG_TIMER_ID, getNextInterval(index)); } - private long getNextInterval() { + private long getNextInterval(int index) { long next = interval; if (specialInterval != null) { - long has = specialInterval.get(currentPosition, -1); + long has = specialInterval.get(index, -1); if (has > 0) { next = has; } @@ -79,18 +79,4 @@ private long getNextInterval() { return next; } - @Override - public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { - - } - - @Override - public void onPageSelected(int position) { - currentPosition = mUltraViewPager.getCurrentItem(); - sendEmptyMessageDelayed(MSG_TIMER_ID, getNextInterval()); - } - - @Override - public void onPageScrollStateChanged(int state) { - } } diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java index 931a989..3bfe2bd 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java @@ -34,6 +34,7 @@ import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.util.AttributeSet; +import android.util.Log; import android.util.SparseIntArray; import android.view.MotionEvent; import android.view.View; @@ -444,6 +445,10 @@ public int getCurrentItem() { return viewPager.getCurrentItem(); } + public int getNextItem() { + return viewPager.getNextItem(); + } + public void setPageTransformer(boolean reverseDrawingOrder, ViewPager.PageTransformer transformer) { viewPager.setPageTransformer(reverseDrawingOrder, transformer); } @@ -469,10 +474,9 @@ private void startTimer() { if (timer == null || viewPager == null || !timer.isStopped) { return; } - viewPager.addOnPageChangeListener(timer); timer.listener = mTimerHandlerListener; timer.removeCallbacksAndMessages(null); - timer.startTimer(); + timer.tick(0); timer.isStopped = false; } @@ -480,7 +484,6 @@ private void stopTimer() { if (timer == null || viewPager == null || timer.isStopped) { return; } - viewPager.removeOnPageChangeListener(timer); timer.removeCallbacksAndMessages(null); timer.listener = null; timer.isStopped = true; @@ -493,4 +496,5 @@ public void setInfiniteRatio(int infiniteRatio) { ((UltraViewPagerAdapter) viewPager.getAdapter()).setInfiniteRatio(infiniteRatio); } } + } diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java index 91ab488..327e080 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java @@ -221,6 +221,13 @@ public int getCurrentItem() { return super.getCurrentItem(); } + public int getNextItem() { + if (pagerAdapter.getCount() != 0) { + int next = super.getCurrentItem() + 1; + return next % pagerAdapter.getRealCount(); + } + return 0; + } /** * Set the currently selected page. From b3cd2f4b362bb54e787a3418322111e97b35ebfd Mon Sep 17 00:00:00 2001 From: longerian Date: Wed, 9 Aug 2017 16:11:38 +0800 Subject: [PATCH 17/54] add deploy install gradle --- .gitignore | 4 +- jcenterDeploy.gradle | 135 ++++++++++++++++++++++++++++++++++++++++++ jcenterInstall.gradle | 66 +++++++++++++++++++++ 3 files changed, 203 insertions(+), 2 deletions(-) create mode 100644 jcenterDeploy.gradle create mode 100644 jcenterInstall.gradle diff --git a/.gitignore b/.gitignore index a1992bb..fb3ae02 100644 --- a/.gitignore +++ b/.gitignore @@ -60,5 +60,5 @@ out/ target/ project.properties -jcenterDeploy.gradle -jcenterInstall.gradle \ No newline at end of file +#jcenterDeploy.gradle +#jcenterInstall.gradle \ No newline at end of file diff --git a/jcenterDeploy.gradle b/jcenterDeploy.gradle new file mode 100644 index 0000000..d9d36fc --- /dev/null +++ b/jcenterDeploy.gradle @@ -0,0 +1,135 @@ +/* + * MIT License + * + * Copyright (c) 2017 Alibaba Group + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +apply plugin: 'com.jfrog.bintray' +apply plugin: 'com.jfrog.artifactory' + +version = libraryVersion + +if (project.hasProperty("android")) { // Android libraries + task sourcesJar(type: Jar) { + classifier = 'sources' + from android.sourceSets.main.java.srcDirs + } + +// task javadoc(type: Javadoc) { +// source = android.sourceSets.main.java.srcDirs +// classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + +// android.libraryVariants.all { variant -> +// println variant.javaCompile.classpath.files +// if(variant.name == 'release') { //我们只需 release 的 javadoc +// task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) { +// // title = '' +// // description = '' +// source = variant.javaCompile.source +// classpath = files(variant.javaCompile.classpath.files, project.android.getBootClasspath()) +// options { +// encoding "utf-8" +// links "http://docs.oracle.com/javase/7/docs/api/" +// linksOffline "http://d.android.com/reference", "${android.sdkDirectory}/docs/reference" +// } +// exclude '**/BuildConfig.java' +// exclude '**/R.java' +// } +// task("javadoc${variant.name.capitalize()}Jar", type: Jar, dependsOn: "generate${variant.name.capitalize()}Javadoc") { +// classifier = 'javadoc' +// from tasks.getByName("generate${variant.name.capitalize()}Javadoc").destinationDir +// } +// artifacts { +// archives tasks.getByName("javadoc${variant.name.capitalize()}Jar") +// } +// } +// } +// +// } +} else { // Java libraries + task sourcesJar(type: Jar, dependsOn: classes) { + classifier = 'sources' + from sourceSets.main.allSource + } +} + +//task javadocJar(type: Jar, dependsOn: javadoc) { +// classifier = 'javadoc' +// from javadoc.destinationDir +//} + +artifacts { +// archives javadocJar + archives sourcesJar +} + +// Bintray +Properties properties = new Properties() +properties.load(project.rootProject.file('local.properties').newDataInputStream()) + +bintray { +// user = properties.getProperty("bintray.user") +// key = properties.getProperty("bintray.apikey") + user = bintrayUser + key = bintrayApikey + + configurations = ['archives'] + pkg { + repo = bintrayRepo + name = bintrayName + desc = libraryDescription + websiteUrl = siteUrl + vcsUrl = gitUrl + licenses = allLicenses + publish = true + publicDownloadNumbers = true + version { + desc = libraryDescription + gpg { + sign = true //Determines whether to GPG sign the files. The default is false +// passphrase = properties.getProperty("bintray.gpg.password") + passphrase = bintrayGPG + //Optional. The passphrase for GPG signing' + } + } + } +} + +artifactory { + contextUrl = 'http://oss.jfrog.org/artifactory' //The base Artifactory URL if not overridden by the publisher/resolver + resolve { + repository { + repoKey = 'libs-release' + } + } + publish { + repository { + repoKey = 'oss-snapshot-local' //The Artifactory repository key to publish to + username = bintray.user + password = bintray.key + maven = true + } + defaults { + //这里的名字和前面bintray.configurations的值一致即可,会将其包含的输出上传到jfrog上去 + publishConfigs('archives') + } + } +} \ No newline at end of file diff --git a/jcenterInstall.gradle b/jcenterInstall.gradle new file mode 100644 index 0000000..f7a7da4 --- /dev/null +++ b/jcenterInstall.gradle @@ -0,0 +1,66 @@ +/* + * MIT License + * + * Copyright (c) 2017 Alibaba Group + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +apply plugin: 'com.github.dcendents.android-maven' + +group = GROUP + +install { + repositories.mavenInstaller { + // This generates POM.xml with proper parameters + pom { + project { + packaging 'aar' + groupId publishedGroupId + artifactId artifact + + // Add your description here + name libraryName + description libraryDescription + url siteUrl + + // Set your license + licenses { + license { + name licenseName + url licenseUrl + } + } + developers { + developer { + id developerId + name developerName + email developerEmail + } + } + scm { + connection gitUrl + developerConnection gitUrl + url siteUrl + + } + } + } + } +} \ No newline at end of file From 5828748d12bb17e2899c8c615f6c257c67ed6179 Mon Sep 17 00:00:00 2001 From: longerian Date: Wed, 9 Aug 2017 16:19:50 +0800 Subject: [PATCH 18/54] add class path var --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 3c06530..329d37d 100644 --- a/build.gradle +++ b/build.gradle @@ -34,7 +34,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.2' + classpath project.hasProperty('classPath') ? classPath : 'com.android.tools.build:gradle:2.2.2' classpath 'com.github.xfumihiro.view-inspector:view-inspector-plugin:0.1.1' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4' classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.0.0' From 764297c346298b84fac199867bd3fd8ce4e4bd44 Mon Sep 17 00:00:00 2001 From: longerian Date: Wed, 9 Aug 2017 17:24:41 +0800 Subject: [PATCH 19/54] delete reading properties --- jcenterDeploy.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jcenterDeploy.gradle b/jcenterDeploy.gradle index d9d36fc..6db4bb4 100644 --- a/jcenterDeploy.gradle +++ b/jcenterDeploy.gradle @@ -82,8 +82,8 @@ artifacts { } // Bintray -Properties properties = new Properties() -properties.load(project.rootProject.file('local.properties').newDataInputStream()) +//Properties properties = new Properties() +//properties.load(project.rootProject.file('local.properties').newDataInputStream()) bintray { // user = properties.getProperty("bintray.user") From 763e3985895fc90428897b2424aa2616be577971 Mon Sep 17 00:00:00 2001 From: longerian Date: Wed, 9 Aug 2017 17:47:24 +0800 Subject: [PATCH 20/54] update deploy gradle --- jcenterDeploy.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jcenterDeploy.gradle b/jcenterDeploy.gradle index 6db4bb4..6b89959 100644 --- a/jcenterDeploy.gradle +++ b/jcenterDeploy.gradle @@ -88,8 +88,8 @@ artifacts { bintray { // user = properties.getProperty("bintray.user") // key = properties.getProperty("bintray.apikey") - user = bintrayUser - key = bintrayApikey + user = project.getProperty('bintrayUser') + key = project.getProperty('bintrayApikey') configurations = ['archives'] pkg { @@ -106,7 +106,7 @@ bintray { gpg { sign = true //Determines whether to GPG sign the files. The default is false // passphrase = properties.getProperty("bintray.gpg.password") - passphrase = bintrayGPG + passphrase = project.getProperty('bintrayGPG') //Optional. The passphrase for GPG signing' } } From ad47ff5a7fd8cce056571cc6a34a7f69805b2c0d Mon Sep 17 00:00:00 2001 From: longerian Date: Wed, 9 Aug 2017 18:19:37 +0800 Subject: [PATCH 21/54] add log --- jcenterDeploy.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jcenterDeploy.gradle b/jcenterDeploy.gradle index 6b89959..1ae8c4f 100644 --- a/jcenterDeploy.gradle +++ b/jcenterDeploy.gradle @@ -88,6 +88,8 @@ artifacts { bintray { // user = properties.getProperty("bintray.user") // key = properties.getProperty("bintray.apikey") + println "--->" + println project.getProperties() user = project.getProperty('bintrayUser') key = project.getProperty('bintrayApikey') From 582a883589da51a9fd1d9e6fb3c8db7d46f56f9b Mon Sep 17 00:00:00 2001 From: longerian Date: Wed, 9 Aug 2017 19:35:56 +0800 Subject: [PATCH 22/54] test deploy script --- jcenterDeploy.gradle | 82 ++++++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 37 deletions(-) diff --git a/jcenterDeploy.gradle b/jcenterDeploy.gradle index 1ae8c4f..a47bcc7 100644 --- a/jcenterDeploy.gradle +++ b/jcenterDeploy.gradle @@ -27,6 +27,10 @@ apply plugin: 'com.jfrog.artifactory' version = libraryVersion +if (project.hasProperty('deployVersion')) { + version = project.getProperty('deployVersion') +} + if (project.hasProperty("android")) { // Android libraries task sourcesJar(type: Jar) { classifier = 'sources' @@ -88,50 +92,54 @@ artifacts { bintray { // user = properties.getProperty("bintray.user") // key = properties.getProperty("bintray.apikey") - println "--->" - println project.getProperties() user = project.getProperty('bintrayUser') key = project.getProperty('bintrayApikey') +} - configurations = ['archives'] - pkg { - repo = bintrayRepo - name = bintrayName - desc = libraryDescription - websiteUrl = siteUrl - vcsUrl = gitUrl - licenses = allLicenses - publish = true - publicDownloadNumbers = true - version { +uploadArchives { + if (version.endsWith("-SNAPSHOT")) { + artifactory { + contextUrl = 'http://oss.jfrog.org/artifactory' //The base Artifactory URL if not overridden by the publisher/resolver + resolve { + repository { + repoKey = 'libs-release' + } + } + publish { + repository { + repoKey = 'oss-snapshot-local' //The Artifactory repository key to publish to + username = bintray.user + password = bintray.key + maven = true + } + defaults { + //the name is the same with that defined in bintray.configurations + publishConfigs('archives') + } + } + } + } else { + configurations = ['archives'] + pkg { + repo = bintrayRepo + name = bintrayName desc = libraryDescription - gpg { - sign = true //Determines whether to GPG sign the files. The default is false + websiteUrl = siteUrl + vcsUrl = gitUrl + licenses = allLicenses + publish = true + publicDownloadNumbers = true + version { + desc = libraryDescription + gpg { + sign = true //Determines whether to GPG sign the files. The default is false // passphrase = properties.getProperty("bintray.gpg.password") - passphrase = project.getProperty('bintrayGPG') - //Optional. The passphrase for GPG signing' + passphrase = project.getProperty('bintrayGPG') + //Optional. The passphrase for GPG signing' + } } } } } -artifactory { - contextUrl = 'http://oss.jfrog.org/artifactory' //The base Artifactory URL if not overridden by the publisher/resolver - resolve { - repository { - repoKey = 'libs-release' - } - } - publish { - repository { - repoKey = 'oss-snapshot-local' //The Artifactory repository key to publish to - username = bintray.user - password = bintray.key - maven = true - } - defaults { - //这里的名字和前面bintray.configurations的值一致即可,会将其包含的输出上传到jfrog上去 - publishConfigs('archives') - } - } -} \ No newline at end of file + From a1ed0d7e35b9803efa59f50546650b79ec354a9b Mon Sep 17 00:00:00 2001 From: longerian Date: Wed, 9 Aug 2017 20:36:46 +0800 Subject: [PATCH 23/54] fix deploy gradle --- jcenterDeploy.gradle | 90 +++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 42 deletions(-) diff --git a/jcenterDeploy.gradle b/jcenterDeploy.gradle index a47bcc7..763c945 100644 --- a/jcenterDeploy.gradle +++ b/jcenterDeploy.gradle @@ -92,54 +92,60 @@ artifacts { bintray { // user = properties.getProperty("bintray.user") // key = properties.getProperty("bintray.apikey") - user = project.getProperty('bintrayUser') - key = project.getProperty('bintrayApikey') -} + user = project.hasProperty('bintrayUser') ? project.getProperty('bintrayUser') : "" + key = project.hasProperty('bintrayApikey') ? project.getProperty('bintrayApikey') : "" -uploadArchives { - if (version.endsWith("-SNAPSHOT")) { - artifactory { - contextUrl = 'http://oss.jfrog.org/artifactory' //The base Artifactory URL if not overridden by the publisher/resolver - resolve { - repository { - repoKey = 'libs-release' - } - } - publish { - repository { - repoKey = 'oss-snapshot-local' //The Artifactory repository key to publish to - username = bintray.user - password = bintray.key - maven = true - } - defaults { - //the name is the same with that defined in bintray.configurations - publishConfigs('archives') - } - } - } - } else { - configurations = ['archives'] - pkg { - repo = bintrayRepo - name = bintrayName + configurations = ['archives'] + pkg { + repo = bintrayRepo + name = bintrayName + desc = libraryDescription + websiteUrl = siteUrl + vcsUrl = gitUrl + licenses = allLicenses + publish = true + publicDownloadNumbers = true + version { desc = libraryDescription - websiteUrl = siteUrl - vcsUrl = gitUrl - licenses = allLicenses - publish = true - publicDownloadNumbers = true - version { - desc = libraryDescription - gpg { - sign = true //Determines whether to GPG sign the files. The default is false + gpg { + sign = true //Determines whether to GPG sign the files. The default is false // passphrase = properties.getProperty("bintray.gpg.password") - passphrase = project.getProperty('bintrayGPG') - //Optional. The passphrase for GPG signing' - } + passphrase = project.hasProperty('bintrayGPG') ? project.getProperty('bintrayGPG') : "" + //Optional. The passphrase for GPG signing' } } } } +artifactory { + contextUrl = 'http://oss.jfrog.org/artifactory' //The base Artifactory URL if not overridden by the publisher/resolver + resolve { + repository { + repoKey = 'libs-release' + } + } + publish { + repository { + repoKey = 'oss-snapshot-local' //The Artifactory repository key to publish to + username = bintray.user + password = bintray.key + maven = true + } + defaults { + //这里的名字和前面bintray.configurations的值一致即可,会将其包含的输出上传到jfrog上去 + publishConfigs('archives') + } + } +} + +bintrayUpload.onlyIf { + !version.endsWith("-SNAPSHOT") +} + +artifactoryPublish.onlyIf { + version.endsWith("-SNAPSHOT") +} +task deploy(dependsOn: ['install', 'bintrayUpload', 'artifactoryPublish']) << { + println "deploy ...." +} \ No newline at end of file From e1445477de7a4b17b434a5c69b18e385892e4c5f Mon Sep 17 00:00:00 2001 From: longerian Date: Wed, 9 Aug 2017 21:08:32 +0800 Subject: [PATCH 24/54] org gradles --- build.gradle | 2 +- jcenterDeploy.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 329d37d..3c06530 100644 --- a/build.gradle +++ b/build.gradle @@ -34,7 +34,7 @@ buildscript { jcenter() } dependencies { - classpath project.hasProperty('classPath') ? classPath : 'com.android.tools.build:gradle:2.2.2' + classpath 'com.android.tools.build:gradle:2.2.2' classpath 'com.github.xfumihiro.view-inspector:view-inspector-plugin:0.1.1' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4' classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.0.0' diff --git a/jcenterDeploy.gradle b/jcenterDeploy.gradle index 763c945..fcb5618 100644 --- a/jcenterDeploy.gradle +++ b/jcenterDeploy.gradle @@ -132,7 +132,7 @@ artifactory { maven = true } defaults { - //这里的名字和前面bintray.configurations的值一致即可,会将其包含的输出上传到jfrog上去 +// the name is the same with that defined in bintray.configurations publishConfigs('archives') } } From 111e5a0a0cc3c6b36138b5740f7e951a6fc1f65e Mon Sep 17 00:00:00 2001 From: MikeAfc Date: Fri, 18 Aug 2017 14:43:09 +0800 Subject: [PATCH 25/54] Fix #32, Fix #35, we support setAdapter first when init UltraVIewPager, and update data when needed. --- .../main/java/com/tmall/ultraviewpager/UltraViewPagerView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java index 327e080..a9049f5 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java @@ -214,7 +214,7 @@ public void setCurrentItem(int item, boolean smoothScroll) { @Override public int getCurrentItem() { - if (pagerAdapter.getCount() != 0) { + if (pagerAdapter != null && pagerAdapter.getCount() != 0) { int position = super.getCurrentItem(); return position % pagerAdapter.getRealCount(); } From 89796ded0d55b22c4a44982a391237d1c5254956 Mon Sep 17 00:00:00 2001 From: longerian Date: Wed, 30 Aug 2017 17:50:10 +0800 Subject: [PATCH 26/54] avoid setting adapter, pageChangeListener, loopStatus repeat when no data or status changing --- .../tmall/ultraviewpager/UltraViewPager.java | 2 ++ .../ultraviewpager/UltraViewPagerAdapter.java | 19 ++++++------- .../ultraviewpager/UltraViewPagerView.java | 27 ++++++++++--------- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java index 3bfe2bd..f2d4c44 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java @@ -427,6 +427,8 @@ public PagerAdapter getAdapter() { public void setOnPageChangeListener(ViewPager.OnPageChangeListener listener) { if (pagerIndicator == null) { + //avoid registering the same listener twice + viewPager.removeOnPageChangeListener(listener); viewPager.addOnPageChangeListener(listener); } else { pagerIndicator.setPageChangeListener(listener); diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java index 2f03d73..1b4eae9 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java @@ -234,18 +234,19 @@ public int getRealCount() { } void setEnableLoop(boolean status) { - this.enableLoop = status; - notifyDataSetChanged(); - if (!status) { - centerListener.resetPosition(); - } else { - try { - centerListener.center(); - } catch (Exception e) { + if (this.enableLoop != status) { + this.enableLoop = status; + notifyDataSetChanged(); + if (!status) { + centerListener.resetPosition(); + } else { + try { + centerListener.center(); + } catch (Exception e) { + } } } - } boolean isEnableLoop() { diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java index 327e080..2937fd9 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java @@ -187,13 +187,15 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh) { @Override public void setAdapter(PagerAdapter adapter) { if (adapter != null) { - pagerAdapter = new UltraViewPagerAdapter(adapter); - pagerAdapter.setCenterListener(this); - pagerAdapter.setEnableLoop(enableLoop); - pagerAdapter.setMultiScrRatio(multiScrRatio); - needsMeasurePage = true; - constrainLength = 0; - super.setAdapter(pagerAdapter); + if (pagerAdapter == null || pagerAdapter.getAdapter() != adapter) { + pagerAdapter = new UltraViewPagerAdapter(adapter); + pagerAdapter.setCenterListener(this); + pagerAdapter.setEnableLoop(enableLoop); + pagerAdapter.setMultiScrRatio(multiScrRatio); + needsMeasurePage = true; + constrainLength = 0; + super.setAdapter(pagerAdapter); + } } else { super.setAdapter(adapter); } @@ -258,9 +260,6 @@ public void setMultiScreen(float ratio) { }else{ setPageMargin((int) (-(pageMargin + convertDp2Px(getContext(), 1f)))); } - - - } private int convertDp2Px(Context context, float dp) { @@ -268,9 +267,11 @@ private int convertDp2Px(Context context, float dp) { } public void setEnableLoop(boolean status) { - enableLoop = status; - if (pagerAdapter != null) { - pagerAdapter.setEnableLoop(enableLoop); + if (enableLoop != status) { + enableLoop = status; + if (pagerAdapter != null) { + pagerAdapter.setEnableLoop(enableLoop); + } } } From 4ce200065f746d8fd87b0e01dcbd02d00de03891 Mon Sep 17 00:00:00 2001 From: longerian Date: Tue, 5 Sep 2017 21:02:26 +0800 Subject: [PATCH 27/54] restore code --- .../ultraviewpager/UltraViewPagerAdapter.java | 18 ++++++++---------- .../ultraviewpager/UltraViewPagerView.java | 8 +++----- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java index 1b4eae9..433a775 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java @@ -234,17 +234,15 @@ public int getRealCount() { } void setEnableLoop(boolean status) { - if (this.enableLoop != status) { - this.enableLoop = status; - notifyDataSetChanged(); - if (!status) { - centerListener.resetPosition(); - } else { - try { - centerListener.center(); - } catch (Exception e) { + this.enableLoop = status; + notifyDataSetChanged(); + if (!status) { + centerListener.resetPosition(); + } else { + try { + centerListener.center(); + } catch (Exception e) { - } } } } diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java index 2937fd9..2529828 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java @@ -267,11 +267,9 @@ private int convertDp2Px(Context context, float dp) { } public void setEnableLoop(boolean status) { - if (enableLoop != status) { - enableLoop = status; - if (pagerAdapter != null) { - pagerAdapter.setEnableLoop(enableLoop); - } + enableLoop = status; + if (pagerAdapter != null) { + pagerAdapter.setEnableLoop(enableLoop); } } From ab0a3da812ce90f53735350367174af60e3cdcd8 Mon Sep 17 00:00:00 2001 From: MikeAfc Date: Thu, 7 Sep 2017 10:16:57 +0800 Subject: [PATCH 28/54] Make getCurrentItemFake() public --- .../main/java/com/tmall/ultraviewpager/UltraViewPagerView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java index baf5157..0ebc1c6 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java @@ -244,7 +244,7 @@ void setCurrentItemFake(int item, boolean smoothScroll) { /** * Get the currently selected page. */ - int getCurrentItemFake() { + public int getCurrentItemFake() { return super.getCurrentItem(); } From 3fd906402b77cab9302528c8087c9d766ff13d34 Mon Sep 17 00:00:00 2001 From: MikeAfc Date: Thu, 7 Sep 2017 10:28:32 +0800 Subject: [PATCH 29/54] FIx #53 --- .../tmall/ultraviewpager/UltraViewPagerView.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java index 0ebc1c6..3f99fb1 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java @@ -34,6 +34,7 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; + import com.tmall.ultraviewpager.transformer.UltraVerticalTransformer; /** @@ -234,7 +235,7 @@ public int getNextItem() { /** * Set the currently selected page. * - * @param item Item index to select + * @param item Item index to select * @param smoothScroll True to smoothly scroll to the new item, false to transition immediately */ void setCurrentItemFake(int item, boolean smoothScroll) { @@ -255,15 +256,7 @@ public void setMultiScreen(float ratio) { needsMeasurePage = true; } float pageMargin = (1 - ratio) * getResources().getDisplayMetrics().widthPixels; - if(scrollMode == UltraViewPager.ScrollMode.VERTICAL){ - setPageMargin((int) (pageMargin)); - }else{ - setPageMargin((int) (-(pageMargin + convertDp2Px(getContext(), 1f)))); - } - } - - private int convertDp2Px(Context context, float dp) { - return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.getResources().getDisplayMetrics()); + setPageMargin((int) (pageMargin)); } public void setEnableLoop(boolean status) { From cffe89fcc03b3676450972aa05a9c5f06816e0f0 Mon Sep 17 00:00:00 2001 From: MikeAfc Date: Thu, 7 Sep 2017 10:49:07 +0800 Subject: [PATCH 30/54] Update demo link in readme, resolve #46 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b1e5406..a49a6dd 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ For other API reference,see [this](ATTRIBUTES.md) to read more. #### DEMO -[Demo Project](https://github.com/alibaba/UltraViewPager/tree/master/examples) +[Demo Project](https://github.com/alibaba/UltraViewPager/tree/master/sample) # Contributing From 28a420698bb358fa34a856d0b745aa7ed05d94ea Mon Sep 17 00:00:00 2001 From: MikeAfc Date: Thu, 7 Sep 2017 11:30:44 +0800 Subject: [PATCH 31/54] Update readme --- README-ch.md | 6 +++--- README.md | 6 +++--- gradle.properties | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README-ch.md b/README-ch.md index 2eef611..e6d23bb 100644 --- a/README-ch.md +++ b/README-ch.md @@ -28,11 +28,11 @@ UltraViewPager继承自RelativeLayout,将ViewPager和indicator置于其中, 竖向滑动是通过在ViewPager的onInterceptTouchEvent和onTouchEvent中交换横竖向的event location,同时设置特殊PageTransformer实现,详见源码. #### 使用方法 -版本请参考mvn repository上的最新版本(目前最新版本是1.0.6),最新的 aar 都会发布到 jcenter 和 MavenCentral 上,确保配置了这两个仓库源,然后引入aar依赖: +版本请参考mvn repository上的最新版本(目前最新版本是1.0.6.1),最新的 aar 都会发布到 jcenter 和 MavenCentral 上,确保配置了这两个仓库源,然后引入aar依赖: ``` //gradle -compile ('com.alibaba.android:ultraviewpager:1.0.6@aar') { +compile ('com.alibaba.android:ultraviewpager:1.0.6.1@aar') { transitive = true } @@ -45,7 +45,7 @@ compile ('com.alibaba.android:ultraviewpager:1.0.6@aar') { com.alibaba.android ultraviewpager - 1.0.6 + 1.0.6.1 aar diff --git a/README.md b/README.md index a49a6dd..bb4e329 100644 --- a/README.md +++ b/README.md @@ -31,13 +31,13 @@ In order to achieve vertical scroll, through exchanging MotionEvent in onInterce #### Usage -Please find the latest version(1.0.6 so far) in maven repository. The newest version has been upload to jcenter and MavenCantral, make sure you have added at least one of these repositories. +Please find the latest version(1.0.6.1 so far) in maven repository. The newest version has been upload to jcenter and MavenCantral, make sure you have added at least one of these repositories. Using Gradle: ``` //gradle -compile ('com.alibaba.android:ultraviewpager:1.0.6@aar') { +compile ('com.alibaba.android:ultraviewpager:1.0.6.1@aar') { transitive = true } ``` @@ -48,7 +48,7 @@ or grab via Maven: com.alibaba.android ultraviewpager - 1.0.6 + 1.0.6.1 aar diff --git a/gradle.properties b/gradle.properties index 026d8d2..e863009 100644 --- a/gradle.properties +++ b/gradle.properties @@ -46,7 +46,7 @@ GROUP=com.alibaba.android ARTIFACT=ultraviewpager VERSION=1 -VERSION_NAME=1.0.6 +VERSION_NAME=1.0.6.1 PACKAGING_TYPE=aar systemProp.compileSdkVersion=23 systemProp.targetSdkVersion=23 From 2e3f82031f2930c01d615267f500601d929816da Mon Sep 17 00:00:00 2001 From: MikeAfc Date: Sat, 16 Sep 2017 10:31:43 +0800 Subject: [PATCH 32/54] Make setCurrentItemFake public --- .../main/java/com/tmall/ultraviewpager/UltraViewPagerView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java index 3f99fb1..8a9b604 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java @@ -238,7 +238,7 @@ public int getNextItem() { * @param item Item index to select * @param smoothScroll True to smoothly scroll to the new item, false to transition immediately */ - void setCurrentItemFake(int item, boolean smoothScroll) { + public void setCurrentItemFake(int item, boolean smoothScroll) { super.setCurrentItem(item, smoothScroll); } From ffdff3a834927d3cdd839b95483954028bab58aa Mon Sep 17 00:00:00 2001 From: MikeAfc Date: Sat, 16 Sep 2017 11:53:58 +0800 Subject: [PATCH 33/54] Add interface to scrollLastPage --- .../IUltraViewPagerFeature.java | 7 +++++- .../tmall/ultraviewpager/UltraViewPager.java | 24 ++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/IUltraViewPagerFeature.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/IUltraViewPagerFeature.java index cc92e7a..14b0bbf 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/IUltraViewPagerFeature.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/IUltraViewPagerFeature.java @@ -144,10 +144,15 @@ interface IUltraViewPagerFeature { */ void disableScrollDirection(UltraViewPager.ScrollDirection direction); + /** + * Scroll to the last page, and return to the first page when the last page is reached. + */ + boolean scrollLastPage(); + /** * Scroll to the next page, and return to the first page when the last page is reached. */ - void scrollNextPage(); + boolean scrollNextPage(); /** * Set multi-screen mode , the aspect ratio of PageViewer should less than or equal to 1.0f diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java index f2d4c44..6b2bdd0 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java @@ -368,15 +368,33 @@ public void disableScrollDirection(UltraViewPager.ScrollDirection direction) { } @Override - public void scrollNextPage() { + public boolean scrollLastPage() { + boolean isChange = false; + if (viewPager != null && viewPager.getAdapter() != null && viewPager.getAdapter().getCount() > 0) { + final int curr = viewPager.getCurrentItemFake(); + int lastPage = 0; + if (curr > 0) { + lastPage = curr - 1; + isChange = true; + } + viewPager.setCurrentItemFake(lastPage, true); + } + return isChange; + } + + @Override + public boolean scrollNextPage() { + boolean isChange = false; if (viewPager != null && viewPager.getAdapter() != null && viewPager.getAdapter().getCount() > 0) { final int curr = viewPager.getCurrentItemFake(); int nextPage = 0; if (curr < viewPager.getAdapter().getCount() - 1) { nextPage = curr + 1; + isChange = true; } viewPager.setCurrentItemFake(nextPage, true); } + return isChange; } @Override @@ -478,12 +496,12 @@ private void startTimer() { } timer.listener = mTimerHandlerListener; timer.removeCallbacksAndMessages(null); - timer.tick(0); + timer.tick(0); timer.isStopped = false; } private void stopTimer() { - if (timer == null || viewPager == null || timer.isStopped) { + if (timer == null || viewPager == null || timer.isStopped) { return; } timer.removeCallbacksAndMessages(null); From 583135e245f94fe7669f0ae57597a96be05f7301 Mon Sep 17 00:00:00 2001 From: MikeAfc Date: Sat, 23 Sep 2017 15:41:49 +0800 Subject: [PATCH 34/54] Update interface --- .../ultraviewpager/UltraViewPagerAdapter.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java index 433a775..34f8fd4 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java @@ -42,8 +42,8 @@ /** * Created by mikeafc on 15/11/25. */ -class UltraViewPagerAdapter extends PagerAdapter { - interface UltraViewPagerCenterListener { +public class UltraViewPagerAdapter extends PagerAdapter { + public interface UltraViewPagerCenterListener { void center(); void resetPosition(); @@ -98,10 +98,9 @@ public Object instantiateItem(ViewGroup container, int position) { if (item instanceof RecyclerView.ViewHolder) childView = ((RecyclerView.ViewHolder) item).itemView; - ViewPager viewPager = (ViewPager) container; - int childCount = viewPager.getChildCount(); + int childCount = container.getChildCount(); for (int i = 0; i < childCount; i++) { - View child = viewPager.getChildAt(i); + View child = container.getChildAt(i); if (isViewFromObject(child, item)) { viewArray.put(realPosition, child); break; @@ -233,7 +232,7 @@ public int getRealCount() { return adapter.getCount(); } - void setEnableLoop(boolean status) { + public void setEnableLoop(boolean status) { this.enableLoop = status; notifyDataSetChanged(); if (!status) { @@ -247,11 +246,11 @@ void setEnableLoop(boolean status) { } } - boolean isEnableLoop() { + public boolean isEnableLoop() { return enableLoop; } - void setMultiScrRatio(float ratio) { + public void setMultiScrRatio(float ratio) { multiScrRatio = ratio; } @@ -259,7 +258,7 @@ boolean isEnableMultiScr() { return !Float.isNaN(multiScrRatio) && multiScrRatio < 1f; } - void setCenterListener(UltraViewPagerCenterListener listener) { + public void setCenterListener(UltraViewPagerCenterListener listener) { centerListener = listener; } From 32363dd8a84686106f9d05806dfafc49a5cdccc1 Mon Sep 17 00:00:00 2001 From: longerian Date: Wed, 20 Dec 2017 14:55:43 +0800 Subject: [PATCH 35/54] update version --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index e863009..b2a1ce7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -46,8 +46,8 @@ GROUP=com.alibaba.android ARTIFACT=ultraviewpager VERSION=1 -VERSION_NAME=1.0.6.1 +VERSION_NAME=1.0.6.4 PACKAGING_TYPE=aar systemProp.compileSdkVersion=23 systemProp.targetSdkVersion=23 -systemProp.buildToolsVersion=23.0.2 \ No newline at end of file +systemProp.buildToolsVersion=23.0.2 From fbf2c9c4e38bdf48d76d5a1f44ab54679e5e76f1 Mon Sep 17 00:00:00 2001 From: longerian Date: Wed, 20 Dec 2017 15:38:00 +0800 Subject: [PATCH 36/54] do not center position when set enable loop --- .../tmall/ultraviewpager/UltraViewPagerAdapter.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java index 34f8fd4..3c607ce 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java @@ -238,11 +238,11 @@ public void setEnableLoop(boolean status) { if (!status) { centerListener.resetPosition(); } else { - try { - centerListener.center(); - } catch (Exception e) { - - } + //try { + // centerListener.center(); + //} catch (Exception e) { + // + //} } } From 856465be1b061e551b2dc952ce1f9118f39eb6ee Mon Sep 17 00:00:00 2001 From: longerian Date: Wed, 31 Jan 2018 15:00:08 +0800 Subject: [PATCH 37/54] update api --- ultraviewpager/build.gradle | 4 ++-- .../java/com/tmall/ultraviewpager/TimerHandler.java | 11 +++++------ .../java/com/tmall/ultraviewpager/UltraViewPager.java | 9 +++++++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ultraviewpager/build.gradle b/ultraviewpager/build.gradle index 7087dcd..aa54d99 100644 --- a/ultraviewpager/build.gradle +++ b/ultraviewpager/build.gradle @@ -72,9 +72,9 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) + compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' - compile "com.android.support:support-v4:23.1.1@aar" + compile 'com.android.support:support-v4:23.1.1@aar' compile 'com.android.support:recyclerview-v7:23.1.1@aar' } diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/TimerHandler.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/TimerHandler.java index 307a182..9a2c65b 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/TimerHandler.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/TimerHandler.java @@ -33,9 +33,10 @@ /** * Created by mikeafc on 15/11/25. */ -class TimerHandler extends Handler { +public class TimerHandler extends Handler { interface TimerHandlerListener { + int getNextItem(); void callBack(); } @@ -43,12 +44,10 @@ interface TimerHandlerListener { long interval; boolean isStopped = true; TimerHandlerListener listener; - UltraViewPager mUltraViewPager; static final int MSG_TIMER_ID = 87108; - TimerHandler(UltraViewPager ultraViewPager, TimerHandlerListener listener, long interval) { - this.mUltraViewPager = ultraViewPager; + public TimerHandler(TimerHandlerListener listener, long interval) { this.listener = listener; this.interval = interval; } @@ -56,11 +55,11 @@ interface TimerHandlerListener { @Override public void handleMessage(Message msg) { if (MSG_TIMER_ID == msg.what) { - int nextIndex = mUltraViewPager.getNextItem(); if (listener != null) { + int nextIndex = listener.getNextItem(); listener.callBack(); + tick(nextIndex); } - tick(nextIndex); } } diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java index 6b2bdd0..afeba59 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java @@ -292,6 +292,11 @@ public IUltraIndicatorBuilder getIndicator() { } private TimerHandler.TimerHandlerListener mTimerHandlerListener = new TimerHandler.TimerHandlerListener() { + @Override + public int getNextItem() { + return getNextItem(); + } + @Override public void callBack() { scrollNextPage(); @@ -306,7 +311,7 @@ public void setAutoScroll(int intervalInMillis) { if (timer != null) { disableAutoScroll(); } - timer = new TimerHandler(this, mTimerHandlerListener, intervalInMillis); + timer = new TimerHandler(mTimerHandlerListener, intervalInMillis); startTimer(); } @@ -318,7 +323,7 @@ public void setAutoScroll(int intervalInMillis, SparseIntArray intervalArray) { if (timer != null) { disableAutoScroll(); } - timer = new TimerHandler(this, mTimerHandlerListener, intervalInMillis); + timer = new TimerHandler(mTimerHandlerListener, intervalInMillis); timer.specialInterval = intervalArray; startTimer(); } From 3e5fb09c40115eed328b1c9859f05fd41d412176 Mon Sep 17 00:00:00 2001 From: longerian Date: Wed, 31 Jan 2018 15:03:48 +0800 Subject: [PATCH 38/54] update gradle --- gradle.properties | 2 +- jcenterDeploy.gradle | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index b2a1ce7..4f6635f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -46,7 +46,7 @@ GROUP=com.alibaba.android ARTIFACT=ultraviewpager VERSION=1 -VERSION_NAME=1.0.6.4 +VERSION_NAME=1.0.6.6 PACKAGING_TYPE=aar systemProp.compileSdkVersion=23 systemProp.targetSdkVersion=23 diff --git a/jcenterDeploy.gradle b/jcenterDeploy.gradle index fcb5618..ab6bc49 100644 --- a/jcenterDeploy.gradle +++ b/jcenterDeploy.gradle @@ -113,6 +113,13 @@ bintray { passphrase = project.hasProperty('bintrayGPG') ? project.getProperty('bintrayGPG') : "" //Optional. The passphrase for GPG signing' } + + mavenCentralSync { + sync = true + user = project.hasProperty('bintrayOssUser') ? project.getProperty('bintrayOssUser') : "" + password = project.hasProperty('bintrayOssPasswork') ? project.getProperty('bintrayOssPasswork') : "" + close = '1' + } } } } From 9c02ff16c24a797d3b01f0762343b02b7423ce14 Mon Sep 17 00:00:00 2001 From: longerian Date: Wed, 31 Jan 2018 15:16:35 +0800 Subject: [PATCH 39/54] add public api --- .../com/tmall/ultraviewpager/TimerHandler.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/TimerHandler.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/TimerHandler.java index 9a2c65b..56b9daa 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/TimerHandler.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/TimerHandler.java @@ -35,7 +35,7 @@ */ public class TimerHandler extends Handler { - interface TimerHandlerListener { + public interface TimerHandlerListener { int getNextItem(); void callBack(); } @@ -78,4 +78,19 @@ private long getNextInterval(int index) { return next; } + public boolean isStopped() { + return isStopped; + } + + public void setStopped(boolean stopped) { + isStopped = stopped; + } + + public void setListener(TimerHandlerListener listener) { + this.listener = listener; + } + + public void setSpecialInterval(SparseIntArray specialInterval) { + this.specialInterval = specialInterval; + } } From b6a57839b4c8da966151dec8e37d9743ed91df16 Mon Sep 17 00:00:00 2001 From: longerian Date: Wed, 31 Jan 2018 15:19:02 +0800 Subject: [PATCH 40/54] add public api --- .../src/main/java/com/tmall/ultraviewpager/UltraViewPager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java index afeba59..a1a2abb 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPager.java @@ -294,7 +294,7 @@ public IUltraIndicatorBuilder getIndicator() { private TimerHandler.TimerHandlerListener mTimerHandlerListener = new TimerHandler.TimerHandlerListener() { @Override public int getNextItem() { - return getNextItem(); + return UltraViewPager.this.getNextItem(); } @Override From 4b0a6e9f5ba46b4e2da95f6f79847fab597358d0 Mon Sep 17 00:00:00 2001 From: longerian Date: Wed, 31 Jan 2018 15:39:33 +0800 Subject: [PATCH 41/54] fix gradle spell error --- jcenterDeploy.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jcenterDeploy.gradle b/jcenterDeploy.gradle index ab6bc49..a8ec6d3 100644 --- a/jcenterDeploy.gradle +++ b/jcenterDeploy.gradle @@ -117,7 +117,7 @@ bintray { mavenCentralSync { sync = true user = project.hasProperty('bintrayOssUser') ? project.getProperty('bintrayOssUser') : "" - password = project.hasProperty('bintrayOssPasswork') ? project.getProperty('bintrayOssPasswork') : "" + password = project.hasProperty('bintrayOssPassword') ? project.getProperty('bintrayOssPassword') : "" close = '1' } } From 3179b8d6a730ea8f4b3234286f48a9e4e28842ad Mon Sep 17 00:00:00 2001 From: longerian Date: Wed, 31 Jan 2018 16:38:02 +0800 Subject: [PATCH 42/54] add public api --- .../java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java index 3c607ce..c2a82d5 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerAdapter.java @@ -254,7 +254,7 @@ public void setMultiScrRatio(float ratio) { multiScrRatio = ratio; } - boolean isEnableMultiScr() { + public boolean isEnableMultiScr() { return !Float.isNaN(multiScrRatio) && multiScrRatio < 1f; } @@ -262,7 +262,7 @@ public void setCenterListener(UltraViewPagerCenterListener listener) { centerListener = listener; } - void setInfiniteRatio(int infiniteRatio) { + public void setInfiniteRatio(int infiniteRatio) { this.infiniteRatio = infiniteRatio; } } From 69e336e236c5d154c5814cc23596d2297344614a Mon Sep 17 00:00:00 2001 From: longerian Date: Thu, 1 Feb 2018 10:38:26 +0800 Subject: [PATCH 43/54] update gradle --- gradle.properties | 6 ++--- gradle/wrapper/gradle-wrapper.properties | 2 +- ultraviewpager/build.gradle | 28 ++++++++++++++++++++---- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/gradle.properties b/gradle.properties index 4f6635f..44be2fc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -48,6 +48,6 @@ ARTIFACT=ultraviewpager VERSION=1 VERSION_NAME=1.0.6.6 PACKAGING_TYPE=aar -systemProp.compileSdkVersion=23 -systemProp.targetSdkVersion=23 -systemProp.buildToolsVersion=23.0.2 +systemProp.compileSdkVersion=25 +systemProp.targetSdkVersion=25 +systemProp.buildToolsVersion=25.0.3 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f6c23dc..fccbf53 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -29,5 +29,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip diff --git a/ultraviewpager/build.gradle b/ultraviewpager/build.gradle index aa54d99..d99741c 100644 --- a/ultraviewpager/build.gradle +++ b/ultraviewpager/build.gradle @@ -26,20 +26,40 @@ apply plugin: 'com.android.library' +buildscript { + repositories { + maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } + maven { url "http://oss.jfrog.org/oss-snapshot-local/" } + mavenCentral() + jcenter() + } + + dependencies { + classpath 'com.android.tools.build:gradle:2.3.0' + } +} + +repositories { + maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } + maven { url "http://oss.jfrog.org/oss-snapshot-local/" } + jcenter() + mavenLocal() +} + ext { bintrayRepo = 'Tangram' bintrayName = 'UltraViewPager' - publishedGroupId = GROUP - libraryName = ARTIFACT - artifact = ARTIFACT + publishedGroupId = project.hasProperty('GROUP') ? GROUP : '' + libraryName = project.hasProperty('ARTIFACT') ? ARTIFACT : '' + artifact = project.hasProperty('ARTIFACT') ? ARTIFACT : '' libraryDescription = 'UltraViewPager is an extension for ViewPager to provide multiple features in a single ViewPager.' siteUrl = 'https://github.com/alibaba/UltraViewPager' gitUrl = 'https://github.com/alibaba/UltraViewPager.git' - libraryVersion = VERSION_NAME + libraryVersion = project.hasProperty('VERSION_NAME') ? VERSION_NAME : '' developerId = 'longerian' developerName = 'longerian' From ee4fb3bf55f1a86436bc0336e93a9c2b169ca355 Mon Sep 17 00:00:00 2001 From: MikeAfc Date: Tue, 27 Mar 2018 10:56:35 +0800 Subject: [PATCH 44/54] =?UTF-8?q?Fix=20=E4=B8=80=E5=B1=8F=E5=A4=9A?= =?UTF-8?q?=E6=98=BE=E5=A4=B1=E6=95=88=EF=BC=8C(=E2=8A=99=EF=B9=8F?= =?UTF-8?q?=E2=8A=99)b?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/tmall/ultraviewpager/UltraViewPagerView.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java index 8a9b604..1f83971 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java @@ -256,7 +256,11 @@ public void setMultiScreen(float ratio) { needsMeasurePage = true; } float pageMargin = (1 - ratio) * getResources().getDisplayMetrics().widthPixels; - setPageMargin((int) (pageMargin)); + if (scrollMode == UltraViewPager.ScrollMode.VERTICAL) { + setPageMargin((int) pageMargin); + } else { + setPageMargin((int) -pageMargin); + } } public void setEnableLoop(boolean status) { From 57b567493ae0c6b569ce2c58f396b0a44518b5fd Mon Sep 17 00:00:00 2001 From: MikeAfc Date: Tue, 27 Mar 2018 11:50:02 +0800 Subject: [PATCH 45/54] Udpate readme --- README-ch.md | 6 +++--- README.md | 6 +++--- gradle.properties | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README-ch.md b/README-ch.md index e6d23bb..f8ce6a7 100644 --- a/README-ch.md +++ b/README-ch.md @@ -28,11 +28,11 @@ UltraViewPager继承自RelativeLayout,将ViewPager和indicator置于其中, 竖向滑动是通过在ViewPager的onInterceptTouchEvent和onTouchEvent中交换横竖向的event location,同时设置特殊PageTransformer实现,详见源码. #### 使用方法 -版本请参考mvn repository上的最新版本(目前最新版本是1.0.6.1),最新的 aar 都会发布到 jcenter 和 MavenCentral 上,确保配置了这两个仓库源,然后引入aar依赖: +版本请参考mvn repository上的最新版本(目前最新版本是1.0.7.0),最新的 aar 都会发布到 jcenter 和 MavenCentral 上,确保配置了这两个仓库源,然后引入aar依赖: ``` //gradle -compile ('com.alibaba.android:ultraviewpager:1.0.6.1@aar') { +compile ('com.alibaba.android:ultraviewpager:1.0.7.0@aar') { transitive = true } @@ -45,7 +45,7 @@ compile ('com.alibaba.android:ultraviewpager:1.0.6.1@aar') { com.alibaba.android ultraviewpager - 1.0.6.1 + 1.0.7.0 aar diff --git a/README.md b/README.md index bb4e329..013e710 100644 --- a/README.md +++ b/README.md @@ -31,13 +31,13 @@ In order to achieve vertical scroll, through exchanging MotionEvent in onInterce #### Usage -Please find the latest version(1.0.6.1 so far) in maven repository. The newest version has been upload to jcenter and MavenCantral, make sure you have added at least one of these repositories. +Please find the latest version(1.0.7.0 so far) in maven repository. The newest version has been upload to jcenter and MavenCantral, make sure you have added at least one of these repositories. Using Gradle: ``` //gradle -compile ('com.alibaba.android:ultraviewpager:1.0.6.1@aar') { +compile ('com.alibaba.android:ultraviewpager:1.0.7.0@aar') { transitive = true } ``` @@ -48,7 +48,7 @@ or grab via Maven: com.alibaba.android ultraviewpager - 1.0.6.1 + 1.0.7.0 aar diff --git a/gradle.properties b/gradle.properties index 44be2fc..62703ca 100644 --- a/gradle.properties +++ b/gradle.properties @@ -46,7 +46,7 @@ GROUP=com.alibaba.android ARTIFACT=ultraviewpager VERSION=1 -VERSION_NAME=1.0.6.6 +VERSION_NAME=1.0.7.0 PACKAGING_TYPE=aar systemProp.compileSdkVersion=25 systemProp.targetSdkVersion=25 From 06e40e6ce6ea98e39fbc87c51c8c9b6db3536d6a Mon Sep 17 00:00:00 2001 From: MikeAfc Date: Fri, 30 Mar 2018 17:47:47 +0800 Subject: [PATCH 46/54] Fix #79, #75 --- .../main/java/com/tmall/ultraviewpager/UltraViewPagerView.java | 3 +++ ultraviewpager/src/main/res/values/attrs.xml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java index 1f83971..1d7d759 100644 --- a/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java +++ b/ultraviewpager/src/main/java/com/tmall/ultraviewpager/UltraViewPagerView.java @@ -84,6 +84,9 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { } protected void onMeasurePage(int widthMeasureSpec, int heightMeasureSpec) { + if (pagerAdapter == null) { + return; + } View child = pagerAdapter.getViewAtPosition(getCurrentItem()); if (child == null) { child = getChildAt(0); diff --git a/ultraviewpager/src/main/res/values/attrs.xml b/ultraviewpager/src/main/res/values/attrs.xml index c2e896d..59cdf47 100644 --- a/ultraviewpager/src/main/res/values/attrs.xml +++ b/ultraviewpager/src/main/res/values/attrs.xml @@ -39,7 +39,7 @@ - + From a2dbee2fe6b43cf7a36ae9991eb14a6d2711ed15 Mon Sep 17 00:00:00 2001 From: MikeAfc Date: Sun, 8 Apr 2018 20:07:41 +0800 Subject: [PATCH 47/54] Remove unused indicator demo. Fix #83 --- sample/src/main/res/values/strings.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml index 0a82d66..c9c96c7 100644 --- a/sample/src/main/res/values/strings.xml +++ b/sample/src/main/res/values/strings.xml @@ -31,7 +31,6 @@ None Circle Icon - Count Left From 6215f31c39bdb1543cb75bf99cdbc6917943a8ef Mon Sep 17 00:00:00 2001 From: MikeAfc Date: Wed, 11 Apr 2018 17:53:23 +0800 Subject: [PATCH 48/54] Update demo --- sample/src/main/AndroidManifest.xml | 9 +- .../ultraviewpager/sample/PagerActivity.java | 40 ++------- .../sample/UPVDemoActivity.java | 87 ++++++++++++------- 3 files changed, 72 insertions(+), 64 deletions(-) diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index d7c16cc..41ac370 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - -