From accd4a0b267982c296cc9fda91a3f8501ad9177d Mon Sep 17 00:00:00 2001 From: Richard Yee Date: Thu, 13 Apr 2017 16:30:34 -0700 Subject: [PATCH 1/2] 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 2/2] 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)); }