1
0
Эх сурвалжийг харах

2.6.5 (#79)

* Fix a bug.

* Optimize code

* Update Readme.
zhpanvip 5 жил өмнө
parent
commit
e2de297135

+ 22 - 3
README.md

@@ -27,7 +27,7 @@
 
 ### 2.setIndicatorStyle
 
-BannerViewPager supports three Indicator Styles now. It's also support to custom indicator style,just need extends BaseIndicatorView or implement the IIndicator and override methods, then you can draw Indicators for whatever you want.
+BannerViewPager supports three Indicator Styles now. 
 
 [Sample Click Here](https://github.com/zhpanvip/BannerViewPager/blob/master/app/src/main/java/com/example/zhpan/circleviewpager/fragment/IndicatorFragment.java)
 
@@ -35,14 +35,25 @@ BannerViewPager supports three Indicator Styles now. It's also support to custom
 |--|--|--|
 | ![CIRCLE](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_circle.gif) | ![DASH](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_dash.gif) | ![NORMAL](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_round_rect.gif) |
 
-### 3.setIndicatorSlideMode
+### 3.Custom Indicator
+
+It's also support to custom indicator style,just need extends BaseIndicatorView or implement the IIndicator and override methods, then you can draw Indicators for whatever you want.
+
+[Sample Click Here](https://github.com/zhpanvip/BannerViewPager/blob/master/app/src/main/java/com/example/zhpan/circleviewpager/fragment/OthersFragment.java)
+
+| Figure Indicator | Drawable Indicator | Indicator below of Banner |
+|--|--|--|
+| ![CIRCLE](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_custom.gif) | ![DASH](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_custom1.gif) | ![NORMAL](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_custom2.gif) |
+
+
+### 4.setIndicatorSlideMode
 
 | NORMAL | SMOOTH |
 |--|--|
 | ![NORMAL](https://github.com/zhpanvip/BannerViewPager/blob/master/image/slide_normal.gif) |  ![SMOOTH](https://github.com/zhpanvip/BannerViewPager/blob/master/image/slide_smooth.gif) |
 
 
-### 4.setPageTransformerStyle
+### 5.setPageTransformerStyle
 
 [Sample Click Here](https://github.com/zhpanvip/BannerViewPager/blob/master/app/src/main/java/com/example/zhpan/circleviewpager/activity/WelcomeActivity.java)
 
@@ -384,6 +395,14 @@ public class FigureIndicatorView extends BaseIndicatorView {
  - [x] Fix issue #34 which Indicator smooth slide problem(2.6.1).
  - [ ] Migrate to ViewPager2 (3.0.0)
 
+## Sponsor
+
+**开源不易 随心赞赏**
+
+| Alipay | WeChat Pay |
+|--|--|
+| ![NORMAL](https://github.com/zhpanvip/BannerViewPager/blob/master/image/pay_alipay.jpb) |  ![SMOOTH](https://github.com/zhpanvip/BannerViewPager/blob/master/image/pay_wechat.png) |
+
 
 ## If you have any question you can scan the QR code to join the QQ group to communicate.
 

+ 23 - 4
README_CN.md

@@ -28,7 +28,7 @@
 | ![MULTI_PAGE](https://github.com/zhpanvip/BannerViewPager/blob/master/image/page_style_multi.gif) |![MULTI_PAGE](https://github.com/zhpanvip/BannerViewPager/blob/master/image/page_style_multi_scale.gif) |![MULTI_PAGE](https://github.com/zhpanvip/BannerViewPager/blob/master/image/page_style_multi_overlay.gif) |
 
 ### 2.setIndicatorStyle
-BannerViewPager支持多种IndicatorViewStyle,同时还提供了完全自定义IndicatorView的功能。只要继承BaseIndicatorView或者实现IIndicator接口,并重写相应方法,就可以为所欲为的打造任意的Indicator了。
+BannerViewPager目前已支持三种IndicatorViewStyle,分别如下:
 
 [IndicatorViewStyle Demo](https://github.com/zhpanvip/BannerViewPager/blob/master/app/src/main/java/com/example/zhpan/circleviewpager/fragment/IndicatorFragment.java)
 
@@ -36,14 +36,26 @@ BannerViewPager支持多种IndicatorViewStyle,同时还提供了完全自定义I
 |--|--|--|
 | ![CIRCLE](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_circle.gif) | ![DASH](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_dash.gif) | ![NORMAL](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_round_rect.gif) |
 
-### 3.setIndicatorSlideMode
+### 3.Custom Indicator
+
+同时BannerViewPager还提供了自定义IndicatorView的功能。只要继承BaseIndicatorView或者实现IIndicator接口,并重写相应方法,就可以为所欲为的打造任意的Indicator了。
+
+[Sample Click Here](https://github.com/zhpanvip/BannerViewPager/blob/master/app/src/main/java/com/example/zhpan/circleviewpager/fragment/OthersFragment.java)
+
+| Figure Indicator | Drawable Indicator | Indicator below of Banner |
+|--|--|--|
+| ![CIRCLE](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_custom.gif) | ![DASH](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_custom1.gif) | ![NORMAL](https://github.com/zhpanvip/BannerViewPager/blob/master/image/style_custom2.gif) |
+
+
+
+### 4.setIndicatorSlideMode
 
 | NORMAL | SMOOTH |
 |--|--|
 | ![NORMAL](https://github.com/zhpanvip/BannerViewPager/blob/master/image/slide_normal.gif) |  ![SMOOTH](https://github.com/zhpanvip/BannerViewPager/blob/master/image/slide_smooth.gif) |
 
 
-### 4.setPageTransformerStyle
+### 5.setPageTransformerStyle
 
 [TransformStyle Demo](https://github.com/zhpanvip/BannerViewPager/blob/master/app/src/main/java/com/example/zhpan/circleviewpager/activity/WelcomeActivity.java)
 
@@ -52,7 +64,6 @@ BannerViewPager支持多种IndicatorViewStyle,同时还提供了完全自定义I
 | 预览 | ![STACK](https://github.com/zhpanvip/BannerViewPager/blob/master/image/transform_stack.gif) | ![ROTATE_DOWN](https://github.com/zhpanvip/BannerViewPager/blob/master/image/transform_rotate.gif) | ![DEPTH](https://github.com/zhpanvip/BannerViewPager/blob/master/image/transform_depth.gif)  |![ACCORDION](https://github.com/zhpanvip/BannerViewPager/blob/master/image/transform_accordion.gif)  |
 
 
-
 ## 开放API
 
 | 方法名 | 方法描述 | 说明 |
@@ -385,6 +396,14 @@ public class FigureIndicatorView extends BaseIndicatorView {
  - [x] 修复 issue #34 Indicator 在Smooth模式下存在的问题 (2.6.1).
  - [ ] ViewPager更换为ViewPager2 (3.0.0)
 
+## Sponsor
+
+**开源不易 随心赞赏**
+
+| 支付宝 | 微信支付 |
+|--|--|
+| ![NORMAL](https://github.com/zhpanvip/BannerViewPager/blob/master/image/pay_alipay.jpb) |  ![SMOOTH](https://github.com/zhpanvip/BannerViewPager/blob/master/image/pay_wechat.png) |
+
 
 ## 有问题可以扫码加QQ群交流
 

BIN
app/release/app-release.apk


+ 1 - 1
app/src/main/java/com/example/zhpan/circleviewpager/fragment/BaseFragment.kt

@@ -44,7 +44,7 @@ abstract class BaseFragment : RxFragment() {
     protected fun initData(j: Int) {
         mDrawableList.clear()
         for (i in 0..j) {
-            val drawable = resources.getIdentifier("t$i", "drawable", mContext.packageName)
+            val drawable = resources.getIdentifier("bg_card$i", "drawable", mContext.packageName)
             mDrawableList.add(drawable)
         }
     }

BIN
app/src/main/res/drawable-xxhdpi/t0.jpg


BIN
app/src/main/res/drawable-xxhdpi/t1.jpg


BIN
app/src/main/res/drawable-xxhdpi/t2.jpg


BIN
app/src/main/res/drawable-xxhdpi/t3.jpg


+ 24 - 0
app/src/main/res/drawable/bg_card0.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android" >
+
+<!-- 实心 -->
+<solid android:color="#CCFF99" />
+<!-- 边框 -->
+<!--<stroke
+    android:width="0.5dp"
+    android:color="#e35d5e" />-->
+<!-- 圆角 -->
+<corners android:radius="0dp" />
+<!-- 边距 -->
+<padding
+    android:bottom="0dp"
+    android:left="0dp"
+    android:right="0dp"
+    android:top="0dp" />
+<!-- 渐变 -->
+<!--<gradient
+    android:angle="270"
+    android:endColor="#FFFF782"
+    android:startColor="#13C7AF" />-->
+
+</shape>

+ 24 - 0
app/src/main/res/drawable/bg_card1.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android" >
+
+<!-- 实心 -->
+<solid android:color="#41F1E5" />
+<!-- 边框 -->
+<!--<stroke
+    android:width="0.5dp"
+    android:color="#e35d5e" />-->
+<!-- 圆角 -->
+<corners android:radius="0dp" />
+<!-- 边距 -->
+<padding
+    android:bottom="0dp"
+    android:left="0dp"
+    android:right="0dp"
+    android:top="0dp" />
+<!-- 渐变 -->
+<!--<gradient
+    android:angle="270"
+    android:endColor="#FFFF782"
+    android:startColor="#13C7AF" />-->
+
+</shape>

+ 24 - 0
app/src/main/res/drawable/bg_card2.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android" >
+
+<!-- 实心 -->
+<solid android:color="#8D41F1" />
+<!-- 边框 -->
+<!--<stroke
+    android:width="0.5dp"
+    android:color="#e35d5e" />-->
+<!-- 圆角 -->
+<corners android:radius="0dp" />
+<!-- 边距 -->
+<padding
+    android:bottom="0dp"
+    android:left="0dp"
+    android:right="0dp"
+    android:top="0dp" />
+<!-- 渐变 -->
+<!--<gradient
+    android:angle="270"
+    android:endColor="#FFFF782"
+    android:startColor="#13C7AF" />-->
+
+</shape>

+ 24 - 0
app/src/main/res/drawable/bg_card3.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android" >
+
+<!-- 实心 -->
+<solid android:color="#FF99CC" />
+<!-- 边框 -->
+<!--<stroke
+    android:width="0.5dp"
+    android:color="#e35d5e" />-->
+<!-- 圆角 -->
+<corners android:radius="0dp" />
+<!-- 边距 -->
+<padding
+    android:bottom="0dp"
+    android:left="0dp"
+    android:right="0dp"
+    android:top="0dp" />
+<!-- 渐变 -->
+<!--<gradient
+    android:angle="270"
+    android:endColor="#FFFF782"
+    android:startColor="#13C7AF" />-->
+
+</shape>

+ 48 - 9
bannerview/src/main/java/com/zhpan/bannerview/BannerViewPager.java

@@ -117,19 +117,57 @@ public class BannerViewPager<T, VH extends ViewHolder> extends RelativeLayout im
     //  触碰控件的时候,翻页应该停止,离开的时候如果之前是开启了翻页的话则重新启动翻页
     @Override
     public boolean dispatchTouchEvent(MotionEvent ev) {
-        int action = ev.getAction();
-        if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_OUTSIDE) {
-            // 开始翻页
-            setLooping(false);
-            startLoop();
-        } else if (action == MotionEvent.ACTION_DOWN) {
-            // 停止翻页
-            setLooping(true);
-            stopLoop();
+        switch (ev.getAction()) {
+            case MotionEvent.ACTION_UP:
+            case MotionEvent.ACTION_CANCEL:
+            case MotionEvent.ACTION_OUTSIDE:
+                setLooping(false);
+                startLoop();
+                break;
+            case MotionEvent.ACTION_DOWN:
+                setLooping(true);
+                stopLoop();
+                break;
         }
         return super.dispatchTouchEvent(ev);
     }
 
+//    private int startX, startY;
+//    @Override
+//    public boolean dispatchTouchEvent(MotionEvent ev) {
+//        switch (ev.getAction()) {
+//            case MotionEvent.ACTION_DOWN:
+//                setLooping(true);
+//                stopLoop();
+//                startX = (int) ev.getX();
+//                startY = (int) ev.getY();
+//                getParent().requestDisallowInterceptTouchEvent(true);
+//                break;
+//            case MotionEvent.ACTION_MOVE:
+//                int endX = (int) ev.getX();
+//                int endY = (int) ev.getY();
+//                int disX = Math.abs(endX - startX);
+//                int disY = Math.abs(endY - startY);
+//                if (disX > disY) {
+//                    getParent().requestDisallowInterceptTouchEvent(true);
+//                } else {
+//                    getParent().requestDisallowInterceptTouchEvent(false);
+//                }
+//                break;
+//            case MotionEvent.ACTION_UP:
+//            case MotionEvent.ACTION_CANCEL:
+//                setLooping(false);
+//                startLoop();
+//                getParent().requestDisallowInterceptTouchEvent(false);
+//                break;
+//            case MotionEvent.ACTION_OUTSIDE:
+//                setLooping(false);
+//                startLoop();
+//                break;
+//        }
+//        return super.dispatchTouchEvent(ev);
+//    }
+
     @Override
     public void onPageSelected(int position) {
         int size = mBannerPagerAdapter.getListSize();
@@ -247,6 +285,7 @@ public class BannerViewPager<T, VH extends ViewHolder> extends RelativeLayout im
         if (holderCreator == null) {
             throw new NullPointerException("You must set HolderCreator for BannerViewPager");
         }
+        currentPosition = 0;
         if (list.size() > 0 && isCanLoop()) {
             currentPosition = MAX_VALUE / 2 - ((MAX_VALUE / 2) % list.size()) + 1;
         }

BIN
image/custom_indicator.gif


BIN
image/page_style_multi.gif


BIN
image/page_style_multi_overlay.gif


BIN
image/page_style_multi_scale.gif


BIN
image/pay_alipay.jpg


BIN
image/pay_wechat.png


BIN
image/preview1.gif


BIN
image/preview2.gif


BIN
image/preview3.gif


BIN
image/qq_group.png


BIN
image/qrcode.png


BIN
image/slide_normal.gif


BIN
image/slide_smooth.gif


BIN
image/style_circle.gif


BIN
image/style_custom1.gif


BIN
image/style_custom2.gif


BIN
image/style_custum.gif


BIN
image/style_dash.gif


BIN
image/style_round_rect.gif